Muli Salem has uploaded a new change for review. Change subject: engine: Alternative Installation Address (1) ......................................................................
engine: Alternative Installation Address (1) This patch adds support to specifying an alternative address for host installation, while adding a new host. Change-Id: I3171a926a0858eb3e2597e45c59285c225580d15 Signed-off-by: Muli Salem <msa...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OVirtNodeUpgrade.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdsOperationActionParameters.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 10 files changed, 76 insertions(+), 15 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/67/13167/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java index 5df1a24..b89e9e6 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java @@ -145,6 +145,7 @@ getParameters().getRootPassword()); installVdsParameters.setOverrideFirewall(getParameters().getOverrideFirewall()); installVdsParameters.setRebootAfterInstallation(getParameters().isRebootAfterInstallation()); + installVdsParameters.setInstallationAddress(getInstallationAddress()); Map<String, String> values = new HashMap<String, String>(); values.put(VdcObjectType.VDS.name().toLowerCase(), getParameters().getvds().getName()); Step installStep = ExecutionHandler.addSubStep(getExecutionContext(), @@ -290,6 +291,7 @@ VDS vds = getParameters().getvds(); String vdsName = vds.getName(); String hostName = vds.getHostName(); + String installationAddress = getParameters().getInstallationAddress(); int maxVdsNameLength = Config.<Integer> GetValue(ConfigValues.MaxVdsNameLength); // check that vds name is not null or empty if (vdsName == null || vdsName.isEmpty()) { @@ -308,6 +310,9 @@ returnValue = false; } else if (getVdsDAO().getAllForHostname(hostName).size() != 0) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_VDS_WITH_SAME_HOST_EXIST); + returnValue = false; + } else if (installationAddress != null && getVdsDAO().getAllForHostname(installationAddress).size() != 0) { + addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_VDS_WITH_GIVEN_INSTALLATION_ADDRESS_EXISTS); returnValue = false; } else { returnValue = returnValue && validateSingleHostAttachedToLocalStorage(); @@ -363,7 +368,7 @@ sshclient = getSSHClient(); sshclient.setHardTimeout(timeout); sshclient.setSoftTimeout(timeout); - sshclient.setHost(vds.getHostName()); + sshclient.setHost(getInstallationAddress()); sshclient.setUser(USER_NAME); sshclient.setPassword(getParameters().getRootPassword()); sshclient.connect(); @@ -396,6 +401,11 @@ return returnValue; } + private String getInstallationAddress() { + return StringUtils.defaultIfEmpty(getParameters().getInstallationAddress(), + getParameters().getVdsStaticData().getHostName()); + } + private boolean validateSingleHostAttachedToLocalStorage() { boolean retrunValue = true; storage_pool storagePool = DbFacade.getInstance().getStoragePoolDao().getForVdsGroup( diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java index 289638e..8c28a43 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InstallVdsCommand.java @@ -79,22 +79,28 @@ @Override protected void executeCommand() { + if (getParameters().getInstallationAddress() == null) { + getParameters().setInstallationAddress(getVds().getHostName()); + } + + T parameters = getParameters(); if ( getVds() != null && isOvirtReInstallOrUpgrade() ) { OVirtNodeUpgrade upgrade = null; try { - T parameters = getParameters(); upgrade = new OVirtNodeUpgrade( getVds(), - parameters.getoVirtIsoFile() + parameters.getoVirtIsoFile(), + parameters.getInstallationAddress() ); upgrade.setCorrelationId(getCorrelationId()); log.infoFormat( - "Execute upgrade host {0}, {1}", + "Execute upgrade host {0}, {1}, via address {2}", getVds().getId(), - getVds().getName() + getVds().getName(), + parameters.getInstallationAddress() ); upgrade.execute(); log.infoFormat( @@ -109,9 +115,10 @@ } catch (Exception e) { log.errorFormat( - "Host installation failed for host {0}, {1}.", + "Host installation failed for host {0}, {1}, via address {2}.", getVds().getId(), getVds().getName(), + parameters.getInstallationAddress(), e ); setSucceeded(false); @@ -130,15 +137,16 @@ VdsDeploy installer = null; try { log.infoFormat( - "Before Installation host {0}, {1}", + "Before Installation host {0}, {1}, via address {2}", getVds().getId(), - getVds().getName() + getVds().getName(), + parameters.getInstallationAddress() ); - T parameters = getParameters(); - installer = new VdsDeploy(getVds()); + installer = new VdsDeploy(getVds(), parameters.getInstallationAddress()); installer.setCorrelationId(getCorrelationId()); installer.setReboot(parameters.isRebootAfterInstallation()); + switch (getVds().getVdsType()) { case VDS: installer.setUser("root"); @@ -177,9 +185,10 @@ } catch (Exception e) { log.errorFormat( - "Host installation failed for host {0}, {1}.", + "Host installation failed for host {0}, {1}, via address {2}.", getVds().getId(), getVds().getName(), + parameters.getInstallationAddress(), e ); setSucceeded(false); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OVirtNodeUpgrade.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OVirtNodeUpgrade.java index 67f4eb0..36e3d03 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OVirtNodeUpgrade.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OVirtNodeUpgrade.java @@ -40,6 +40,7 @@ private VDS _vds; private String _iso; + private String installationAddress; private Exception _failException = null; @@ -94,9 +95,10 @@ * @param vds vds to install. * @param iso image to send. */ - public OVirtNodeUpgrade(VDS vds, String iso) { + public OVirtNodeUpgrade(VDS vds, String iso, String installationAddress) { _vds = vds; _iso = Config.resolveOVirtISOsRepositoryPath() + File.separator + iso; + this.installationAddress = installationAddress; _messages = new InstallerMessages(_vds); _dialog = new EngineSSHDialog(); @@ -143,7 +145,7 @@ _setVdsStatus(VDSStatus.Installing); _dialog.useDefaultKeyPair(); - _dialog.setHost(_vds.getHostName()); + _dialog.setHost(installationAddress); _dialog.connect(); _messages.post( InstallerMessages.Severity.INFO, diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java index 2a0d284..a36e8f2 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsDeploy.java @@ -84,6 +84,7 @@ private final InstallerMessages _messages; private VDS _vds; + private String installationAddress; private boolean _isNode = false; private boolean _reboot = false; private String _correlationId = null; @@ -628,6 +629,7 @@ return null; }}, }; + /** * Execute the next termination vector entry. */ @@ -783,8 +785,9 @@ * Constructor. * @param vds vds to install. */ - public VdsDeploy(VDS vds) { + public VdsDeploy(VDS vds, String installationAddress) { _vds = vds; + this.installationAddress = installationAddress; _messages = new InstallerMessages(_vds); _dialog = new EngineSSHDialog(); @@ -892,7 +895,7 @@ try { _setVdsStatus(VDSStatus.Installing); - _dialog.setHost(_vds.getHostName()); + _dialog.setHost(installationAddress); _dialog.connect(); _messages.post( InstallerMessages.Severity.INFO, diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdsOperationActionParameters.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdsOperationActionParameters.java index 6e530b5..39ac08f 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdsOperationActionParameters.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdsOperationActionParameters.java @@ -1,9 +1,15 @@ package org.ovirt.engine.core.common.action; import javax.validation.Valid; +import javax.validation.constraints.Size; +import org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions; +import org.ovirt.engine.core.common.businessentities.EditableOnVdsStatus; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VdsStatic; +import org.ovirt.engine.core.common.validation.annotation.HostnameOrIp; +import org.ovirt.engine.core.common.validation.group.CreateEntity; +import org.ovirt.engine.core.common.validation.group.UpdateEntity; public class VdsOperationActionParameters extends VdsActionParameters { private static final long serialVersionUID = 4156122527623908516L; @@ -19,6 +25,16 @@ * reboot the installed Host when done */ private boolean rebootAfterInstallation = true; + + /** + * An address that is used for host installation only, if not set, the {@link VdsStatic#hostname} will be used + * instead + */ + @EditableOnVdsStatus + @HostnameOrIp(message = "VALIDATION.VDS.INSTALLATION.ADDRESS", + groups = { CreateEntity.class, UpdateEntity.class }) + @Size(max = BusinessEntitiesDefinitions.HOST_HOSTNAME_SIZE) + private String installationAddress; public VdsOperationActionParameters(VdsStatic vdsStatic, String rootPassword) { super(vdsStatic.getId()); @@ -45,6 +61,14 @@ _rootPassword = value; } + public String getInstallationAddress() { + return installationAddress; + } + + public void setInstallationAddress(String value) { + installationAddress = value; + } + public VdsOperationActionParameters() { } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java index bd53bd8..5610a30 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java @@ -160,6 +160,7 @@ ACTION_TYPE_FAILED_SPECIFY_DOMAIN_IS_NOT_EXPORT_DOMAIN, ACTION_TYPE_FAILED_DETECTED_ACTIVE_VMS, ACTION_TYPE_FAILED_VDS_WITH_SAME_HOST_EXIST, + ACTION_TYPE_FAILED_VDS_WITH_GIVEN_INSTALLATION_ADDRESS_EXISTS, ACTION_TYPE_FAILED_ILLEGAL_MEMORY_SIZE, ACTION_TYPE_FAILED_ILLEGAL_NUM_OF_MONITORS, ACTION_TYPE_FAILED_ILLEGAL_DOMAIN_NAME, diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index 11c0477..49d538c 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -482,6 +482,7 @@ -Please remove VLAN from the interface. NETWORK_ALREADY_ATTACHED_TO_CLUSTER=Logical Network is already attached to Cluster. ACTION_TYPE_FAILED_VDS_WITH_SAME_HOST_EXIST=Cannot ${action} ${type}. Host with the same address already exists. +ACTION_TYPE_FAILED_VDS_WITH_GIVEN_INSTALLATION_ADDRESS_EXISTS=Cannot ${action} ${type}. Host with the same address as the given installation address already exists. ACTION_TYPE_FAILED_ILLEGAL_MEMORY_SIZE=Cannot ${action} ${type}. Illegal memory size is provided, size needs to be between ${minMemorySize} MB and ${maxMemorySize} MB. ACTION_TYPE_FAILED_ILLEGAL_NUM_OF_MONITORS=Cannot ${action} ${type}. Illegal number of monitors is provided, max allowed number of monitors is 1 for VNC and the max number in the ValidNumOfMonitors configuration variable for SPICE. ACTION_TYPE_FAILED_ILLEGAL_DOMAIN_NAME=Cannot ${action} ${type}. Illegal Domain name: ${Domain}. Domain name has unsupported special character ${Char}. @@ -585,6 +586,7 @@ VALIDATION.VDS_GROUP.MigrateOnError.NOT_NULL=Cluster migrate on error option is required VALIDATION.STORAGE_POOL.ID.NOT_NULL=Data Center ID is required VALIDATION.VDS.HOSTNAME.HOSTNAME_OR_IP=Host address must be a FQDN or a valid IP address +VALIDATION.VDS.INSTALLATION.ADDRESS=Host installation address must be a FQDN or a valid IP address. VALIDATION.VDS.CONSOLEADDRESSS.HOSTNAME_OR_IP=Console address must be a FQDN or a valid IP address VALIDATION.VDS.POWER_MGMT.ADDRESS.HOSTNAME_OR_IP=Host power management address must be a FQDN or a valid IP address VALIDATION.VM.NUM_OF_MONITORS.EXCEEDED=VM exceeded the number of allowed monitors diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index 17f25cf..9d2c8e3 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -1294,6 +1294,9 @@ @DefaultStringValue("Cannot ${action} ${type}. Host with the same address already exists.") String ACTION_TYPE_FAILED_VDS_WITH_SAME_HOST_EXIST(); + @DefaultStringValue("Cannot ${action} ${type}. Host with the same address as the given installation address already exists.") + String ACTION_TYPE_FAILED_VDS_WITH_GIVEN_INSTALLATION_ADDRESS_EXISTS(); + @DefaultStringValue("Cannot ${action} ${type}. Illegal memory size is provided, size needs to be between ${minMemorySize} MB and ${maxMemorySize} MB.") String ACTION_TYPE_FAILED_ILLEGAL_MEMORY_SIZE(); @@ -1564,6 +1567,9 @@ @DefaultStringValue("Host power management address must be a FQDN or a valid IP address") String VALIDATION_VDS_POWER_MGMT_ADDRESS_HOSTNAME_OR_IP(); + @DefaultStringValue("Host installation address must be a FQDN or a valid IP address.") + String VALIDATION_VDS_INSTALLATION_ADDRESS(); + @DefaultStringValue("VM exceeded the number of allowed monitors") String VALIDATION_VM_NUM_OF_MONITORS_EXCEEDED(); diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index e2bb661..55fdab8 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -479,6 +479,7 @@ -Please remove VLAN from the interface. NETWORK_ALREADY_ATTACHED_TO_CLUSTER=Logical Network is already attached to Cluster. ACTION_TYPE_FAILED_VDS_WITH_SAME_HOST_EXIST=Cannot ${action} ${type}. Host with the same address already exists. +ACTION_TYPE_FAILED_VDS_WITH_GIVEN_INSTALLATION_ADDRESS_EXISTS=Cannot ${action} ${type}. Host with the same address as the given installation address already exists. ACTION_TYPE_FAILED_ILLEGAL_MEMORY_SIZE=Cannot ${action} ${type}. Illegal memory size is provided, size needs to be between ${minMemorySize} MB and ${maxMemorySize} MB. ACTION_TYPE_FAILED_ILLEGAL_NUM_OF_MONITORS=Cannot ${action} ${type}. Illegal number of monitors is provided, max allowed number of monitors is 1 for VNC and the max number in the ValidNumOfMonitors configuration variable for SPICE. ACTION_TYPE_FAILED_ILLEGAL_DOMAIN_NAME=Cannot ${action} ${type}. Illegal Domain name: ${Domain}. Domain name has unsupported special character ${Char}. @@ -583,6 +584,7 @@ VALIDATION_VDS_GROUP_MigrateOnError_NOT_NULL=Cluster migrate on error option is required VALIDATION_STORAGE_POOL_ID_NOT_NULL=Data Center ID is required VALIDATION_VDS_HOSTNAME_HOSTNAME_OR_IP=Host address must be a FQDN or a valid IP address +VALIDATION_VDS_INSTALLATION_ADDRESS=Host installation address must be a FQDN or a valid IP address. VALIDATION_VDS_POWER_MGMT_ADDRESS_HOSTNAME_OR_IP=Host power management address must be a FQDN or a valid IP address VALIDATION_VM_NUM_OF_MONITORS_EXCEEDED=VM exceeded the number of allowed monitors VALIDATION_STORAGE_DOMAIN_NAME_INVALID=Storage Domain name must be formed of "a-z0-9A-Z" or "-_" diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 8721a49..70a0ccb 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -476,6 +476,7 @@ -Please remove VLAN from the interface. NETWORK_ALREADY_ATTACHED_TO_CLUSTER=Logical Network is already attached to Cluster. ACTION_TYPE_FAILED_VDS_WITH_SAME_HOST_EXIST=Cannot ${action} ${type}. Host with the same address already exists. +ACTION_TYPE_FAILED_VDS_WITH_GIVEN_INSTALLATION_ADDRESS_EXISTS=Cannot ${action} ${type}. Host with the same address as the given installation address already exists. ACTION_TYPE_FAILED_ILLEGAL_MEMORY_SIZE=Cannot ${action} ${type}. Illegal memory size is provided, size needs to be between ${minMemorySize} MB and ${maxMemorySize} MB. ACTION_TYPE_FAILED_ILLEGAL_NUM_OF_MONITORS=Cannot ${action} ${type}. Illegal number of monitors is provided, max allowed number of monitors is 1 for VNC and the max number in the ValidNumOfMonitors configuration variable for Spice. ACTION_TYPE_FAILED_ILLEGAL_DOMAIN_NAME=Cannot ${action} ${type}. Illegal Domain name: ${Domain}. Domain name has unsupported special character ${Char}. @@ -576,6 +577,7 @@ VALIDATION_VDS_GROUP_MigrateOnError_NOT_NULL=Cluster migrate on error option is required VALIDATION_STORAGE_POOL_ID_NOT_NULL=Data Center ID is required VALIDATION_VDS_HOSTNAME_HOSTNAME_OR_IP=Host address must be a FQDN or a valid IP address +VALIDATION_VDS_INSTALLATION_ADDRESS=Host installation address must be a FQDN or a valid IP address. VALIDATION_VDS_POWER_MGMT_ADDRESS_HOSTNAME_OR_IP=Host power management address must be a FQDN or a valid IP address VALIDATION_VM_NUM_OF_MONITORS_EXCEEDED=VM exceeded the number of allowed monitors VALIDATION_VM_TEMPLATE_NAME_MAX=VM Template name must not exceed 40 characters -- To view, visit http://gerrit.ovirt.org/13167 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3171a926a0858eb3e2597e45c59285c225580d15 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Muli Salem <msa...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches