From 499946f51c51683094b60375d71dad24357b9880 Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Mon, 18 Dec 2023 16:41:22 +0800 Subject: [PATCH] fix(host-deployer): pass config files to deploy vm --- pkg/hostman/diskutils/qemu_kvm/driver.go | 2 +- .../hostdeployer/deployserver/deployserver.go | 12 ++++++++++++ pkg/hostman/hostdeployer/deployserver/localdeploy.go | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/hostman/diskutils/qemu_kvm/driver.go b/pkg/hostman/diskutils/qemu_kvm/driver.go index 3bd70c461a5..5d2c1033434 100644 --- a/pkg/hostman/diskutils/qemu_kvm/driver.go +++ b/pkg/hostman/diskutils/qemu_kvm/driver.go @@ -53,7 +53,7 @@ var ( RUN_ON_HOST_ROOT_PATH = "/opt/cloud/host-deployer" DEPLOY_ISO = "/opt/cloud/host-deployer/host_deployer_v1.iso" - DEPLOYER_BIN = "/opt/yunion/bin/host-deployer" + DEPLOYER_BIN = "/opt/yunion/bin/host-deployer --common-config-file /opt/yunion/common.conf --config /opt/yunion/host.conf" YUNIONOS_PASSWD = "mosbaremetal" ) diff --git a/pkg/hostman/hostdeployer/deployserver/deployserver.go b/pkg/hostman/hostdeployer/deployserver/deployserver.go index 534d74a784b..1f00071309d 100644 --- a/pkg/hostman/hostdeployer/deployserver/deployserver.go +++ b/pkg/hostman/hostdeployer/deployserver/deployserver.go @@ -360,6 +360,18 @@ func (s *SDeployService) PrepareEnv() error { if err != nil { return errors.Wrapf(err, "cp files failed %s", out) } + if DeployOption.Config != "" && fileutils2.Exists(DeployOption.Config) { + out, err = procutils.NewCommand("cp", "-Lrf", DeployOption.Config, "/opt/yunion/host.conf").Output() + if err != nil { + return errors.Wrapf(err, "cp files failed %s", out) + } + } + if DeployOption.CommonConfigFile != "" && fileutils2.Exists(DeployOption.CommonConfigFile) { + out, err = procutils.NewCommand("cp", "-Lrf", DeployOption.CommonConfigFile, "/opt/yunion/common.conf").Output() + if err != nil { + return errors.Wrapf(err, "cp files failed %s", out) + } + } err = procutils.NewCommand("mkdir", "-p", qemu_kvm.RUN_ON_HOST_ROOT_PATH).Run() if err != nil { diff --git a/pkg/hostman/hostdeployer/deployserver/localdeploy.go b/pkg/hostman/hostdeployer/deployserver/localdeploy.go index a5909d18251..4398affeaeb 100644 --- a/pkg/hostman/hostdeployer/deployserver/localdeploy.go +++ b/pkg/hostman/hostdeployer/deployserver/localdeploy.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/pkg/errors" + commonconsts "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/hostman/diskutils" "yunion.io/x/onecloud/pkg/hostman/guestfs/fsdriver" deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis" @@ -113,6 +114,7 @@ func LocalInitEnv() error { if err := fsdriver.Init(DeployOption.PrivatePrefixes, DeployOption.CloudrootDir); err != nil { return errors.Wrap(err, "init fsdriver") } + commonconsts.SetAllowVmSELinux(DeployOption.AllowVmSELinux) winutils.SetChntpwPath("/opt/yunion/bin/chntpw.static") return nil }