From b9689f96674c03ad799631814295a799660dfca5 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Mon, 16 Oct 2006 20:16:13 +0000 Subject: [PATCH] DeleteNodeNetwork need not require node_id_or_hostname to be passed in --- PLC/Methods/AdmDeleteNodeNetwork.py | 17 ++++++++++++++++- PLC/Methods/AdmGetAllNodeNetworks.py | 6 +++--- PLC/Methods/DeleteNodeNetwork.py | 11 ++--------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/PLC/Methods/AdmDeleteNodeNetwork.py b/PLC/Methods/AdmDeleteNodeNetwork.py index e395ac16..b446183b 100644 --- a/PLC/Methods/AdmDeleteNodeNetwork.py +++ b/PLC/Methods/AdmDeleteNodeNetwork.py @@ -1,3 +1,9 @@ +from PLC.Faults import * +from PLC.Method import Method +from PLC.Parameter import Parameter, Mixed +from PLC.Auth import PasswordAuth +from PLC.Nodes import Node, Nodes +from PLC.NodeNetworks import NodeNetwork, NodeNetworks from PLC.Methods.DeleteNodeNetwork import DeleteNodeNetwork class AdmDeleteNodeNetwork(DeleteNodeNetwork): @@ -5,4 +11,13 @@ class AdmDeleteNodeNetwork(DeleteNodeNetwork): Deprecated. See DeleteNodeNetwork. """ - status = "deprecated" + accepts = [ + PasswordAuth(), + Mixed(Node.fields['node_id'], + Node.fields['hostname']), + Mixed(NodeNetwork.fields['nodenetwork_id'], + NodeNetwork.fields['hostname']) + ] + + def call(self, auth, node_id_or_hostname, nodenetwork_id_or_hostname): + return DeleteNodeNetwork.call(self, auth, nodenetwork_id_or_hostname) diff --git a/PLC/Methods/AdmGetAllNodeNetworks.py b/PLC/Methods/AdmGetAllNodeNetworks.py index 0dd73e32..c947d256 100644 --- a/PLC/Methods/AdmGetAllNodeNetworks.py +++ b/PLC/Methods/AdmGetAllNodeNetworks.py @@ -25,13 +25,13 @@ class AdmGetAllNodeNetworks(GetNodeNetworks): 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]).values() if not nodes: raise PLCInvalidArgument, "No such node" node = nodes[0] + if not node['nodenetwork_ids']: + return [] + return GetNodeNetworks.call(self, auth, node['nodenetwork_ids']) diff --git a/PLC/Methods/DeleteNodeNetwork.py b/PLC/Methods/DeleteNodeNetwork.py index d2c6d4ad..7b546de7 100644 --- a/PLC/Methods/DeleteNodeNetwork.py +++ b/PLC/Methods/DeleteNodeNetwork.py @@ -20,15 +20,13 @@ class DeleteNodeNetwork(Method): accepts = [ PasswordAuth(), - Mixed(Node.fields['node_id'], - Node.fields['hostname']), Mixed(NodeNetwork.fields['nodenetwork_id'], NodeNetwork.fields['hostname']) ] returns = Parameter(int, '1 if successful') - def call(self, auth, node_id_or_hostname, nodenetwork_id_or_hostname): + def call(self, auth, nodenetwork_id_or_hostname): # Get node network information nodenetworks = NodeNetworks(self.api, [nodenetwork_id_or_hostname]).values() if not nodenetworks: @@ -36,16 +34,11 @@ class DeleteNodeNetwork(Method): nodenetwork = nodenetworks[0] # Get node information - nodes = Nodes(self.api, [node_id_or_hostname]).values() + nodes = Nodes(self.api, [nodenetwork['node_id']]).values() if not nodes: raise PLCInvalidArgument, "No such node" node = nodes[0] - # Check if node network is associated with specified node - if node['node_id'] != nodenetwork['node_id'] or \ - nodenetwork['nodenetwork_id'] not in node['nodenetwork_ids']: - raise PLCInvalidArgument, "Node network not associated with node" - # Authenticated functino assert self.caller is not None -- 2.47.0