@Override
  public void onFailed(Guid cmdId, List<Guid> childCmdIds) {
    super.onFailed(cmdId, childCmdIds);

    ImagesHandler.updateImageStatus(getDiskId(), ImageStatus.ILLEGAL);
    log.error("Failed extending disk. ID: {}", getDiskId());
    updateAuditLog(AuditLogType.USER_EXTEND_DISK_SIZE_FAILURE, getCommand().getNewDiskSizeInGB());

    getCommand().getParameters().setTaskGroupSuccess(false);
    getCommand().endAction();
    CommandCoordinatorUtil.removeAllCommandsInHierarchy(cmdId);
  }
Ejemplo n.º 2
0
  private boolean removeVm() {
    final List<DiskImage> diskImages =
        DisksFilter.filterImageDisks(getVm().getDiskList(), ONLY_NOT_SHAREABLE, ONLY_ACTIVE);

    final List<LunDisk> lunDisks =
        DisksFilter.filterLunDisks(getVm().getDiskMap().values(), ONLY_NOT_SHAREABLE);

    for (VmNic nic : getInterfaces()) {
      new ExternalNetworkManager(nic).deallocateIfExternal();
    }

    removeMemoryVolumes();

    TransactionSupport.executeInNewTransaction(
        () -> {
          removeVmFromDb();
          if (getParameters().isRemoveDisks()) {
            for (DiskImage image : diskImages) {
              getCompensationContext().snapshotEntityStatus(image.getImage(), ImageStatus.ILLEGAL);
              ImagesHandler.updateImageStatus(image.getImage().getId(), ImageStatus.LOCKED);
            }

            for (LunDisk lunDisk : lunDisks) {
              ImagesHandler.removeLunDisk(lunDisk);
            }

            getCompensationContext().stateChanged();
          } else {
            for (DiskImage image : diskImages) {
              imageDao.updateImageVmSnapshotId(image.getImageId(), null);
            }
          }
          return null;
        });

    Collection<DiskImage> unremovedDisks = Collections.emptyList();
    if (getParameters().isRemoveDisks()) {
      if (!diskImages.isEmpty()) {
        unremovedDisks = removeVmImages(diskImages).getActionReturnValue();
      }
      unremovedDisks.addAll(removeCinderDisks());
      if (!unremovedDisks.isEmpty()) {
        processUnremovedDisks(unremovedDisks);
        return false;
      }
    }

    vmDeleted.fire(getVmId());
    return true;
  }