use of org.ovirt.engine.core.common.businessentities.ExternalHostGroup in project ovirt-engine by oVirt.
the class NewHostModel method discoverHostName_SelectedItemChanged.
private void discoverHostName_SelectedItemChanged() {
if (Boolean.TRUE.equals(getIsDiscoveredHosts().getEntity())) {
ExternalDiscoveredHost dhost = (ExternalDiscoveredHost) getExternalDiscoveredHosts().getSelectedItem();
ExternalHostGroup dhg = (ExternalHostGroup) getExternalHostGroups().getSelectedItem();
if (dhost != null && dhg != null) {
setOriginalName(dhost.getName());
getName().setEntity(dhost.getName());
getHost().setEntity(// $NON-NLS-1$
dhost.getName() + "." + // $NON-NLS-1$
(dhg.getDomainName() != null ? dhg.getDomainName() : ""));
}
}
}
use of org.ovirt.engine.core.common.businessentities.ExternalHostGroup in project ovirt-engine by oVirt.
the class HostPopupView method edit.
@Override
public void edit(final HostModel object) {
driver.edit(object);
setTabIndexes(0);
object.getFetchResult().getEntityChangedEvent().addListener((ev, sender, args) -> {
String fetchResultText = object.getFetchResult().getEntity();
if (ConstantsManager.getInstance().getConstants().errorLoadingFingerprint().equals(fetchResultText)) {
fetchResult.addStyleName(style.fetchResultErrorLabel());
} else {
fetchResult.removeStyleName(style.fetchResultErrorLabel());
}
fetchResult.setText(fetchResultText);
});
object.getPkSection().getPropertyChangedEvent().addListener((ev, sender, args) -> {
if ("IsAvailable".equals(args.propertyName)) {
// $NON-NLS-1$
setPkPasswordSectionVisiblity(false);
}
});
object.getProviders().getSelectedItemChangedEvent().addListener((ev, sender, args) -> object.updateHosts());
object.getExternalHostProviderEnabled().getEntityChangedEvent().addListener((ev, sender, args) -> {
boolean showForemanProviders = object.getExternalHostProviderEnabled().getEntity();
boolean doProvisioning = object.externalProvisionEnabled();
boolean isProvisioned = showForemanProviders && doProvisioning;
providersEditor.setVisible(showForemanProviders);
// showing or hiding radio buttons
provisionedHostSection.setVisible(isProvisioned);
discoveredHostSection.setVisible(isProvisioned);
// disabling ip and name textbox when using provisioned hosts
hostAddressEditor.setEnabled(!isProvisioned);
hostAddressLabel.setStyleName(OvirtCss.LABEL_DISABLED, isProvisioned);
if (isProvisioned) {
object.updateHosts();
object.getIsDiscoveredHosts().setEntity(true);
} else {
if (doProvisioning) {
object.cleanHostParametersFields();
}
hideProviderWidgets(object);
object.getIsDiscoveredHosts().setEntity(null);
}
});
object.getIsDiscoveredHosts().getEntityChangedEvent().addListener((ev, sender, args) -> {
if (object.getIsDiscoveredHosts().getEntity() != null) {
if (object.getIsDiscoveredHosts().getEntity()) {
rbDiscoveredHost.asRadioButton().setValue(true);
showDiscoveredHostsWidgets(true);
} else if (!object.getIsDiscoveredHosts().getEntity()) {
rbProvisionedHost.asRadioButton().setValue(true);
showProvisionedHostsWidgets(true);
}
}
});
nameEditor.asValueBox().addKeyDownHandler(event -> Scheduler.get().scheduleDeferred(() -> {
if (object.getExternalHostProviderEnabled().getEntity() && Boolean.TRUE.equals(object.getIsDiscoveredHosts().getEntity())) {
ExternalHostGroup dhg = (ExternalHostGroup) object.getExternalHostGroups().getSelectedItem();
if (dhg != null) {
String base = nameEditor.asEditor().getSubEditor().getValue();
if (base == null) {
base = constants.empty();
}
String generatedHostName = // $NON-NLS-1$
base + "." + (dhg.getDomainName() != null ? dhg.getDomainName() : constants.empty());
object.getHost().setEntity(generatedHostName);
}
}
}));
if (object.isPasswordSectionViewable()) {
rbPassword.setValue(true);
rbPassword.setFocus(true);
fetchSshFingerprint.hideLabel();
object.setAuthenticationMethod(AuthenticationMethod.Password);
displayPassPkWindow(true);
rbPassword.addClickHandler(event -> {
object.setAuthenticationMethod(AuthenticationMethod.Password);
displayPassPkWindow(true);
});
rbPublicKey.addClickHandler(event -> {
object.setAuthenticationMethod(AuthenticationMethod.PublicKey);
displayPassPkWindow(false);
});
} else {
passwordSection.getElement().getStyle().setDisplay(Display.NONE);
rbPublicKey.getElement().getStyle().setDisplay(Display.NONE);
rbPublicKeyLabel.setStyleName(OvirtCss.LABEL_DISABLED);
object.setAuthenticationMethod(AuthenticationMethod.PublicKey);
}
updateHostsButton.setResource(resources.searchButtonImage());
// Create SPM related controls.
IEventListener<EventArgs> spmListener = (ev, sender, args) -> createSpmControls(object);
object.getSpmPriority().getItemsChangedEvent().addListener(spmListener);
object.getSpmPriority().getSelectedItemChangedEvent().addListener(spmListener);
createSpmControls(object);
initExternalHostProviderWidgets(object.showExternalProviderPanel());
// TODO: remove setIsChangeable when configured ssh username is enabled
userNameEditor.setEnabled(false);
networkProviderTab.setVisible(object.showNetworkProviderTab());
networkProviderWidget.edit(object.getNetworkProviderModel());
this.fenceAgentsEditor.edit(object.getFenceAgentListModel());
this.proxySourceEditor.edit(object.getPmProxyPreferencesList());
addTextAndLinkAlert(fetchPanel, constants.fetchingHostFingerprint(), object.getSSHFingerPrint());
providerSearchFilterLabel.setText(constants.hostPopupProviderSearchFilter());
nameEditor.setFocus(true);
hostedEngineTab.setVisible(object.getIsHeSystem() && object.getIsNew());
object.getHostedEngineWarning().getPropertyChangedEvent().addListener((ev, sender, args) -> {
EntityModel entity = (EntityModel) sender;
if ("IsAvailable".equals(args.propertyName)) {
// $NON-NLS-1$
hostedEngineWarningLabel.setVisible(entity.getIsAvailable());
}
});
affinityLabelSelectionWidget.init(object.getLabelList());
}
use of org.ovirt.engine.core.common.businessentities.ExternalHostGroup in project ovirt-engine by oVirt.
the class ForemanHostProviderProxy method mapHostGroups.
private List<ExternalHostGroup> mapHostGroups(List<ForemanHostGroup> foremanHostGroups) {
Map<Integer, ExternalHostGroup> hostGroups = new HashMap<>();
for (ForemanHostGroup hostGroup : foremanHostGroups) {
ExternalHostGroup hostgroup = new ExternalHostGroup();
hostgroup.setHostgroupId(hostGroup.getId());
hostgroup.setName(hostGroup.getName());
hostgroup.setOperatingsystemId(hostGroup.getOperatingSystemId());
hostgroup.setEnvironmentId(hostGroup.getEnvironmentId());
hostgroup.setDomainId(hostGroup.getDomainId());
hostgroup.setSubnetId(hostGroup.getSubnetId());
hostgroup.setParameters(hostGroup.getParameters());
hostgroup.setMediumId(hostGroup.getMediumId());
hostgroup.setArchitectureId(hostGroup.getArchitectureId());
hostgroup.setPtableId(hostGroup.getPtableId());
hostgroup.setOperatingsystemName(hostGroup.getOperatingSystemName());
hostgroup.setDomainName(hostGroup.getDomainName());
hostgroup.setSubnetName(hostGroup.getSubnetName());
hostgroup.setArchitectureName(hostGroup.getArchitectureName());
hostgroup.setAncestry(hostGroup.getAncestry());
hostgroup.setEnvironmentName(hostGroup.getEnvironmentName());
hostgroup.setPtableName(hostGroup.getPtableName());
hostgroup.setMediumName(hostGroup.getMediumName());
hostgroup.setPuppetCaProxyId(hostGroup.getPuppetCaProxyId());
hostgroup.setPuppetProxyId(hostGroup.getPuppetProxyId());
hostGroups.put(hostGroup.getId(), hostgroup);
}
List<ExternalHostGroup> ret = new ArrayList<>(foremanHostGroups.size());
for (ForemanHostGroup hostGroup : foremanHostGroups) {
if (hostGroup.getAncestry() != null) {
String[] ancestries = hostGroup.getAncestry().split("/");
if (hostGroup.getMediumName() == null) {
for (int i = ancestries.length - 1; i >= 0; i--) {
ExternalHostGroup hg = hostGroups.get(Integer.parseInt(ancestries[i]));
String medName = hg.getMediumName();
if (medName != null) {
int medId = hg.getMediumId();
hostGroups.get(hostGroup.getId()).setMediumName(medName);
hostGroups.get(hostGroup.getId()).setMediumId(medId);
break;
}
}
}
if (hostGroup.getEnvironmentName() == null) {
for (int i = ancestries.length - 1; i >= 0; i--) {
ExternalHostGroup hg = hostGroups.get(Integer.parseInt(ancestries[i]));
String envName = hg.getEnvironmentName();
if (envName != null) {
int envId = hg.getEnvironmentId();
hostGroups.get(hostGroup.getId()).setEnvironmentName(envName);
hostGroups.get(hostGroup.getId()).setEnvironmentId(envId);
break;
}
}
}
if (hostGroup.getPtableName() == null) {
for (int i = ancestries.length - 1; i >= 0; i--) {
ExternalHostGroup hg = hostGroups.get(Integer.parseInt(ancestries[i]));
String ptableName = hg.getPtableName();
if (ptableName != null) {
int ptableId = hg.getPtableId();
hostGroups.get(hostGroup.getId()).setPtableName(ptableName);
hostGroups.get(hostGroup.getId()).setPtableId(ptableId);
break;
}
}
}
if (hostGroup.getArchitectureName() == null) {
for (int i = ancestries.length - 1; i >= 0; i--) {
ExternalHostGroup hg = hostGroups.get(Integer.parseInt(ancestries[i]));
String archName = hg.getArchitectureName();
if (archName != null) {
int archId = hg.getArchitectureId();
hostGroups.get(hostGroup.getId()).setArchitectureName(archName);
hostGroups.get(hostGroup.getId()).setArchitectureId(archId);
break;
}
}
}
if (hostGroup.getOperatingSystemName() == null) {
for (int i = ancestries.length - 1; i >= 0; i--) {
ExternalHostGroup hg = hostGroups.get(Integer.parseInt(ancestries[i]));
String osName = hg.getOperatingsystemName();
if (osName != null) {
int osId = hg.getOperatingsystemId();
hostGroups.get(hostGroup.getId()).setOperatingsystemName(osName);
hostGroups.get(hostGroup.getId()).setOperatingsystemId(osId);
break;
}
}
}
if (hostGroup.getDomainName() == null) {
for (int i = ancestries.length - 1; i >= 0; i--) {
ExternalHostGroup hg = hostGroups.get(Integer.parseInt(ancestries[i]));
String domainName = hg.getDomainName();
if (domainName != null) {
int domainId = hg.getDomainId();
hostGroups.get(hostGroup.getId()).setDomainName(domainName);
hostGroups.get(hostGroup.getId()).setDomainId(domainId);
break;
}
}
}
if (hostGroup.getSubnetName() == null) {
for (int i = ancestries.length - 1; i >= 0; i--) {
ExternalHostGroup hg = hostGroups.get(Integer.parseInt(ancestries[i]));
String subnetName = hg.getSubnetName();
if (subnetName != null) {
int subnetId = hg.getSubnetId();
hostGroups.get(hostGroup.getId()).setSubnetName(subnetName);
hostGroups.get(hostGroup.getId()).setSubnetId(subnetId);
break;
}
}
}
if (hostGroup.getParameters() == null) {
for (int i = ancestries.length - 1; i >= 0; i--) {
ExternalHostGroup hg = hostGroups.get(Integer.parseInt(ancestries[i]));
Map<String, String> parameters = hg.getParameters();
if (parameters != null) {
hostGroups.get(hostGroup.getId()).setParameters(parameters);
break;
}
}
}
}
ret.add(hostGroups.get(hostGroup.getId()));
}
return ret;
}
use of org.ovirt.engine.core.common.businessentities.ExternalHostGroup in project ovirt-engine by oVirt.
the class GetHostGroupsFromExternalProviderQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
Provider hostProvider = getParameters().getProvider();
List<ExternalHostGroup> providerHostGroups = getProviderHostGroups(hostProvider);
getQueryReturnValue().setReturnValue(providerHostGroups);
}
use of org.ovirt.engine.core.common.businessentities.ExternalHostGroup in project ovirt-engine by oVirt.
the class HostListModel method onSaveInternal.
public void onSaveInternal(boolean approveInitiated) {
HostModel model = (HostModel) getWindow();
if (model.getProgress() != null) {
return;
}
VDS host = model.getIsNew() ? new VDS() : (VDS) Cloner.clone(getSelectedItem());
// Save changes.
host.setVdsName(model.getName().getEntity());
host.setComment(model.getComment().getEntity());
host.setHostName(model.getHost().getEntity().trim());
host.setPort(Integer.parseInt(model.getPort().getEntity().toString()));
host.setSshPort(Integer.parseInt(model.getAuthSshPort().getEntity().toString()));
boolean sshUsernameSet = model.getUserName().getEntity() != null;
host.setSshUsername(sshUsernameSet ? model.getUserName().getEntity() : null);
boolean sshFpSet = model.getFetchSshFingerprint().getEntity() != null;
host.setSshKeyFingerprint(!sshFpSet ? null : model.getFetchSshFingerprint().getEntity());
host.setVdsSpmPriority(model.getSpmPriorityValue());
boolean consoleAddressSet = model.getConsoleAddressEnabled().getEntity();
host.setConsoleAddress(!consoleAddressSet ? null : model.getConsoleAddress().getEntity());
Guid oldClusterId = host.getClusterId();
Guid newClusterId = model.getCluster().getSelectedItem().getId();
host.setClusterId(newClusterId);
host.setVdsSpmPriority(model.getSpmPriorityValue());
host.setFenceProxySources(FenceProxySourceTypeHelper.parseFromString(model.getPmProxyPreferences()));
// Save other PM parameters.
host.setPmEnabled(model.getIsPm().getEntity());
host.setDisablePowerManagementPolicy(model.getDisableAutomaticPowerManagement().getEntity());
host.setPmKdumpDetection(model.getPmKdumpDetection().getEntity());
host.setCurrentKernelCmdline(model.getKernelCmdline().getEntity());
host.setKernelCmdlineBlacklistNouveau(model.getKernelCmdlineBlacklistNouveau().getEntity());
host.setKernelCmdlineParsable(model.isKernelCmdlineParsable());
host.setKernelCmdlineIommu(model.getKernelCmdlineIommu().getEntity());
host.setKernelCmdlineKvmNested(model.getKernelCmdlineKvmNested().getEntity());
host.setKernelCmdlineUnsafeInterrupts(model.getKernelCmdlineUnsafeInterrupts().getEntity());
host.setKernelCmdlinePciRealloc(model.getKernelCmdlinePciRealloc().getEntity());
cancelConfirm();
model.startProgress();
if (model.getIsNew()) {
AddVdsActionParameters parameters = new AddVdsActionParameters();
parameters.setVdsId(host.getId());
parameters.setvds(host);
parameters.setFenceAgents(model.getFenceAgentListModel().getFenceAgents());
if (model.getUserPassword().getEntity() != null) {
parameters.setPassword(model.getUserPassword().getEntity());
}
parameters.setOverrideFirewall(model.getOverrideIpTables().getEntity());
parameters.setAuthMethod(model.getAuthenticationMethod());
Provider<?> networkProvider = model.getNetworkProviders().getSelectedItem();
if (networkProvider != null) {
parameters.getVdsStaticData().setOpenstackNetworkProviderId(networkProvider.getId());
parameters.setNetworkMappings(model.getInterfaceMappings().getEntity());
}
if (model.getProviders().getSelectedItem() != null) {
parameters.getVdsStaticData().setHostProviderId(model.getProviders().getSelectedItem().getId());
}
if (Boolean.TRUE.equals(model.getIsDiscoveredHosts().getEntity())) {
Provider<?> provider = model.getProviders().getSelectedItem();
ExternalHostGroup hostGroup = (ExternalHostGroup) model.getExternalHostGroups().getSelectedItem();
ExternalComputeResource computeResource = (ExternalComputeResource) model.getExternalComputeResource().getSelectedItem();
ExternalDiscoveredHost discoveredHost = (ExternalDiscoveredHost) model.getExternalDiscoveredHosts().getSelectedItem();
parameters.initVdsActionParametersForProvision(provider.getId(), hostGroup, computeResource, discoveredHost.getMac(), discoveredHost.getName(), discoveredHost.getIp());
}
parameters.setHostedEngineDeployConfiguration(new HostedEngineDeployConfiguration(model.getHostedEngineHostModel().getSelectedItem()));
parameters.setAffinityLabels(model.getLabelList().getSelectedItems());
Frontend.getInstance().runAction(ActionType.AddVds, parameters, result -> {
Object[] array = (Object[]) result.getState();
HostListModel<Void> localModel = (HostListModel<Void>) array[0];
boolean localApproveInitiated = (Boolean) array[1];
localModel.postOnSaveInternal(result.getReturnValue(), localApproveInitiated);
}, new Object[] { this, approveInitiated });
} else {
// Update VDS -> consists of changing VDS cluster first and then updating rest of VDS properties:
UpdateVdsActionParameters parameters = new UpdateVdsActionParameters();
parameters.setvds(host);
parameters.setVdsId(host.getId());
// $NON-NLS-1$
parameters.setPassword("");
parameters.setInstallHost(false);
parameters.setAuthMethod(model.getAuthenticationMethod());
parameters.setFenceAgents(model.getFenceAgentListModel().getFenceAgents());
parameters.setAffinityLabels(model.getLabelList().getSelectedItems());
if (model.getExternalHostProviderEnabled().getEntity() && model.getProviders().getSelectedItem() != null) {
host.setHostProviderId(model.getProviders().getSelectedItem().getId());
}
if (!oldClusterId.equals(newClusterId)) {
Frontend.getInstance().runAction(ActionType.ChangeVDSCluster, new ChangeVDSClusterParameters(newClusterId, host.getId()), result -> {
Object[] array = (Object[]) result.getState();
HostListModel<Void> localModel = (HostListModel<Void>) array[0];
UpdateVdsActionParameters localParameters = (UpdateVdsActionParameters) array[1];
boolean localApproveInitiated = (Boolean) array[2];
ActionReturnValue localReturnValue = result.getReturnValue();
if (localReturnValue != null && localReturnValue.getSucceeded()) {
localModel.postOnSaveInternalChangeCluster(localParameters, localApproveInitiated);
} else {
localModel.getWindow().stopProgress();
}
}, new Object[] { this, parameters, approveInitiated });
} else {
postOnSaveInternalChangeCluster(parameters, approveInitiated);
}
}
}
Aggregations