<role>rw-project-mano:rw-cloud-role</role>
<key-set>
<name>project-name</name>
+ <path>/rw-project:project/rw-project:name</path>
<path>/rw-cloud:update-cloud-status/rw-cloud:project-name</path>
</key-set>
</key-definition>
</role-definition>
<role-definition>
- <role>rw-project-mano:lcm-admin</role>
+ <role>rw-project-mano:account-admin</role>
<keys-role>rw-project-mano:rw-cloud-role</keys-role>
<authorize>
<permissions>create read update delete execute</permissions>
<role>rw-project-mano:rw-config-agent-role</role>
<key-set>
<name>project-name</name>
+ <path>/rw-project:project/rw-project:name</path>
<path>/rw-config-agent:update-cfg-agent-status/rw-config-agent:project-name</path>
</key-set>
</key-definition>
</role-definition>
<role-definition>
- <role>rw-project-mano:lcm-admin</role>
+ <role>rw-project-mano:account-admin</role>
<keys-role>rw-project-mano:rw-config-agent-role</keys-role>
<authorize>
<permissions>create read update delete execute</permissions>
import rift.tasklets
from rift.tasklets.rwproject.project import (
- StateMachine,
User,
UserState,
RoleKeys,
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:
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):
"[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()
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)
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))
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))