aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasteroide <thomas.duval@orange.com>2015-09-15 11:19:53 +0200
committerasteroide <thomas.duval@orange.com>2015-09-15 11:19:53 +0200
commitbb25f6725db07518166d94a1d871a26b3b8c34ae (patch)
treec7b4bf24174e30cbb09f4baff53c941c6394e61e
parent0c488612d6e33c5c03794d9858ace0d116b78fb4 (diff)
Rebuild the intraextension attribute with the new Moon API.
Change-Id: Ibcbec7b1ebc9bdc29a894312a29dd3f9e3823c3a
-rw-r--r--moonclient/moonclient/shell.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/moonclient/moonclient/shell.py b/moonclient/moonclient/shell.py
index 10b96511..7303fb79 100644
--- a/moonclient/moonclient/shell.py
+++ b/moonclient/moonclient/shell.py
@@ -79,15 +79,21 @@ class MoonClient(App):
@property
def intraextension(self):
if not self._intraextension:
- project = self.get_url("/v3/projects?name={}".format(self.tenant), authtoken=True)["projects"][0]["id"]
- self.log.debug("project={}".format(project))
- data = self.get_url("/v3/OS-MOON/intra_extensions", authtoken=True)
- for uuid in data["intra_extensions"]:
- ie = self.get_url("/v3/OS-MOON/intra_extensions/{}".format(uuid), authtoken=True)
- if ie["intra_extensions"]["tenant"] == project:
- self._intraextension = uuid
- self.tenant = project
- break
+ self.log.debug("Setting intraextension")
+ project_id = self.get_url("/v3/projects?name={}".format(self.tenant), authtoken=True)["projects"][0]["id"]
+ self.log.debug("project_id={}".format(project_id))
+ tenants = self.get_url("/v3/OS-MOON/tenants", authtoken=True)
+ self.log.debug("tenants={}".format(tenants))
+ if project_id not in tenants:
+ self.log.info("Tenant [{}] was not added in Moon".format(project_id))
+ return
+ if tenants[project_id]['intra_authz_extension_id']:
+ self._intraextension = tenants[project_id]['intra_authz_extension_id']
+ elif tenants[project_id]['intra_admin_extension_id']:
+ self._intraextension = tenants[project_id]['intra_admin_extension_id']
+ else:
+ self._intraextension = None
+ self.log.info("No intra_extension found for tenant [{}].".format(project_id))
return self._intraextension
def get_tenant_uuid(self, tenant_name):