Example #1
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 #2
0
 /** Check if it is DRBD device and if it could be resized. */
 private boolean checkDRBD() {
   if (blockDevInfo.getBlockDevice().isDrbd()) {
     final DrbdVolumeInfo dvi = blockDevInfo.getDrbdVolumeInfo();
     final BlockDevInfo oBDI = blockDevInfo.getOtherBlockDevInfo();
     if (!dvi.isConnected(false)) {
       printErrorAndRetry("Not resizing. DRBD resource is not connected.");
       sizeWi.setEnabled(false);
       resizeButton.setEnabled(false);
       return false;
     } else if (dvi.isSyncing()) {
       printErrorAndRetry("Not resizing. DRBD resource is syncing.");
       sizeWi.setEnabled(false);
       resizeButton.setEnabled(false);
       return false;
     } else if (!oBDI.getBlockDevice().isAttached()) {
       printErrorAndRetry(
           "Not resizing. DRBD resource is not attached on " + oBDI.getHost() + ".");
       sizeWi.setEnabled(false);
       resizeButton.setEnabled(false);
       return false;
     } else if (!blockDevInfo.getBlockDevice().isAttached()) {
       printErrorAndRetry(
           "Not resizing. DRBD resource is not attached on " + blockDevInfo.getHost() + ".");
       sizeWi.setEnabled(false);
       resizeButton.setEnabled(false);
       return false;
     } else if (!oBDI.getBlockDevice().isPrimary() && !blockDevInfo.getBlockDevice().isPrimary()) {
       printErrorAndRetry("Not resizing. Must be primary at least on one node.");
       sizeWi.setEnabled(false);
       resizeButton.setEnabled(false);
       return false;
     }
   }
   return true;
 }