private boolean isHostAvailable(VDS host) { boolean isStatusUp = host.getStatus() == VDSStatus.Up; return isStatusUp; }
public boolean shouldVdsBeFenced() { boolean result = false; switch (this.getStatus()) { case Down: case InstallFailed: case Maintenance: case NonOperational: case NonResponsive: case Kdumping: // it should happen only after restart when host is stuck in status Kdumping result = true; break; default: break; } return result; }
private List<VDS> filterUpHosts(List<VDS> hosts) { List<VDS> result = new ArrayList<>(); for (VDS host : hosts) { if (host.getStatus() == VDSStatus.Up) { result.add(host); } } return result; }
private List<VDS> filterUpHosts(List<VDS> hosts) { List<VDS> result = new ArrayList<>(); for (VDS host : hosts) { if (host.getStatus() == VDSStatus.Up) { result.add(host); } } return result; } });
@Override protected boolean editTransportProperties(VDS vds) { if (VDSStatus.Maintenance.equals(vds.getStatus())) { return true; } return false; }
private boolean isSelectAsSpmCommandAllowed(List<VDS> selectedItems) { if (selectedItems.size() != 1) { return false; } VDS vds = selectedItems.get(0); if (vds.getStatus() != VDSStatus.Up || !vds.getClusterSupportsVirtService() || vds.getSpmStatus() != VdsSpmStatus.None) { return false; } if (vds.getVdsSpmPriority() == BusinessEntitiesDefinitions.HOST_MIN_SPM_PRIORITY) { return false; } return true; }
private void updateActionAvailability() { getUpdateMomPolicyCommand().setIsAvailable(true); List<VDS> items = getSelectedItems() != null ? getSelectedItems() : new ArrayList<VDS>(); boolean allHostRunning = !items.isEmpty(); for (VDS vds : items) { if (vds.getStatus() != VDSStatus.Up) { allHostRunning = false; break; } } getUpdateMomPolicyCommand().setIsExecutionAllowed(allHostRunning); }
private void updateConfigureLocalStorageCommandAvailability1() { List<VDS> items = getSelectedItems() != null ? getSelectedItems() : new ArrayList<VDS>(); getConfigureLocalStorageCommand().setIsExecutionAllowed(items.size() == 1 && items.get(0).getStatus() == VDSStatus.Maintenance); if (!Boolean.TRUE.equals(hasAdminSystemPermission) && getConfigureLocalStorageCommand().getIsExecutionAllowed()) { getConfigureLocalStorageCommand().getExecuteProhibitionReasons().add(ConstantsManager.getInstance() .getConstants() .configuringLocalStoragePermittedOnlyAdministratorsWithSystemLevelPermissionsReason()); getConfigureLocalStorageCommand().setIsExecutionAllowed(false); } }
/** * Load active hosts bound to active cluster. */ private void loadHosts() { // append just active hosts AsyncDataProvider.getInstance().getHostListByCluster(new AsyncQuery<>( hosts -> { final List<VDS> activeHosts = new ArrayList<>(); for (VDS host : hosts) { if (VDSStatus.Up.equals(host.getStatus())) { activeHosts.add(host); } } getDefaultHost().setItems(activeHosts); // hide host tab when no active host is available if (activeHosts.isEmpty()) { setIsHostTabVisible(false); } }), vm.getClusterName()); }
protected void exportOva() { VM selectedEntity = (VM) getSelectedItem(); if (selectedEntity == null) { return; } if (getWindow() != null) { return; } ExportOvaModel model = getSelectedItems().size() == 1 ? new ExportOvaModel(selectedEntity.getName()) : new ExportOvaModel(); setWindow(model); model.startProgress(); setupExportOvaModel(model); AsyncDataProvider.getInstance().getHostListByDataCenter(new AsyncQuery<>( hosts -> postExportOvaGetHosts(hosts.stream() .filter(host -> host.getStatus() == VDSStatus.Up) .collect(Collectors.toList())) ), extractStoragePoolIdNullSafe(selectedEntity)); }
@Test public void testGetAllForStoragePoolAndStatuses() { prepareHostWithDifferentStatus(); List<VDS> result = dao.getAllForStoragePoolAndStatuses(existingVds.getStoragePoolId(), EnumSet.of(existingVds.getStatus(), existingVds2.getStatus())); assertTrue(CollectionUtils.disjunction(result, Arrays.asList(existingVds, existingVds2)).isEmpty()); assertCorrectGetAllResult(result); }
private void postGetHostList(List<VDS> hosts) { Cluster cluster = getCluster().getSelectedItem(); ArrayList<MoveHostData> items = new ArrayList<>(); for (VDS vds : hosts) { if (!cluster.getId().equals(vds.getClusterId()) && (vds.getStatus() == VDSStatus.Maintenance || vds.getStatus() == VDSStatus.PendingApproval) && vds.getSupportedClusterVersionsSet().contains(cluster.getCompatibilityVersion())) { MoveHostData entity = new MoveHostData(vds); entity.setActivateHost(true); items.add(entity); } } ArrayList<Guid> previouslySelectedHostIDs = new ArrayList<>(); if (getItems() != null) { for (MoveHostData entity : getItems()) { if (entity.getIsSelected()) { previouslySelectedHostIDs.add(entity.getEntity().getId()); } } } setItems(items); for (MoveHostData entity : items) { entity.setIsSelected(previouslySelectedHostIDs.contains(entity.getEntity().getId())); } }
protected void exportOva() { VmTemplate selectedEntity = getSelectedItem(); if (selectedEntity == null) { return; } if (getWindow() != null) { return; } ExportOvaModel model = getSelectedItems().size() == 1 ? new ExportOvaModel(selectedEntity.getName()) : new ExportOvaModel(); setWindow(model); model.startProgress(); setupExportOvaModel(model); AsyncDataProvider.getInstance().getHostListByDataCenter(new AsyncQuery<>( hosts -> postExportOvaGetHosts(hosts.stream() .filter(host -> host.getStatus() == VDSStatus.Up) .collect(Collectors.toList())) ), extractStoragePoolIdNullSafe(selectedEntity)); }
@Override protected void setAllowChangeHost(VDS vds) { if (vds.getStatus() != VDSStatus.InstallFailed) { getHost().setIsChangeable(false); getAuthSshPort().setIsChangeable(false); } else { getHost().setIsChangeable(true); getAuthSshPort().setIsChangeable(true); } }
public void onSshRestart() { ConfirmationModel model = (ConfirmationModel) getConfirmWindow(); if (model.getProgress() != null) { return; } ArrayList<ActionParametersBase> list = new ArrayList<>(); for (Object item : getSelectedItems()) { VDS vds = (VDS) item; VdsActionParameters params = new VdsActionParameters(vds.getId()); params.setPrevVdsStatus(vds.getStatus()); list.add(params); } model.startProgress(); Frontend.getInstance().runMultipleAction( ActionType.SshHostReboot, list, result -> { ConfirmationModel localModel = (ConfirmationModel) result.getState(); localModel.stopProgress(); cancelConfirm(); }, model ); }
private void updateActionAvailability() { VDS vds = getEntity(); if (vds != null && vds.getStatus() == VDSStatus.Up) { getSyncStorageDevicesCommand().setIsExecutionAllowed(true); getCreateBrickCommand().setIsExecutionAllowed(canCreateBrick()); } else { getSyncStorageDevicesCommand().setIsExecutionAllowed(false); getCreateBrickCommand().setIsExecutionAllowed(false); } }
protected void checkVdsActivateSucceeded(final String searchStr) { Frontend.getInstance().runQuery(QueryType.Search, new SearchParameters(searchStr, SearchType.VDS), new AsyncQuery<QueryReturnValue>(returnValue -> { List<VDS> hosts = returnValue.getReturnValue(); boolean succeeded = true; for (VDS host : hosts) { if (host.getStatus() != VDSStatus.Up) { succeeded = false; } } getWindow().stopProgress(); cancel(); if (succeeded) { postAction(); } else { errorPopupManager.show(ConstantsManager.getInstance().getConstants().hostActivationTimeOut()); } })); } }
private void prepare4() { if (timer != null) { timer.cancel(); timer = null; } PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment; EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext(); HostListModel<?> model = enlistmentContext.getModel(); ConfigureLocalStorageModel configureModel = (ConfigureLocalStorageModel) model.getWindow(); if (context.host.getStatus() != VDSStatus.Up) { prepare3(); } else { // Add storage domain. StorageServerConnections connection = new StorageServerConnections(); connection.setConnection(configureModel.getStorage().getPath().getEntity()); connection.setStorageType(StorageType.LOCALFS); context.connection = connection; StorageServerConnectionParametersBase parameters = new StorageServerConnectionParametersBase(connection, context.host.getId(), false); parameters.setCorrelationId(getCorrelationId()); Frontend.getInstance().runAction(ActionType.AddStorageServerConnection, parameters, result -> { ActionReturnValue returnValue = result.getReturnValue(); context.addStorageServerConnectionReturnValue = returnValue; prepare5(); }); } }