fix(region): cloudpods misc fix

This commit is contained in:
ioito
2022-04-06 16:19:51 +08:00
parent 5670fe825b
commit 83faca0aba
4 changed files with 16 additions and 4 deletions

View File

@@ -165,7 +165,7 @@ func (self *SDisk) Resize(ctx context.Context, sizeMb int64) error {
func (self *SDisk) Reset(ctx context.Context, snapId string) (string, error) {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(snapId), "snapshot")
_, err := self.region.perform(&modules.Disks, self.Id, "reset", params)
_, err := self.region.perform(&modules.Disks, self.Id, "disk-reset", params)
return self.Id, err
}

View File

@@ -169,7 +169,6 @@ func (self *SRegion) GetImage(id string) (*SImage, error) {
if err != nil {
return nil, err
}
log.Errorf("resp: %s", resp.PrettyString())
return image, resp.Unmarshal(image)
}

View File

@@ -379,7 +379,20 @@ func (self *SRegion) SaveImage(id, imageName, notes string) (*SImage, error) {
if err != nil {
return nil, err
}
return self.GetImage(imageId)
caches, err := self.GetStoragecaches()
if err != nil {
return nil, errors.Wrapf(err, "GetStoragecaches")
}
if len(caches) == 0 {
return nil, fmt.Errorf("no storage cache found")
}
caches[0].region = self
image, err := self.GetImage(imageId)
if err != nil {
return nil, err
}
image.cache = &caches[0]
return image, nil
}
func (self *SInstance) AllocatePublicIpAddress() (string, error) {

View File

@@ -120,7 +120,7 @@ func (self *SRegion) GetIStoragecacheById(id string) (cloudprovider.ICloudStorag
func (self *SRegion) GetStoragecaches() ([]SStoragecache, error) {
caches := []SStoragecache{}
return caches, self.list(&modules.Storagecaches, nil, caches)
return caches, self.list(&modules.Storagecaches, nil, &caches)
}
func (self *SRegion) GetStoragecache(id string) (*SStoragecache, error) {