1 # Delete an Emulation link
3 # Marta Carbone - unipi
7 from PLC.Faults import *
8 from PLC.Method import Method
9 from PLC.Parameter import Parameter, Mixed
10 from PLC.Nodes import Node, Nodes
11 from PLC.Auth import Auth
12 from PLC.Method import Method
13 from PLC.NodeTags import *
14 from PLC.Accessors.Accessors_dummynetbox import * # import dummynet accessors
16 class DeleteEmulationLink(Method):
18 Delete a connection between a node and a dummynetbox.
20 Returns 1 if successful, faults otherwise.
23 roles = ['admin', 'pi', 'tech']
27 Parameter(int, 'node_id'),
30 returns = Parameter(int, '1 is successful, 0 if not found, fault otherwise')
32 def call(self, auth, node_id):
34 assert self.caller is not None
36 # check for node existence
37 nodes= Nodes(self.api, [node_id])
39 raise PLCInvalidArgument, "Node %s not found" % node_id
41 # check for roles permission to call this method
42 if 'admin' not in self.caller['roles']:
43 if site not in self.caller['site_ids']:
44 raise PLCPermissionDenied, "Not allowed to delete this link"
46 # check for the right subclass
47 subclass = GetNodeSubclass(self.api)
48 node_subclass = subclass.call(auth, node_id)
49 if node_subclass != None:
50 raise PLCInvalidArgument, "%s is not a node, subclass is %s" % (node_id, node_subclass)
52 # Delete from the nodetags the entry with
53 # the given node_id and tagtype = 'dummynetbox'
54 nodetag = NodeTags(self.api, {'node_id':node_id, 'tagname':'dummynetbox_id'})