remove vpc router when delete account
fix
@@ -20,6 +20,8 @@ import org.zstack.header.errorcode.ErrorCode;
import org.zstack.header.host.HostInventory;
import org.zstack.header.host.HostVO;
import org.zstack.header.host.HostVO_;
+import org.zstack.header.identity.AccountInventory;
+import org.zstack.header.identity.AccountVO;
import org.zstack.header.message.MessageReply;
import org.zstack.header.network.l2.L2NetworkConstant;
import org.zstack.header.network.l2.L2NetworkDetachStruct;
@@ -69,6 +71,10 @@ public class ApplianceVmCascadeExtension extends AbstractAsyncCascadeExtension {
return OP_DELETION;
}
+ if (AccountVO.class.getSimpleName().equals(action.getParentIssuer())) {
+ return OP_DELETION;
+ }
+
if (HostVO.class.getSimpleName().equals(action.getParentIssuer())) {
if (ZoneVO.class.getSimpleName().equals(action.getRootIssuer())) {
return OP_DELETION;
@@ -501,7 +507,8 @@ public class ApplianceVmCascadeExtension extends AbstractAsyncCascadeExtension {
@Override
public List<String> getEdgeNames() {
return Arrays.asList(HostVO.class.getSimpleName(), L3NetworkVO.class.getSimpleName(),
- IpRangeVO.class.getSimpleName(), PrimaryStorageVO.class.getSimpleName(), L2NetworkVO.class.getSimpleName());
+ IpRangeVO.class.getSimpleName(), PrimaryStorageVO.class.getSimpleName(), L2NetworkVO.class.getSimpleName(),
+ AccountVO.class.getSimpleName());
}
@Override
@@ -666,6 +673,30 @@ public class ApplianceVmCascadeExtension extends AbstractAsyncCascadeExtension {
if (!vmvos.isEmpty()) {
ret = ApplianceVmInventory.valueOf1(vmvos);
}
+ } else if (AccountVO.class.getSimpleName().equals(action.getParentIssuer())) {
+ final List<String> auuids = CollectionUtils.transformToList((List<AccountInventory>) action.getParentIssuerContext(), new Function<String, AccountInventory>() {
+ @Override
+ public String call(AccountInventory arg) {
+ return arg.getUuid();
+ }
+ });
+
+ List<ApplianceVmVO> vos = new Callable<List<ApplianceVmVO>>() {
+ @Override
+ @Transactional(readOnly = true)
+ public List<ApplianceVmVO> call() {
+ String sql = "select d from ApplianceVmVO d, AccountResourceRefVO r where d.uuid = r.resourceUuid and" +
+ " r.resourceType = :rtype and r.accountUuid in (:auuids)";
+ TypedQuery<ApplianceVmVO> q = dbf.getEntityManager().createQuery(sql, ApplianceVmVO.class);
+ q.setParameter("auuids", auuids);
+ q.setParameter("rtype", "VpcRouterVmVO");
+ return q.getResultList();
+ }
+ }.call();
+
+ if (!vos.isEmpty()) {
+ return ApplianceVmInventory.valueOf1(vos);
+ }
}
return ret;
