Exemple #1
0
 /** Remove all the services in the group and the group. */
 @Override
 public void removeMyselfNoConfirm(final Host dcHost, final boolean testOnly) {
   final List<ServiceInfo> children = new ArrayList<ServiceInfo>();
   if (!testOnly) {
     @SuppressWarnings("unchecked")
     final Enumeration<DefaultMutableTreeNode> e = getNode().children();
     try {
       while (e.hasMoreElements()) {
         final DefaultMutableTreeNode n = e.nextElement();
         final ServiceInfo child = (ServiceInfo) n.getUserObject();
         child.getService().setRemoved(true);
         children.add(child);
       }
     } catch (java.util.NoSuchElementException ele) {
       LOG.info("removeMyselfNoConfirm: removing aborted");
       return;
     }
   }
   if (getService().isNew()) {
     if (!testOnly) {
       getService().setNew(false);
       getBrowser().getCRMGraph().killRemovedVertices();
       getService().doneRemoving();
     }
   } else {
     String cloneId = null;
     boolean master = false;
     final CloneInfo ci = getCloneInfo();
     if (ci != null) {
       cloneId = ci.getHeartbeatId(testOnly);
       master = ci.getService().isMaster();
     }
     super.removeMyselfNoConfirm(dcHost, testOnly);
     for (final ServiceInfo child : children) {
       child.removeConstraints(dcHost, testOnly);
     }
     CRM.removeResource(
         dcHost, null, getHeartbeatId(testOnly), cloneId, /* clone id */ master, testOnly);
     for (final ServiceInfo child : children) {
       child.cleanupResource(dcHost, testOnly);
     }
   }
   if (!testOnly) {
     for (final ServiceInfo child : children) {
       getBrowser().mHeartbeatIdToServiceLock();
       getBrowser().getHeartbeatIdToServiceInfo().remove(child.getService().getHeartbeatId());
       getBrowser().mHeartbeatIdToServiceUnlock();
       getBrowser().removeFromServiceInfoHash(child);
       child.cleanup();
       child.getService().doneRemoving();
     }
   }
 }
Exemple #2
0
 /** Sets whether the group services are managed. */
 @Override
 void setManaged(final boolean isManaged, final Host dcHost, final boolean testOnly) {
   if (!testOnly) {
     setUpdated(true);
   }
   final ClusterStatus cs = getBrowser().getClusterStatus();
   final List<String> resources = cs.getGroupResources(getHeartbeatId(testOnly), testOnly);
   if (resources != null) {
     for (final String hbId : resources) {
       CRM.setManaged(dcHost, hbId, isManaged, testOnly);
     }
   }
 }
Exemple #3
0
  /** Applies the the whole group if for example an order has changed. */
  void applyWhole(
      final Host dcHost,
      final boolean createGroup,
      final List<String> newOrder,
      final boolean testOnly) {
    final String[] params = getParametersFromXML();
    if (!testOnly) {
      Tools.invokeAndWait(
          new Runnable() {
            @Override
            public void run() {
              final MyButton ab = getApplyButton();
              if (ab != null) {
                ab.setEnabled(false);
              }
            }
          });
    }
    getInfoPanel();
    waitForInfoPanel();

    final Map<String, String> groupMetaArgs = new LinkedHashMap<String, String>();
    for (String param : params) {
      if (GUI_ID.equals(param) || PCMK_ID.equals(param)) {
        continue;
      }
      String value = getComboBoxValue(param);
      if (value == null) {
        value = "";
      }
      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);
        }
      }
    }
    final Map<String, Map<String, String>> pacemakerResAttrs =
        new HashMap<String, Map<String, String>>();
    final Map<String, Map<String, String>> pacemakerResArgs =
        new HashMap<String, Map<String, String>>();
    final Map<String, Map<String, String>> pacemakerMetaArgs =
        new HashMap<String, Map<String, String>>();
    final Map<String, String> instanceAttrId = new HashMap<String, String>();
    final Map<String, Map<String, String>> nvpairIdsHash =
        new HashMap<String, Map<String, String>>();
    final Map<String, Map<String, Map<String, String>>> pacemakerOps =
        new HashMap<String, Map<String, Map<String, String>>>();
    final Map<String, String> operationsId = new HashMap<String, String>();
    final Map<String, String> metaAttrsRefId = new HashMap<String, String>();
    final Map<String, String> operationsRefId = new HashMap<String, String>();
    final Map<String, Boolean> stonith = new HashMap<String, Boolean>();

    final ClusterStatus cs = getBrowser().getClusterStatus();
    for (final String resId : newOrder) {
      final ServiceInfo gsi = getBrowser().getServiceInfoFromCRMId(resId);
      if (gsi == null) {
        continue;
      }
      Tools.invokeAndWait(
          new Runnable() {
            @Override
            public void run() {
              gsi.getInfoPanel();
            }
          });
    }
    Tools.waitForSwing();
    for (final String resId : newOrder) {
      final ServiceInfo gsi = getBrowser().getServiceInfoFromCRMId(resId);
      if (gsi == null) {
        continue;
      }
      pacemakerResAttrs.put(resId, gsi.getPacemakerResAttrs(testOnly));
      pacemakerResArgs.put(resId, gsi.getPacemakerResArgs());
      pacemakerMetaArgs.put(resId, gsi.getPacemakerMetaArgs());
      instanceAttrId.put(resId, cs.getResourceInstanceAttrId(resId));
      nvpairIdsHash.put(resId, cs.getParametersNvpairsIds(resId));
      pacemakerOps.put(resId, gsi.getOperations(resId));
      operationsId.put(resId, cs.getOperationsId(resId));
      metaAttrsRefId.put(resId, gsi.getMetaAttrsRefId());
      operationsRefId.put(resId, gsi.getOperationsRefId());
      stonith.put(resId, gsi.getResourceAgent().isStonith());
    }
    final CloneInfo ci = getCloneInfo();
    String cloneId = null;
    boolean master = false;
    final Map<String, String> cloneMetaArgs = new LinkedHashMap<String, String>();
    String cloneMetaAttrsRefIds = null;
    if (createGroup && ci != null) {
      cloneId = ci.getHeartbeatId(testOnly);
      final String[] cloneParams = ci.getParametersFromXML();
      master = ci.getService().isMaster();
      cloneMetaAttrsRefIds = ci.getMetaAttrsRefId();
      for (String param : cloneParams) {
        if (GUI_ID.equals(param) || PCMK_ID.equals(param)) {
          continue;
        }
        final String value = ci.getComboBoxValue(param);
        if (value.equals(ci.getParamDefault(param))) {
          continue;
        }
        if (!GUI_ID.equals(param) && !"".equals(value)) {
          cloneMetaArgs.put(param, value);
        }
      }
    }
    CRM.replaceGroup(
        createGroup,
        dcHost,
        cloneId,
        master,
        cloneMetaArgs,
        cloneMetaAttrsRefIds,
        newOrder,
        groupMetaArgs,
        getHeartbeatId(testOnly),
        pacemakerResAttrs,
        pacemakerResArgs,
        pacemakerMetaArgs,
        instanceAttrId,
        nvpairIdsHash,
        pacemakerOps,
        operationsId,
        metaAttrsRefId,
        getMetaAttrsRefId(),
        operationsRefId,
        stonith,
        testOnly);
    if (!testOnly) {
      storeComboBoxValues(params);
      getBrowser().reload(getNode(), false);
    }
    getBrowser().getCRMGraph().repaint();
  }
Exemple #4
0
  /** 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();
  }