make dissociate action idempotennt

This commit is contained in:
Qiu Jian
2019-01-16 00:55:29 +08:00
parent 1287af044f
commit c90d6b1acd
+6 -1
View File
@@ -641,8 +641,13 @@ func (self *SElasticip) AllowPerformDissociate(ctx context.Context, userCred mcc
}
func (self *SElasticip) PerformDissociate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
if len(self.AssociateId) == 0 {
return nil, nil // success
}
// associate with an invalid vm
if !self.IsAssociated() {
return nil, httperrors.NewConflictError("eip is not associated with instance")
return nil, self.Dissociate(ctx, userCred)
}
if self.Status != EIP_STATUS_READY {