From fc0e60c5ec50b20fdc896389ae65fa464b4448d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Sat, 17 Nov 2018 13:02:10 +0800 Subject: [PATCH] =?UTF-8?q?azure=E4=BD=BF=E7=94=A8=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=94=A8=E6=88=B7=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/compute/guestdrivers/aws.go | 6 ++++-- pkg/compute/guestdrivers/azure.go | 11 ++++------- pkg/util/azure/classic_host.go | 4 ---- pkg/util/azure/host.go | 3 ++- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/pkg/compute/guestdrivers/aws.go b/pkg/compute/guestdrivers/aws.go index 163a7278e0..ff6bb28987 100644 --- a/pkg/compute/guestdrivers/aws.go +++ b/pkg/compute/guestdrivers/aws.go @@ -5,6 +5,8 @@ import ( "fmt" "time" + "yunion.io/x/onecloud/pkg/util/ansible" + "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/onecloud/pkg/cloudcommon/db" @@ -158,7 +160,7 @@ func (self *SAwsGuestDriver) RequestDeployGuestOnHost(ctx context.Context, guest return nil, err } - data := fetchIVMinfo(desc, iVM, guest.Id, DEFAULT_USER, passwd, action) + data := fetchIVMinfo(desc, iVM, guest.Id, ansible.PUBLIC_CLOUD_ANSIBLE_USER, passwd, action) return data, nil }) case "rebuild": @@ -210,7 +212,7 @@ func (self *SAwsGuestDriver) RequestDeployGuestOnHost(ctx context.Context, guest } } - data := fetchIVMinfo(desc, iVM, guest.Id, DEFAULT_USER, passwd, action) + data := fetchIVMinfo(desc, iVM, guest.Id, ansible.PUBLIC_CLOUD_ANSIBLE_USER, passwd, action) return data, nil }) diff --git a/pkg/compute/guestdrivers/azure.go b/pkg/compute/guestdrivers/azure.go index 139dbad0e5..6afc543997 100644 --- a/pkg/compute/guestdrivers/azure.go +++ b/pkg/compute/guestdrivers/azure.go @@ -9,6 +9,7 @@ import ( "yunion.io/x/onecloud/pkg/cloudprovider" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" + "yunion.io/x/onecloud/pkg/util/ansible" "yunion.io/x/onecloud/pkg/util/seclib2" "yunion.io/x/pkg/utils" @@ -22,10 +23,6 @@ type SAzureGuestDriver struct { SManagedVirtualizedGuestDriver } -const ( - DEFAULT_USER = "yunion" -) - func init() { driver := SAzureGuestDriver{} models.RegisterGuestDriver(&driver) @@ -169,7 +166,7 @@ func (self *SAzureGuestDriver) RequestDeployGuestOnHost(ctx context.Context, gue return nil, err } - data := fetchIVMinfo(desc, iVM, guest.Id, DEFAULT_USER, passwd, action) + data := fetchIVMinfo(desc, iVM, guest.Id, ansible.PUBLIC_CLOUD_ANSIBLE_USER, passwd, action) return data, nil } }) @@ -192,7 +189,7 @@ func (self *SAzureGuestDriver) RequestDeployGuestOnHost(ctx context.Context, gue if err != nil { return nil, err } - data := fetchIVMinfo(desc, iVM, guest.Id, DEFAULT_USER, passwd, action) + data := fetchIVMinfo(desc, iVM, guest.Id, ansible.PUBLIC_CLOUD_ANSIBLE_USER, passwd, action) return data, nil }) } else if action == "rebuild" { @@ -209,7 +206,7 @@ func (self *SAzureGuestDriver) RequestDeployGuestOnHost(ctx context.Context, gue } log.Debugf("VMrebuildRoot %s, and status is ready", iVM.GetGlobalId()) - data := fetchIVMinfo(desc, iVM, guest.Id, DEFAULT_USER, passwd, action) + data := fetchIVMinfo(desc, iVM, guest.Id, ansible.PUBLIC_CLOUD_ANSIBLE_USER, passwd, action) return data, nil }) diff --git a/pkg/util/azure/classic_host.go b/pkg/util/azure/classic_host.go index 1a943b7dd1..f2c7aa5654 100644 --- a/pkg/util/azure/classic_host.go +++ b/pkg/util/azure/classic_host.go @@ -13,10 +13,6 @@ type SClassicHost struct { zone *SZone } -const ( - DEFAULT_USER = "yunion" -) - func (self *SClassicHost) GetMetadata() *jsonutils.JSONDict { return nil } diff --git a/pkg/util/azure/host.go b/pkg/util/azure/host.go index 4dd6fff0ee..970a497cd7 100644 --- a/pkg/util/azure/host.go +++ b/pkg/util/azure/host.go @@ -8,6 +8,7 @@ import ( "yunion.io/x/log" "yunion.io/x/onecloud/pkg/cloudprovider" "yunion.io/x/onecloud/pkg/compute/models" + "yunion.io/x/onecloud/pkg/util/ansible" ) type SHost struct { @@ -118,7 +119,7 @@ func (self *SHost) _createVM(name string, imgId string, sysDiskSize int32, cpu i }, OsProfile: OsProfile{ ComputerName: name, - AdminUsername: DEFAULT_USER, + AdminUsername: ansible.PUBLIC_CLOUD_ANSIBLE_USER, AdminPassword: passwd, CustomData: userData, },