diff --git a/pkg/hostman/guestfs/fsdriver/drivers.go b/pkg/hostman/guestfs/fsdriver/drivers.go index 1884bd207d..44993d48c3 100644 --- a/pkg/hostman/guestfs/fsdriver/drivers.go +++ b/pkg/hostman/guestfs/fsdriver/drivers.go @@ -42,8 +42,9 @@ func Init(initPrivatePrefixes []string, cloudrootDir string) error { } linuxFsDrivers := []newRootFsDriverFunc{ - NewFangdeRootFs, - NewCentosRootFs, NewFedoraRootFs, NewAnolisRootFs, NewGalaxyKylinRootFs, NewRhelRootFs, + NewCentosRootFs, NewFedoraRootFs, + NewFangdeRootFs, NewUnionOSRootFs, + NewAnolisRootFs, NewGalaxyKylinRootFs, NewRhelRootFs, NewFangdeDeskRootfs, NewUKylinRootfs, NewDebianRootFs, NewCirrosRootFs, NewCirrosNewRootFs, NewUbuntuRootFs, NewGentooRootFs, NewArchLinuxRootFs, NewOpenWrtRootFs, NewCoreOsRootFs, diff --git a/pkg/hostman/guestfs/fsdriver/linux.go b/pkg/hostman/guestfs/fsdriver/linux.go index 36d7cb9dc6..9ee887c68b 100644 --- a/pkg/hostman/guestfs/fsdriver/linux.go +++ b/pkg/hostman/guestfs/fsdriver/linux.go @@ -133,6 +133,11 @@ func (l *sLinuxRootFs) ChangeUserPasswd(rootFs IDiskPartition, account, gid, pub } else { secret, err = utils.EncryptAESBase64(gid, password) } + // put /.autorelabel if selinux enabled + err = rootFs.FilePutContents("/.autorelabel", "", false, false) + if err != nil { + return "", errors.Wrap(err, "fail to put .autorelabel") + } } else { return "", fmt.Errorf("ChangeUserPasswd error: %v", err) } diff --git a/pkg/hostman/guestfs/fsdriver/uos.go b/pkg/hostman/guestfs/fsdriver/uos.go new file mode 100644 index 0000000000..57b6b433a5 --- /dev/null +++ b/pkg/hostman/guestfs/fsdriver/uos.go @@ -0,0 +1,81 @@ +// 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 SUnionOSRootFs struct { + *sRedhatLikeRootFs +} + +func NewUnionOSRootFs(part IDiskPartition) IRootFsDriver { + return &SUnionOSRootFs{sRedhatLikeRootFs: newRedhatLikeRootFs(part)} +} + +func (d *SUnionOSRootFs) GetName() string { + return "UOS/Server" +} + +func (d *SUnionOSRootFs) String() string { + return "UOSSrvRootFs" +} + +func (d *SUnionOSRootFs) RootSignatures() []string { + sigs := []string{"/etc/UnionTech-release"} + for _, sig := range d.sRedhatLikeRootFs.RootSignatures() { + if sig != "/etc/redhat-release" { + sigs = append(sigs, sig) + } + } + return sigs +} + +func (d *SUnionOSRootFs) GetReleaseInfo(rootFs IDiskPartition) *deployapi.ReleaseInfo { + rel, _ := rootFs.FileGetContents("UnionTech-release", false) + var version string + if len(rel) > 0 { + relStr := string(rel) + endPos := strings.IndexByte(relStr, '(') + if endPos > 0 { + relStr = strings.TrimSpace(relStr[:endPos]) + } + dat := strings.Split(relStr, " ") + version = dat[len(dat)-1] + } + return deployapi.NewReleaseInfo(d.GetName(), version, d.GetArch(rootFs)) +} + +func (d *SUnionOSRootFs) DeployNetworkingScripts(rootFs IDiskPartition, nics []*types.SServerNic) error { + relInfo := d.GetReleaseInfo(rootFs) + if err := d.sRedhatLikeRootFs.deployNetworkingScripts(rootFs, nics, relInfo, true); err != nil { + return err + } + return nil +} + +func (c *SUnionOSRootFs) EnableSerialConsole(rootFs IDiskPartition, sysInfo *jsonutils.JSONDict) error { + return c.enableSerialConsole(c, rootFs, sysInfo) +} + +func (c *SUnionOSRootFs) DisableSerialConsole(rootFs IDiskPartition) error { + return c.disableSerialConcole(c, rootFs) +}