-import os
-
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
-from PLC.NodeNetworks import NodeNetwork, NodeNetworks
from PLC.Nodes import Node, Nodes
-from PLC.Auth import PasswordAuth
+from PLC.NodeNetworks import NodeNetwork, NodeNetworks
+from PLC.Auth import Auth
+from PLC.Methods.GetNodeNetworks import GetNodeNetworks
-class AdmGetAllNodeNetworks(Method):
+class AdmGetAllNodeNetworks(GetNodeNetworks):
"""
- Returns all the networks this node is connected to, as an array of
- structs.
-
+ Deprecated. Functionality can be implemented with GetNodes and
+ GetNodeNetworks.
"""
+ status = "deprecated"
+
roles = ['admin', 'pi', 'user', 'tech']
accepts = [
- PasswordAuth(),
+ Auth(),
Mixed(Node.fields['node_id'],
- Node.fields['hostname'])
+ Node.fields['hostname'])
]
- returns = [NodeNetwork.all_fields]
+ returns = [NodeNetwork.fields]
def call(self, auth, node_id_or_hostname):
- # Authenticated function
- 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])
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()
-
- return nodenetworks
+
+ if not node['nodenetwork_ids']:
+ return []
+
+ return GetNodeNetworks.call(self, auth, node['nodenetwork_ids'])