Vinzenz Feenstra has uploaded a new change for review. Change subject: Use FQDN from guest agent for RDP ......................................................................
Use FQDN from guest agent for RDP This commit adds the support for retrieving the guestFQDN value from VDSM and stores it in the VmDynamic database. We're not storing FQDN which are localhost or localhost.localdomain Additionally a new vdc_option "RdpUseFqdnIfAvailable" has been introduced, to give the administrators the option to disable this feature. If RdpUseFqdnIfAvailable is true (default) RDP will use the reported FQDN if it is not null or an empty string. The value can now be read on the Frontend from the RdpConsoleModel and it will check whether or not the vdc_option RdpUseFqdnIfAvailable was set. The FQDN value is now also part of the GuestInfo data in the REST API. Change-Id: I1e7f8e46c6a71ccbfe9af9bf85271d7294b03526 Signed-off-by: Vinzenz Feenstra <vfeen...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDynamicDAODbFacadeImpl.java M backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDynamicDAOTest.java M backend/manager/modules/dal/src/test/resources/fixtures.xml M backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java M backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java M backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmGeneralModelForm.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RdpConsoleModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmGeneralModel.java M packaging/dbscripts/create_dwh_views.sql M packaging/dbscripts/create_views.sql A packaging/dbscripts/upgrade/03_03_0920_add_fqdn_to_vm_dynamic.sql M packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql M packaging/dbscripts/vms_sp.sql 27 files changed, 158 insertions(+), 14 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/48/19748/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java index 7d4cda7..e30e644 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java @@ -687,6 +687,7 @@ tempVar.setStatus(VMStatus.Down); tempVar.setVmHost(""); tempVar.setVmIp(""); + tempVar.setVmFQDN(""); tempVar.setDisplayType(getParameters().getVmStaticData().getDefaultDisplayType()); VmDynamic vmDynamic = tempVar; DbFacade.getInstance().getVmDynamicDao().save(vmDynamic); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java index df1b9d7..ac2d2e7 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java @@ -1063,6 +1063,7 @@ tempVar.setStatus(VMStatus.ImageLocked); tempVar.setVmHost(""); tempVar.setVmIp(""); + tempVar.setVmFQDN(""); tempVar.setAppList(getParameters().getVm().getDynamicData().getAppList()); getVmDynamicDAO().save(tempVar); getCompensationContext().snapshotNewEntity(tempVar); diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java index e96c672..9b837f1 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java @@ -420,6 +420,14 @@ this.vmDynamic.setVmIp(value); } + public String getVmFQDN() { + return this.vmDynamic.getVmFQDN(); + } + + public void setVmFQDN(String fqdn) { + this.vmDynamic.setVmFQDN(fqdn); + } + public String getVmHost() { String vmHost = this.vmDynamic.getVmHost(); if (!StringHelper.isNullOrEmpty(this.getVmIp())) { @@ -1188,6 +1196,7 @@ setDisplaySecurePort(vm.getDisplaySecurePort()); setVmHost(vm.getVmHost()); setVmIp(vm.getVmIp()); + setVmFQDN(vm.getVmFQDN()); // if (!string.IsNullOrEmpty(vm.app_list)) // { diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java index b274814..7d4113f 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java @@ -13,6 +13,7 @@ private Guid id; private VMStatus status; private String vmIp; + private String vmFQDN; private String vmHost; private Integer vmPid; private Date lastStartTime; @@ -84,6 +85,7 @@ result = prime * result + ((utcDiff == null) ? 0 : utcDiff.hashCode()); result = prime * result + ((vmHost == null) ? 0 : vmHost.hashCode()); result = prime * result + ((vmIp == null) ? 0 : vmIp.hashCode()); + result = prime * result + ((vmFQDN == null) ? 0 : vmFQDN.hashCode()); result = prime * result + ((lastStartTime == null) ? 0 : lastStartTime.hashCode()); result = prime * result + ((vmPid == null) ? 0 : vmPid.hashCode()); result = prime * result + (lastWatchdogEvent == null ? 0 : lastWatchdogEvent.hashCode()); @@ -135,6 +137,7 @@ && ObjectUtils.objectsEqual(utcDiff, other.utcDiff) && ObjectUtils.objectsEqual(vmHost, other.vmHost) && ObjectUtils.objectsEqual(vmIp, other.vmIp) + && ObjectUtils.objectsEqual(vmFQDN, other.vmFQDN) && ObjectUtils.objectsEqual(lastStartTime, other.lastStartTime) && ObjectUtils.objectsEqual(vmPid, other.vmPid) && ObjectUtils.objectsEqual(lastWatchdogEvent, other.lastWatchdogEvent) @@ -303,6 +306,14 @@ this.vmHost = value; } + public String getVmFQDN() { + return this.vmFQDN; + } + + public void setVmFQDN(String fqdn) { + this.vmFQDN = fqdn; + } + public String getVmIp() { return this.vmIp; } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java index 8fdcc4b..4b701fb 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java @@ -1513,6 +1513,10 @@ @DefaultValueAttribute("60") AutoStartVmsRunnerIntervalInSeconds(538), + @TypeConverterAttribute(Boolean.class) + @DefaultValueAttribute("true") + UseFqdnForRdpIfAvailable(539), + Invalid(65535); private int intValue; diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java index 6cfa364..d91b78f 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java @@ -27,6 +27,7 @@ SpiceProxyDefault(ConfigAuthType.User), ClientModeSpiceDefault(ConfigAuthType.User), ClientModeRdpDefault(ConfigAuthType.User), + UseFqdnForRdpIfAvailable(ConfigAuthType.User), WebSocketProxy(ConfigAuthType.User), WebSocketProxyTicketValiditySeconds(ConfigAuthType.User), HighUtilizationForEvenlyDistribute(ConfigAuthType.User), diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java index af3c568..6543442 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java @@ -277,6 +277,7 @@ entity.setVmtDescription(rs.getString("vmt_description")); entity.setStatus(VMStatus.forValue(rs.getInt("status"))); entity.setVmIp(rs.getString("vm_ip")); + entity.setVmFQDN(rs.getString("vm_fqdn")); entity.setVmHost(rs.getString("vm_host")); entity.setVmPid((Integer) rs.getObject("vm_pid")); entity.setDbGeneration(rs.getLong("db_generation")); diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDynamicDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDynamicDAODbFacadeImpl.java index e3f2207..ef14347 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDynamicDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDynamicDAODbFacadeImpl.java @@ -87,6 +87,7 @@ .addValue("status", vm.getStatus()) .addValue("vm_host", vm.getVmHost()) .addValue("vm_ip", vm.getVmIp()) + .addValue("vm_fqdn", vm.getVmFQDN()) .addValue("last_start_time", vm.getLastStartTime()) .addValue("vm_pid", vm.getVmPid()) .addValue("display", vm.getDisplay()) @@ -138,6 +139,7 @@ entity.setId(getGuidDefaultEmpty(rs, "vm_guid")); entity.setVmHost(rs.getString("vm_host")); entity.setVmIp(rs.getString("vm_ip")); + entity.setVmFQDN(rs.getString("vm_fqdn")); entity.setLastStartTime(DbFacadeUtils.fromDate(rs .getTimestamp("last_start_time"))); entity.setVmPid((Integer) rs.getObject("vm_pid")); diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDynamicDAOTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDynamicDAOTest.java index 47a9f1c..c095945 100644 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDynamicDAOTest.java +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDynamicDAOTest.java @@ -119,6 +119,7 @@ VmDynamic existingVm2 = dao.get(new Guid("77296e00-0cad-4e5a-9299-008a7b6f4356")); existingVm.setStatus(VMStatus.Down); existingVm2.setVmIp("111"); + existingVm2.setVmFQDN("localhost.localdomain"); dao.updateAll(Arrays.asList(new VmDynamic[] { existingVm, existingVm2 })); diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml b/backend/manager/modules/dal/src/test/resources/fixtures.xml index 50fe7cb..76cae4f 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -2410,6 +2410,7 @@ <column>vm_guid</column> <column>status</column> <column>vm_ip</column> + <column>vm_fqdn</column> <column>vm_host</column> <column>vm_pid</column> <column>last_start_time</column> @@ -2442,6 +2443,7 @@ <row> <value>77296e00-0cad-4e5a-9299-008a7b6f4356</value> <value>5</value> + <null /> <null /> <null /> <null /> @@ -2483,6 +2485,7 @@ <null /> <null /> <null /> + <null /> <value>9bf7c640-b620-456f-a550-0348f366544a</value> <!-- console_user_id --> <null /> <null /> @@ -2510,6 +2513,7 @@ <row> <value>77296e00-0cad-4e5a-9299-008a7b6f4354</value> <value>1</value> + <null /> <null /> <null /> <null /> @@ -2552,6 +2556,7 @@ <null /> <null /> <null /> + <null /> <null /> <!-- console_user_id --> <null /> <value>afce7a39-8e8c-4819-ba9c-796d316592e7</value> @@ -2585,6 +2590,7 @@ <null /> <null /> <null /> + <null /> <null /> <!-- console_user_id --> <null /> <value>afce7a39-8e8c-4819-ba9c-796d316592e7</value> diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd index 41df119..7f96ec8 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd @@ -2388,6 +2388,7 @@ <xs:complexType name="GuestInfo"> <xs:sequence> <xs:element ref="ips" minOccurs="0" maxOccurs="1"/> + <xs:element name="fqdn" type="xs:string" minOccurs="0" maxOccurs="1"/> </xs:sequence> </xs:complexType> diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java index 64ff091..86f78fc 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java @@ -68,6 +68,7 @@ addVnicProfilesFeature(features); addStorageDomainImageFeature(features); addGlusterHooksFeature(features); + addFeatureReportVmFQDN(features); } return features; } @@ -358,4 +359,11 @@ feature.setDescription("Ability to attach/detach storage server connections to/from a specific storage domain (common use case: disaster recovery)."); features.getFeature().add(feature); } + + private void addFeatureReportVmFQDN(Features features) { + Feature feature = new Feature(); + feature.setName("VM FQDN"); + feature.setDescription("Ability to report the fully qualified domain name (FQDN) of a Virtual Machine"); + features.getFeature().add(feature); + } } diff --git a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java index 39aed40..b5c75e3 100644 --- a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java +++ b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java @@ -361,14 +361,26 @@ model.setHost(new Host()); model.getHost().setId(entity.getRunOnVds().toString()); } - if (entity.getVmIp()!=null && !entity.getVmIp().isEmpty()) { + final boolean hasIps = entity.getVmIp() != null && !entity.getVmIp().isEmpty(); + final boolean hasFqdn = entity.getVmFQDN() != null && !entity.getVmFQDN().isEmpty(); + if (hasIps || hasFqdn) { model.setGuestInfo(new GuestInfo()); - model.getGuestInfo().setIps(new IPs()); - for (String item : entity.getVmIp().split(" ")) { - if (!item.equals("")) { - IP ip = new IP(); - ip.setAddress(item.trim()); - model.getGuestInfo().getIps().getIPs().add(ip); + + if (hasFqdn) { + model.getGuestInfo().setFqdn(entity.getVmFQDN()); + } + + if (hasIps){ + IPs ips = new IPs(); + for (String item : entity.getVmIp().split(" ")) { + if (!item.equals("")) { + IP ip = new IP(); + ip.setAddress(item.trim()); + ips.getIPs().add(ip); + } + } + if (!ips.getIPs().isEmpty()) { + model.getGuestInfo().setIps(ips); } } } diff --git a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java index 08bdc43..2038012 100644 --- a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java +++ b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java @@ -160,6 +160,18 @@ } @Test + public void testGuestFQDN() { + org.ovirt.engine.core.common.businessentities.VM vm = new org.ovirt.engine.core.common.businessentities.VM(); + VmDynamic vmDynamic = new VmDynamic(); + vmDynamic.setStatus(VMStatus.Up); + vmDynamic.setVmFQDN("localhost.localdomain"); + vm.setDynamicData(vmDynamic); + OsTypeMockUtils.mockOsTypes(); + VM map = VmMapper.map(vm, null); + assertNotNull(map.getGuestInfo().getFqdn()); + assertEquals(map.getGuestInfo().getFqdn(), "localhost.localdomain"); + } + @Test public void testGustIps() { org.ovirt.engine.core.common.businessentities.VM vm = new org.ovirt.engine.core.common.businessentities.VM(); VmDynamic vmDynamic = new VmDynamic(); diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java index 282f7a6..1d9e0e6 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java @@ -276,6 +276,7 @@ vm.setConsoleUserId(null); vm.setGuestOs(null); vm.setVmIp(null); + vm.setVmFQDN(null); List<VmNetworkInterface> interfaces = vm.getInterfaces(); for (VmNetworkInterface ifc : interfaces) { NetworkStatistics statistics = ifc.getStatistics(); diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java index 015db73..e1e6ae5 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java @@ -193,6 +193,17 @@ initAppsList(xmlRpcStruct, vm); vm.setGuestOs(AssignStringValue(xmlRpcStruct, VdsProperties.guest_os)); + if (xmlRpcStruct.containsKey(VdsProperties.VM_FQDN)) { + vm.setVmFQDN(AssignStringValue(xmlRpcStruct, VdsProperties.VM_FQDN)); + String fqdn = vm.getVmFQDN().trim(); + if ("localhost".equalsIgnoreCase(fqdn) || "localhost.localdomain".equalsIgnoreCase(fqdn)) { + vm.setVmFQDN(null); + } + else { + vm.setVmFQDN(fqdn); + } + } + vm.setVmIp(AssignStringValue(xmlRpcStruct, VdsProperties.VM_IP)); if (vm.getVmIp() != null) { if (vm.getVmIp().startsWith("127.0.")) { diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java index c6da040..e388ab4 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java @@ -175,6 +175,7 @@ // vm configuration (i.e. VmDynamic) public static final String guest_cur_user_name = "username"; public static final String VM_IP = "guestIPs"; + public static final String VM_FQDN = "guestFQDN"; public static final String vm_usage_mem_percent = "memUsage"; public static final String vm_host = "guestName"; public static final String app_list = "appsList"; diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java index e8472b3..9db785a 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java @@ -1563,4 +1563,7 @@ @DefaultStringValue("Network") String networkProfilePopup(); + + @DefaultStringValue("FQDN") + String fqdn(); } diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmGeneralModelForm.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmGeneralModelForm.java index ce76af8..ffedc55 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmGeneralModelForm.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmGeneralModelForm.java @@ -35,6 +35,7 @@ TextBoxLabel domain = new TextBoxLabel(); TextBoxLabel compatibilityVersion = new TextBoxLabel(); TextBoxLabel vmId = new TextBoxLabel(); + TextBoxLabel fqdn = new TextBoxLabel(); BooleanLabel isHighlyAvailable; @@ -44,7 +45,7 @@ private final Driver driver = GWT.create(Driver.class); public VmGeneralModelForm(ModelProvider<VmGeneralModel> modelProvider, CommonApplicationConstants constants) { - super(modelProvider, 3, 7); + super(modelProvider, 3, 8); isHighlyAvailable = new BooleanLabel(constants.yes(), constants.no()); driver.initialize(this); @@ -88,6 +89,14 @@ } }); + formBuilder.addFormItem(new FormItem(constants.fqdn(), fqdn, 7, 2) { + @Override + public boolean getIsAvailable() { + String fqdn = getModel().getFqdn(); + return !(fqdn == null || fqdn.isEmpty()); + } + }); + // Removed because VDSM and guest agent don't support returning of the time zone within the guest. // TODO: Uncomment again once this will be implemented. // diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java index a34d467..669bce3 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java @@ -197,6 +197,7 @@ vm.setId(instance.getId()); vm.setVmHost(instance.getVmHost()); vm.setVmIp(instance.getVmIp()); + vm.setVmFQDN(instance.getVmFQDN()); vm.setLastStartTime(instance.getLastStartTime()); vm.setVmMemSizeMb(instance.getVmMemSizeMb()); vm.setName(instance.getName()); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RdpConsoleModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RdpConsoleModel.java index e53fcac..216e792 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RdpConsoleModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RdpConsoleModel.java @@ -2,6 +2,7 @@ import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.queries.ConfigurationValues; +import org.ovirt.engine.core.compat.StringHelper; import org.ovirt.engine.ui.uicommonweb.ConsoleUtils; import org.ovirt.engine.ui.uicommonweb.TypeResolver; import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; @@ -14,6 +15,7 @@ private IRdp privaterdp; private ClientConsoleMode clientConsoleMode; + private boolean useFQDNIfAvailable; private final ConsoleUtils consoleUtils; @@ -43,6 +45,14 @@ } } + private void setUseFqdnIfAvailable(boolean value) { + useFQDNIfAvailable = value; + } + + private boolean getUseFqdnIfAvailable() { + return useFQDNIfAvailable; + } + private void setrdp(IRdp value) { privaterdp = value; } @@ -52,6 +62,7 @@ this.consoleUtils = (ConsoleUtils) TypeResolver.getInstance().resolve(ConsoleUtils.class); setRdpImplementation( ClientConsoleMode.valueOf((String) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.ClientModeRdpDefault))); + setUseFqdnIfAvailable((Boolean) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.UseFqdnForRdpIfAvailable)); } @Override @@ -59,7 +70,21 @@ if (getEntity() != null) { getLogger().debug("Connecting to RDP console..."); //$NON-NLS-1$ - getrdp().setAddress(getEntity().getVmHost().split("[ ]", -1)[0]); //$NON-NLS-1$ + boolean haveFqdn = false; + if (getUseFqdnIfAvailable()) { + getLogger().debug("RDP connection is using FQDN if available"); //$NON-NLS-1$ + if (!StringHelper.isNullOrEmpty(getEntity().getVmFQDN())) { + getLogger().debug("RDP connection is using FQDN because it is available"); //$NON-NLS-1$ + haveFqdn = true; + getrdp().setAddress(getEntity().getVmFQDN()); + } + } + + if (!haveFqdn) { + getLogger().debug("RDP connection is not using FQDN"); //$NON-NLS-1$ + getrdp().setAddress(getEntity().getVmHost().split("[ ]", -1)[0]); //$NON-NLS-1$ + } + getrdp().setGuestID(getEntity().getId().toString()); // Try to connect. diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmGeneralModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmGeneralModel.java index e2b7415..d41ed81 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmGeneralModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmGeneralModel.java @@ -484,6 +484,22 @@ } } + private String fqdn; + + public String getFqdn() + { + return fqdn; + } + + public void setFqdn(String value) + { + if (!StringHelper.stringsEqual(fqdn, value)) + { + fqdn = value; + onPropertyChanged(new PropertyChangedEventArgs("FQDN")); //$NON-NLS-1$ + } + } + private String compatibilityVersion; public String getCompatibilityVersion() @@ -580,6 +596,7 @@ vm.getVdsGroupCompatibilityVersion().toString() : ""); //$NON-NLS-1$ setVmId(vm.getId().toString()); + setFqdn(vm.getVmFQDN()); setHasAlert(vm.getVmPauseStatus() != VmPauseStatus.NONE && vm.getVmPauseStatus() != VmPauseStatus.NOERR); if (getHasAlert()) diff --git a/packaging/dbscripts/create_dwh_views.sql b/packaging/dbscripts/create_dwh_views.sql index 0a44c12..af4fb8a 100644 --- a/packaging/dbscripts/create_dwh_views.sql +++ b/packaging/dbscripts/create_dwh_views.sql @@ -269,6 +269,7 @@ cast(c.cpu_user as smallint) as user_cpu_usage_percent, c.disks_usage, b.vm_ip, + b.vm_fqdn, b.client_ip as vm_client_ip, b.console_cur_user_name as current_user_name, CASE diff --git a/packaging/dbscripts/create_views.sql b/packaging/dbscripts/create_views.sql index ddc1331..e0f2b69 100644 --- a/packaging/dbscripts/create_views.sql +++ b/packaging/dbscripts/create_views.sql @@ -565,7 +565,7 @@ vm_static.default_display_type as default_display_type, vm_static.priority as priority,vm_static.iso_path as iso_path, vm_static.origin as origin, vds_groups.compatibility_version as vds_group_compatibility_version, vm_static.initrd_url as initrd_url, vm_static.kernel_url as kernel_url, vm_static.kernel_params as kernel_params, vm_dynamic.pause_status as pause_status, vm_dynamic.exit_message as exit_message, vm_dynamic.exit_status as exit_status,vm_static.migration_support as migration_support,vm_static.predefined_properties as predefined_properties,vm_static.userdefined_properties as userdefined_properties,vm_static.min_allocated_mem as min_allocated_mem, vm_dynamic.hash as hash, vm_static.cpu_pinning as cpu_pinning, vm_static.db_generation as db_generation, vm_static.host_cpu_flags as host_cpu_flags, vm_static.tunnel_migration as tunnel_migration, vm_static.vnc_keyboard_layout as vnc_keyboard_layout, vm_static.is_run_and_pause as is_run_and_pause, vm_static.created_by_user_id as created_by_user_id, - vm_dynamic.last_watchdog_event as last_watchdog_event, vm_dynamic.last_watchdog_action as last_watchdog_action, vm_dynamic.is_run_once as is_run_once + vm_dynamic.last_watchdog_event as last_watchdog_event, vm_dynamic.last_watchdog_action as last_watchdog_action, vm_dynamic.is_run_once as is_run_once, vm_dynamic.vm_fqdn as vm_fqdn FROM vm_static INNER JOIN vm_dynamic ON vm_static.vm_guid = vm_dynamic.vm_guid INNER JOIN vm_static AS vm_templates ON vm_static.vmt_guid = vm_templates.vm_guid INNER JOIN @@ -602,7 +602,7 @@ vms.vds_group_compatibility_version, vms.initrd_url, vms.kernel_url, vms.kernel_params, vms.pause_status, vms.exit_status, vms.exit_message, vms.min_allocated_mem, storage_domain_static.id AS storage_id, vms.quota_id as quota_id, vms.quota_name as quota_name, vms.tunnel_migration as tunnel_migration, - vms.vnc_keyboard_layout as vnc_keyboard_layout, vms.is_run_and_pause as is_run_and_pause, vms.created_by_user_id as created_by_user_id + vms.vnc_keyboard_layout as vnc_keyboard_layout, vms.is_run_and_pause as is_run_and_pause, vms.created_by_user_id as created_by_user_id, vms.vm_fqdn FROM vms LEFT OUTER JOIN tags_vm_map_view ON vms.vm_guid = tags_vm_map_view.vm_id LEFT OUTER JOIN vm_device ON vm_device.vm_id = vms.vm_guid LEFT OUTER JOIN diff --git a/packaging/dbscripts/upgrade/03_03_0920_add_fqdn_to_vm_dynamic.sql b/packaging/dbscripts/upgrade/03_03_0920_add_fqdn_to_vm_dynamic.sql new file mode 100644 index 0000000..5047a5d --- /dev/null +++ b/packaging/dbscripts/upgrade/03_03_0920_add_fqdn_to_vm_dynamic.sql @@ -0,0 +1 @@ +select fn_db_add_column('vm_dynamic', 'vm_fqdn', 'TEXT DEFAULT '''''); diff --git a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql index a02d727..5c9d5a1 100644 --- a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql +++ b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql @@ -561,6 +561,8 @@ select fn_db_add_config_value('ClientModeSpiceDefault','Auto','general'); -- Rdp client mode default settings (Auto, Native, Plugin) select fn_db_add_config_value('ClientModeRdpDefault','Auto','general'); +-- Rdp client - Use FQDN reported by guest agent if available over IP and or generated hostname (VM Name + Domain) +select fn_db_add_config_value('UseFqdnForRdpIfAvailable','true','general'); -- Websocket proxy configuration (Off, Engine:port, Host:port or specific ip/hostname:port of websockets proxy) select fn_db_add_config_value('WebSocketProxy','Off','general'); -- Websocket ticket validity in seconds diff --git a/packaging/dbscripts/vms_sp.sql b/packaging/dbscripts/vms_sp.sql index c97f60e..7f35515 100644 --- a/packaging/dbscripts/vms_sp.sql +++ b/packaging/dbscripts/vms_sp.sql @@ -220,6 +220,7 @@ v_vm_guid UUID, v_vm_host VARCHAR(255) , v_vm_ip VARCHAR(255) , + v_vm_fqdn VARCHAR(255) , v_last_start_time TIMESTAMP WITH TIME ZONE , v_vm_pid INTEGER , v_display INTEGER , @@ -245,8 +246,8 @@ RETURNS VOID AS $procedure$ BEGIN -INSERT INTO vm_dynamic(app_list, guest_cur_user_name, console_cur_user_name, guest_last_login_time, guest_last_logout_time, console_user_id, guest_os, migrating_to_vds, RUN_ON_VDS, status, vm_guid, vm_host, vm_ip, last_start_time, vm_pid, display, acpi_enable, session, display_ip, display_type, kvm_enable, boot_sequence, display_secure_port, utc_diff, last_vds_run_on, client_ip, guest_requested_memory, hibernation_vol_handle,exit_status,pause_status,exit_message, guest_agent_nics_hash, last_watchdog_event, last_watchdog_action, is_run_once) - VALUES(v_app_list, v_guest_cur_user_name, v_console_cur_user_name, v_guest_last_login_time, v_guest_last_logout_time, v_console_user_id, v_guest_os, v_migrating_to_vds, v_run_on_vds, v_status, v_vm_guid, v_vm_host, v_vm_ip, v_last_start_time, v_vm_pid, v_display, v_acpi_enable, v_session, v_display_ip, v_display_type, v_kvm_enable, v_boot_sequence, v_display_secure_port, v_utc_diff, v_last_vds_run_on, v_client_ip, v_guest_requested_memory, v_hibernation_vol_handle, v_exit_status, v_pause_status, v_exit_message, v_guest_agent_nics_hash, v_last_watchdog_event, v_last_watchdog_action, v_is_run_once); +INSERT INTO vm_dynamic(app_list, guest_cur_user_name, console_cur_user_name, guest_last_login_time, guest_last_logout_time, console_user_id, guest_os, migrating_to_vds, RUN_ON_VDS, status, vm_guid, vm_host, vm_ip, last_start_time, vm_pid, display, acpi_enable, session, display_ip, display_type, kvm_enable, boot_sequence, display_secure_port, utc_diff, last_vds_run_on, client_ip, guest_requested_memory, hibernation_vol_handle,exit_status,pause_status,exit_message, guest_agent_nics_hash, last_watchdog_event, last_watchdog_action, is_run_once, vm_fqdn) + VALUES(v_app_list, v_guest_cur_user_name, v_console_cur_user_name, v_guest_last_login_time, v_guest_last_logout_time, v_console_user_id, v_guest_os, v_migrating_to_vds, v_run_on_vds, v_status, v_vm_guid, v_vm_host, v_vm_ip, v_last_start_time, v_vm_pid, v_display, v_acpi_enable, v_session, v_display_ip, v_display_type, v_kvm_enable, v_boot_sequence, v_display_secure_port, v_utc_diff, v_last_vds_run_on, v_client_ip, v_guest_requested_memory, v_hibernation_vol_handle, v_exit_status, v_pause_status, v_exit_message, v_guest_agent_nics_hash, v_last_watchdog_event, v_last_watchdog_action, v_is_run_once, v_vm_fqdn); END; $procedure$ LANGUAGE plpgsql; @@ -265,6 +266,7 @@ v_vm_guid UUID, v_vm_host VARCHAR(255) , v_vm_ip VARCHAR(255) , + v_vm_fqdn VARCHAR(255) , v_last_start_time TIMESTAMP WITH TIME ZONE , v_vm_pid INTEGER , v_display INTEGER , @@ -300,7 +302,7 @@ guest_last_logout_time = v_guest_last_logout_time, console_user_id = v_console_user_id, guest_os = v_guest_os,migrating_to_vds = v_migrating_to_vds,RUN_ON_VDS = v_run_on_vds, - status = v_status,vm_host = v_vm_host,vm_ip = v_vm_ip, + status = v_status,vm_host = v_vm_host,vm_ip = v_vm_ip,vm_fqdn = v_vm_fqdn, last_start_time = v_last_start_time, vm_pid = v_vm_pid,display = v_display,acpi_enable = v_acpi_enable, session = v_session,display_ip = v_display_ip, -- To view, visit http://gerrit.ovirt.org/19748 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1e7f8e46c6a71ccbfe9af9bf85271d7294b03526 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.3 Gerrit-Owner: Vinzenz Feenstra <vfeen...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches