mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
Merge pull request #15185 from gouqi11/fix/remotefile
fix/remotefile guest
This commit is contained in:
@@ -2673,6 +2673,9 @@ func (self *SGuest) syncRemoveCloudVM(ctx context.Context, userCred mcclient.Tok
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(self.ExternalId) == 0 {
|
||||
return self.purge(ctx, userCred)
|
||||
}
|
||||
iVM, err := iregion.GetIVMById(self.ExternalId)
|
||||
if err == nil { //漂移归位
|
||||
if hostId := iVM.GetIHostId(); len(hostId) > 0 {
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
type SProject struct {
|
||||
multicloud.SProjectBase
|
||||
multicloud.RemoteFileTags
|
||||
|
||||
Id string
|
||||
Name string
|
||||
|
||||
@@ -17,6 +17,8 @@ package remotefile
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
@@ -85,8 +87,18 @@ func (self *SRegion) GetIZoneById(id string) (cloudprovider.ICloudZone, error) {
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIVMById(id string) (cloudprovider.ICloudVM, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
func (region *SRegion) GetIVMById(id string) (cloudprovider.ICloudVM, error) {
|
||||
instances, err := region.client.GetInstances()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
instance := SInstance{}
|
||||
for _, v := range instances {
|
||||
if v.Id == id {
|
||||
return &instance, nil
|
||||
}
|
||||
}
|
||||
return nil, errors.Wrapf(errors.ErrNotFound, "GetIVMById:%s", id)
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIDiskById(id string) (cloudprovider.ICloudDisk, error) {
|
||||
|
||||
Reference in New Issue
Block a user