1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Nodes import Node, Nodes
5 from PLC.Slices import Slice, Slices
6 from PLC.Auth import Auth
8 class AddSliceToNodesWhitelist(Method):
10 Adds the specified slice to the whitelist on the specified nodes. Nodes may be
11 either local or foreign nodes.
13 If the slice is already associated with a node, no errors are
16 Returns 1 if successful, faults otherwise.
23 Mixed(Slice.fields['slice_id'],
24 Slice.fields['name']),
25 [Mixed(Node.fields['node_id'],
26 Node.fields['hostname'])]
29 returns = Parameter(int, '1 if successful')
31 def call(self, auth, slice_id_or_name, node_id_or_hostname_list):
32 # Get slice information
33 slices = Slices(self.api, [slice_id_or_name])
35 raise PLCInvalidArgument, "No such slice"
38 if slice['peer_id'] is not None:
39 raise PLCInvalidArgument, "Not a local slice"
41 # Get specified nodes, add them to the slice
42 nodes = Nodes(self.api, node_id_or_hostname_list)
44 if node['peer_id'] is not None:
45 raise PLCInvalidArgument, "%s not a local node" % node['hostname']
46 if slice['slice_id'] not in node['slice_ids_whitelist']:
47 slice.add_to_node_whitelist(node, commit = False)
51 self.event_objects = {'Node': [node['node_id'] for node in nodes],
52 'Slice': [slice['slice_id']]}