+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):
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)
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'])
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:
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