3 from PLC.Faults import *
4 from PLC.Method import Method
5 from PLC.Parameter import Parameter, Mixed
6 from PLC.Nodes import Node, Nodes
7 from PLC.Slices import Slice, Slices
8 from PLC.Auth import Auth
10 class DeleteSliceFromNodesWhitelist(Method):
12 Deletes the specified slice from the whitelist on the specified nodes. Nodes may be
13 either local or foreign nodes.
15 If the slice is already associated with a node, no errors are
18 Returns 1 if successful, faults otherwise.
25 Mixed(Slice.fields['slice_id'],
26 Slice.fields['name']),
27 [Mixed(Node.fields['node_id'],
28 Node.fields['hostname'])]
31 returns = Parameter(int, '1 if successful')
33 def call(self, auth, slice_id_or_name, node_id_or_hostname_list):
34 # Get slice information
35 slices = Slices(self.api, [slice_id_or_name])
37 raise PLCInvalidArgument, "No such slice"
40 if slice['peer_id'] is not None:
41 raise PLCInvalidArgument, "Not a local slice"
43 # Get specified nodes, add them to the slice
44 nodes = Nodes(self.api, node_id_or_hostname_list)
46 if node['peer_id'] is not None:
47 raise PLCInvalidArgument, "%s not a local node" % node['hostname']
48 if slice['slice_id'] in node['slice_ids_whitelist']:
49 slice.delete_from_node_whitelist(node, commit = False)
53 self.event_objects = {'Node': [node['node_id'] for node in nodes],
54 'Slice': [slice['slice_id']]}