From bb25f6725db07518166d94a1d871a26b3b8c34ae Mon Sep 17 00:00:00 2001 From: asteroide Date: Tue, 15 Sep 2015 11:19:53 +0200 Subject: Rebuild the intraextension attribute with the new Moon API. Change-Id: Ibcbec7b1ebc9bdc29a894312a29dd3f9e3823c3a --- moonclient/moonclient/shell.py | 24 +++++++++++++++--------- 1 file 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): -- cgit 1.2.3-korg