mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): unified vpc not found error
This commit is contained in:
@@ -854,6 +854,9 @@ func (self *SVpc) GetIRegion() (cloudprovider.ICloudRegion, error) {
|
||||
}
|
||||
|
||||
func (self *SVpc) GetIVpc() (cloudprovider.ICloudVpc, error) {
|
||||
if len(self.ExternalId) == 0 {
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "empty external id")
|
||||
}
|
||||
provider, err := self.GetDriver()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "vpc.GetDriver")
|
||||
|
||||
@@ -127,29 +127,6 @@ func (self *SGoogleRegionDriver) RequestCreateVpc(ctx context.Context, userCred
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SGoogleRegionDriver) RequestDeleteVpc(ctx context.Context, userCred mcclient.TokenCredential, region *models.SCloudregion, vpc *models.SVpc, task taskman.ITask) error {
|
||||
taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) {
|
||||
region, err := vpc.GetIRegion()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "vpc.GetIRegion")
|
||||
}
|
||||
ivpc, err := region.GetIVpcById(vpc.GetExternalId())
|
||||
if err != nil {
|
||||
if errors.Cause(err) == cloudprovider.ErrNotFound {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, errors.Wrap(err, "region.GetIVpcById")
|
||||
}
|
||||
|
||||
err = ivpc.Delete()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "ivpc.Delete")
|
||||
}
|
||||
return nil, nil
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SGoogleRegionDriver) IsSupportedDBInstance() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1252,17 +1252,13 @@ func (self *SManagedVirtualizationRegionDriver) RequestCreateVpc(ctx context.Con
|
||||
|
||||
func (self *SManagedVirtualizationRegionDriver) RequestDeleteVpc(ctx context.Context, userCred mcclient.TokenCredential, region *models.SCloudregion, vpc *models.SVpc, task taskman.ITask) error {
|
||||
taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) {
|
||||
region, err := vpc.GetIRegion()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "vpc.GetIRegion")
|
||||
}
|
||||
ivpc, err := region.GetIVpcById(vpc.GetExternalId())
|
||||
ivpc, err := vpc.GetIVpc()
|
||||
if err != nil {
|
||||
if errors.Cause(err) == cloudprovider.ErrNotFound {
|
||||
// already deleted, do nothing
|
||||
return nil, nil
|
||||
}
|
||||
return nil, errors.Wrap(err, "region.GetIVpcById")
|
||||
return nil, errors.Wrap(err, "GetIVpc")
|
||||
}
|
||||
err = ivpc.Delete()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user