3 from PLC.Parameter import Parameter, Mixed, python_type
4 from PLC.Filter import Filter
5 from PLC.Nodes import Node, Nodes
9 components = name.split('.')
10 for comp in components[1:]:
11 mod = getattr(mod, comp)
15 c = getattr(import_deep("PLC.Methods.GetNodes"),"GetNodes")
16 # rename call to __origcall so we can still invoke
17 original = getattr(c,"call")
18 setattr(c,"__origcall",original)
21 node_fields['nodenetwork_ids']=Parameter([int], "Legacy version of interface_ids")
22 for k,v in Node.fields.iteritems():
25 accepts = getattr(c,"accepts")
27 arg1=Mixed([Mixed(Node.fields['node_id'],
28 Node.fields['hostname'])],
29 Parameter(str,"hostname"),
30 Parameter(int,"node_id"),
33 newaccepts = [arg0,arg1,arg2]
34 setattr(c,"accepts",newaccepts)
35 newreturns = [node_fields]
36 setattr(c,"returns",newreturns)
38 def GetNodesCall(self, auth, node_filter = None, return_fields = None):
39 # convert nodenetwork_ids -> interface_ids
40 if node_filter <> None and \
41 node_filter.has_key('nodenetwork_ids') and \
42 not node_filter.has_key('interface_ids'):
43 node_filter['interface_ids']=node_filter['nodenetwork_ids']
45 nodes = self.__origcall(auth,node_filter,return_fields)
47 # add in a interface_ids -> nodenetwork_ids
49 if node.has_key('interface_ids'):
50 node['nodenetwork_ids']=node['interface_ids']
54 setattr(c,"call",GetNodesCall)