Oved Ourfali has uploaded a new change for review. Change subject: core+setup: adding the public glance repository ......................................................................
core+setup: adding the public glance repository This patch adds a stored procedure to add the public glance repository, and in addition a setup plugin that uses it, if needed. Change-Id: I415dd452f644e1adf150713f3dfdc094ae9af160 Signed-off-by: Oved Ourfali <[email protected]> (cherry picked from commit 146b9c89e8cc4ddfd05fb038cdaf6d6c126e2845) --- M packaging/dbscripts/inst_sp.sql M packaging/setup/ovirt_engine_setup/constants.py M packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/__init__.py A packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/public_glance_repository.py 4 files changed, 113 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/88/24988/1 diff --git a/packaging/dbscripts/inst_sp.sql b/packaging/dbscripts/inst_sp.sql index a2ad551e..3badb02 100644 --- a/packaging/dbscripts/inst_sp.sql +++ b/packaging/dbscripts/inst_sp.sql @@ -48,3 +48,34 @@ where vds_group_id = v_cluster_id; END; $procedure$ LANGUAGE plpgsql; + +-- Adds a new glance provider, according to the specified arguments +CREATE OR REPLACE FUNCTION inst_add_glance_provider( + v_provider_id UUID, + v_provider_name VARCHAR(128), + v_provider_description VARCHAR(4000), + v_provider_url VARCHAR(512), + v_storage_domain_id UUID +) +RETURNS VOID +AS $procedure$ +BEGIN + -- Adding the Glance provider + insert into providers(id, name, description, url, provider_type, auth_required) + select v_provider_id, v_provider_name, v_provider_description, v_provider_url, 'OPENSTACK_IMAGE', false + where not exists (select id from providers where id = v_provider_id); + + -- Adding a proper storage domain static entry + insert into storage_domain_static(id, storage, storage_name, storage_domain_type, storage_type, storage_domain_format_type, recoverable) + select v_storage_domain_id, v_provider_id, v_provider_name, 4, 8, 0, true + where not exists (select id from storage_domain_static where id = v_storage_domain_id); + + -- Adding a proper storage domain dynamic entry + insert into storage_domain_dynamic(id, available_disk_size, used_disk_size) + select v_storage_domain_id, 0, 0 + where not exists (select id from storage_domain_dynamic where id = v_storage_domain_id); + +END; $procedure$ +LANGUAGE plpgsql; + + diff --git a/packaging/setup/ovirt_engine_setup/constants.py b/packaging/setup/ovirt_engine_setup/constants.py index b2dc3f8..9803211 100644 --- a/packaging/setup/ovirt_engine_setup/constants.py +++ b/packaging/setup/ovirt_engine_setup/constants.py @@ -856,6 +856,7 @@ JBOSS_DIRECT_HTTPS_PORT = 'OVESETUP_CONFIG/jbossDirectHttpsPort' WEBSOCKET_PROXY_PORT = 'OVESETUP_CONFIG/websocketProxyPort' JBOSS_DEBUG_ADDRESS = 'OVESETUP_CONFIG/jbossDebugAddress' + ADD_OVIRT_GLANCE_REPOSITORY = 'OVESETUP_CONFIG/addOvirtGlanceRepository' MAC_RANGE_POOL = 'OVESETUP_CONFIG/macRangePool' diff --git a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/__init__.py b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/__init__.py index 44b6e43..0860452 100644 --- a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/__init__.py +++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/__init__.py @@ -33,6 +33,7 @@ from . import tools from . import iso_domain from . import macrange +from . import public_glance_repository @util.export @@ -48,6 +49,7 @@ tools.Plugin(context=context) iso_domain.Plugin(context=context) macrange.Plugin(context=context) + public_glance_repository.Plugin(context=context) # vim: expandtab tabstop=4 shiftwidth=4 diff --git a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/public_glance_repository.py b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/public_glance_repository.py new file mode 100644 index 0000000..a9c56f6 --- /dev/null +++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/public_glance_repository.py @@ -0,0 +1,79 @@ +# +# ovirt-engine-setup -- ovirt engine setup +# Copyright (C) 2014 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +"""Plugin to add the oVirt public Glance repository.""" + + +import gettext +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-engine-setup') + + +from otopi import util +from otopi import plugin + + +from ovirt_engine_setup import constants as osetupcons + + [email protected] +class Plugin(plugin.PluginBase): + """Plugin to add the oVirt public Glance repository.""" + + def __init__(self, context): + super(Plugin, self).__init__(context=context) + + @plugin.event( + stage=plugin.Stages.STAGE_INIT, + ) + def _init(self): + self.environment.setdefault( + osetupcons.ConfigEnv.ADD_OVIRT_GLANCE_REPOSITORY, + True, + ) + + @plugin.event( + stage=plugin.Stages.STAGE_MISC, + after=( + osetupcons.Stages.DB_CONNECTION_AVAILABLE, + ), + condition=lambda self: self.environment[ + osetupcons.ConfigEnv.ADD_OVIRT_GLANCE_REPOSITORY + ], + ) + def _misc(self): + self.environment[osetupcons.DBEnv.STATEMENT].execute( + statement=""" + select inst_add_glance_provider( + %(provider_id)s, + %(provider_name)s, + %(provider_description)s, + %(provider_url)s, + %(storage_domain_id)s + ) + """, + args=dict( + provider_id="ceab03af-7220-4d42-8f5c-9b557f5d29af", + provider_name="ovirt-image-repository", + provider_description="Public Glance repository for oVirt", + provider_url="http://glance.ovirt.org:9292", + storage_domain_id="072fbaa1-08f3-4a40-9f34-a5ca22dd1d74" + ), + ) + + +# vim: expandtab tabstop=4 shiftwidth=4 -- To view, visit http://gerrit.ovirt.org/24988 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I415dd452f644e1adf150713f3dfdc094ae9af160 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.4 Gerrit-Owner: Oved Ourfali <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
