summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--keystone-moon/keystone/contrib/moon/core.py5
-rw-r--r--moonclient/moonclient/shell.py24
2 files changed, 20 insertions, 9 deletions
diff --git a/keystone-moon/keystone/contrib/moon/core.py b/keystone-moon/keystone/contrib/moon/core.py
index aa6db0cc..dc431a49 100644
--- a/keystone-moon/keystone/contrib/moon/core.py
+++ b/keystone-moon/keystone/contrib/moon/core.py
@@ -853,6 +853,11 @@ class IntraExtensionManager(manager.Manager):
ie_dict["name"] = filter_input(intra_extension_dict["name"])
ie_dict["model"] = filter_input(intra_extension_dict["model"])
ie_dict["genre"] = filter_input(intra_extension_dict["genre"])
+ if not ie_dict["genre"]:
+ if "admin" in ie_dict["model"] or "root" in ie_dict["model"]:
+ ie_dict["genre"] = "admin"
+ else:
+ ie_dict["genre"] = "authz"
ie_dict["description"] = filter_input(intra_extension_dict["description"])
ref = self.driver.set_intra_extension_dict(ie_dict['id'], ie_dict)
self.moonlog_api.debug("Creation of IE: {}".format(ref))
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):