From cd1dee079f08afe822909ad9218a83c43378edd1 Mon Sep 17 00:00:00 2001 From: Philip Joseph Date: Tue, 11 Apr 2017 10:29:01 +0000 Subject: [PATCH] Fix role definition for projects Change-Id: I812b526426be090bfc34290074efea48ebd5accc Signed-off-by: Philip Joseph --- common/plugins/yang/rw-cloud.role.xml | 3 +- common/plugins/yang/rw-config-agent.role.xml | 3 +- common/plugins/yang/rw-sdn.role.xml | 1 + models/plugins/yang/nsr.role.xml | 1 + models/plugins/yang/project-nsd.role.xml | 1 + models/plugins/yang/project-vnfd.role.xml | 1 + models/plugins/yang/rw-vnfr.role.xml | 3 +- models/plugins/yang/vlr.role.xml | 1 + .../plugins/yang/rw-launchpad.role.xml | 1 + .../rift/tasklets/rwprojectmano/rolesmano.py | 38 ++++++++++++++++--- 10 files changed, 44 insertions(+), 9 deletions(-) diff --git a/common/plugins/yang/rw-cloud.role.xml b/common/plugins/yang/rw-cloud.role.xml index 6fb24865..c4e8bac4 100644 --- a/common/plugins/yang/rw-cloud.role.xml +++ b/common/plugins/yang/rw-cloud.role.xml @@ -4,6 +4,7 @@ rw-project-mano:rw-cloud-role project-name + /rw-project:project/rw-project:name /rw-cloud:update-cloud-status/rw-cloud:project-name @@ -18,7 +19,7 @@ - rw-project-mano:lcm-admin + rw-project-mano:account-admin rw-project-mano:rw-cloud-role create read update delete execute diff --git a/common/plugins/yang/rw-config-agent.role.xml b/common/plugins/yang/rw-config-agent.role.xml index 2951e5a8..c0071ca6 100644 --- a/common/plugins/yang/rw-config-agent.role.xml +++ b/common/plugins/yang/rw-config-agent.role.xml @@ -4,6 +4,7 @@ rw-project-mano:rw-config-agent-role project-name + /rw-project:project/rw-project:name /rw-config-agent:update-cfg-agent-status/rw-config-agent:project-name @@ -18,7 +19,7 @@ - rw-project-mano:lcm-admin + rw-project-mano:account-admin rw-project-mano:rw-config-agent-role create read update delete execute diff --git a/common/plugins/yang/rw-sdn.role.xml b/common/plugins/yang/rw-sdn.role.xml index 62944f86..8e962e04 100644 --- a/common/plugins/yang/rw-sdn.role.xml +++ b/common/plugins/yang/rw-sdn.role.xml @@ -4,6 +4,7 @@ rw-project-mano:rw-sdn-role project-name + /rw-project:project/rw-project:name /rw-sdn:update-sdn-status/rw-sdn:project-name diff --git a/models/plugins/yang/nsr.role.xml b/models/plugins/yang/nsr.role.xml index 0548c7b5..ecf963bd 100644 --- a/models/plugins/yang/nsr.role.xml +++ b/models/plugins/yang/nsr.role.xml @@ -4,6 +4,7 @@ rw-project-mano:nsr-role project-name + /rw-project:project/rw-project:name /nsr:exec-scale-out/nsr:project-name /nsr:exec-scale-in/nsr:project-name /nsr:exec-ns-service-primitive/nsr:project-name diff --git a/models/plugins/yang/project-nsd.role.xml b/models/plugins/yang/project-nsd.role.xml index afacae33..b0599343 100644 --- a/models/plugins/yang/project-nsd.role.xml +++ b/models/plugins/yang/project-nsd.role.xml @@ -4,6 +4,7 @@ rw-project-mano:project-nsd-role project-name + /rw-project:project/rw-project:name diff --git a/models/plugins/yang/project-vnfd.role.xml b/models/plugins/yang/project-vnfd.role.xml index a32c92f1..8c8ee08f 100644 --- a/models/plugins/yang/project-vnfd.role.xml +++ b/models/plugins/yang/project-vnfd.role.xml @@ -4,6 +4,7 @@ rw-project-mano:project-vnfd-role project-name + /rw-project:project/rw-project:name diff --git a/models/plugins/yang/rw-vnfr.role.xml b/models/plugins/yang/rw-vnfr.role.xml index 91786902..08f22023 100644 --- a/models/plugins/yang/rw-vnfr.role.xml +++ b/models/plugins/yang/rw-vnfr.role.xml @@ -4,7 +4,8 @@ rw-project-mano:rw-vnfr-role project-name - + /rw-project:project/rw-project:name + diff --git a/models/plugins/yang/vlr.role.xml b/models/plugins/yang/vlr.role.xml index 90350dc9..cb6f9ee2 100644 --- a/models/plugins/yang/vlr.role.xml +++ b/models/plugins/yang/vlr.role.xml @@ -4,6 +4,7 @@ rw-project-mano:vlr-role project-name + /rw-project:project/rw-project:name diff --git a/rwlaunchpad/plugins/yang/rw-launchpad.role.xml b/rwlaunchpad/plugins/yang/rw-launchpad.role.xml index 0efb351b..110a713e 100644 --- a/rwlaunchpad/plugins/yang/rw-launchpad.role.xml +++ b/rwlaunchpad/plugins/yang/rw-launchpad.role.xml @@ -4,6 +4,7 @@ rw-project-mano:rw-launchpad-role project-name + /rw-project:project/rw-project:name diff --git a/rwprojectmano/plugins/rwprojectmano/rift/tasklets/rwprojectmano/rolesmano.py b/rwprojectmano/plugins/rwprojectmano/rift/tasklets/rwprojectmano/rolesmano.py index 2988a205..d6d12c48 100644 --- a/rwprojectmano/plugins/rwprojectmano/rift/tasklets/rwprojectmano/rolesmano.py +++ b/rwprojectmano/plugins/rwprojectmano/rift/tasklets/rwprojectmano/rolesmano.py @@ -35,7 +35,6 @@ from gi.repository import ( import rift.tasklets from rift.tasklets.rwproject.project import ( - StateMachine, User, UserState, RoleKeys, @@ -87,7 +86,7 @@ class ProjectConfigSubscriber(object): def update_user(self, cfg): user = User().pb(cfg) - self._log.debug("Update user {} for project {}". + self._log.error("Update user {} for project {}". format(user.key, self.project_name)) cfg_roles = {} for cfg_role in cfg.mano_role: @@ -260,6 +259,18 @@ class ProjectConfigSubscriber(object): self.pub.deregister() +class RoleState(Enum): + """Role states""" + NONE = 0 + NEW = 1 + INIT_DONE = 2 + ACTIVE = 3 + UPDATE = 4 + UPDATE_DONE = 5 + ERROR = 6 + DELETE = 7 + DELETE_DONE = 8 + class RoleConfigPublisher(rift.tasklets.DtsConfigPublisher): @@ -285,6 +296,21 @@ class RoleConfigPublisher(rift.tasklets.DtsConfigPublisher): "[rw-rbac-internal:user-name='{}']".format(user_key[1]) + \ "[rw-rbac-internal:user-domain='{}']".format(user_key[0]) + @classmethod + def yang_state_str(cls, state): + """ Return the state as a yang enum string """ + state_to_str_map = {RoleState.NONE: "none", + RoleState.NEW: "new", + RoleState.INIT_DONE: "init-done", + RoleState.ACTIVE: "active", + RoleState.UPDATE: "update", + RoleState.UPDATE_DONE: "update-done", + RoleState.ERROR: "error", + RoleState.DELETE: "delete", + RoleState.DELETE_DONE: "delete_done", + } + return state_to_str_map[state] + def create_project_roles(self): for name in self.proj_roles: role = RoleKeys() @@ -333,7 +359,7 @@ class RoleConfigPublisher(rift.tasklets.DtsConfigPublisher): pbUser = pbRole.create_user() pbUser.user_name = user.user_name pbUser.user_domain = user.user_domain - pbUser.state_machine.state = user.state.name + pbUser.state_machine.state = user.state pbRole.user.append(pbUser) @@ -356,9 +382,9 @@ class RoleConfigPublisher(rift.tasklets.DtsConfigPublisher): update = False if update: - user.state = StateMachine.new + user.state = RoleConfigPublisher.yang_state_str(RoleState.UPDATE) else: - user.state = StateMachine.new + user.state = RoleConfigPublisher.yang_state_str(RoleState.NEW) xpath = self.role_xpath(role_key) self.log.debug("update role: {} user: {} ".format(role_key, user_key)) @@ -375,7 +401,7 @@ class RoleConfigPublisher(rift.tasklets.DtsConfigPublisher): except KeyError: return - user.state = StateMachine.delete + user.state = RoleConfigPublisher.yang_state_str(RoleState.DELETE) xpath = self.role_xpath(role_key) self.log.error("deleting role: {} user: {} ".format(role_key, user_key)) -- 2.25.1