svn keywords
[plcapi.git] / PLC / Methods / GetSlivers.py
index ce43f72..1806387 100644 (file)
@@ -1,4 +1,5 @@
 # $Id$
+# $URL$
 import time
 
 from PLC.Faults import *
@@ -17,10 +18,6 @@ from PLC.Roles import Roles
 from PLC.Keys import Key, Keys
 from PLC.SliceTags import SliceTag, SliceTags
 from PLC.InitScripts import InitScript, InitScripts
-from PLC.Config import Config
-
-# XXX we don't really know whether this PLC is loaded from /etc/planetlab/plc_config or elsewhere
-plc_config = Config()
 
 # XXX used to check if slice expiration time is sane
 MAXINT =  2L**31-1
@@ -168,8 +165,6 @@ class v43GetSlivers(Method):
     }
 
     def call(self, auth, node_id_or_hostname = None):
-        global plc_config
-
         timestamp = int(time.time())
 
         # Get node
@@ -250,21 +245,9 @@ class v43GetSlivers(Method):
             sites = Sites(self.api, site_filter, site_return_filter)
             site = sites[0]
             person_filter =  {'person_id':site['person_ids'],'enabled':True}
-            person_return_filter = ['person_id', 'enabled', 'key_ids','role_ids'] 
+            person_return_filter = ['person_id', 'enabled', 'key_ids','role_ids','roles'
             site_persons = Persons(self.api, person_filter, person_return_filter)
 
-            # XXX This snippet below maps role names to role_ids,
-            # which is really DUMB.  Why can't one just pass 'roles'
-            # as a return_filter to Persons() above.
-            __roles = {}
-            dbroles = Roles(self.api)
-            for dbrole in dbroles:
-                __roles[dbrole['name']]=dbrole['role_id']
-            __theroles = []
-            for role in theroles:
-                __theroles.append(__roles[role])
-            theroles=__theroles
-
             # collect the keys into a table to weed out duplicates
             site_keys = {}
             for site_person in site_persons:
@@ -286,7 +269,7 @@ class v43GetSlivers(Method):
 
         # 'root' account setup on nodes from all 'admin' users
         # registered with the PLC main site
-        personsitekeys=getpersonsitekeys(plc_config.PLC_SLICE_PREFIX,['admin'])
+        personsitekeys=getpersonsitekeys(self.api.config.PLC_SLICE_PREFIX,['admin'])
         accounts.append({'name':'root','keys':personsitekeys})
 
        node.update_last_contact()