From e7740fb3a7be34daad8d41edeb083af8f434bf10 Mon Sep 17 00:00:00 2001 From: Kiseok Kim Date: Fri, 25 Aug 2017 09:07:50 +0000 Subject: [PATCH] Adds 'all_tenants' search option in volumeprovider/cinder.py When user create a docker volume with a pre-created cinder volume, user can't see the docker volume if the pre-created cinder volume's tenant is diffent to the tenant Fuxi use. This patch adds 'all_tenants' option configurable. With this, user can search cinder volumes over all tenant. Change-Id: I0519f54c07e7ac84f53b580a34b3b4064183d8a6 Closes-Bug: #1656960 --- fuxi/common/config.py | 5 ++++- fuxi/volumeprovider/cinder.py | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fuxi/common/config.py b/fuxi/common/config.py index 2dc0960..0b39974 100644 --- a/fuxi/common/config.py +++ b/fuxi/common/config.py @@ -114,7 +114,10 @@ cinder_opts = [ cfg.BoolOpt('multiattach', default=False, help=_('Allow the volume to be attached to more than ' - 'one instance.')) + 'one instance.')), + cfg.BoolOpt('all_tenants', + default=True, + help=_('Allow access over all tenants by provided auth')) ] nova_group = cfg.OptGroup( diff --git a/fuxi/volumeprovider/cinder.py b/fuxi/volumeprovider/cinder.py index 27c83a7..f010d99 100644 --- a/fuxi/volumeprovider/cinder.py +++ b/fuxi/volumeprovider/cinder.py @@ -128,6 +128,8 @@ class Cinder(provider.Provider): try: search_opts = {'name': docker_volume_name, 'metadata': {consts.VOLUME_FROM: CONF.volume_from}} + if cinder_conf.all_tenants: + search_opts.update({'all_tenants': "true"}) vols = self.cinderclient.volumes.list(search_opts=search_opts) except cinder_exception.ClientException as ex: LOG.error("Error happened while getting volume list " @@ -408,6 +410,8 @@ class Cinder(provider.Provider): docker_volumes = [] try: search_opts = {'metadata': {consts.VOLUME_FROM: CONF.volume_from}} + if cinder_conf.all_tenants: + search_opts.update({'all_tenants': "true"}) for vol in self.cinderclient.volumes.list(search_opts=search_opts): docker_volume_name = vol.name if not docker_volume_name: