from PLC.InterfaceTags import InterfaceTag, InterfaceTags
from PLC.NodeTags import NodeTag, NodeTags
+from PLC.Accessors.Accessors_standard import * # import node accessors
+
# could not define this in the class..
# create a dict with the allowed actions for each type of node
allowed_actions = {
'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'
return file
- # see also InstallBootstrapFS in bootmanager that does similar things
- def get_nodefamily (self, node):
- # get defaults from the myplc build
- try:
- (pldistro,arch) = file("/etc/planetlab/nodefamily").read().strip().split("-")
- except:
- (pldistro,arch) = ("planetlab","i386")
-
- # with no valid argument, return system-wide defaults
+ # see also GetNodeFlavour that does similar things
+ def get_nodefamily (self, node, auth):
+ pldistro = self.api.config.PLC_FLAVOUR_NODE_PLDISTRO
+ fcdistro = self.api.config.PLC_FLAVOUR_NODE_FCDISTRO
+ arch = self.api.config.PLC_FLAVOUR_NODE_ARCH
if not node:
- return (pldistro,arch)
-
+ return (pldistro,fcdistro,arch)
+
node_id=node['node_id']
+
+ # no support for deployment-based BootCD's, use kvariants instead
+ node_pldistro = GetNodePldistro (self.api).call(auth, node_id)
+ if node_pldistro: pldistro = node_pldistro
- tag=Nodes(self.api,[node_id],['arch'])[0]['arch']
- if tag: arch=tag
- tag=Nodes(self.api,[node_id],['pldistro'])[0]['pldistro']
- if tag: pldistro=tag
+ node_fcdistro = GetNodeFcdistro (self.api).call(auth, node_id)
+ if node_fcdistro: fcdistro = node_fcdistro
- return (pldistro,arch)
+ node_arch = GetNodeArch (self.api).call(auth,node_id)
+ if node_arch: arch = node_arch
+
+ return (pldistro,fcdistro,arch)
def bootcd_version (self):
try:
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)
+ (pldistro,fcdistro,arch) = self.get_nodefamily(node,auth)
+ self.nodefamily="%s-%s-%s"%(pldistro,fcdistro,arch)
# apply on globals
for attr in [ "BOOTCDDIR", "BOOTCDBUILD", "GENERICDIR" ]:
# - 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()