Skip to content

Commit c335ed0

Browse files
committed
Use a list for the tenant mapping
We were using single strings to hold the tenant informatio, so it was not possible to map several tenants inside a VO. This change uses lists to that we are able to do such a mapping, using a new element in the JSON file (i.e. "tenants"). Log a warning about the old format, so that users can be aware of this.
1 parent 2565556 commit c335ed0

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

caso/extract/base.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import keystoneclient.v2_0.client
2121
from oslo_config import cfg
22+
from oslo_log import log
2223
import six
2324

2425
opts = [
@@ -45,6 +46,8 @@
4546
CONF = cfg.CONF
4647
CONF.register_opts(opts, group="extractor")
4748

49+
LOG = log.getLogger(__name__)
50+
4851
openstack_vm_statuses = {
4952
'active': 'started',
5053
'build': 'started',
@@ -81,7 +84,16 @@ def __init__(self):
8184
else:
8285
self.voms_map = {}
8386
for vo, vomap in mapping.iteritems():
84-
self.voms_map[vomap["tenant"]] = vo
87+
tenant = vomap.get("tenant", None)
88+
tenants = vomap.get("tenants", [])
89+
if tenant is not None:
90+
LOG.warning("Using deprecated 'tenant' mapping, please "
91+
"use 'tenants' instead")
92+
tenants.append(tenant)
93+
if not tenants:
94+
LOG.warning("No tenant mapping found for VO %s" % tenant)
95+
for tenant in tenants:
96+
self.voms_map[tenant] = vo
8597

8698
def _get_keystone_client(self, tenant):
8799
client = keystoneclient.v2_0.client.Client(

doc/source/configuration.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ credentials to connect to the API). Check the following:
5252
* ``password`` (default: None), password of the user.
5353
* ``endpoint`` (default: None), keystone endpoint to authenticate with.
5454
* ``mapping_file`` (default: ``/etc/caso/voms.json``). File containing the
55-
mapping from VOs to local tenants as configured in Keystone-VOMS. If
56-
you are running ``cASO`` on keystone host, it likely
57-
is ``/etc/keystone/voms.json``. Otherwise, you have to sync this file.
55+
mapping from VOs to local tenants as configured in Keystone-VOMS, in the
56+
form::
57+
{
58+
"VO": {
59+
"tenants": ["foo", "bar"],
60+
}
61+
}
5862
* ``insecure`` (default: ``False``), wether to check or not the server's
5963
certificate.
6064

etc/caso/voms.json.sample

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"VO FQAN": {
3-
"tenant": "local tenant"
3+
"tenants": ["local tenant 1", "local tenant 2"]
44
},
55
"VO NAME": {
6-
"tenant": "local tenant"
6+
"tenant": ["local tenant 3"]
77
}
88
}
99

0 commit comments

Comments
 (0)