mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
vpcs: 自动删除wire
This commit is contained in:
@@ -701,7 +701,7 @@ func (self *SVpc) Delete(ctx context.Context, userCred mcclient.TokenCredential)
|
||||
}
|
||||
|
||||
func (self *SVpc) CustomizeDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) error {
|
||||
if len(self.ExternalId) > 0 {
|
||||
if self.Id != api.DEFAULT_VPC_ID {
|
||||
return self.StartDeleteVpcTask(ctx, userCred)
|
||||
} else {
|
||||
return self.RealDelete(ctx, userCred)
|
||||
|
||||
@@ -937,3 +937,20 @@ func (self *SWire) getMoreDetails(extra *jsonutils.JSONDict) *jsonutils.JSONDict
|
||||
}
|
||||
return extra
|
||||
}
|
||||
|
||||
func (man *SWireManager) removeWiresByVpc(ctx context.Context, userCred mcclient.TokenCredential, vpc *SVpc) error {
|
||||
wires := []SWire{}
|
||||
q := man.Query().Equals("vpc_id", vpc.Id)
|
||||
err := db.FetchModelObjects(man, q, &wires)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var errs []error
|
||||
for i := range wires {
|
||||
wire := &wires[i]
|
||||
if err := wire.Delete(ctx, userCred); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user