Added iso image download support.
authorMarta Carbone <marta@prova.iet.unipi.it>
Tue, 17 Feb 2009 13:03:36 +0000 (13:03 +0000)
committerMarta Carbone <marta@prova.iet.unipi.it>
Tue, 17 Feb 2009 13:03:36 +0000 (13:03 +0000)
Added some fix to image permission and dummynet box configuration tool.

PLC/Methods/ConfigureDummynetBox.py
PLC/Methods/GetDummyBoxMedium.py

index 34344fe..7bc8218 100644 (file)
@@ -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
index 3030859..dc1deb2 100644 (file)
@@ -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)