コード例 #1
0
  public void PostGetClusterNetworkList_New(java.util.ArrayList<network> network_list) {
    java.util.ArrayList<network> networks = new java.util.ArrayList<network>();
    for (network a : network_list) {
      if (a.getStatus() == NetworkStatus.Operational) {
        networks.add(a);
      }
    }

    java.util.ArrayList<VmNetworkInterface> nics = Linq.<VmNetworkInterface>Cast(getItems());
    int nicCount = nics.size();
    String newNicName = DataProvider.GetNewNicName(nics);

    VmInterfaceModel model = (VmInterfaceModel) getWindow();
    model.getNetwork().setItems(networks);
    model.getNetwork().setSelectedItem(networks.size() > 0 ? networks.get(0) : null);
    model
        .getNicType()
        .setItems(DataProvider.GetNicTypeList(getEntityStronglyTyped().getos(), false));
    model
        .getNicType()
        .setSelectedItem(DataProvider.GetDefaultNicType(getEntityStronglyTyped().getos()));
    model.getName().setEntity(newNicName);
    model.getMAC().setIsAvailable(false);

    UICommand tempVar = new UICommand("OnSave", this);
    tempVar.setTitle("OK");
    tempVar.setIsDefault(true);
    model.getCommands().add(tempVar);
    UICommand tempVar2 = new UICommand("Cancel", this);
    tempVar2.setTitle("Cancel");
    tempVar2.setIsCancel(true);
    model.getCommands().add(tempVar2);
  }
コード例 #2
0
 private String AvailableName(java.util.ArrayList<String> list) {
   String retVal = getCommonName();
   java.util.ArrayList<Integer> notAvialbleNumberList = new java.util.ArrayList<Integer>();
   String temp;
   for (String str : list) {
     temp = str.replace(getCommonName(), "");
     if (StringHelper.isNullOrEmpty(temp)) {
       temp = "0";
     }
     int tempInt = 0;
     RefObject<Integer> tempRef_tempInt = new RefObject<Integer>(tempInt);
     boolean tempVar = IntegerCompat.TryParse(temp, tempRef_tempInt);
     tempInt = tempRef_tempInt.argvalue;
     if (tempVar) {
       notAvialbleNumberList.add(tempInt);
     }
   }
   Collections.sort(notAvialbleNumberList);
   int i = 0;
   for (i = 0; i < notAvialbleNumberList.size(); i++) {
     if (notAvialbleNumberList.get(i) == i) {
       continue;
     }
     break;
   }
   if (i > 0) {
     retVal = getCommonName() + (new Integer(i)).toString();
   }
   return retVal;
 }
コード例 #3
0
  public void OnManage() {
    ListModel model = (ListModel) getWindow();

    java.util.ArrayList<EntityModel> items = Linq.<EntityModel>Cast(model.getItems());
    java.util.ArrayList<network> networks = Linq.<network>Cast(getItems());

    if (getEntity() == null) {
      Cancel();
      return;
    }

    java.util.ArrayList<VdcActionParametersBase> prms1 =
        new java.util.ArrayList<VdcActionParametersBase>();
    for (EntityModel a : items) {
      boolean value = false;
      for (network b : networks) {
        if (b.getId().equals(((network) a.getEntity()).getId())) {
          value = true;
          break;
        }
      }
      if (a.getIsSelected() && !value) {
        prms1.add(new AttachNetworkToVdsGroupParameter(getEntity(), (network) a.getEntity()));
      }
    }

    // Call the command only if necessary (i.e. only if there are paramters):
    if (prms1.size() > 0) {
      Frontend.RunMultipleAction(VdcActionType.AttachNetworkToVdsGroup, prms1);
    }

    java.util.ArrayList<VdcActionParametersBase> prms2 =
        new java.util.ArrayList<VdcActionParametersBase>();
    for (EntityModel a : items) {
      boolean value = true;
      for (network b : networks) {
        if (b.getId().equals(((network) a.getEntity()).getId())) {
          value = false;
          break;
        }
      }
      if (!a.getIsSelected() && !value) {
        prms2.add(new AttachNetworkToVdsGroupParameter(getEntity(), (network) a.getEntity()));
      }
    }

    // Call the command only if necessary (i.e. only if there are paramters):
    if (prms2.size() > 0) {
      Frontend.RunMultipleAction(VdcActionType.DetachNetworkToVdsGroup, prms2);
    }

    Cancel();
  }
コード例 #4
0
  private void UpdateOptions() {
    getCompulsoryActions().clear();
    getOptionalActions().clear();

    if (getEntity() != null) {
      storage_pool dataCenter = null;
      if (getEntity().getstorage_pool_id() != null) {
        dataCenter = DataProvider.GetDataCenterById(getEntity().getstorage_pool_id().getValue());
      }
      if (dataCenter == null || dataCenter.getstorage_pool_type() != StorageType.LOCALFS) {
        // Add host action.
        UICommand addHostAction = new UICommand("AddHost", this);

        // 				var hosts = DataProvider.GetHostListByCluster(Entity.name)
        // 					.Skip(1)
        // 					.ToList();
        java.util.ArrayList<VDS> hosts = DataProvider.GetHostListByCluster(getEntity().getname());
        if (hosts.size() > 1) {
          hosts.remove(0);
        }

        if (hosts.isEmpty()) {
          addHostAction.setTitle(ClusterConfigureHostsAction);
          getCompulsoryActions().add(addHostAction);
        } else {
          addHostAction.setTitle(ClusterAddAnotherHostAction);
          getOptionalActions().add(addHostAction);
        }
        if (getEntity().getstorage_pool_id() == null) {
          addHostAction.setIsExecutionAllowed(false);
          addHostAction
              .getExecuteProhibitionReasons()
              .add("The Cluster isn't attached to a Data Center");
          return;
        }
        java.util.ArrayList<VDSGroup> clusters =
            DataProvider.GetClusterList((Guid) getEntity().getstorage_pool_id());
        Version minimalClusterVersion = Linq.GetMinVersionByClusters(clusters);
        java.util.ArrayList<VDS> availableHosts = new java.util.ArrayList<VDS>();
        for (VDS vds : DataProvider.GetHostList()) {
          if ((!Linq.IsHostBelongsToAnyOfClusters(clusters, vds))
              && (vds.getstatus() == VDSStatus.Maintenance
                  || vds.getstatus() == VDSStatus.PendingApproval)
              && (vds.getVersion().getFullVersion() == null
                  || Extensions.GetFriendlyVersion(vds.getVersion().getFullVersion())
                          .compareTo(minimalClusterVersion)
                      >= 0)) {
            availableHosts.add(vds);
          }
        }
        // Select host action.
        UICommand selectHostAction = new UICommand("SelectHost", this);

        if (availableHosts.size() > 0 && clusters.size() > 0) {
          if (hosts.isEmpty()) {
            selectHostAction.setTitle(SelectHostsAction);
            getCompulsoryActions().add(selectHostAction);
          } else {
            selectHostAction.setTitle(SelectHostsAction);
            getOptionalActions().add(selectHostAction);
          }
        }
      } else {
        UICommand tempVar = new UICommand("AddHost", this);
        tempVar.setTitle(ClusterAddAnotherHostAction);
        UICommand addHostAction = tempVar;
        UICommand tempVar2 = new UICommand("SelectHost", this);
        tempVar2.setTitle(SelectHostsAction);
        UICommand selectHost = tempVar2;
        VDS host = DataProvider.GetLocalStorageHost(dataCenter.getname());
        if (host != null) {
          addHostAction.setIsExecutionAllowed(false);
          selectHost.setIsExecutionAllowed(false);
          String hasHostReason =
              "This Cluster belongs to a Local Data Center which already contain a Host";
          addHostAction.getExecuteProhibitionReasons().add(hasHostReason);
          selectHost.getExecuteProhibitionReasons().add(hasHostReason);
        }
        getCompulsoryActions().add(addHostAction);
        getOptionalActions().add(selectHost);
      }
    }
  }