mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #17469 from ioito/hotfix/qx-default-user
fix(region): default username
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user