Removed user id checks, the `apache' user will be always used.
authorMarta Carbone <marta@prova.iet.unipi.it>
Fri, 5 Sep 2008 18:38:59 +0000 (18:38 +0000)
committerMarta Carbone <marta@prova.iet.unipi.it>
Fri, 5 Sep 2008 18:38:59 +0000 (18:38 +0000)
PLC/Methods/ConfigureDummynetBox.py

index 9ac69b9..4c75236 100644 (file)
@@ -25,6 +25,7 @@ import os                                       # ssh
 # used to send configuration requests
 # to the dummynet box.
 DBOX_KNOWN_HOSTS="/var/tmp/.dbox_known_hosts"
+DBOX_KEY="/usr/share/dummynet/dbox_key"
 
 DEFAULT_TIMEOUT= "1H"
 
@@ -151,15 +152,6 @@ class ConfigureDummynetBox(Method):
        SSH = "ssh -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=yes ";
        SSH += "-o UserKnownHostsFile=" + "'"+DBOX_KNOWN_HOSTS+"'" + " ";
 
-       # use the right key, we need
-       # apache:apache key when called from python,
-       # root:root when called from php or plcsh
-       DBOX_KEY="/usr/share/dummynet/dbox_key"
-       id = os.popen("id -u").read()
-       id = int(id)
-       if (id != 0):
-               DBOX_KEY += "_apache";
-
        # the ssh command takes as input
        # the node_ip, the slicename, the port number
        # a timeout and a filename (0 don't upload)
@@ -199,14 +191,16 @@ class ConfigureDummynetBox(Method):
                cmd_line += " noerror"
 
        # send the command to the dummynetbox
+       # get output and return code
        command = os.popen(cmd_line);
        output = command.read();
        ret = str(command.close());
+
        if (ret == "None"):
-               ret = cmd_line + "Command executed"
-               return "OK " + ret + "\n" + output
+               ret = "0"
        else:
-               ret = "Some errors occurred, a detailed description of the output follows"
-               return cmd_line + "ERROR " + ret + "\n" + output
+               ret = "1"
+
+       ret += " \n" + output
 
        return ret