From 49b6557372cb6cf7251755f8170e0fc884eddf88 Mon Sep 17 00:00:00 2001 From: Marta Carbone Date: Mon, 18 Jan 2010 08:35:30 +0000 Subject: [PATCH] Removed dummynet stuff. --- PLC/Accessors/Accessors_dummynetbox.py | 22 ------- PLC/Accessors/__init__.py | 1 - PLC/Methods/DeleteEmulationLink.py | 61 ------------------ PLC/Methods/GetBootMedium.py | 35 +--------- PLC/Methods/UpdateEmulationLink.py | 88 -------------------------- PLC/Methods/__init__.py | 2 - 6 files changed, 2 insertions(+), 207 deletions(-) delete mode 100644 PLC/Accessors/Accessors_dummynetbox.py delete mode 100644 PLC/Methods/DeleteEmulationLink.py delete mode 100644 PLC/Methods/UpdateEmulationLink.py diff --git a/PLC/Accessors/Accessors_dummynetbox.py b/PLC/Accessors/Accessors_dummynetbox.py deleted file mode 100644 index f0697e8..0000000 --- a/PLC/Accessors/Accessors_dummynetbox.py +++ /dev/null @@ -1,22 +0,0 @@ -# Marta Carbone - unipi -# $Id$ -# $URL$ - -from PLC.Nodes import Node -from PLC.Accessors.Factory import define_accessors, all_roles - -import sys -current_module = sys.modules[__name__] - -# XXX define possible subclasses -# define the dummynetbox SubClass strings -dbox_subclass = 'DummynetBox' - -# define the type of a node as a dummynetbox -define_accessors(current_module, Node, 'Subclass', 'subclass', 'node/config', - 'type of node definition', get_roles=all_roles, set_roles='pi') - -# define the dummynetbox connected to a node -define_accessors(current_module, Node, 'DummynetBox', 'dummynetbox_id', 'node/config', - 'dummynetbox connected to the node', get_roles=all_roles, set_roles='pi') - diff --git a/PLC/Accessors/__init__.py b/PLC/Accessors/__init__.py index cb615b8..eea8004 100644 --- a/PLC/Accessors/__init__.py +++ b/PLC/Accessors/__init__.py @@ -3,6 +3,5 @@ __all__ = """ Accessors_standard Accessors_wireless -Accessors_dummynetbox Accessors_site """.split() diff --git a/PLC/Methods/DeleteEmulationLink.py b/PLC/Methods/DeleteEmulationLink.py deleted file mode 100644 index 9a7df1c..0000000 --- a/PLC/Methods/DeleteEmulationLink.py +++ /dev/null @@ -1,61 +0,0 @@ -# Delete an Emulation link -# -# Marta Carbone - unipi -# $Id$ -# $URL$ - -from PLC.Faults import * -from PLC.Method import Method -from PLC.Parameter import Parameter, Mixed -from PLC.Nodes import Node, Nodes -from PLC.Auth import Auth -from PLC.Method import Method -from PLC.NodeTags import * -from PLC.Accessors.Accessors_dummynetbox import * # import dummynet accessors - -class DeleteEmulationLink(Method): - """ - Delete a connection between a node and a dummynetbox. - - Returns 1 if successful, faults otherwise. - - """ - roles = ['admin', 'pi', 'tech'] - - accepts = [ - Auth(), - Parameter(int, 'node_id'), - ] - - returns = Parameter(int, '1 is successful, 0 if not found, fault otherwise') - - def call(self, auth, node_id): - - assert self.caller is not None - - # check for node existence - nodes= Nodes(self.api, [node_id]) - if not nodes: - raise PLCInvalidArgument, "Node %s not found" % node_id - - # check for roles permission to call this method - if 'admin' not in self.caller['roles']: - if site not in self.caller['site_ids']: - raise PLCPermissionDenied, "Not allowed to delete this link" - - # check for the right subclass - subclass = GetNodeSubclass(self.api) - node_subclass = subclass.call(auth, node_id) - if node_subclass != None: - raise PLCInvalidArgument, "%s is not a node, subclass is %s" % (node_id, node_subclass) - - # Delete from the nodetags the entry with - # the given node_id and tagtype = 'dummynetbox' - nodetag = NodeTags(self.api, {'node_id':node_id, 'tagname':'dummynetbox_id'}) - - if not nodetag: - return 0 - - nodetag[0].delete() - - return 1 diff --git a/PLC/Methods/GetBootMedium.py b/PLC/Methods/GetBootMedium.py index 07e9bd2..e314122 100644 --- a/PLC/Methods/GetBootMedium.py +++ b/PLC/Methods/GetBootMedium.py @@ -26,10 +26,6 @@ allowed_actions = { 'generic-iso', 'generic-usb', ], - 'dummynet' : [ 'node-preview', - 'dummynet-iso', - 'dummynet-usb', - ], } # compute a new key @@ -70,11 +66,6 @@ class GetBootMedium(Method): (*) generic-iso (*) generic-usb - for a 'dummynet' node: - (*) node-preview - (*) dummynet-iso - (*) dummynet-usb - Apart for the preview mode, this method generates a new node key for the specified node, effectively invalidating any old boot medium. @@ -104,7 +95,6 @@ class GetBootMedium(Method): Options: an optional array of keywords. options are not supported for generic images - options are not supported for dummynet boxes Currently supported are - 'partition' - for USB actions only - 'cramfs' @@ -356,20 +346,6 @@ class GetBootMedium(Method): type, build_sh_options, log_file) - # dummynet node - elif node_type == 'dummynet': - # the build script expect the following parameters: - # the package base directory - # the working directory - # the full path of the configuration file - # the name of the resulting image file - # the type of the generated image - # the name of the log file - command = "%s -b %s -w %s -f %s -o %s -t %s -l %s" \ - % (self.BOOTCDBUILD, self.BOOTCDDIR, self.WORKDIR, - floppy_file, node_image, type, log_file) - command = "touch %s %s; echo 'dummynet build script not yet supported'" \ - % (log_file, node_image) if self.DEBUG: print "The build command line is %s" % command @@ -452,7 +428,7 @@ class GetBootMedium(Method): raise PLCInvalidArgument, "unknown option %s"%option # compute nodename according the action - if action.find("node-") == 0 or action.find("dummynet-") == 0: + if action.find("node-") == 0: nodename = node['hostname'] else: node = None @@ -461,12 +437,6 @@ class GetBootMedium(Method): def hexa2 (c): return chr((c>>4)+65) + chr ((c&16)+65) nodename = "".join(map(hexa2,tempbytes)) - # override some global definition, according node_type - if node_type == 'dummynet': - self.BOOTCDDIR = "/usr/share/dummynet" # the base installation dir - self.BOOTCDBUILD = "/usr/share/dummynet/build.sh" # dummynet build script - self.WORKDIR = "/var/tmp/DummynetBoxMedium" # temporary working dir - # get nodefamily (pldistro,arch) = self.get_nodefamily(node) self.nodefamily="%s-%s"%(pldistro,arch) @@ -525,8 +495,7 @@ class GetBootMedium(Method): # - build and invoke the build command # - delivery the resulting image file - if action == 'node-iso' or action == 'node-usb' \ - or action == 'dummynet-iso' or action == 'dummynet-usb': + if action == 'node-iso' or action == 'node-usb': ### check we've got required material version = self.bootcd_version() diff --git a/PLC/Methods/UpdateEmulationLink.py b/PLC/Methods/UpdateEmulationLink.py deleted file mode 100644 index 4516369..0000000 --- a/PLC/Methods/UpdateEmulationLink.py +++ /dev/null @@ -1,88 +0,0 @@ -# Connect a Node with a Dummynet box, using Accessors -# -# Marta Carbone - unipi -# $Id$ -# $URL$ - -from PLC.Faults import * -from PLC.Method import Method -from PLC.Parameter import Parameter, Mixed -from PLC.Nodes import Node, Nodes -from PLC.NodeGroups import NodeGroup, NodeGroups -from PLC.Sites import Site, Sites -from PLC.Auth import Auth -from PLC.Accessors.Accessors_dummynetbox import * # import dummynet accessors - -class UpdateEmulationLink(Method): - """ - Connect a Node with a Dummynet box. - Takes as input two node_id, the first should be a regular node, - the second a dummynet box. - - This operation is restricted to PIs and techs owner of the site - on which the Dummynet box and the Node are located. - Admins may create emulation links for any site, but the Dummynet - and the Node must belong to the same site. - - XXX Dummynet accessors should not be called directly, since they can - be used to create connection whitout checks. - - Returns 1 if successful, faults otherwise. - """ - - roles = ['admin', 'pi', 'tech'] - - accepts = [ - Auth(), - Parameter(int, 'node_id'), # a node - Mixed(Parameter(int, 'node_id'), # a dummynet box, or None to delete the entry - None), - ] - - returns = Parameter(int, '1 is successful, fault otherwise') - - # Before to create the link we do the following checks: - # - node existence, - # - dummnet box existence, - # - right roles (admin, pi, tech), - # - node and dummynet box site should match. - - def call(self, auth, node_id, dummynet_id): - - assert self.caller is not None - - # check for node existence - # Retrieve nodes from database - # We do not fetch both node and dummynet - # since we need to preserve the order of returned objects - nodes= Nodes(self.api, {'node_id':node_id, 'node_type':'regular'}) - if not nodes: - raise PLCInvalidArgument, "Node %s not found" % node_id - node = nodes[0] - - # check for dummynet box existence - nodes = Nodes(self.api, {'node_id':dummynet_id, 'node_type':'dummynet'}) - if (dummynet_id != None) and not nodes: - raise PLCInvalidArgument, "Dummynet box %s not found" % dummynet_id - - # check for site matching when create a link - if (dummynet_id != None): - dummynet = nodes[0] - - # check if the node and the dummynet_id - # belong to the same site - if (node['site_id'] != dummynet['site_id']): - raise PLCInvalidArgument, \ - "The Dummynet box must belog to the same site of the Node" - - # check for roles permission to call this method - if 'admin' not in self.caller['roles']: - if site not in self.caller['site_ids']: - raise PLCPermissionDenied, "Not allowed to manage on this link" - - # Add the dummynetbox - emulation_link = SetNodeDummynetBox(self.api) - emulation_link.call(auth, node_id, dummynet_id) - - return 1 - diff --git a/PLC/Methods/__init__.py b/PLC/Methods/__init__.py index 52fb070..81ffd92 100644 --- a/PLC/Methods/__init__.py +++ b/PLC/Methods/__init__.py @@ -54,7 +54,6 @@ DeleteBootState DeleteConfFile DeleteConfFileFromNode DeleteConfFileFromNodeGroup -DeleteEmulationLink DeleteIlink DeleteInitScript DeleteInterface @@ -160,7 +159,6 @@ UnBindObjectFromPeer UpdateAddress UpdateAddressType UpdateConfFile -UpdateEmulationLink UpdateIlink UpdateInitScript UpdateInterface -- 2.43.0