From: Mark Huang Date: Wed, 20 Sep 2006 20:32:02 +0000 (+0000) Subject: - remove extraneous import X-Git-Tag: pycurl-7_13_1~721 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=9e9e77f5690c719146665ecf2428d0a3fc677961;p=plcapi.git - remove extraneous import - no need to retrieve extra Node fields - whitespace nits - also check for invalid nodenetwork_ids --- diff --git a/PLC/Methods/AdmGetAllNodeNetworks.py b/PLC/Methods/AdmGetAllNodeNetworks.py index 24afa655..bcd2ac47 100644 --- a/PLC/Methods/AdmGetAllNodeNetworks.py +++ b/PLC/Methods/AdmGetAllNodeNetworks.py @@ -1,5 +1,3 @@ -import os - from PLC.Faults import * from PLC.Method import Method from PLC.Parameter import Parameter, Mixed @@ -11,7 +9,6 @@ class AdmGetAllNodeNetworks(Method): """ Returns all the networks this node is connected to, as an array of structs. - """ roles = ['admin', 'pi', 'user', 'tech'] @@ -29,23 +26,20 @@ class AdmGetAllNodeNetworks(Method): assert self.caller is not None # Get node information - nodes = Nodes(self.api, [node_id_or_hostname], NodeNetwork.all_fields).values() + nodes = Nodes(self.api, [node_id_or_hostname]).values() if not nodes: - raise PLCInvalidArgument, "No such node" + raise PLCInvalidArgument, "No such node" node = nodes[0] - + # Get node networks for this node - nodenetwork_ids = node['nodenetwork_ids'] - if not nodenetwork_ids: - raise PLCInvalidArgument, "Node has no node networks" - nodenetworks = NodeNetworks(self.api, nodenetwork_ids).values() + nodenetworks = NodeNetworks(self.api, node['nodenetwork_ids']).values() + if not nodenetworks: + raise PLCInvalidArgument, "Node has no node networks" # Filter out undesired or None fields (XML-RPC cannot marshal # None) and turn each node into a real dict. - valid_return_fields_only = lambda (key, value): \ - key in NodeNetwork.all_fields and value is not None + valid_return_fields_only = lambda (key, value): value is not None nodenetworks = [dict(filter(valid_return_fields_only, nodenetwork.items())) \ - for nodenetwork in nodenetworks] - + for nodenetwork in nodenetworks] return nodenetworks