예제 #1
0
  private boolean isPlugAvailableByDisks(boolean plug) {
    ArrayList<Disk> disks =
        getSelectedItems() != null ? Linq.<Disk>cast(getSelectedItems()) : new ArrayList<Disk>();

    for (Disk disk : disks) {
      boolean isLocked =
          disk.getDiskStorageType() == DiskStorageType.IMAGE
              && ((DiskImage) disk).getImageStatus() == ImageStatus.LOCKED;

      boolean isDiskHotpluggableInterface = false;
      if (getEntity() != null) {
        isDiskHotpluggableInterface =
            AsyncDataProvider.getInstance()
                .getDiskHotpluggableInterfaces(
                    getEntity().getOs(), getEntity().getVdsGroupCompatibilityVersion())
                .contains(disk.getDiskInterface());
      }

      if (disk.getPlugged() == plug || isLocked || (!isDiskHotpluggableInterface && !isVmDown())) {
        return false;
      }
    }

    return true;
  }
예제 #2
0
  private void updateActionAvailability() {
    Disk disk = getSelectedItem();

    getNewCommand().setIsExecutionAllowed(true);

    getAttachCommand().setIsExecutionAllowed(true);

    getEditCommand()
        .setIsExecutionAllowed(
            disk != null
                && isSingleDiskSelected()
                && !isDiskLocked(disk)
                && (isVmDown()
                    || !disk.getPlugged()
                    || (isExtendImageSizeSupported() && isExtendImageSizeEnabled())));

    getRemoveCommand()
        .setIsExecutionAllowed(atLeastOneDiskSelected() && isRemoveCommandAvailable());

    getMoveCommand()
        .setIsExecutionAllowed(
            atLeastOneDiskSelected() && (isMoveCommandAvailable() || isLiveMoveCommandAvailable()));

    updateScanAlignmentCommandAvailability();

    getPlugCommand().setIsExecutionAllowed(isPlugCommandAvailable(true));

    getUnPlugCommand().setIsExecutionAllowed(isPlugCommandAvailable(false));

    ChangeQuotaModel.updateChangeQuotaActionAvailability(
        getItems() != null ? (List<Disk>) getItems() : null,
        getSelectedItems() != null ? getSelectedItems() : null,
        getSystemTreeSelectedItem(),
        getChangeQuotaCommand());
  }
 public static List<CinderDisk> filterDisksBasedOnCinder(
     Collection<? extends Disk> listOfDisks, boolean onlyPluggedDisks) {
   List<CinderDisk> cinderDisks = new ArrayList<>();
   for (Disk disk : listOfDisks) {
     if (disk.getDiskStorageType() == DiskStorageType.CINDER) {
       if (!onlyPluggedDisks || disk.getPlugged()) {
         cinderDisks.add((CinderDisk) disk);
       }
     }
   }
   return cinderDisks;
 }
예제 #4
0
  private boolean isRemoveCommandAvailable() {
    ArrayList<Disk> disks =
        getSelectedItems() != null ? Linq.<Disk>cast(getSelectedItems()) : new ArrayList<Disk>();

    for (Disk disk : disks) {
      if (isDiskLocked(disk) || (!isVmDown() && disk.getPlugged())) {
        return false;
      }
    }

    return true;
  }
예제 #5
0
  private boolean isMoveCommandAvailable() {
    ArrayList<Disk> disks =
        getSelectedItems() != null ? Linq.<Disk>cast(getSelectedItems()) : new ArrayList<Disk>();

    for (Disk disk : disks) {
      if (!isImageDiskOK(disk) || (!isVmDown() && disk.getPlugged()) || disk.isDiskSnapshot()) {
        return false;
      }
    }

    return true;
  }