X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FGetSliceSshKeys.py;fp=PLC%2FMethods%2FGetSliceSshKeys.py;h=60617c11c63bbb0ca33b534f20f5d8c7c6fd732c;hb=3dfe7a1b32434ca886aa65326641c4df8bfab94d;hp=393d94f407618c13115471c920dcc0b2cb1e6366;hpb=1c4f6c43455b1e8225073e2f6a04ba03cfc5d84b;p=plcapi.git diff --git a/PLC/Methods/GetSliceSshKeys.py b/PLC/Methods/GetSliceSshKeys.py index 393d94f..60617c1 100644 --- a/PLC/Methods/GetSliceSshKeys.py +++ b/PLC/Methods/GetSliceSshKeys.py @@ -1,3 +1,5 @@ +from types import StringTypes + from PLC.Method import Method from PLC.Parameter import Parameter, Mixed from PLC.Filter import Filter @@ -32,20 +34,20 @@ class GetSliceSshKeys(Method): def call(self, auth, slice_id_or_name): filter={} - if isinstance(int,slice_id_or_name): + if isinstance(slice_id_or_name,int): filter['slice_id']=slice_id_or_name - elif isinstance(str,slice_id_or_name): + elif isinstance(slice_id_or_name,StringTypes): filter['name']=slice_id_or_name filter['tagname']='ssh_key' # retrieve only sliver tags filter['~node_id']=None # slice_tags don't expose hostname, sigh.. - slice_tags=SliceTags(api,filter) + slice_tags=SliceTags(self.api,filter,['node_id','tagname','value']) node_ids = [st['node_id'] for st in slice_tags] # fetch nodes - nodes=Nodes(api,node_ids) + nodes=Nodes(self.api,node_ids,['node_id','hostname']) # hash on node_id nodes_hash=dict( [ (n['node_id'],n['hostname']) for n in nodes]) # return values hashed on hostname - return dict([ (nodes_hash[nodes_hash[st['node_id']]],st['value']) for st in slice_tags]) + return dict([ (nodes_hash[st['node_id']],st['value']) for st in slice_tags])