public void OnSelectHost() { MoveHost model = (MoveHost) getWindow(); if (model.getProgress() != null) { return; } if (!model.Validate()) { return; } model.setSelectedHosts(new java.util.ArrayList<VDS>()); for (EntityModel a : Linq.<EntityModel>Cast(model.getItems())) { if (a.getIsSelected()) { model.getSelectedHosts().add((VDS) a.getEntity()); } } VDSGroup cluster = (VDSGroup) model.getCluster().getSelectedItem(); java.util.ArrayList<VdcActionParametersBase> paramerterList = new java.util.ArrayList<VdcActionParametersBase>(); for (VDS host : model.getSelectedHosts()) { // Try to change host's cluster as neccessary. if (host.getvds_group_id() != null && !host.getvds_group_id().equals(cluster.getId())) { paramerterList.add(new ChangeVDSClusterParameters(cluster.getId(), host.getId())); } } model.StartProgress(null); Frontend.RunMultipleAction( VdcActionType.ChangeVDSCluster, paramerterList, new IFrontendMultipleActionAsyncCallback() { @Override public void Executed(FrontendMultipleActionAsyncResult result) { ClusterGuideModel clusterGuideModel = (ClusterGuideModel) result.getState(); java.util.ArrayList<VDS> hosts = ((MoveHost) clusterGuideModel.getWindow()).getSelectedHosts(); java.util.ArrayList<VdcReturnValueBase> retVals = (java.util.ArrayList<VdcReturnValueBase>) result.getReturnValue(); if (retVals != null && hosts.size() == retVals.size()) { int i = 0; for (VDS selectedHost : hosts) { if (selectedHost.getstatus() == VDSStatus.PendingApproval && retVals.get(i) != null && retVals.get(i).getSucceeded()) { Frontend.RunAction( VdcActionType.ApproveVds, new ApproveVdsParameters(selectedHost.getId())); } } i++; } clusterGuideModel.getWindow().StopProgress(); clusterGuideModel.Cancel(); clusterGuideModel.PostAction(); } }, this); }
public void OnAddHost() { CancelConfirm(); HostModel model = (HostModel) getWindow(); if (model.getProgress() != null) { return; } if (!model.Validate()) { return; } // Save changes. VDS host = new VDS(); host.setvds_name((String) model.getName().getEntity()); host.sethost_name((String) model.getHost().getEntity()); host.setManagmentIp((String) model.getManagementIp().getEntity()); host.setport((Integer) model.getPort().getEntity()); host.setvds_group_id(((VDSGroup) model.getCluster().getSelectedItem()).getId()); host.setpm_enabled((Boolean) model.getIsPm().getEntity()); host.setpm_user( (Boolean) model.getIsPm().getEntity() ? (String) model.getPmUserName().getEntity() : null); host.setpm_password( (Boolean) model.getIsPm().getEntity() ? (String) model.getPmPassword().getEntity() : null); host.setpm_type( (Boolean) model.getIsPm().getEntity() ? (String) model.getPmType().getSelectedItem() : null); host.setPmOptionsMap( (Boolean) model.getIsPm().getEntity() ? new ValueObjectMap(model.getPmOptionsMap(), false) : null); AddVdsActionParameters vdsActionParams = new AddVdsActionParameters(); vdsActionParams.setvds(host); vdsActionParams.setVdsId(host.getId()); vdsActionParams.setRootPassword((String) model.getRootPassword().getEntity()); model.StartProgress(null); Frontend.RunAction( VdcActionType.AddVds, vdsActionParams, new IFrontendActionAsyncCallback() { @Override public void Executed(FrontendActionAsyncResult result) { ClusterGuideModel localModel = (ClusterGuideModel) result.getState(); localModel.PostOnAddHost(result.getReturnValue()); } }, this); }