aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuan HE <ruan.he@orange.com>2015-09-15 09:23:50 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2015-09-15 09:23:50 +0000
commite6342366f5141ca5da775d5dc1a6b68af012caad (patch)
tree168073aed7eded01159f0a0ad19663842434361d
parentcfc2a16441ee3e031b453d56cce4b482b7b2f132 (diff)
parentbb25f6725db07518166d94a1d871a26b3b8c34ae (diff)
Merge "Rebuild the intraextension attribute with the new Moon API."
-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):