+++ /dev/null
-# 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')
-
__all__ = """
Accessors_standard
Accessors_wireless
-Accessors_dummynetbox
Accessors_site
""".split()
+++ /dev/null
-# 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
'generic-iso',
'generic-usb',
],
- 'dummynet' : [ 'node-preview',
- 'dummynet-iso',
- 'dummynet-usb',
- ],
}
# compute a new key
(*) 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.
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'
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
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
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)
# - 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()
+++ /dev/null
-# 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
-
DeleteConfFile
DeleteConfFileFromNode
DeleteConfFileFromNodeGroup
-DeleteEmulationLink
DeleteIlink
DeleteInitScript
DeleteInterface
UpdateAddress
UpdateAddressType
UpdateConfFile
-UpdateEmulationLink
UpdateIlink
UpdateInitScript
UpdateInterface