Changed dummynet box configuration files.
authorMarta Carbone <marta@prova.iet.unipi.it>
Mon, 23 Jun 2008 11:34:51 +0000 (11:34 +0000)
committerMarta Carbone <marta@prova.iet.unipi.it>
Mon, 23 Jun 2008 11:34:51 +0000 (11:34 +0000)
PLC/Methods/GetDummyBoxMedium.py
PLC/Methods/GetDummyBoxUsers.py

index 5a81677..058342a 100644 (file)
@@ -19,6 +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 = "/tmp/DummynetBoxMedium"
+BASE_IMAGE = "/usr/share/dummynet/picobsd.bin"
 
 class GetDummyBoxMedium(Method):
     """
@@ -68,10 +69,10 @@ class GetDummyBoxMedium(Method):
         file += 'IP_GATEWAY="%s"\n' % dummybox['gateway']
         file += 'IP_DNS1="%s"\n' % dummybox['dns1']
         file += 'IP_DNS2="%s"\n' % dummybox['dns2']
-        file += 'DUMMYBOX_ID=%s\n' % dummybox['dummybox_id']
-        file += 'DUMMYBOX_KEY=%s\n' % new_key
+        file += 'DUMMYBOX_ID="%s"\n' % dummybox['dummybox_id']
+        file += 'DUMMYBOX_KEY="%s"\n' % new_key
         
-        file += 'CS_IP=%s\n' % self.api.config.PLC_API_HOST
+        file += 'CS_IP="%s"\n' % self.api.config.PLC_API_HOST
 
         # write the configuration file
         # WORK_DIR must be writable
@@ -85,7 +86,6 @@ class GetDummyBoxMedium(Method):
     def call(self, auth, dummybox_id):
 
         # set file names
-       BASE_IMAGE = WORK_DIR + '/picobsd.bin'
         IMAGE_NAME = str(WORK_DIR) + "/dummybox_" + str(dummybox_id) + ".bin"
         configfile = WORK_DIR + '/dummybox.conf'
         lockfile =  WORK_DIR + '/lockfile'
@@ -140,5 +140,5 @@ class GetDummyBoxMedium(Method):
         dummybox.sync()
 
         # return the file
-        #return IMAGE_NAME
+        return IMAGE_NAME
         return base64.b64encode(file(IMAGE_NAME).read())
index 732cbf8..d867b78 100644 (file)
@@ -57,7 +57,7 @@ class GetDummyBoxUsers(Method):
                # to format the output files
                # port-forwarding should be denied in the main sshd configuration file
                ssh_command = "/home/user/dbox.cmd "
-               ssh_configuration = ",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty "
+               ssh_configuration = ",no-port-forwarding,no-agent-forwarding,no-X11-forwarding "
 
                # Get dummyboxes information
                dummyboxes = DummyBoxes(self.api, dummybox_id, ['site_id'])
@@ -149,7 +149,11 @@ class GetDummyBoxUsers(Method):
                authorized_keys_file += "# and $SSH_ORIGINAL_COMMAND is the command line inserted by the node\n"
 
                for i in authorized_keys_dict:
-                       authorized_keys_file += "command=" + "\"" + ssh_command + str(authorized_keys_dict[i]);
-                       authorized_keys_file += " $SSH_ORIGINAL_COMMAND" + "\"" + ssh_configuration + str(i) + "\n"
+                       # index of the key
+                       key_index = str(authorized_keys_dict[i])
+
+                       # create the dummynet box command
+                       authorized_keys_file += "command=\"" + ssh_command + key_index;
+                       authorized_keys_file += " $SSH_ORIGINAL_COMMAND\"" + ssh_configuration + str(i) + "\n"
 
                return user_map+NEWFILE_MARK+"\n"+authorized_keys_file