Esempio n. 1
0
  @Override
  public CascadeAction createActionForChildResource(CascadeAction action) {
    if (CascadeConstant.DELETION_CODES.contains(action.getActionCode())) {
      int op = toDeletionOpCode(action);
      if (op == OP_NOPE || op == OP_STOP || op == OP_REMOVE_INSTANCE_OFFERING) {
        return null;
      }

      List<VmInstanceInventory> vms = vmFromDeleteAction(action);
      if (vms == null) {
        return null;
      }

      return action.copy().setParentIssuer(NAME).setParentIssuerContext(vms);
    }

    return null;
  }
Esempio n. 2
0
  private int toDeletionOpCode(CascadeAction action) {
    if (!CascadeConstant.DELETION_CODES.contains(action.getActionCode())) {
      return OP_NOPE;
    }

    if (PrimaryStorageVO.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;
      } else {
        return OP_STOP;
      }
    }

    if (L3NetworkVO.class.getSimpleName().equals(action.getParentIssuer())) {
      return OP_DETACH_NIC;
    }

    if (IpRangeVO.class.getSimpleName().equals(action.getParentIssuer())
        && IpRangeVO.class.getSimpleName().equals(action.getRootIssuer())) {
      return OP_STOP;
    }

    if (VmInstanceVO.class.getSimpleName().equals(action.getParentIssuer())) {
      return OP_DELETION;
    }

    if (InstanceOfferingVO.class.getSimpleName().equals(action.getParentIssuer())) {
      return OP_REMOVE_INSTANCE_OFFERING;
    }

    if (AccountVO.class.getSimpleName().equals(action.getParentIssuer())) {
      return OP_DELETION;
    }

    return OP_NOPE;
  }