Eli Mesika has uploaded a new change for review. Change subject: core: add keystone url field to external providers ......................................................................
core: add keystone url field to external providers [RFE] Add keystone URL for OpenStack external providers that require authentication. Currently, all OpenStack external providers like Neutron and Glance are using the same Keystone authentication URL stored in the KeystoneAuthUrl configuration value. The requirement is to add a URL field per such provider for setting that URL and enable different OpenStack providers using different Keystone authentication URLs Change-Id: Ib1aa930cd8dec576a6408402dd883ab5162e1f9d Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1157999 Signed-off-by: Eli Mesika <emes...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/network/openstack/OpenstackNetworkProviderProxy.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/storage/OpenStackImageProviderProxy.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Provider.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/provider/ProviderDaoDbFacadeImpl.java M backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/provider/ProviderDaoTest.java M backend/manager/modules/dal/src/test/resources/fixtures.xml M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml M packaging/dbscripts/providers_sp.sql A packaging/dbscripts/upgrade/03_06_0520_add_keystone_url.sql M packaging/etc/engine-config/engine-config.properties 15 files changed, 70 insertions(+), 25 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/80/34880/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/network/openstack/OpenstackNetworkProviderProxy.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/network/openstack/OpenstackNetworkProviderProxy.java index 1bee5b3..8f097ad 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/network/openstack/OpenstackNetworkProviderProxy.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/network/openstack/OpenstackNetworkProviderProxy.java @@ -22,8 +22,6 @@ import org.ovirt.engine.core.common.businessentities.network.ProviderNetwork; import org.ovirt.engine.core.common.businessentities.network.VmNic; import org.ovirt.engine.core.common.businessentities.network.VnicProfile; -import org.ovirt.engine.core.common.config.Config; -import org.ovirt.engine.core.common.config.ConfigValues; import org.ovirt.engine.core.common.errors.VdcBLLException; import org.ovirt.engine.core.common.errors.VdcBllErrors; import org.ovirt.engine.core.utils.NetworkUtils; @@ -68,7 +66,7 @@ if (provider.isRequiringAuthentication()) { final String tenantName = provider.getAdditionalProperties().getTenantName(); final KeystoneTokenProvider keystoneTokenProvider = - new KeystoneTokenProvider(Config.<String> getValue(ConfigValues.KeystoneAuthUrl), + new KeystoneTokenProvider(provider.getKeystoneURL(), provider.getUsername(), provider.getPassword()); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/storage/OpenStackImageProviderProxy.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/storage/OpenStackImageProviderProxy.java index fcc0548..b9ed4e5 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/storage/OpenStackImageProviderProxy.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/storage/OpenStackImageProviderProxy.java @@ -31,8 +31,6 @@ import org.ovirt.engine.core.common.businessentities.StorageFormatType; import org.ovirt.engine.core.common.businessentities.StorageType; import org.ovirt.engine.core.common.businessentities.VolumeFormat; -import org.ovirt.engine.core.common.config.Config; -import org.ovirt.engine.core.common.config.ConfigValues; import org.ovirt.engine.core.common.errors.VdcBLLException; import org.ovirt.engine.core.common.errors.VdcBllErrors; import org.ovirt.engine.core.compat.Guid; @@ -170,7 +168,7 @@ private OpenStackTokenProvider getTokenProvider() { if (tokenProvider == null && getProvider().isRequiringAuthentication()) { String tenantName = provider.getAdditionalProperties().getTenantName(); - tokenProvider = new KeystoneTokenProvider(Config.<String> getValue(ConfigValues.KeystoneAuthUrl), + tokenProvider = new KeystoneTokenProvider(getProvider().getKeystoneURL(), getProvider().getUsername(), getProvider().getPassword()).getProviderByTenant(tenantName); } return tokenProvider; diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Provider.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Provider.java index 3922b79..875ad45 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Provider.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Provider.java @@ -51,6 +51,8 @@ @Valid private P additionalProperties; + private String keystoneURL; + @Override public String getName() { return name; @@ -139,6 +141,14 @@ return getId(); } + public String getKeystoneURL() { + return keystoneURL; + } + + public void setKeystoneURL(String keystoneURL) { + this.keystoneURL = keystoneURL; + } + @Override public int hashCode() { final int prime = 31; @@ -153,6 +163,7 @@ result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode()); result = prime * result + ((getCustomProperties() == null) ? 0 : getCustomProperties().hashCode()); result = prime * result + ((getAdditionalProperties() == null) ? 0 : getAdditionalProperties().hashCode()); + result = prime * result + ((getKeystoneURL() == null) ? 0 : getKeystoneURL().hashCode()); return result; } @@ -230,6 +241,13 @@ } else if (!getAdditionalProperties().equals(other.getAdditionalProperties())) { return false; } + if (getKeystoneURL() == null) { + if (other.getKeystoneURL() != null) { + return false; + } + } else if (!getKeystoneURL().equals(other.getKeystoneURL())) { + return false; + } return true; } @@ -256,6 +274,8 @@ .append(getCustomProperties()) .append(", additionalProperties=") .append(getAdditionalProperties()) + .append(", keystoneURL=") + .append(getKeystoneURL()) .append("]"); return builder.toString(); } 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 d938b9b..fe80441 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 @@ -1464,10 +1464,6 @@ @TypeConverterAttribute(String.class) @DefaultValueAttribute("Auto") - KeystoneAuthUrl, - - @TypeConverterAttribute(String.class) - @DefaultValueAttribute("Auto") ClientModeSpiceDefault, @TypeConverterAttribute(String.class) 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 82086ea..1296b9d 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 @@ -133,7 +133,6 @@ IscsiMultipathingSupported, BootMenuSupported(ConfigAuthType.User), MixedDomainTypesInDataCenter, - KeystoneAuthUrl, VirtIoRngDeviceSupported(ConfigAuthType.User), ClusterRequiredRngSourcesDefault(ConfigAuthType.User), SpiceFileTransferToggleSupported(ConfigAuthType.User), diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/provider/ProviderDaoDbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/provider/ProviderDaoDbFacadeImpl.java index 1e16224..9750c1b 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/provider/ProviderDaoDbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/provider/ProviderDaoDbFacadeImpl.java @@ -68,7 +68,8 @@ .addValue("auth_username", entity.getUsername()) .addValue("auth_password", DbFacadeUtils.encryptPassword(entity.getPassword())) .addValue("custom_properties", - SerializationFactory.getSerializer().serialize(entity.getCustomProperties())); + SerializationFactory.getSerializer().serialize(entity.getCustomProperties())) + .addValue("keystone_url", entity.getKeystoneURL()); } @Override @@ -110,6 +111,7 @@ entity.setCustomProperties(SerializationFactory.getDeserializer() .deserialize(rs.getString("custom_properties"), HashMap.class)); entity.setAdditionalProperties(mapAdditionalProperties(rs, entity)); + entity.setKeystoneURL(rs.getString("keystone_url")); return entity; } diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/provider/ProviderDaoTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/provider/ProviderDaoTest.java index 2bcdeb8..09ac09c 100644 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/provider/ProviderDaoTest.java +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/provider/ProviderDaoTest.java @@ -27,6 +27,7 @@ additionalProperties.setTenantName("10ant"); additionalProperties.setPluginType(OpenstackNetworkPluginType.LINUX_BRIDGE.name()); provider.setAdditionalProperties(additionalProperties); + provider.setKeystoneURL("http://keystone-server:35357/v2.0/"); return provider; } diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml b/backend/manager/modules/dal/src/test/resources/fixtures.xml index c83d916..804dc9a 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -1038,6 +1038,7 @@ <column>tenant_name</column> <column>plugin_type</column> <column>agent_configuration</column> + <column>keystone_url</column> <row> <value>1115c1c6-cb15-4832-b2a4-023770607111</value> <value>provider</value> @@ -1050,6 +1051,7 @@ <value>bubu</value> <value>LINUX_BRIDGE</value> <value>{"messagingConfiguration" : {"brokerTpe" : "QPID", "address" : "test", "port" : 5672, "username" : null, "password" : null}, "networkMappings" : ""}</value> + <value>http://keystone-server:35357/v2.0/</value> </row> </table> diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.java index ad8bd9d..442a71e 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.java @@ -13,7 +13,6 @@ import org.ovirt.engine.core.common.businessentities.ProviderType; import org.ovirt.engine.core.common.businessentities.TenantProviderProperties; import org.ovirt.engine.core.common.errors.VdcBllErrors; -import org.ovirt.engine.core.common.queries.ConfigurationValues; import org.ovirt.engine.core.compat.StringHelper; import org.ovirt.engine.ui.frontend.AsyncQuery; import org.ovirt.engine.ui.frontend.Frontend; @@ -48,9 +47,6 @@ private static final String CMD_CANCEL_IMPORT = "CancelImport"; //$NON-NLS-1$ private static final String EMPTY_ERROR_MESSAGE = ""; //$NON-NLS-1$ - private final String keystoneUrl = - (String) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigurationValues.KeystoneAuthUrl); - protected final SearchableListModel sourceListModel; private final VdcActionType action; protected final Provider provider; @@ -65,6 +61,7 @@ private ListModel<ProviderType> type; private UICommand testCommand; private EntityModel<String> testResult = new EntityModel<String>(); + private EntityModel<String> keystoneURL = new EntityModel<String>(); private NeutronAgentModel neutronAgentModel = new NeutronAgentModel(); @@ -137,6 +134,10 @@ return type == ProviderType.OPENSTACK_NETWORK || type == ProviderType.OPENSTACK_IMAGE; } + public EntityModel<String> getKeystoneURL() { + return keystoneURL; + } + private boolean isTypeRequiresAuthentication() { return false; } @@ -168,6 +169,7 @@ getUsername().setIsChangable(authenticationRequired); getPassword().setIsChangable(authenticationRequired); getTenantName().setIsChangable(authenticationRequired); + getKeystoneURL().setIsChangable(authenticationRequired); } }); setType(new ListModel<ProviderType>() { @@ -237,13 +239,16 @@ getUsername().validateEntity(new IValidation[] { new NotEmptyValidation() }); getPassword().validateEntity(new IValidation[] { new NotEmptyValidation() }); getTenantName().validateEntity(new IValidation[] { new NotEmptyValidation()} ); + getKeystoneURL().validateEntity(new IValidation[] { new NotEmptyValidation(), + new UrlValidation(Uri.SCHEME_HTTP, Uri.SCHEME_HTTPS) }); getUrl().validateEntity(new IValidation[] { new NotEmptyValidation(), new UrlValidation(Uri.SCHEME_HTTP, Uri.SCHEME_HTTPS) }); return getUrl().getIsValid() && getUsername().getIsValid() && getPassword().getIsValid() && - getTenantName().getIsValid(); + getTenantName().getIsValid() && + getKeystoneURL().getIsValid(); } private void cancel() { @@ -275,6 +280,7 @@ } properties.setTenantName(getTenantName().getEntity()); } + provider.setKeystoneURL(getKeystoneURL().getEntity()); } else { provider.setUsername(null); provider.setPassword(null); @@ -284,6 +290,7 @@ properties.setTenantName(null); } } + provider.setKeystoneURL(null); } } @@ -434,7 +441,7 @@ if (result == null || !result.getSucceeded()) { if (result != null) { errorMessage = Frontend.getInstance().translateVdcFault(result.getFault()); - } else if ((Boolean) requiresAuthentication.getEntity() && StringHelper.isNullOrEmpty(keystoneUrl)) { + } else if ((Boolean) requiresAuthentication.getEntity() && StringHelper.isNullOrEmpty(getKeystoneURL().toString())) { errorMessage = ConstantsManager.getInstance().getConstants().noAuthUrl(); } else { errorMessage = ConstantsManager.getInstance().getConstants().testFailedUnknownErrorMsg(); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java index 920280e..b07108b 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java @@ -3289,6 +3289,9 @@ @DefaultStringValue("Username") String usernameProvider(); + @DefaultStringValue("Keystone URL") + String keystoneURLProvider(); + @DefaultStringValue("Password") String passwordProvider(); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.java index 8a7c4f1..cdd1651 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.java @@ -99,6 +99,11 @@ StringEntityModelTextBoxEditor tenantNameEditor; @UiField + @Path(value = "keystoneURL.entity") + @WithElementId + StringEntityModelTextBoxEditor keystoneURLEditor; + + @UiField @Path(value = "pluginType.selectedItem") @WithElementId ListModelSuggestBoxEditor pluginTypeEditor; @@ -153,6 +158,7 @@ passwordEditor.setLabel(constants.passwordProvider()); tenantNameEditor.setLabel(constants.tenantName()); pluginTypeEditor.setLabel(constants.pluginType()); + keystoneURLEditor.setLabel(constants.keystoneURLProvider()); // Agent configuration tab agentConfigurationTab.setLabel(constants.providerPopupAgentConfigurationTabLabel()); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml index e2966ef..d98e21d 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml @@ -70,6 +70,7 @@ <ge:EntityModelCheckBoxEditor ui:field="requiresAuthenticationEditor" /> <ge:StringEntityModelTextBoxEditor ui:field="usernameEditor" addStyleNames="{style.authField}" /> <ge:StringEntityModelPasswordBoxEditor ui:field="passwordEditor" addStyleNames="{style.authField}" /> + <ge:StringEntityModelTextBoxEditor ui:field="keystoneURLEditor" addStyleNames="{style.authField}" /> <ge:StringEntityModelTextBoxEditor ui:field="tenantNameEditor" addStyleNames="{style.authField}" /> </g:FlowPanel> </g:FlowPanel> diff --git a/packaging/dbscripts/providers_sp.sql b/packaging/dbscripts/providers_sp.sql index f788c52..de5c73a 100644 --- a/packaging/dbscripts/providers_sp.sql +++ b/packaging/dbscripts/providers_sp.sql @@ -19,7 +19,8 @@ v_custom_properties TEXT, v_tenant_name VARCHAR DEFAULT NULL, v_plugin_type VARCHAR DEFAULT NULL, - v_agent_configuration TEXT DEFAULT NULL) + v_agent_configuration TEXT DEFAULT NULL, + v_keystone_url TEXT DEFAULT NULL) RETURNS VOID AS $procedure$ BEGIN @@ -35,7 +36,8 @@ custom_properties, tenant_name, plugin_type, - agent_configuration) + agent_configuration, + keystone_url) VALUES( v_id, v_name, @@ -48,7 +50,8 @@ v_custom_properties, v_tenant_name, v_plugin_type, - v_agent_configuration); + v_agent_configuration, + v_keystone_url); END; $procedure$ LANGUAGE plpgsql; @@ -68,7 +71,8 @@ v_custom_properties TEXT, v_tenant_name VARCHAR DEFAULT NULL, v_plugin_type VARCHAR DEFAULT NULL, - v_agent_configuration TEXT DEFAULT NULL) + v_agent_configuration TEXT DEFAULT NULL, + v_keystone_url TEXT DEFAULT NULL) RETURNS VOID AS $procedure$ BEGIN @@ -84,7 +88,8 @@ tenant_name = v_tenant_name, plugin_type = v_plugin_type, _update_date = NOW(), - agent_configuration = v_agent_configuration + agent_configuration = v_agent_configuration, + keystone_url = v_keystone_url WHERE id = v_id; END; $procedure$ LANGUAGE plpgsql; diff --git a/packaging/dbscripts/upgrade/03_06_0520_add_keystone_url.sql b/packaging/dbscripts/upgrade/03_06_0520_add_keystone_url.sql new file mode 100644 index 0000000..9a7229d --- /dev/null +++ b/packaging/dbscripts/upgrade/03_06_0520_add_keystone_url.sql @@ -0,0 +1,9 @@ +SELECT fn_db_add_column('providers', 'keystone_url', 'TEXT DEFAULT NULL'); + +UPDATE providers set keystone_url = (select option_value from vdc_options where option_name = 'KeystoneAuthUrl') + WHERE auth_required; + +-- this must be done here since 0000_config.sql is running in the pre-upgrade stage + +select fn_db_delete_config_value('KeystoneAuthUrl','general'); + diff --git a/packaging/etc/engine-config/engine-config.properties b/packaging/etc/engine-config/engine-config.properties index 6e94968..d3dc9d9 100644 --- a/packaging/etc/engine-config/engine-config.properties +++ b/packaging/etc/engine-config/engine-config.properties @@ -302,8 +302,6 @@ GlusterRefreshRateHooks.description="Refresh rate (in seconds) of gluster hooks from gluster servers" GlusterRefreshRateHooks.type=Integer GlusterRefreshRateHooks.validValues=30..3600 -KeystoneAuthUrl.description="OpenStack Keystone URL (e.g. http://keystone-server:35357/v2.0/)" -KeystoneAuthUrl.type=String DefaultWindowsTimeZone.description="Default time zone to be used when creating new Windows VMs" DefaultWindowsTimeZone.type=WindowsTimeZone DefaultGeneralTimeZone.description="Default time zone to be used when creating Linux and Other-OS VMs" -- To view, visit http://gerrit.ovirt.org/34880 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib1aa930cd8dec576a6408402dd883ab5162e1f9d Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eli Mesika <emes...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches