From b23ca39cdd9df3e35e6192786a64362fc2154d40 Mon Sep 17 00:00:00 2001 From: Marta Carbone Date: Tue, 17 Feb 2009 13:03:36 +0000 Subject: [PATCH] Added iso image download support. Added some fix to image permission and dummynet box configuration tool. --- PLC/Methods/ConfigureDummynetBox.py | 1 - PLC/Methods/GetDummyBoxMedium.py | 17 +++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/PLC/Methods/ConfigureDummynetBox.py b/PLC/Methods/ConfigureDummynetBox.py index 34344fe..7bc8218 100644 --- a/PLC/Methods/ConfigureDummynetBox.py +++ b/PLC/Methods/ConfigureDummynetBox.py @@ -179,7 +179,6 @@ class ConfigureDummynetBox(Method): link_config['upload_extra-delay'] = os.path.basename(link_config['upload_extra-delay']); cmd_line += pipe_build(link_config, "upload_extra-delay", " extra-delay ") else: - link_config['extra-delay'] = os.path.basename(link_config['extra-delay']); cmd_line += pipe_build(link_config, "extra-delay", " extra-delay ") # add plr, bw, delay, noerror diff --git a/PLC/Methods/GetDummyBoxMedium.py b/PLC/Methods/GetDummyBoxMedium.py index 3030859..dc1deb2 100644 --- a/PLC/Methods/GetDummyBoxMedium.py +++ b/PLC/Methods/GetDummyBoxMedium.py @@ -19,7 +19,7 @@ from PLC.DummyBoxes import DummyBox, DummyBoxes # main class for a DummyBox from PLC.Methods.GetBootMedium import compute_key # key generation function WORK_DIR = "/var/tmp/DummynetBoxMedium" -BASE_IMAGE = "/usr/share/dummynet/picobsd.bin" +BASE_IMAGE = "/usr/share/dummynet/picobsd" class GetDummyBoxMedium(Method): """ @@ -40,7 +40,8 @@ class GetDummyBoxMedium(Method): accepts = [ Auth(), - Parameter(int, "A dummybox_id") + Parameter(int, "The dummybox_id"), + Parameter(str, "The image type (bin or iso)") ] returns = Parameter(str, "DummynetBox boot medium") @@ -83,7 +84,7 @@ class GetDummyBoxMedium(Method): return # Here starts the execution of the call - def call(self, auth, dummybox_id): + def call(self, auth, dummybox_id, type): # Check for dummybox existence dummyboxes = DummyBoxes(self.api, [dummybox_id]) @@ -94,7 +95,12 @@ class GetDummyBoxMedium(Method): # Get the dummynet box hostname dummybox_hostname = dummybox['hostname'] - IMAGE_NAME = str(WORK_DIR) + "/dummybox_" + dummybox_hostname + ".bin" + + # Select the base image, default to bin image + if type != 'iso': + type="bin" + IMAGE_NAME = str(WORK_DIR) + "/dummybox_" + dummybox_hostname + str(type) + BASE_IMAGE = BASE_IMAGE + "." + str(type) configfile = WORK_DIR + '/dummybox.conf' lockfile = WORK_DIR + '/lockfile' @@ -128,6 +134,9 @@ class GetDummyBoxMedium(Method): shell_script = "(cp %s %s; export MATCH=`grep -abo START_USER_DATA %s | cut -d: -f1`; " \ % (BASE_IMAGE, IMAGE_NAME, IMAGE_NAME) + # set permission file + shell_script += " chmod u+w %s; chmod u+w %s; " % (IMAGE_NAME, configfile) + # cat the configuration file in the raw image shell_script += "cat %s | dd of=%s seek=$MATCH conv=notrunc bs=1)" \ % (configfile, IMAGE_NAME) -- 2.43.0