diff --git a/pkg/hostman/guestfs/fsdriver/alma.go b/pkg/hostman/guestfs/fsdriver/alma.go new file mode 100644 index 0000000000..7d320652e7 --- /dev/null +++ b/pkg/hostman/guestfs/fsdriver/alma.go @@ -0,0 +1,74 @@ +// Copyright 2019 Yunion +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package fsdriver + +import ( + "strings" + + "yunion.io/x/jsonutils" + + "yunion.io/x/onecloud/pkg/cloudcommon/types" + deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis" +) + +type SAlmaRootFs struct { + *sRedhatLikeRootFs +} + +func NewAlmaLinuxRootFs(part IDiskPartition) IRootFsDriver { + return &SAlmaRootFs{sRedhatLikeRootFs: newRedhatLikeRootFs(part)} +} + +func (d *SAlmaRootFs) GetName() string { + return "AlmaLinux" +} + +func (d *SAlmaRootFs) String() string { + return "AlmaRootFs" +} + +func (d *SAlmaRootFs) RootSignatures() []string { + sig := d.sLinuxRootFs.RootSignatures() + return append([]string{"/etc/sysconfig/network", "/etc/almalinux-release"}, sig...) +} + +func (d *SAlmaRootFs) GetReleaseInfo(rootFs IDiskPartition) *deployapi.ReleaseInfo { + rel, _ := rootFs.FileGetContents("/etc/almalinux-release", false) + var version string + if len(rel) > 0 { + dat := strings.Split(string(rel), " ") + if len(dat) > 2 { + version = dat[2] + } + } + return deployapi.NewReleaseInfo(d.GetName(), version, d.GetArch(rootFs)) +} + +func (d *SAlmaRootFs) DeployNetworkingScripts(rootFs IDiskPartition, nics []*types.SServerNic) error { + relInfo := d.GetReleaseInfo(rootFs) + if err := d.sRedhatLikeRootFs.deployNetworkingScripts(rootFs, nics, relInfo); err != nil { + return err + } + return nil +} + +func (c *SAlmaRootFs) EnableSerialConsole(rootFs IDiskPartition, sysInfo *jsonutils.JSONDict) error { + return c.enableSerialConsoleSystemd(rootFs) +} + +func (c *SAlmaRootFs) DisableSerialConsole(rootFs IDiskPartition) error { + c.disableSerialConsoleSystemd(rootFs) + return nil +} diff --git a/pkg/hostman/guestfs/fsdriver/drivers.go b/pkg/hostman/guestfs/fsdriver/drivers.go index c5ce353bd2..5acbb38092 100644 --- a/pkg/hostman/guestfs/fsdriver/drivers.go +++ b/pkg/hostman/guestfs/fsdriver/drivers.go @@ -38,7 +38,8 @@ func GetRootfsDrivers() []newRootFsDriverFunc { func Init(cloudrootDir string) error { linuxFsDrivers := []newRootFsDriverFunc{ NewFangdeRootFs, NewUnionOSRootFs, - NewAnolisRootFs, NewRockyRootFs, + NewAnolisRootFs, NewRockyRootFs, NewOpenCloudOsRootFs, NewAlmaLinuxRootFs, + NewOpenKylinRootfs, NewUOSDesktopRootfs, NewGalaxyKylinRootFs, NewNeoKylinRootFs, NewFangdeDeskRootfs, NewUKylinRootfs, NewCentosRootFs, NewFedoraRootFs, diff --git a/pkg/hostman/guestfs/fsdriver/opencloudos.go b/pkg/hostman/guestfs/fsdriver/opencloudos.go new file mode 100644 index 0000000000..9baf7c66bf --- /dev/null +++ b/pkg/hostman/guestfs/fsdriver/opencloudos.go @@ -0,0 +1,74 @@ +// Copyright 2019 Yunion +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package fsdriver + +import ( + "strings" + + "yunion.io/x/jsonutils" + + "yunion.io/x/onecloud/pkg/cloudcommon/types" + deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis" +) + +type SOpenCloudOsRootFs struct { + *sRedhatLikeRootFs +} + +func NewOpenCloudOsRootFs(part IDiskPartition) IRootFsDriver { + return &SOpenCloudOsRootFs{sRedhatLikeRootFs: newRedhatLikeRootFs(part)} +} + +func (d *SOpenCloudOsRootFs) GetName() string { + return "OpenCloudOS" +} + +func (d *SOpenCloudOsRootFs) String() string { + return "OpenCloudOsRootFs" +} + +func (d *SOpenCloudOsRootFs) RootSignatures() []string { + sig := d.sLinuxRootFs.RootSignatures() + return append([]string{"/etc/sysconfig/network", "/etc/opencloudos-release"}, sig...) +} + +func (d *SOpenCloudOsRootFs) GetReleaseInfo(rootFs IDiskPartition) *deployapi.ReleaseInfo { + rel, _ := rootFs.FileGetContents("/etc/opencloudos-release", false) + var version string + if len(rel) > 0 { + dat := strings.Split(string(rel), " ") + if len(dat) > 1 { + version = dat[1] + } + } + return deployapi.NewReleaseInfo(d.GetName(), version, d.GetArch(rootFs)) +} + +func (d *SOpenCloudOsRootFs) DeployNetworkingScripts(rootFs IDiskPartition, nics []*types.SServerNic) error { + relInfo := d.GetReleaseInfo(rootFs) + if err := d.sRedhatLikeRootFs.deployNetworkingScripts(rootFs, nics, relInfo); err != nil { + return err + } + return nil +} + +func (c *SOpenCloudOsRootFs) EnableSerialConsole(rootFs IDiskPartition, sysInfo *jsonutils.JSONDict) error { + return c.enableSerialConsoleSystemd(rootFs) +} + +func (c *SOpenCloudOsRootFs) DisableSerialConsole(rootFs IDiskPartition) error { + c.disableSerialConsoleSystemd(rootFs) + return nil +} diff --git a/pkg/hostman/guestfs/fsdriver/openkylin.go b/pkg/hostman/guestfs/fsdriver/openkylin.go new file mode 100644 index 0000000000..1be2d4ce94 --- /dev/null +++ b/pkg/hostman/guestfs/fsdriver/openkylin.go @@ -0,0 +1,50 @@ +// Copyright 2019 Yunion +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package fsdriver + +import ( + deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis" +) + +type SOpenKylinRootFs struct { + *SUbuntuRootFs +} + +func NewOpenKylinRootfs(part IDiskPartition) IRootFsDriver { + return &SOpenKylinRootFs{SUbuntuRootFs: NewUbuntuRootFs(part).(*SUbuntuRootFs)} +} + +func (d *SOpenKylinRootFs) GetName() string { + return "OpenKylin" +} + +func (d *SOpenKylinRootFs) String() string { + return "OpenKylinRootFs" +} + +func (d *SOpenKylinRootFs) RootSignatures() []string { + sig := d.sDebianLikeRootFs.RootSignatures() + return append([]string{"/etc/lsb-release", "/etc/kylin-build", "/etc/ukui-tablet-desktop.conf"}, sig...) +} + +func (d *SOpenKylinRootFs) GetReleaseInfo(rootFs IDiskPartition) *deployapi.ReleaseInfo { + info := d.SUbuntuRootFs.GetReleaseInfo(rootFs) + info.Distro = d.GetName() + return info +} + +func (d *SOpenKylinRootFs) AllowAdminLogin() bool { + return false +} diff --git a/pkg/hostman/guestfs/fsdriver/uosdesktop.go b/pkg/hostman/guestfs/fsdriver/uosdesktop.go new file mode 100644 index 0000000000..801e14640f --- /dev/null +++ b/pkg/hostman/guestfs/fsdriver/uosdesktop.go @@ -0,0 +1,50 @@ +// Copyright 2019 Yunion +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package fsdriver + +import ( + deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis" +) + +type SUOSDesktopRootFs struct { + *SUbuntuRootFs +} + +func NewUOSDesktopRootfs(part IDiskPartition) IRootFsDriver { + return &SUOSDesktopRootFs{SUbuntuRootFs: NewUbuntuRootFs(part).(*SUbuntuRootFs)} +} + +func (d *SUOSDesktopRootFs) GetName() string { + return "UOSDesktop" +} + +func (d *SUOSDesktopRootFs) String() string { + return "UOSDesktopRootFs" +} + +func (d *SUOSDesktopRootFs) RootSignatures() []string { + sig := d.sDebianLikeRootFs.RootSignatures() + return append([]string{"/etc/lsb-release", "/etc/deepin-version"}, sig...) +} + +func (d *SUOSDesktopRootFs) GetReleaseInfo(rootFs IDiskPartition) *deployapi.ReleaseInfo { + info := d.SUbuntuRootFs.GetReleaseInfo(rootFs) + info.Distro = d.GetName() + return info +} + +func (d *SUOSDesktopRootFs) AllowAdminLogin() bool { + return false +}