예제 #1
0
 /** Returns possible choices for drop down lists. */
 @Override
 protected Object[] getParamPossibleChoices(final String param) {
   if (DiskData.SOURCE_FILE.equals(param)) {
     final Set<String> sourceFileDirs = new TreeSet<String>();
     sourceFileDirs.add(LIBVIRT_IMAGE_LOCATION);
     for (final Host h : getVMSVirtualDomainInfo().getDefinedOnHosts()) {
       final VMSXML vmsxml = getBrowser().getVMSXML(h);
       if (vmsxml != null) {
         sourceFileDirs.addAll(vmsxml.getsourceFileDirs());
       }
     }
     return sourceFileDirs.toArray(new String[sourceFileDirs.size()]);
   } else if (DiskData.SOURCE_DEVICE.equals(param)) {
     for (final Host h : getVMSVirtualDomainInfo().getDefinedOnHosts()) {
       final VMSXML vmsxml = getBrowser().getVMSXML(h);
       final List<String> bds = new ArrayList<String>();
       bds.add(null);
       if (vmsxml != null) {
         for (final BlockDevInfo bdi : h.getBrowser().getBlockDevInfos()) {
           if (bdi.getBlockDevice().isDrbd()) {
             bds.add(bdi.getDrbdVolumeInfo().getDeviceByRes());
           } else {
             bds.add(bdi.getName());
           }
         }
         return bds.toArray(new String[bds.size()]);
       }
     }
   }
   return POSSIBLE_VALUES.get(param);
 }
예제 #2
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);
  }
예제 #3
0
 /** Removes this disk without confirmation dialog. */
 @Override
 protected void removeMyselfNoConfirm(final boolean testOnly) {
   final String virshOptions = getVMSVirtualDomainInfo().getVirshOptions();
   for (final Host h : getVMSVirtualDomainInfo().getDefinedOnHosts()) {
     final VMSXML vmsxml = getBrowser().getVMSXML(h);
     if (vmsxml != null) {
       final Map<String, String> parameters = new HashMap<String, String>();
       parameters.put(DiskData.SAVED_TARGET_DEVICE, getName());
       vmsxml.removeDiskXML(getVMSVirtualDomainInfo().getDomainName(), parameters, virshOptions);
     }
   }
   getBrowser().periodicalVMSUpdate(getVMSVirtualDomainInfo().getDefinedOnHosts());
   removeNode();
 }
예제 #4
0
 /** Modify device xml. */
 @Override
 protected void modifyXML(
     final VMSXML vmsxml,
     final Node node,
     final String domainName,
     final Map<String, String> params) {
   if (vmsxml != null) {
     vmsxml.modifyDiskXML(node, domainName, params);
   }
 }