@Override protected String renderNullSafe(VDS object) { return object.getName(); } });
private Set<String> getUsedHostNamesFromIds(List<Guid> usedHosts, Map<Guid, VDS> allHostIdsMap) { return usedHosts .stream() .map(guid -> allHostIdsMap.get(guid).getName()) .sorted() .collect(Collectors.toCollection(LinkedHashSet::new)); }
private void populateHostMaps(List<VDS> hosts, Map<String, VDS> allHostNamesMap, Map<Guid, VDS> allHostIdsMap) { hosts.forEach(host -> { allHostNamesMap.put(host.getName(), host); allHostIdsMap.put(host.getId(), host); }); }
protected String getVdsSearchString(final MoveHost moveHost) { StringBuilder buf = new StringBuilder("Host: "); //$NON-NLS-1$ for (MoveHostData hostData : moveHost.getSelectedHosts()) { if (buf.length() > 6) { buf.append(" or "); //$NON-NLS-1$ } buf.append("name = "); //$NON-NLS-1$ buf.append(hostData.getEntity().getName()); } return buf.toString(); }
public void setDefaultNames(VDS host) { context.host = host; setCommonName(host.getName().replace('.', '-') + "-Local"); //$NON-NLS-1$ setDefaultNames1(); }
/** * Format the message of pinned/high performance VMs existed on selected hosts to maintenance and display it on HostMaintenanceConfirmationModel dialog * */ private void formatAndDisplayPinnedVmsMsg(List<String> pinnedVmsNames, List<Guid> hostsIdsForPinnedVms, HostMaintenanceConfirmationModel model) { if (!pinnedVmsNames.isEmpty()) { List<String> hostsNamesForPinnedVms = getSelectedItems().stream().filter(d -> hostsIdsForPinnedVms.contains(d.getId())).map(d -> d.getName()).collect(Collectors.toList()); String formatedPinnedVMsInfoMsg = ConstantsManager.getInstance().getConstants().areYouSureYouWantToPlaceFollowingHostsIntoMaintenanceModeDueToPinnedVmsMsg() + "VM(s): " //$NON-NLS-1$ + String.join(", ", pinnedVmsNames) //$NON-NLS-1$ + "\nHost(s): " //$NON-NLS-1$ + String.join(", ", hostsNamesForPinnedVms); //$NON-NLS-1$ model.setPinnedVMsInfoPanelVisible(true); model.setPinnedVMsInfoMessage(formatedPinnedVMsInfoMsg); } }
@Override protected VDS getEntity(int index) { VDS provider = mock(VDS.class); when(provider.getId()).thenReturn(GUIDS[index]); when(provider.getName()).thenReturn(NAMES[index]); return provider; }
@Override protected VDS getEntity(int index) { VDS host = mock(VDS.class); when(host.getId()).thenReturn(GUIDS[index]); when(host.getName()).thenReturn(NAMES[index]); return host; }
@Override public void search() { if (getEntity() != null) { setSearchString("events: host.name=" + getEntity().getName()); //$NON-NLS-1$ super.search(); } }
@Override public String getVdsName() { if (StringUtils.isEmpty(vdsName)) { if (getVdsNoLoad() == null) { if (getVdsStatic() != null) { vdsName = getVdsStatic().getName(); } } else { if (getVds() != null) { vdsName = getVds().getName(); } } } return vdsName; }
public NetworkHostListModel() { setTitle(ConstantsManager.getInstance().getConstants().hostsTitle()); setHelpTag(HelpTag.hosts); setHashName("hosts"); //$NON-NLS-1$ setComparator( Comparator.comparing((PairQueryable<VdsNetworkInterface, VDS> p) -> p.getSecond() .getClusterName()).thenComparing(p -> p.getSecond().getName())); setSetupNetworksCommand(new UICommand("SetupNetworks", this)); //$NON-NLS-1$ updateActionAvailability(); }
public NumaSupportModel(List<VDS> hosts, VDS host, Model parentModel) { this.parentModel = parentModel; setHosts(new ListModel<VDS>()); setNumaNodeList(new ArrayList<VdsNumaNode>()); setTitle(ConstantsManager.getInstance().getMessages().numaTopologyTitle(host.getName())); setHelpTag(HelpTag.numa_support); setHashName("numa_support"); //$NON-NLS-1$ initCommands(); initHosts(hosts, host); }
@Mapping(from = VDS.class, to = ExternalHost.class) public static ExternalHost map(VDS entity, ExternalHost template) { ExternalHost model = template != null? template: new ExternalHost(); String name = entity.getName(); if (name != null) { model.setId(string2hex(name)); model.setName(name); } if (entity.getHostName() != null) { model.setAddress(entity.getHostName()); } return model; }
public void stop(String uiCommand) { ConfirmationModel model = new ConfirmationModel(); setConfirmWindow(model); model.setTitle(ConstantsManager.getInstance().getConstants().stopHostsTitle()); model.setHelpTag(HelpTag.stop_host); model.setHashName("stop_host"); //$NON-NLS-1$ model.setMessage(ConstantsManager.getInstance().getConstants().areYouSureYouWantToStopTheFollowingHostsMsg()); // model.Items = SelectedItems.Cast<VDS>().Select(a => a.vds_name); ArrayList<String> items = new ArrayList<>(); for (Object item : getSelectedItems()) { VDS vds = (VDS) item; items.add(vds.getName()); } model.setItems(items); UICommand tempVar = UICommand.createDefaultOkUiCommand(uiCommand, this); //$NON-NLS-1$ model.getCommands().add(tempVar); UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this); //$NON-NLS-1$ model.getCommands().add(tempVar2); }
public void restart(String uiCommand) { final UIConstants constants = ConstantsManager.getInstance().getConstants(); final UIMessages messages = ConstantsManager.getInstance().getMessages(); ConfirmationModel model = new ConfirmationModel(); setConfirmWindow(model); model.setTitle(constants.restartHostsTitle()); model.setHelpTag(HelpTag.restart_host); model.setHashName("restart_host"); //$NON-NLS-1$ model.setMessage(constants.areYouSureYouWantToRestartTheFollowingHostsMsg()); ArrayList<String> items = new ArrayList<>(); for (Object item : getSelectedItems()) { VDS vds = (VDS) item; int runningVms = vds.getVmCount(); if (runningVms > 0) { items.add(messages.hostNumberOfRunningVms(vds.getName(), runningVms)); } else { items.add(vds.getName()); } } model.setItems(items); UICommand tempVar = new UICommand(uiCommand, this); //$NON-NLS-1$ tempVar.setTitle(constants.ok()); tempVar.setIsDefault(true); model.getCommands().add(tempVar); UICommand tempVar2 = new UICommand("Cancel", this); //$NON-NLS-1$ tempVar2.setTitle(constants.cancel()); tempVar2.setIsCancel(true); model.getCommands().add(tempVar2); }
@Override public ExternalHost get() { // Convert the resource identifier to the host group name: String name = hex2string(id); // The backend doesn't have a way to retrieve a host by ide, so we have to iterate them: GetHostListFromExternalProviderParameters parameters = new GetHostListFromExternalProviderParameters(); parameters.setFilterOutExistingHosts(true); parameters.setProviderId(asGuid(providerId)); QueryReturnValue result = runQuery(QueryType.GetHostListFromExternalProvider, parameters); List<VDS> entities = result.getReturnValue(); if (entities != null) { for (VDS entity : entities) { if (name.equals(entity.getName())) { return addLinks(populate(map(entity), entity)); } } } // No luck: return notFound(); }
public HostSetupNetworksModel(SearchableListModel listModel, VDS host) { this.sourceListModel = listModel; setEntity(host); setTitle(ConstantsManager.getInstance().getMessages().setupHostNetworksTitle(host.getName())); setHelpTag(HelpTag.host_setup_networks); setHashName("host_setup_networks"); //$NON-NLS-1$ setNicsChangedEvent(new Event<>(NICS_CHANGED_EVENT_DEFINITION)); setOperationCandidateEvent(new Event<OperationCandidateEventArgs>(OPERATION_CANDIDATE_EVENT_DEFINITION)); setLldpChangedEvent(new Event<>(LLDP_CHANGED_EVENT_DEFINITION)); setCheckConnectivity(new EntityModel<Boolean>()); getCheckConnectivity().setEntity(true); setConnectivityTimeout(new EntityModel<Integer>()); setCommitChanges(new EntityModel<Boolean>()); getCommitChanges().setEntity(true); setShowVf(new EntityModel<>()); getShowVf().setEntity(false); getShowVf().getPropertyChangedEvent().addListener((ev, sender, args) -> redraw()); // ok command okCommand = UICommand.createDefaultOkUiCommand("OnSetupNetworks", this); //$NON-NLS-1$ getCommands().add(okCommand); // cancel command getCommands().add(UICommand.createCancelUiCommand("Cancel", this)); //$NON-NLS-1$ newLabelModel = new NewNetworkLabelModel(this); }
private static Object cloneVDS(VDS instance) { VDS obj = new VDS(); obj.setHostName(instance.getHostName()); obj.setSshKeyFingerprint(instance.getSshKeyFingerprint()); obj.setSshPort(instance.getSshPort()); obj.setSshUsername(instance.getSshUsername()); obj.setFenceAgents(cloneAgents(instance.getFenceAgents())); obj.setDisablePowerManagementPolicy(instance.isDisablePowerManagementPolicy()); obj.setPmKdumpDetection(instance.isPmKdumpDetection()); obj.setPort(instance.getPort()); obj.setServerSslEnabled(instance.isServerSslEnabled()); obj.setClusterId(instance.getClusterId()); obj.setId(instance.getId()); obj.setVdsName(instance.getName()); obj.setVdsStrength(instance.getVdsStrength()); obj.setVdsType(instance.getVdsType()); obj.setUniqueId(instance.getUniqueId()); obj.setVdsSpmPriority(instance.getVdsSpmPriority()); obj.setCurrentKernelCmdline(instance.getCurrentKernelCmdline()); obj.setKernelCmdlineParsable(instance.isKernelCmdlineParsable()); obj.setLastStoredKernelCmdline(instance.getLastStoredKernelCmdline()); obj.setKernelCmdlineBlacklistNouveau(instance.isKernelCmdlineBlacklistNouveau()); obj.setKernelCmdlineIommu(instance.isKernelCmdlineIommu()); obj.setKernelCmdlineKvmNested(instance.isKernelCmdlineKvmNested()); obj.setKernelCmdlinePciRealloc(instance.isKernelCmdlinePciRealloc()); obj.setKernelCmdlineFips(instance.isKernelCmdlineFips()); obj.setKernelCmdlineUnsafeInterrupts(instance.isKernelCmdlineUnsafeInterrupts()); return obj; }