Example #1
0
  /** Returns maximum block size available in the group. */
  private String getMaxBlockSize() {
    final long free = blockDevInfo.getFreeInVolumeGroup() / 1024;

    String maxBlockSize = "0";
    try {
      final long taken = Long.parseLong(blockDevInfo.getBlockDevice().getBlockSize());
      final BlockDevInfo oBDI = blockDevInfo.getOtherBlockDevInfo();
      long max = free + taken;
      final String lvm = blockDevInfo.getBlockDevice().getName();
      if (hostCheckBoxes != null) {
        for (final Host h : hostCheckBoxes.keySet()) {
          if (blockDevInfo.getHost() == h) {
            continue;
          }
          if (hostCheckBoxes.get(h).isSelected()) {
            for (final BlockDevice b : h.getBlockDevices()) {
              if (lvm.equals(b.getName()) || (oBDI != null && oBDI.getBlockDevice() == b)) {
                final long oFree = h.getFreeInVolumeGroup(b.getVolumeGroup()) / 1024;
                final long oTaken = Long.parseLong(b.getBlockSize());
                if (oFree + oTaken < max) {
                  /* take the smaller maximum. */
                  max = oFree + oTaken;
                }
              }
            }
          }
        }
      }
      maxBlockSize = Long.toString(max);
    } catch (final Exception e) {
      Tools.appWarning("could not get max size");
      /* ignore */
    }
    return maxBlockSize;
  }
Example #2
0
 /** Returns array of volume group checkboxes. */
 private Map<String, JCheckBox> getPVCheckBoxes(final Set<String> selectedPVs) {
   final Map<String, JCheckBox> components = new LinkedHashMap<String, JCheckBox>();
   for (final BlockDevice pv : host.getPhysicalVolumes()) {
     final String pvName = pv.getName();
     final JCheckBox button = new JCheckBox(pvName, selectedPVs.contains(pvName));
     button.setBackground(Tools.getDefaultColor("ConfigDialog.Background.Light"));
     components.put(pvName, button);
   }
   return components;
 }
Example #3
0
 /** LVM Resize and DRBD Resize. */
 private boolean resize(final String size) {
   final boolean ret =
       LVM.resize(blockDevInfo.getHost(), blockDevInfo.getBlockDevice().getName(), size, false);
   if (ret) {
     answerPaneSetText(
         "Lodical volume was successfully resized on " + blockDevInfo.getHost() + ".");
     /* resize lvm volume on the other node. */
     final String lvm = blockDevInfo.getBlockDevice().getName();
     final BlockDevInfo oBDI = blockDevInfo.getOtherBlockDevInfo();
     boolean resizingFailed = false;
     for (final Host h : hostCheckBoxes.keySet()) {
       if (h == blockDevInfo.getHost() || !hostCheckBoxes.get(h).isSelected()) {
         continue;
       }
       for (final BlockDevice b : h.getBlockDevices()) {
         if (lvm.equals(b.getName()) || (oBDI != null && oBDI.getBlockDevice() == b)) {
           /* drbd or selected other host */
           final boolean oRet = LVM.resize(h, b.getName(), size, false);
           if (oRet) {
             answerPaneAddText(
                 "Lodical volume was successfully" + " resized on " + h.getName() + ".");
           } else {
             answerPaneAddTextError(
                 "Resizing of " + b.getName() + " on host " + h.getName() + " failed.");
             resizingFailed = true;
           }
           break;
         }
         if (resizingFailed) {
           break;
         }
       }
     }
     if (oBDI != null && !resizingFailed) {
       final boolean dRet = blockDevInfo.resizeDrbd(false);
       if (dRet) {
         answerPaneAddText(
             "DRBD resource "
                 + blockDevInfo.getDrbdVolumeInfo().getName()
                 + " was successfully resized.");
       } else {
         answerPaneAddTextError(
             "DRBD resource " + blockDevInfo.getDrbdVolumeInfo().getName() + " resizing failed.");
       }
     }
   } else {
     answerPaneAddTextError(
         "Resizing of "
             + blockDevInfo.getName()
             + " on host "
             + blockDevInfo.getHost()
             + " failed.");
   }
   return ret;
 }
Example #4
0
 /** Returns true if the specified host has specified PVs without VGs. */
 private boolean hostHasPVS(final Host host) {
   final Map<String, BlockDevice> oPVS = new HashMap<String, BlockDevice>();
   for (final BlockDevice bd : host.getPhysicalVolumes()) {
     oPVS.put(bd.getName(), bd);
   }
   final Set<String> pvs = pvCheckBoxes.keySet();
   int selected = 0;
   for (final String pv : pvs) {
     if (!pvCheckBoxes.get(pv).isSelected()) {
       continue;
     }
     selected++;
     final BlockDevice opv = oPVS.get(pv);
     if (opv == null) {
       return false;
     }
     if (!opv.isPhysicalVolume() || opv.isVolumeGroupOnPhysicalVolume()) {
       return false;
     }
   }
   return selected > 0;
 }