remove Event import
[plcapi.git] / PLC / Method.py
index 3d7383c..1236f0c 100644 (file)
@@ -16,8 +16,8 @@ from PLC.NovaShell import NovaShell
 from PLC.Faults import *
 from PLC.Parameter import Parameter, Mixed, python_type, xmlrpc_type
 from PLC.Auth import Auth
+from PLC.Timestamp import Timestamp
 from PLC.Debug import profile
-from PLC.Events import Event, Events
 from PLC.Nodes import Node, Nodes
 from PLC.Persons import Person, Persons
 
@@ -64,8 +64,8 @@ w
     def __init__(self, api,caller=None):
         self.name = self.__class__.__name__
         self.api = api
-        self.admin_shell = NovaShell()
-        self.client_shell = None
+        self.api.admin_shell = NovaShell()
+        self.api.client_shell = None
 
         if caller: 
             # let a method call another one by propagating its caller
@@ -321,14 +321,15 @@ w
     def authenticate(self, auth):
 
         # establish nova connection
-        self.client_shell = NovaShell(user=auth['Username'],
+        self.api.client_shell = NovaShell(user=auth['Username'],
                                   password=auth['AuthString'],
                                   tenant=auth['Tenant'])
-        self.client_shell.authenticate()
-        self.caller = self.client_shell.keystone.users.find(name=auth['Username'])
-        self.caller_tenant = self.client_shell.keystone.tenants.find(name=auth['Tenant'])
-        caller_roles = self.client_shell.keystone.roles.roles_for_user(self.caller, self.caller_tenant)
+        self.api.client_shell.authenticate()
+        self.caller = Person(self.api, object=self.api.client_shell.keystone.users.find(name=auth['Username']))
+        self.caller_tenant = self.api.client_shell.keystone.tenants.find(name=auth['Tenant'])
+        caller_roles = self.api.client_shell.keystone.roles.roles_for_user(self.caller, self.caller_tenant)
         role_names = [role.name for role in caller_roles] 
+        self.caller['roles'] = role_names 
         if not set(role_names).intersection(self.roles):
             method_message="method %s has roles [%s]"%(self.name,','.join(self.roles))
             person_message="caller %s has roles [%s]"%(self.caller.name,','.join(role_names))