mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-30 18:23:35 +08:00
Merge pull request #5261 from tb365/bugfix/tb-bugfix-0226
ctyun get vm by id fix
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -203,6 +203,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")
|
||||
|
||||
Reference in New Issue
Block a user