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