Fix role definition for projects 49/1549/1
authorPhilip Joseph <philip.joseph@riftio.com>
Tue, 11 Apr 2017 10:29:01 +0000 (10:29 +0000)
committerPhilip Joseph <philip.joseph@riftio.com>
Tue, 11 Apr 2017 11:12:08 +0000 (16:42 +0530)
Change-Id: I812b526426be090bfc34290074efea48ebd5accc
Signed-off-by: Philip Joseph <philip.joseph@riftio.com>
common/plugins/yang/rw-cloud.role.xml
common/plugins/yang/rw-config-agent.role.xml
common/plugins/yang/rw-sdn.role.xml
models/plugins/yang/nsr.role.xml
models/plugins/yang/project-nsd.role.xml
models/plugins/yang/project-vnfd.role.xml
models/plugins/yang/rw-vnfr.role.xml
models/plugins/yang/vlr.role.xml
rwlaunchpad/plugins/yang/rw-launchpad.role.xml
rwprojectmano/plugins/rwprojectmano/rift/tasklets/rwprojectmano/rolesmano.py

index 6fb2486..c4e8bac 100644 (file)
@@ -4,6 +4,7 @@
     <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>
@@ -18,7 +19,7 @@
   </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>
index 2951e5a..c0071ca 100644 (file)
@@ -4,6 +4,7 @@
     <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>
@@ -18,7 +19,7 @@
   </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>
index 62944f8..8e962e0 100644 (file)
@@ -4,6 +4,7 @@
     <role>rw-project-mano:rw-sdn-role</role>
     <key-set>
       <name>project-name</name>
+      <path>/rw-project:project/rw-project:name</path>
       <path>/rw-sdn:update-sdn-status/rw-sdn:project-name</path>
     </key-set>
   </key-definition>
index 0548c7b..ecf963b 100644 (file)
@@ -4,6 +4,7 @@
     <role>rw-project-mano:nsr-role</role>
     <key-set>
       <name>project-name</name>
+      <path>/rw-project:project/rw-project:name</path>
       <path>/nsr:exec-scale-out/nsr:project-name</path>
       <path>/nsr:exec-scale-in/nsr:project-name</path>
       <path>/nsr:exec-ns-service-primitive/nsr:project-name</path>
index afacae3..b059934 100644 (file)
@@ -4,6 +4,7 @@
     <role>rw-project-mano:project-nsd-role</role>
     <key-set>
       <name>project-name</name>
+      <path>/rw-project:project/rw-project:name</path>
     </key-set>
   </key-definition>
 
index a32c92f..8c8ee08 100644 (file)
@@ -4,6 +4,7 @@
     <role>rw-project-mano:project-vnfd-role</role>
     <key-set>
       <name>project-name</name>
+      <path>/rw-project:project/rw-project:name</path>
     </key-set>
   </key-definition>
 
index 9178690..08f2202 100644 (file)
@@ -4,7 +4,8 @@
     <role>rw-project-mano:rw-vnfr-role</role>
     <key-set>
       <name>project-name</name>
-    </key-set>
+      <path>/rw-project:project/rw-project:name</path>
+   </key-set>
   </key-definition>
 
   <role-definition>
index 90350dc..cb6f9ee 100644 (file)
@@ -4,6 +4,7 @@
     <role>rw-project-mano:vlr-role</role>
     <key-set>
       <name>project-name</name>
+      <path>/rw-project:project/rw-project:name</path>
     </key-set>
   </key-definition>
 
index 0efb351..110a713 100644 (file)
@@ -4,6 +4,7 @@
     <role>rw-project-mano:rw-launchpad-role</role>
     <key-set>
       <name>project-name</name>
+      <path>/rw-project:project/rw-project:name</path>
     </key-set>
   </key-definition>
 
index 2988a20..d6d12c4 100644 (file)
@@ -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))