diff options
author | 2015-07-24 12:36:12 +0200 | |
---|---|---|
committer | 2015-07-24 12:36:12 +0200 | |
commit | 7348b8effd253c355e998875877a3135817d6eb0 (patch) | |
tree | 9e5b38203c99b79b984fd0d4522c8a6f462d700d /keystone-moon/keystone/contrib/moon/controllers.py | |
parent | 5637b139e1696f665263fcfdaf97f8a2b37c5bfb (diff) |
add_tenant function in controllers.py nox check if tenant name exist in Keystone
fix some bugs in enforce function and SQL functions
Change-Id: Ie760aad146d249fa6d98edbbb64dae732724e756
Diffstat (limited to 'keystone-moon/keystone/contrib/moon/controllers.py')
-rw-r--r-- | keystone-moon/keystone/contrib/moon/controllers.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/keystone-moon/keystone/contrib/moon/controllers.py b/keystone-moon/keystone/contrib/moon/controllers.py index fadc2731..047059d0 100644 --- a/keystone-moon/keystone/contrib/moon/controllers.py +++ b/keystone-moon/keystone/contrib/moon/controllers.py @@ -74,8 +74,10 @@ class Tenants(controller.V3Controller): @controller.protected() def add_tenant(self, context, **kw): user_id = self._get_user_id_from_token(context.get("token_id")) - # TODO: get tenant name from keystone + # Next line will raise an error if tenant doesn't exist + k_tenant_dict = self.resource_api.get_project_by_name(kw.get("name", None)) tenant_dict = dict() + tenant_dict['id'] = k_tenant_dict['id'] tenant_dict['name'] = kw.get("name", None) tenant_dict['description'] = kw.get("description", None) tenant_dict['intra_authz_ext_id'] = kw.get("intra_authz_ext_id", None) @@ -97,9 +99,11 @@ class Tenants(controller.V3Controller): @controller.protected() def set_tenant(self, context, **kw): user_id = self._get_user_id_from_token(context.get('token_id')) + # Next line will raise an error if tenant doesn't exist + k_tenant_dict = self.resource_api.get_project(kw.get('id', None)) tenant_id = kw.get('id', None) tenant_dict = dict() - tenant_dict['name'] = kw.get("name", None) + tenant_dict['name'] = k_tenant_dict.get("name", None) tenant_dict['description'] = kw.get("description", None) tenant_dict['intra_authz_ext_id'] = kw.get("intra_authz_ext_id", None) tenant_dict['intra_admin_ext_id'] = kw.get("intra_admin_ext_id", None) @@ -162,7 +166,7 @@ class IntraExtensions(controller.V3Controller): intra_extension_dict["aggregation_algorithm"] = kw.get("intra_extension_aggregation_algorithm", dict()) intra_extension_dict["sub_meta_rules"] = kw.get("intra_extension_sub_meta_rules", dict()) intra_extension_dict["rules"] = kw.get("intra_extension_rules", dict()) - return self.admin_api.load_intra_extension_dict(user_id, intra_extension_dict) + return self.admin_api.load_intra_extension_dict(user_id, intra_extension_dict=intra_extension_dict) @controller.protected() def get_intra_extension(self, context, **kw): |