aboutsummaryrefslogtreecommitdiffstats
path: root/moonclient
diff options
context:
space:
mode:
authorRuan HE <ruan.he@orange.com>2015-09-15 14:04:45 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2015-09-15 14:04:45 +0000
commitabe028e7984be2d7f9dff7aabe461cc82a3b60c0 (patch)
treef364d75e37a15de50750588f1fc8279314af1403 /moonclient
parente067e0527af08e57548a1c15ce612e72f0df5d5b (diff)
parente89009255e779356affcfd2e82f2b6f9070f0184 (diff)
Merge "Add informations about tenant in the Moon Application."
Diffstat (limited to 'moonclient')
-rw-r--r--moonclient/moonclient/shell.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/moonclient/moonclient/shell.py b/moonclient/moonclient/shell.py
index 7303fb79..60e8e416 100644
--- a/moonclient/moonclient/shell.py
+++ b/moonclient/moonclient/shell.py
@@ -35,6 +35,8 @@ class MoonClient(App):
port = "35357"
tenant = None
_intraextension = None
+ _tenant_id = None
+ _tenant_name = None
post = {
"auth": {
"identity": {
@@ -74,19 +76,32 @@ class MoonClient(App):
self.post["auth"]["scope"]["project"]["name"] = creds["tenant_name"]
self.host = creds["auth_url"].replace("https://", "").replace("http://", "").split("/")[0].split(":")[0]
self.port = creds["auth_url"].replace("https://", "").replace("http://", "").split("/")[0].split(":")[1]
- self.tenant = creds["tenant_name"]
+ self._tenant_name = creds["tenant_name"]
+
+ @property
+ def tenant_id(self):
+ if not self._tenant_id:
+ self._tenant_id = self.get_url("/v3/projects?name={}".format(self._tenant_name),
+ authtoken=True)["projects"][0]["id"]
+ return self._tenant_id
+
+ @property
+ def tenant_name(self):
+ return self._tenant_name
@property
def intraextension(self):
if not self._intraextension:
self.log.debug("Setting intraextension")
- project_id = self.get_url("/v3/projects?name={}".format(self.tenant), authtoken=True)["projects"][0]["id"]
+ project_id = self.get_url("/v3/projects?name={}".format(self._tenant_name),
+ 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
+ self._tenant_id = project_id
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']: