Yaniv Bronhaim has uploaded a new change for review. Change subject: core: add host_provider_id to vdsStatic ......................................................................
core: add host_provider_id to vdsStatic This allows to sign the provider id, which in hosts mostly foreman server id that added as external provider. With saving the ID we'll be able to gather more info about the host later on. Change-Id: Icced7dda43fee83aa904a068cff48b1fd3da4b76 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1113003 Signed-off-by: Yaniv Bronhaim <ybron...@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/RegisterVdsQuery.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsStaticDAODbFacadeImpl.java M backend/manager/modules/dal/src/test/resources/fixtures.xml M backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java M backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/serialization/json/JsonObjectSerializationEntitiesTest.java M packaging/dbscripts/create_tables.sql M packaging/dbscripts/create_views.sql M packaging/dbscripts/vds_sp.sql 12 files changed, 56 insertions(+), 23 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/59/30059/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 bc48d39..7606b4a 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 @@ -102,20 +102,10 @@ } } - TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { - @Override - public Void runInTransaction() { - AddVdsStaticToDb(); - AddVdsDynamicToDb(); - AddVdsStatisticsToDb(); - getCompensationContext().stateChanged(); - return null; - } - }); - if (getParameters().getAddProvisioned()) { HostProviderProxy proxy = ((HostProviderProxy) ProviderProxyFactory.getInstance().create(getHostProvider())); + getParameters().getvds().getStaticData().setHostProviderId(getParameters().getProviderId()); proxy.provisionHost( getParameters().getvds(), getParameters().getHostGroup(), @@ -131,6 +121,17 @@ AuditLogDirector.log(logable, AuditLogType.VDS_PROVISION); } + TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { + @Override + public Void runInTransaction() { + AddVdsStaticToDb(); + AddVdsDynamicToDb(); + AddVdsStatisticsToDb(); + getCompensationContext().stateChanged(); + return null; + } + }); + // set vds spm id if (getVdsGroup().getStoragePoolId() != null) { VdsActionParameters tempVar = new VdsActionParameters(getVdsIdRef()); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RegisterVdsQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RegisterVdsQuery.java index 17d0a02..8047bcc 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RegisterVdsQuery.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RegisterVdsQuery.java @@ -261,7 +261,7 @@ getStrippedVdsUniqueId(), getStrippedVdsUniqueId(), getParameters().getVdsPort(), - IsPending); newho + IsPending); CaptureCommandErrorsToLogger(rc, "RegisterVdsQuery::Register"); returnValue = false; @@ -285,7 +285,7 @@ getParameters().getSSHUser(), vdsGroupId, Guid.Empty, getParameters().getVdsName(), Config.<Boolean> getValue(ConfigValues.SSLEnabled), - VDSType.VDS); + VDSType.VDS, Guid.Empty); vds.setSshKeyFingerprint(getParameters().getSSHFingerprint()); log.debugFormat( diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java index e397e0b..cc3986c 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java @@ -1291,6 +1291,14 @@ mVdsStatic.setSshKeyFingerprint(sshKeyFingerprint); } + public Guid getHostProviderId() { + return mVdsStatic.getHostProviderId(); + } + + public void setHostProviderId(Guid hostProviderId) { + mVdsStatic.setHostProviderId(hostProviderId); + } + private float maxSchedulingMemory; public void calculateFreeVirtualMemory() { diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java index 200a15a..5990f27 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java @@ -169,6 +169,8 @@ @Size(max = BusinessEntitiesDefinitions.SSH_KEY_FINGERPRINT_SIZE) private String sshKeyFingerprint; + private Guid hostProviderId; + public boolean isAutoRecoverable() { return autoRecoverable; } @@ -192,10 +194,11 @@ disablePowerManagementPolicy = false; pmKdumpDetection = true; this.protocol = VdsProtocol.XML; + this.hostProviderId = Guid.Empty; } public VdsStatic(String host_name, String ip, String uniqueId, int port, int ssh_port, String ssh_username, Guid vds_group_id, Guid vds_id, - String vds_name, boolean server_SSL_enabled, VDSType vds_type) { + String vds_name, boolean server_SSL_enabled, VDSType vds_type, Guid host_provider_id) { this(); this.hostName = host_name; this.managementIp = ip; @@ -212,6 +215,7 @@ this.name = vds_name; this.serverSslEnabled = server_SSL_enabled; this.setVdsType(vds_type); + this.hostProviderId = host_provider_id; } public boolean isServerSslEnabled() { @@ -510,6 +514,10 @@ this.consoleAddress = consoleAddress; } + public void setHostProviderId (Guid hostProviderId) { this.hostProviderId = hostProviderId; } + + public Guid getHostProviderId () { return hostProviderId; } + /** * Converts a PM Options map to string * @@ -597,6 +605,7 @@ result = prime * result + ((vdsStrength == null) ? 0 : vdsStrength.hashCode()); result = prime * result + ((vdsType == null) ? 0 : vdsType.hashCode()); result = prime * result + (disablePowerManagementPolicy ? 0 : 1); + result = prime * result + ((hostProviderId == null) ? 0 : hostProviderId.hashCode()); return result; } @@ -644,6 +653,7 @@ && ObjectUtils.objectsEqual(vdsStrength, other.vdsStrength) && vdsType == other.vdsType && ObjectUtils.objectsEqual(sshKeyFingerprint, other.sshKeyFingerprint)) - && disablePowerManagementPolicy == other.disablePowerManagementPolicy; + && disablePowerManagementPolicy == other.disablePowerManagementPolicy + && ObjectUtils.objectsEqual(hostProviderId, other.hostProviderId); } } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java index efbbbe7..f8cf8e9 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java @@ -335,6 +335,7 @@ entity.setVdsSpmPriority(rs.getInt("vds_spm_priority")); entity.setAutoRecoverable(rs.getBoolean("recoverable")); entity.setSshKeyFingerprint(rs.getString("sshKeyFingerprint")); + entity.setHostProviderId(getGuidDefaultEmpty(rs, "host_provider_id")); entity.setHardwareManufacturer(rs.getString("hw_manufacturer")); entity.setHardwareProductName(rs.getString("hw_product_name")); entity.setHardwareVersion(rs.getString("hw_version")); diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsStaticDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsStaticDAODbFacadeImpl.java index 7b0e433..769b213 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsStaticDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsStaticDAODbFacadeImpl.java @@ -102,7 +102,8 @@ .addValue("sshKeyFingerprint", vds.getSshKeyFingerprint()) .addValue("ssh_port", vds.getSshPort()) .addValue("ssh_username", vds.getSshUsername()) - .addValue("disable_auto_pm", vds.isDisablePowerManagementPolicy()); + .addValue("disable_auto_pm", vds.isDisablePowerManagementPolicy()) + .addValue("host_provider_id", vds.getHostProviderId()); } @Override @@ -163,6 +164,7 @@ entity.setSshKeyFingerprint(rs.getString("sshKeyFingerprint")); entity.setConsoleAddress(rs.getString("console_address")); entity.setDisablePowerManagementPolicy(rs.getBoolean("disable_auto_pm")); + entity.setHostProviderId(getGuidDefaultEmpty(rs, "host_provider_id")); return entity; } diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml b/backend/manager/modules/dal/src/test/resources/fixtures.xml index 3e504d8..cfb98cc 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -1292,6 +1292,7 @@ <column>ssh_username</column> <column>pm_detect_kdump</column> <column>protocol</column> + <column>host_provider_id</column> <row> <value>afce7a39-8e8c-4819-ba9c-796d316592e6</value> <value>magenta-vdsc</value> @@ -1324,6 +1325,7 @@ <value>22</value> <value>root</value> <value>1</value> + <value>0</value> <value>0</value> </row> <row> @@ -1359,6 +1361,7 @@ <value>root</value> <value>1</value> <value>1</value> + <value>0</value> </row> <row> <value>afce7a39-8e8c-4819-ba9c-796d316592e8</value> @@ -1393,6 +1396,7 @@ <value>root</value> <value>1</value> <value>2</value> + <value>0</value> </row> <row> <value>23f6d691-5dfb-472b-86dc-9e1d2d3c18f3</value> @@ -1426,6 +1430,7 @@ <value>22</value> <value>root</value> <value>1</value> + <value>0</value> <value>0</value> </row> <row> @@ -1461,6 +1466,7 @@ <value>root</value> <value>1</value> <value>1</value> + <value>0</value> </row> </table> diff --git a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java index 475d58a..fc6af17 100644 --- a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java +++ b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java @@ -40,6 +40,7 @@ inverse.setPort(to.getPort()); inverse.setProtocol(to.getProtocol()); inverse.setSshKeyFingerprint(to.getSshKeyFingerprint()); + inverse.setHostProviderId(to.getHostProviderId()); inverse.setSshPort(to.getSshPort()); inverse.setSshUsername(to.getSshUsername()); inverse.setVdsSpmPriority(to.getVdsSpmPriority()); diff --git a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/serialization/json/JsonObjectSerializationEntitiesTest.java b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/serialization/json/JsonObjectSerializationEntitiesTest.java index 3ecbd16..bcd7a8e 100644 --- a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/serialization/json/JsonObjectSerializationEntitiesTest.java +++ b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/serialization/json/JsonObjectSerializationEntitiesTest.java @@ -55,7 +55,8 @@ Guid.newGuid(), random.nextString(10), random.nextBoolean(), - random.nextEnum(VDSType.class)); + random.nextEnum(VDSType.class), + Guid.newGuid()); vdsStatic.setPmOptions("option1=value1,option2=value2"); Object[][] data = new Object[][] { diff --git a/packaging/dbscripts/create_tables.sql b/packaging/dbscripts/create_tables.sql index e525e62..bddeec2 100644 --- a/packaging/dbscripts/create_tables.sql +++ b/packaging/dbscripts/create_tables.sql @@ -995,6 +995,7 @@ vds_spm_priority smallint DEFAULT 5, recoverable boolean DEFAULT true NOT NULL, sshkeyfingerprint character varying(128), + host_provider_id uuid, CONSTRAINT vds_static_vds_spm_priority_check CHECK (((vds_spm_priority >= (-1)) AND (vds_spm_priority <= 10))) ); diff --git a/packaging/dbscripts/create_views.sql b/packaging/dbscripts/create_views.sql index 5de1ed7..68734d6 100644 --- a/packaging/dbscripts/create_views.sql +++ b/packaging/dbscripts/create_views.sql @@ -760,7 +760,7 @@ vds_groups.virt_service as vds_group_virt_service, vds_groups.gluster_service as vds_group_gluster_service, vds_dynamic.host_os as host_os, vds_dynamic.kvm_version as kvm_version, vds_dynamic.libvirt_version as libvirt_version, vds_dynamic.spice_version as spice_version, vds_dynamic.gluster_version as gluster_version, vds_dynamic.kernel_version as kernel_version, vds_dynamic.iscsi_initiator_name as iscsi_initiator_name, vds_dynamic.transparent_hugepages_state as transparent_hugepages_state, vds_statistics.anonymous_hugepages as anonymous_hugepages, vds_dynamic.non_operational_reason as non_operational_reason, - vds_static.recoverable as recoverable, vds_static.sshKeyFingerprint as sshKeyFingerprint, vds_dynamic.hw_manufacturer as hw_manufacturer, vds_dynamic.hw_product_name as hw_product_name, vds_dynamic.hw_version as hw_version, + vds_static.recoverable as recoverable, vds_static.sshKeyFingerprint as sshKeyFingerprint, vds_static.host_provider_id as host_provider_id, vds_dynamic.hw_manufacturer as hw_manufacturer, vds_dynamic.hw_product_name as hw_product_name, vds_dynamic.hw_version as hw_version, vds_dynamic.hw_serial_number as hw_serial_number, vds_dynamic.hw_uuid as hw_uuid, vds_dynamic.hw_family as hw_family, vds_static.console_address as console_address, vds_dynamic.hbas as hbas, vds_dynamic.supported_emulated_machines as supported_emulated_machines, vds_dynamic.supported_rng_sources as supported_rng_sources, vds_static.ssh_port as ssh_port, vds_static.ssh_username as ssh_username, vds_statistics.ha_score as ha_score, vds_statistics.ha_configured as ha_configured, vds_statistics.ha_active as ha_active, vds_statistics.ha_global_maintenance as ha_global_maintenance, diff --git a/packaging/dbscripts/vds_sp.sql b/packaging/dbscripts/vds_sp.sql index 201d3e3..2cddd87 100644 --- a/packaging/dbscripts/vds_sp.sql +++ b/packaging/dbscripts/vds_sp.sql @@ -423,7 +423,8 @@ v_console_address VARCHAR(255), v_ssh_port INTEGER, v_ssh_username VARCHAR(255), - v_disable_auto_pm BOOLEAN) + v_disable_auto_pm BOOLEAN, + v_host_provider_id UUID) RETURNS VOID AS $procedure$ @@ -434,12 +435,12 @@ vds_type,vds_strength,pm_type,pm_user,pm_password,pm_port,pm_options,pm_enabled, pm_proxy_preferences, pm_secondary_ip, pm_secondary_type, pm_secondary_user, pm_secondary_password, pm_secondary_port, pm_secondary_options, pm_secondary_concurrent, pm_detect_kdump, - vds_spm_priority, sshKeyFingerprint, console_address, ssh_port, ssh_username, disable_auto_pm) + vds_spm_priority, sshKeyFingerprint, console_address, ssh_port, ssh_username, disable_auto_pm, host_provider_id) VALUES(v_vds_id,v_host_name, v_free_text_comment, v_ip, v_vds_unique_id, v_port, v_protocol, v_vds_group_id, v_vds_name, v_server_SSL_enabled, v_vds_type,v_vds_strength,v_pm_type,v_pm_user,v_pm_password,v_pm_port,v_pm_options,v_pm_enabled, v_pm_proxy_preferences, v_pm_secondary_ip, v_pm_secondary_type, v_pm_secondary_user, v_pm_secondary_password, v_pm_secondary_port, v_pm_secondary_options, v_pm_secondary_concurrent, v_pm_detect_kdump, - v_vds_spm_priority, v_sshKeyFingerprint, v_console_address, v_ssh_port, v_ssh_username, v_disable_auto_pm); + v_vds_spm_priority, v_sshKeyFingerprint, v_console_address, v_ssh_port, v_ssh_username, v_disable_auto_pm, v_host_provider_id); END; end if; RETURN; @@ -483,7 +484,8 @@ v_console_address VARCHAR(255), v_ssh_port INTEGER, v_ssh_username VARCHAR(255), - v_disable_auto_pm BOOLEAN) + v_disable_auto_pm BOOLEAN, + v_host_provider_id UUID) RETURNS VOID --The [vds_static] table doesn't have a timestamp column. Optimistic concurrency logic cannot be generated @@ -502,7 +504,7 @@ pm_secondary_user = v_pm_secondary_user, pm_secondary_password = v_pm_secondary_password, pm_secondary_port = v_pm_secondary_port, pm_secondary_options = v_pm_secondary_options, pm_secondary_concurrent = v_pm_secondary_concurrent, pm_detect_kdump = v_pm_detect_kdump, - otp_validity = v_otp_validity, vds_spm_priority = v_vds_spm_priority, sshKeyFingerprint = v_sshKeyFingerprint, + otp_validity = v_otp_validity, vds_spm_priority = v_vds_spm_priority, sshKeyFingerprint = v_sshKeyFingerprint, host_provider_id = v_host_provider_id, console_address = v_console_address, ssh_port = v_ssh_port, ssh_username = v_ssh_username, disable_auto_pm = v_disable_auto_pm WHERE vds_id = v_vds_id; END; -- To view, visit http://gerrit.ovirt.org/30059 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icced7dda43fee83aa904a068cff48b1fd3da4b76 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim <ybron...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches