Beispiel #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;
 }
Beispiel #2
0
  /** Returns the input pane. */
  @Override
  protected JComponent getInputPane() {
    createButton.setEnabled(false);
    final JPanel pane = new JPanel(new SpringLayout());
    /* vg name */
    final JPanel inputPane = new JPanel(new SpringLayout());
    inputPane.setBackground(Browser.BUTTON_PANEL_BACKGROUND);

    /* find next free group volume name */
    String defaultName;
    final Set<String> volumeGroups = host.getVolumeGroupNames();
    int i = 0;
    while (true) {
      defaultName = "vg" + String.format("%02d", i);
      if (volumeGroups == null || !volumeGroups.contains(defaultName)) {
        break;
      }
      i++;
    }
    vgNameWi =
        WidgetFactory.createInstance(
            Widget.Type.TEXTFIELD,
            defaultName,
            Widget.NO_ITEMS,
            Widget.NO_REGEXP,
            250,
            Widget.NO_ABBRV,
            new AccessMode(ConfigData.AccessType.OP, !AccessMode.ADVANCED),
            Widget.NO_BUTTON);
    inputPane.add(new JLabel("VG Name"));
    inputPane.add(vgNameWi);

    createButton.addActionListener(new CreateActionListener());
    inputPane.add(createButton);
    SpringUtilities.makeCompactGrid(
        inputPane, 1, 3, /* rows, cols */ 1, 1, /* initX, initY */ 1, 1); /* xPad, yPad */

    pane.add(inputPane);
    /* Volume groups. */
    final JPanel pvsPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    final Set<String> selectedPVs = new HashSet<String>();
    final Set<Host> selectedHosts = new HashSet<Host>();
    for (final BlockDevInfo sbdi : selectedBlockDevInfos) {
      if (sbdi.getBlockDevice().isDrbd()) {
        selectedPVs.add(sbdi.getBlockDevice().getDrbdBlockDevice().getName());
      } else {
        selectedPVs.add(sbdi.getName());
      }
      selectedHosts.add(sbdi.getHost());
    }
    pvCheckBoxes = getPVCheckBoxes(selectedPVs);
    pvsPane.add(new JLabel("Select physical volumes: "));
    for (final String pvName : pvCheckBoxes.keySet()) {
      pvCheckBoxes.get(pvName).addItemListener(new ItemChangeListener(true));
      pvsPane.add(pvCheckBoxes.get(pvName));
    }
    final JScrollPane pvSP = new JScrollPane(pvsPane);
    pvSP.setPreferredSize(new Dimension(0, 45));
    pane.add(pvSP);

    final JPanel hostsPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    final Cluster cluster = host.getCluster();
    hostCheckBoxes = Tools.getHostCheckBoxes(cluster);
    hostsPane.add(new JLabel("Select Hosts: "));
    for (final Host h : hostCheckBoxes.keySet()) {
      hostCheckBoxes.get(h).addItemListener(new ItemChangeListener(true));
      if (host == h) {
        hostCheckBoxes.get(h).setEnabled(false);
        hostCheckBoxes.get(h).setSelected(true);
      } else if (isOneDrbd(selectedBlockDevInfos)) {
        hostCheckBoxes.get(h).setEnabled(false);
        hostCheckBoxes.get(h).setSelected(false);
      } else if (hostHasPVS(h)) {
        hostCheckBoxes.get(h).setEnabled(true);
        hostCheckBoxes.get(h).setSelected(selectedHosts.contains(h));
      } else {
        hostCheckBoxes.get(h).setEnabled(false);
        hostCheckBoxes.get(h).setSelected(false);
      }
      hostsPane.add(hostCheckBoxes.get(h));
    }
    final JScrollPane sp = new JScrollPane(hostsPane);
    sp.setPreferredSize(new Dimension(0, 45));
    pane.add(sp);
    pane.add(getProgressBarPane(null));
    pane.add(getAnswerPane(""));
    SpringUtilities.makeCompactGrid(
        pane, 5, 1, /* rows, cols */ 0, 0, /* initX, initY */ 0, 0); /* xPad, yPad */
    checkButtons();
    return pane;
  }