Merge pull request #17469 from ioito/hotfix/qx-default-user

fix(region): default username
This commit is contained in:
Zexi Li
2023-07-11 10:08:26 +08:00
committed by GitHub
6 changed files with 17 additions and 12 deletions
+2 -3
View File
@@ -118,11 +118,10 @@ func (self *SAwsGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapa
}
}
func (self *SAwsGuestDriver) GetDefaultAccount(desc cloudprovider.SManagedVMCreateConfig) string {
if strings.ToLower(desc.OsType) == strings.ToLower(osprofile.OS_TYPE_WINDOWS) {
func (self *SAwsGuestDriver) GetDefaultAccount(osType, osDist, imageType string) string {
if strings.ToLower(osType) == strings.ToLower(osprofile.OS_TYPE_WINDOWS) {
return api.VM_DEFAULT_WINDOWS_LOGIN_USER
}
return api.VM_AWS_DEFAULT_LOGIN_USER
}
+1 -1
View File
@@ -244,7 +244,7 @@ func (self *SAzureGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCa
}
}
func (self *SAzureGuestDriver) GetDefaultAccount(desc cloudprovider.SManagedVMCreateConfig) string {
func (self *SAzureGuestDriver) GetDefaultAccount(osType, osDist, imageType string) string {
return api.VM_AZURE_DEFAULT_LOGIN_USER
}
+2 -2
View File
@@ -373,8 +373,8 @@ func (self *SBaseGuestDriver) GetUserDataType() string {
return cloudprovider.CLOUD_CONFIG
}
func (self *SBaseGuestDriver) GetDefaultAccount(desc cloudprovider.SManagedVMCreateConfig) string {
if strings.ToLower(desc.OsType) == strings.ToLower(osprofile.OS_TYPE_WINDOWS) {
func (self *SBaseGuestDriver) GetDefaultAccount(osType, osDist, imageType string) string {
if strings.ToLower(osType) == strings.ToLower(osprofile.OS_TYPE_WINDOWS) {
return api.VM_DEFAULT_WINDOWS_LOGIN_USER
}
return api.VM_DEFAULT_LINUX_LOGIN_USER
+7 -1
View File
@@ -464,7 +464,13 @@ func (self *SManagedVirtualizedGuestDriver) RequestDeployGuestOnHost(ctx context
desc := cloudprovider.SManagedVMCreateConfig{}
// 账号必须在desc.GetConfig()之前设置,避免默认用户不能正常注入
desc.Account = guest.GetDriver().GetDefaultAccount(desc)
osInfo := struct {
OsType string
OsDistribution string
ImageType string
}{}
config.Unmarshal(&osInfo, "desc")
desc.Account = guest.GetDriver().GetDefaultAccount(osInfo.OsType, osInfo.OsDistribution, osInfo.ImageType)
err = desc.GetConfig(config)
if err != nil {
return errors.Wrapf(err, "desc.GetConfig")
+4 -4
View File
@@ -278,14 +278,14 @@ func (self *SQcloudGuestDriver) GetInstanceCapability() cloudprovider.SInstanceC
}
}
func (self *SQcloudGuestDriver) GetDefaultAccount(desc cloudprovider.SManagedVMCreateConfig) string {
func (self *SQcloudGuestDriver) GetDefaultAccount(osType, osDist, imageType string) string {
userName := api.VM_DEFAULT_LINUX_LOGIN_USER
if desc.ImageType == "system" {
if desc.OsDistribution == "Ubuntu" {
if imageType == "system" {
if osDist == "Ubuntu" {
userName = "ubuntu"
}
}
if strings.ToLower(desc.OsType) == strings.ToLower(osprofile.OS_TYPE_WINDOWS) {
if strings.ToLower(osType) == strings.ToLower(osprofile.OS_TYPE_WINDOWS) {
userName = api.VM_DEFAULT_WINDOWS_LOGIN_USER
}
+1 -1
View File
@@ -96,7 +96,7 @@ type IGuestDriver interface {
RemoteDeployGuestForRebuildRoot(ctx context.Context, guest *SGuest, ihost cloudprovider.ICloudHost, task taskman.ITask, desc cloudprovider.SManagedVMCreateConfig) (jsonutils.JSONObject, error)
GetGuestInitialStateAfterCreate() string
GetGuestInitialStateAfterRebuild() string
GetDefaultAccount(desc cloudprovider.SManagedVMCreateConfig) string
GetDefaultAccount(osType, osDist, imageType string) string
GetInstanceCapability() cloudprovider.SInstanceCapability
OnGuestDeployTaskDataReceived(ctx context.Context, guest *SGuest, task taskman.ITask, data jsonutils.JSONObject) error