예제 #1
0
파일: GroupInfo.java 프로젝트: rdndnl/lcmc
 /**
  * Adds service to this group. Adds it in the submenu in the menu tree and initializes it.
  *
  * @param newServiceInfo service info object of the new service
  */
 void addGroupServicePanel(final ServiceInfo newServiceInfo, final boolean reloadNode) {
   final DefaultMutableTreeNode gn = getNode();
   if (gn == null) {
     return;
   }
   newServiceInfo
       .getService()
       .setResourceClass(newServiceInfo.getResourceAgent().getResourceClass());
   newServiceInfo.setGroupInfo(this);
   getBrowser().addNameToServiceInfoHash(newServiceInfo);
   getBrowser().addToHeartbeatIdList(newServiceInfo);
   final DefaultMutableTreeNode newServiceNode = new DefaultMutableTreeNode(newServiceInfo);
   newServiceInfo.setNode(newServiceNode);
   Tools.invokeLater(
       !Tools.CHECK_SWING_THREAD,
       new Runnable() {
         @Override
         public void run() {
           gn.add(newServiceNode);
           if (reloadNode) {
             getBrowser().reloadAndWait(gn, false);
             getBrowser().reloadAndWait(newServiceNode, true);
           }
         }
       });
 }
예제 #2
0
파일: VGCreate.java 프로젝트: rdndnl/lcmc
 /** Enables and disabled buttons. */
 protected void checkButtons() {
   boolean enable = true;
   for (final Host h : hostCheckBoxes.keySet()) {
     if (hostCheckBoxes.get(h).isSelected() && !hostHasPVS(h)) {
       enable = false;
       break;
     }
   }
   Tools.invokeLater(new EnableCreateRunnable(enable));
 }
예제 #3
0
  /** Applies the changes. */
  @Override
  void apply(final boolean testOnly) {
    if (testOnly) {
      return;
    }
    Tools.invokeAndWait(
        new Runnable() {
          @Override
          public void run() {
            getApplyButton().setEnabled(false);
            getRevertButton().setEnabled(false);
            getInfoPanel();
          }
        });
    waitForInfoPanel();
    final Map<String, String> parameters = getHWParameters(getResource().isNew());
    final String[] params = getRealParametersFromXML();
    for (final Host h : getVMSVirtualDomainInfo().getDefinedOnHosts()) {
      final VMSXML vmsxml = getBrowser().getVMSXML(h);
      if (vmsxml != null) {
        final String domainName = getVMSVirtualDomainInfo().getDomainName();
        final Node domainNode = vmsxml.getDomainNode(domainName);
        /* fix host ports */

        fixSourceHostParams(parameters);
        final String fixedNames = parameters.get(DiskData.SOURCE_HOST_NAME);
        final String fixedPorts = parameters.get(DiskData.SOURCE_HOST_PORT);

        for (final String p : sourceHostNameWi.keySet()) {
          sourceHostNameWi.get(p).setValueAndWait(fixedNames);
        }
        for (final String p : sourceHostPortWi.keySet()) {
          sourceHostPortWi.get(p).setValueAndWait(fixedPorts);
        }
        modifyXML(vmsxml, domainNode, domainName, parameters);
        final String virshOptions = getVMSVirtualDomainInfo().getVirshOptions();
        vmsxml.saveAndDefine(domainNode, domainName, virshOptions);
      }
    }
    getResource().setNew(false);
    getBrowser().reload(getNode(), false);
    getBrowser().periodicalVMSUpdate(getVMSVirtualDomainInfo().getDefinedOnHosts());
    Tools.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            tablePanel.setVisible(true);
          }
        });
    if (!testOnly) {
      storeComboBoxValues(params);
    }
    checkResourceFieldsChanged(null, params);
  }
예제 #4
0
 /** Adds disk table with only this disk to the main panel. */
 @Override
 protected void addHardwareTable(final JPanel mainPanel) {
   tablePanel =
       getTablePanel(
           "Disk", VMSVirtualDomainInfo.DISK_TABLE, getNewBtn(getVMSVirtualDomainInfo()));
   if (getResource().isNew()) {
     Tools.invokeLater(
         !Tools.CHECK_SWING_THREAD,
         new Runnable() {
           @Override
           public void run() {
             tablePanel.setVisible(false);
           }
         });
   }
   mainPanel.add(tablePanel);
 }
예제 #5
0
파일: Connect.java 프로젝트: rdndnl/lcmc
  /** Checks hosts, if they are connected and if not reconnects them. */
  protected void checkHosts() {
    final StringBuilder text = new StringBuilder();
    boolean pending = false;
    boolean oneFailed = false;
    for (final Host host : getCluster().getHosts()) {
      String status;
      if (host.getSSH().isConnectionFailed()) {
        status = "failed.";
        oneFailed = true;
      } else if (host.isConnected()) {
        status = "connected.";
      } else {
        pending = true;
        status = "connecting...";
      }
      text.append(host.getName() + " " + status + "\n");
    }
    LOG.debug("checkHosts: pending: " + pending + ", one failed: " + oneFailed);
    if (pending) {
      answerPaneSetText(text.toString());
    } else if (oneFailed) {
      printErrorAndRetry(text.toString());
    } else {
      answerPaneSetText(text.toString());
      try {
        Thread.sleep(1000);
      } catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
      }

      Tools.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              buttonClass(nextButton()).pressButton();
            }
          });
    }
  }
예제 #6
0
파일: GroupInfo.java 프로젝트: rdndnl/lcmc
  /** Applies the changes to the group parameters. */
  @Override
  void apply(final Host dcHost, final boolean testOnly) {
    if (!testOnly) {
      Tools.invokeAndWait(
          new Runnable() {
            @Override
            public void run() {
              getApplyButton().setEnabled(false);
              getRevertButton().setEnabled(false);
            }
          });
    }
    getInfoPanel();
    waitForInfoPanel();
    final String[] params = getParametersFromXML();
    if (!testOnly) {
      Tools.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              getApplyButton().setToolTipText("");
              final Widget idField = getWidget(GUI_ID, null);
              idField.setEnabled(false);
            }
          });

      /* add myself to the hash with service name and id as
       * keys */
      getBrowser().removeFromServiceInfoHash(this);
      final String oldHeartbeatId = getHeartbeatId(testOnly);
      if (oldHeartbeatId != null) {
        getBrowser().mHeartbeatIdToServiceLock();
        getBrowser().getHeartbeatIdToServiceInfo().remove(oldHeartbeatId);
        getBrowser().mHeartbeatIdToServiceUnlock();
      }
      if (getService().isNew()) {
        final String id = getComboBoxValue(GUI_ID);
        getService().setIdAndCrmId(id);
        if (getTypeRadioGroup() != null) {
          getTypeRadioGroup().setEnabled(false);
        }
      }
      getBrowser().addNameToServiceInfoHash(this);
      getBrowser().addToHeartbeatIdList(this);
    }

    /*
        MSG_ADD_GRP group
                param_id1 param_name1 param_value1
                param_id2 param_name2 param_value2
                ...
                param_idn param_namen param_valuen
    */
    final String heartbeatId = getHeartbeatId(testOnly);
    if (getService().isNew()) {
      final Set<ServiceInfo> parents = getBrowser().getCRMGraph().getParents(this);
      final List<Map<String, String>> colAttrsList = new ArrayList<Map<String, String>>();
      final List<Map<String, String>> ordAttrsList = new ArrayList<Map<String, String>>();
      final List<String> parentIds = new ArrayList<String>();
      for (final ServiceInfo parentInfo : parents) {
        final String parentId = parentInfo.getService().getHeartbeatId();
        parentIds.add(parentId);
        final Map<String, String> colAttrs = new LinkedHashMap<String, String>();
        final Map<String, String> ordAttrs = new LinkedHashMap<String, String>();
        colAttrs.put(CRMXML.SCORE_STRING, CRMXML.INFINITY_STRING);
        ordAttrs.put(CRMXML.SCORE_STRING, CRMXML.INFINITY_STRING);
        if (getService().isMaster()) {
          colAttrs.put("with-rsc-role", "Master");
          ordAttrs.put("first-action", "promote");
          ordAttrs.put("then-action", "start");
        }
        colAttrsList.add(colAttrs);
        ordAttrsList.add(ordAttrs);
      }
      CRM.setOrderAndColocation(
          dcHost,
          heartbeatId,
          parentIds.toArray(new String[parentIds.size()]),
          colAttrsList,
          ordAttrsList,
          testOnly);
      @SuppressWarnings("unchecked")
      final Enumeration<DefaultMutableTreeNode> e = getNode().children();
      final List<String> newOrder = new ArrayList<String>();
      while (e.hasMoreElements()) {
        final DefaultMutableTreeNode n = e.nextElement();
        final ServiceInfo child = (ServiceInfo) n.getUserObject();
        newOrder.add(child.getHeartbeatId(testOnly));
      }
      applyWhole(dcHost, true, newOrder, testOnly);
      if (!testOnly) {
        setApplyButtons(null, params);
      }
      getBrowser().getCRMGraph().repaint();
      return;
    } else {
      final Map<String, String> groupMetaArgs = new LinkedHashMap<String, String>();
      for (String param : params) {
        if (GUI_ID.equals(param) || PCMK_ID.equals(param)) {
          continue;
        }
        final String value = getComboBoxValue(param);
        if (value.equals(getParamDefault(param))) {
          continue;
        }
        if (!"".equals(value)) {
          if (CRMXML.GROUP_ORDERED_META_ATTR.equals(param)) {
            groupMetaArgs.put("ordered", value);
          } else {
            groupMetaArgs.put(param, value);
          }
        }
      }
      CRM.setParameters(
          dcHost,
          "-R",
          null, /* crm id */
          null, /* TODO: clone id */
          false, /* master */
          null, /* cloneMetaArgs, */
          groupMetaArgs,
          heartbeatId, /* group id */
          null, /* pacemakerResAttrs, */
          null, /* pacemakerResArgs, */
          null, /* pacemakerMetaArgs, */
          null, /* cs.getResourceInstanceAttrId(heartbeatId), */
          null, /* cs.getParametersNvpairsIds(heartbeatId), */
          null, /* getOperations(heartbeatId), */
          null, /* cs.getOperationsId(heartbeatId), */
          null, /* getMetaAttrsRefId(), */
          null, /* cloneMetaAttrsRefIds, */
          getMetaAttrsRefId(),
          null, /* getOperationsRefId(), */
          false, /* stonith */
          testOnly);
    }
    final CloneInfo ci = getCloneInfo();
    if (ci == null) {
      setLocations(heartbeatId, dcHost, testOnly);
    } else {
      ci.setLocations(heartbeatId, dcHost, testOnly);
    }
    if (!testOnly) {
      storeComboBoxValues(params);
      getBrowser().reload(getNode(), false);
    }
    final ClusterStatus cs = getBrowser().getClusterStatus();
    final List<String> resources = cs.getGroupResources(getHeartbeatId(testOnly), testOnly);
    if (resources != null) {
      for (final String hbId : resources) {
        final ServiceInfo gsi = getBrowser().getServiceInfoFromCRMId(hbId);

        if (gsi != null
            && gsi.checkResourceFieldsCorrect(null, gsi.getParametersFromXML(), false, false, true)
            && gsi.checkResourceFieldsChanged(
                null, gsi.getParametersFromXML(), false, false, true)) {
          gsi.apply(dcHost, testOnly);
        }
      }
    }
    if (!testOnly) {
      setApplyButtons(null, params);
    }
    getBrowser().getCRMGraph().repaint();
  }
예제 #7
0
 /** Returns true if the value of the parameter is ok. */
 @Override
 protected boolean checkParam(final String param, final String newValue) {
   if (DiskData.TYPE.equals(param)) {
     Tools.invokeLater(
         !Tools.CHECK_SWING_THREAD,
         new Runnable() {
           @Override
           public void run() {
             final boolean file = FILE_TYPE.equals(newValue);
             final boolean block = BLOCK_TYPE.equals(newValue);
             final boolean network = NETWORK_TYPE.equals(newValue);
             for (final String p : sourceFileWi.keySet()) {
               sourceFileWi.get(p).setVisible(file);
             }
             for (final String p : sourceDeviceWi.keySet()) {
               sourceDeviceWi.get(p).setVisible(block);
             }
             for (final Map<String, Widget> w : checkFieldList) {
               for (String p : w.keySet()) {
                 w.get(p).setVisible(network);
               }
             }
           }
         });
     checkOneParam(DiskData.SOURCE_FILE);
     checkOneParam(DiskData.SOURCE_DEVICE);
   } else if (DiskData.TARGET_BUS_TYPE.equals(param)) {
     final Set<String> devices = new LinkedHashSet<String>();
     devices.add(null);
     if (newValue != null) {
       final String[] targetDevices = TARGET_DEVICES_MAP.get(newValue);
       if (targetDevices != null) {
         for (final String dev : targetDevices) {
           if (!getVMSVirtualDomainInfo().isDevice(dev)) {
             devices.add(dev);
           }
         }
       }
     }
     final String saved = getParamSaved(DiskData.TARGET_DEVICE);
     String selected = null;
     devices.add(saved);
     if (saved == null || getResource().isNew()) {
       if (devices.size() > 1) {
         selected = devices.toArray(new String[devices.size()])[1];
       }
     } else {
       selected = saved;
     }
     if (prevTargetBusType == null || !prevTargetBusType.equals(newValue)) {
       final String sel = selected;
       for (final String p : targetDeviceWi.keySet()) {
         targetDeviceWi.get(p).reloadComboBox(sel, devices.toArray(new String[devices.size()]));
       }
       prevTargetBusType = newValue;
     }
     final String tbs = getComboBoxValue(DiskData.TARGET_BUS_TYPE);
     if (getParamSaved(DiskData.DRIVER_NAME) == null && !tbs.equals(previousTargetBusType)) {
       if ("ide/cdrom".equals(newValue)) {
         for (final String p : readonlyWi.keySet()) {
           readonlyWi.get(p).setValue("True");
         }
         for (final String p : driverTypeWi.keySet()) {
           if (getResource().isNew()) {
             driverTypeWi.get(p).setValue("raw");
           } else {
             if (driverTypeWi.get(p).getValue() != null) {
               driverTypeWi.get(p).setValue(null);
             }
           }
         }
       } else if ("virtio/disk".equals(newValue)) {
         for (final String p : driverTypeWi.keySet()) {
           driverTypeWi.get(p).setValue("raw");
         }
         for (final String p : driverCacheWi.keySet()) {
           driverCacheWi.get(p).setValue("none");
         }
       } else {
         for (final String p : readonlyWi.keySet()) {
           readonlyWi.get(p).setValue("False");
           driverTypeWi.get(p).setValue("raw");
         }
       }
     }
     previousTargetBusType = tbs;
     checkOneParam(DiskData.SOURCE_FILE);
     checkOneParam(DiskData.SOURCE_DEVICE);
   }
   if (isRequired(param) && (newValue == null || "".equals(newValue))) {
     return false;
   }
   return true;
 }