<fix>[eip]: change owner of vip when change owner of eip
Resolves:
@@ -1784,11 +1784,26 @@ public class EipManagerImpl extends AbstractService implements EipManager, VipRe
@Override
public void resourceOwnerAfterChange(AccountResourceRefInventory ref, String newOwnerUuid) {
- if (!VmInstanceVO.class.getSimpleName().equals(ref.getResourceType())) {
+ if (VmInstanceVO.class.getSimpleName().equals(ref.getResourceType())) {
+ changeEipOwner(ref, newOwnerUuid);
+ }
+
+ if (EipVO.class.getSimpleName().equals(ref.getResourceType())) {
+ changeVipOwner(ref, newOwnerUuid);
+ }
+ }
+
+ @Transactional
+ private void changeVipOwner(AccountResourceRefInventory ref, String newOwnerUuid) {
+ String vipUuid = Q.New(EipVO.class).eq(EipVO_.uuid, ref.getResourceUuid()).select(EipVO_.vipUuid).findValue();
+
+ if (StringUtils.isBlank(vipUuid)) {
+ logger.debug(String.format("Eip[uuid:%s] doesn't have any vip, there is no need to change owner of vip.",
+ ref.getResourceUuid()));
return;
}
- changeEipOwner(ref, newOwnerUuid);
+ acntMgr.changeResourceOwner(vipUuid, newOwnerUuid);
}
@Transactional
