From 7b520d4f36d10e9a4b408ade61f8e312c07b2dfe Mon Sep 17 00:00:00 2001 From: Andy Ning Date: Wed, 20 Jun 2018 09:01:41 -0400 Subject: [PATCH] Add image download support to DC config This is part of Distributed Cloud keystone scalability. Signed-off-by: Andy Ning Change-Id: Ia39bf0b7a53d28188bb0cf9585d0b15a0ea66539 Story: 2002842 Task: 22785 Signed-off-by: Don Penney Signed-off-by: Jack Ding --- ...-image-download-support-to-DC-config.patch | 32 ++++++++ .../centos/meta_patches/PATCH_ORDER | 1 + ...-image-download-support-to-DC-config.patch | 73 +++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 openstack/python-glance-store/centos/meta_patches/0005-Add-image-download-support-to-DC-config.patch create mode 100644 openstack/python-glance-store/centos/patches/0004-Add-image-download-support-to-DC-config.patch diff --git a/openstack/python-glance-store/centos/meta_patches/0005-Add-image-download-support-to-DC-config.patch b/openstack/python-glance-store/centos/meta_patches/0005-Add-image-download-support-to-DC-config.patch new file mode 100644 index 00000000..c648ebf2 --- /dev/null +++ b/openstack/python-glance-store/centos/meta_patches/0005-Add-image-download-support-to-DC-config.patch @@ -0,0 +1,32 @@ +From e314323f74f4b434b812baccc444a0724abe507b Mon Sep 17 00:00:00 2001 +From: Andy Ning +Date: Thu, 14 Jun 2018 16:42:20 -0400 +Subject: [PATCH 1/1] Add image download support to DC config + +--- + SPECS/python-glance-store.spec | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/SPECS/python-glance-store.spec b/SPECS/python-glance-store.spec +index 977b2bc..54442bb 100644 +--- a/SPECS/python-glance-store.spec ++++ b/SPECS/python-glance-store.spec +@@ -17,6 +17,7 @@ Source0: https://tarballs.openstack.org/%{upstream_name}/%{upstream_name} + Patch0001: 0001-Check-ceph-cluster-free-space-before-creating-image.patch + Patch0002: 0002-Add-glance-driver.patch + Patch0003: 0003-Add-glance-schedule-greenthreads.patch ++Patch0004: 0004-Add-image-download-support-to-DC-config.patch + + BuildArch: noarch + +@@ -92,6 +93,7 @@ Requires: python3-oslo-privsep >= 1.9.0 + %patch0001 -p1 + %patch0002 -p1 + %patch0003 -p1 ++%patch0004 -p1 + + %build + %py2_build +-- +2.7.4 + diff --git a/openstack/python-glance-store/centos/meta_patches/PATCH_ORDER b/openstack/python-glance-store/centos/meta_patches/PATCH_ORDER index e0858259..3e5fb3c4 100644 --- a/openstack/python-glance-store/centos/meta_patches/PATCH_ORDER +++ b/openstack/python-glance-store/centos/meta_patches/PATCH_ORDER @@ -2,3 +2,4 @@ 0002-meta-patch-Check-ceph-cluster-free-space.patch 0003-meta-patch-Glance-Driver.patch 0004-meta-Add-glance-schedulre-greenthreads.patch +0005-Add-image-download-support-to-DC-config.patch diff --git a/openstack/python-glance-store/centos/patches/0004-Add-image-download-support-to-DC-config.patch b/openstack/python-glance-store/centos/patches/0004-Add-image-download-support-to-DC-config.patch new file mode 100644 index 00000000..c03c5313 --- /dev/null +++ b/openstack/python-glance-store/centos/patches/0004-Add-image-download-support-to-DC-config.patch @@ -0,0 +1,73 @@ +From 7448d61cc5dfa9c658a739cbb2dae678971a347b Mon Sep 17 00:00:00 2001 +From: Andy Ning +Date: Thu, 14 Jun 2018 16:35:44 -0400 +Subject: [PATCH 1/1] Add image download support to DC config + +--- + glance_store/_drivers/glance.py | 36 ++++++++++++++++++++++++++++++++++-- + 1 file changed, 34 insertions(+), 2 deletions(-) + +diff --git a/glance_store/_drivers/glance.py b/glance_store/_drivers/glance.py +index 554a5a1..70f3e65 100644 +--- a/glance_store/_drivers/glance.py ++++ b/glance_store/_drivers/glance.py +@@ -34,13 +34,23 @@ import glance_store.location + from keystoneclient import exceptions as keystone_exc + from keystoneclient import service_catalog as keystone_sc + +-import keystoneauth1.loading +-import keystoneauth1.session ++import keystoneauth1.loading as loading ++import keystoneauth1.session as session + + from glanceclient import client as glance_client ++from glanceclient import Client + from cinderclient import exceptions as glance_exception + + CONF = cfg.CONF ++_registry_client = 'glance.registry.client' ++CONF.import_opt('use_user_token', _registry_client) ++CONF.import_opt('admin_user', _registry_client) ++CONF.import_opt('admin_password', _registry_client) ++CONF.import_opt('admin_tenant_name', _registry_client) ++CONF.import_opt('auth_url', _registry_client) ++CONF.import_opt('auth_strategy', _registry_client) ++CONF.import_opt('auth_region', _registry_client) ++ + LOG = logging.getLogger(__name__) + + _GLANCE_OPTS = [ +@@ -51,8 +61,30 @@ _GLANCE_OPTS = [ + default='image:glance:internalURL', + help=_("Glance catalog info")),] + ++def get_glanceclient_dc(): ++ ++ loader = loading.get_plugin_loader('password') ++ auth = loader.load_from_options( ++ auth_url=CONF.auth_url, ++ username=CONF.admin_user, ++ password=CONF.admin_password, ++ user_domain_id='default', ++ project_name=CONF.admin_tenant_name, ++ project_domain_id='default') ++ auth_session = session.Session(auth=auth) ++ c = Client('2', session=auth_session) ++ ++ return c ++ ++ + def get_glanceclient(conf, remote_region, context=None): + ++ # In DC config, need to authentication against central region ++ # keystone. ++ if not CONF.use_user_token: ++ c = get_glanceclient_dc() ++ return c ++ + glance_store = conf.glance_store + + if glance_store.cinder_endpoint_template: +-- +2.7.4 +