From c08f35b9f8539bc5e6a1b04b4bfb4f3df849f3a5 Mon Sep 17 00:00:00 2001 From: TangBin Date: Wed, 26 Feb 2020 11:16:42 +0800 Subject: [PATCH 1/4] ctyun get vm by id fix --- pkg/multicloud/ctyun/host.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/multicloud/ctyun/host.go b/pkg/multicloud/ctyun/host.go index 5627646113..b1ebbd21ec 100644 --- a/pkg/multicloud/ctyun/host.go +++ b/pkg/multicloud/ctyun/host.go @@ -265,6 +265,10 @@ func (self *SRegion) GetVMs() ([]SInstance, error) { } func (self *SRegion) GetVMById(vmId string) (*SInstance, error) { + if len(vmId) == 0 { + return nil, errors.Wrap(cloudprovider.ErrNotFound, "SRegion.GetVMById.EmptyVmID") + } + vms, err := self.getVMs(vmId) if err != nil { return nil, errors.Wrap(err, "SRegion.GetVMById") From 5c3ba45f4da5e2b6f495ac543e11444e559ab8eb Mon Sep 17 00:00:00 2001 From: TangBin Date: Wed, 26 Feb 2020 14:41:03 +0800 Subject: [PATCH 2/4] ctyun attach disk fix --- pkg/multicloud/ctyun/instance.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/multicloud/ctyun/instance.go b/pkg/multicloud/ctyun/instance.go index 048fc61293..4cb3d9aec3 100644 --- a/pkg/multicloud/ctyun/instance.go +++ b/pkg/multicloud/ctyun/instance.go @@ -166,6 +166,13 @@ func (self *SInstance) Refresh() error { return cloudprovider.ErrNotFound } + // update details + detail, err := self.host.zone.region.GetVMDetails(self.GetId()) + if err != nil { + return errors.Wrap(err, "SInstance.Refresh.GetDetails") + } + + self.vmDetails = detail return jsonutils.Update(self, new) } From 5140a0f7a6060e07c78e911b6f83bf5c19dce1b3 Mon Sep 17 00:00:00 2001 From: TangBin Date: Wed, 26 Feb 2020 16:25:50 +0800 Subject: [PATCH 3/4] ctyun eip charge type fix --- pkg/compute/models/elasticips.go | 4 +++- pkg/multicloud/ctyun/eip.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/compute/models/elasticips.go b/pkg/compute/models/elasticips.go index 8166c05e35..c520dd0932 100644 --- a/pkg/compute/models/elasticips.go +++ b/pkg/compute/models/elasticips.go @@ -366,7 +366,9 @@ func (self *SElasticip) SyncWithCloudEip(ctx context.Context, userCred mcclient. self.ExternalId = ext.GetGlobalId() self.IsEmulated = ext.IsEmulated() - self.ChargeType = ext.GetInternetChargeType() + if chargeType := ext.GetInternetChargeType(); len(chargeType) > 0 { + self.ChargeType = chargeType + } factory, _ := provider.GetProviderFactory() if factory != nil && factory.IsSupportPrepaidResources() { diff --git a/pkg/multicloud/ctyun/eip.go b/pkg/multicloud/ctyun/eip.go index d51ca6b67b..8cb4693dee 100644 --- a/pkg/multicloud/ctyun/eip.go +++ b/pkg/multicloud/ctyun/eip.go @@ -188,7 +188,7 @@ func (self *SEip) GetBandwidth() int { func (self *SEip) GetInternetChargeType() string { // todo: fix me - return api.EIP_CHARGE_TYPE_BY_BANDWIDTH + return "" } func (self *SEip) Delete() error { From bce284a4c402028f5e98eb07f6f013e9859522c0 Mon Sep 17 00:00:00 2001 From: TangBin Date: Wed, 26 Feb 2020 17:12:41 +0800 Subject: [PATCH 4/4] ctyun vpc create fix --- pkg/multicloud/ctyun/region.go | 1 + pkg/multicloud/ctyun/vpc.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/pkg/multicloud/ctyun/region.go b/pkg/multicloud/ctyun/region.go index ffcdb1bb0e..a119051a8e 100644 --- a/pkg/multicloud/ctyun/region.go +++ b/pkg/multicloud/ctyun/region.go @@ -115,6 +115,7 @@ func (self *SRegion) CreateVpc(name, cidr string) (*SVpc, error) { return nil, err } + vpc.ResVpcID, _ = resp.GetString("returnObj", "id") vpc.region = self return vpc, nil } diff --git a/pkg/multicloud/ctyun/vpc.go b/pkg/multicloud/ctyun/vpc.go index c0aaab847e..743a51da97 100644 --- a/pkg/multicloud/ctyun/vpc.go +++ b/pkg/multicloud/ctyun/vpc.go @@ -204,6 +204,10 @@ func (self *SRegion) GetVpc(vpcId string) (*SVpc, error) { return nil, errors.Wrap(err, "SRegion.GetVpc.DoGet") } + if id, _ := resp.GetString("returnObj", "resVpcId"); len(id) == 0 { + return nil, errors.Wrap(cloudprovider.ErrNotFound, "SRegion.GetVpc.GetID") + } + err = resp.Unmarshal(vpc, "returnObj") if err != nil { return nil, errors.Wrap(err, "SRegion.GetVpc.Unmarshal")