merging the nepi-3.0-pre-release branch with nepi-3-dev
[nepi.git] / src / nepi / resources / linux / ping.py
index 0a5796a..6db0a8d 100644 (file)
@@ -18,7 +18,7 @@
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
 from nepi.execution.attribute import Attribute, Flags, Types
-from nepi.execution.resource import clsinit_copy 
+from nepi.execution.resource import clsinit_copy
 from nepi.resources.linux.application import LinuxApplication
 from nepi.util.timefuncs import tnow
 
@@ -33,6 +33,7 @@ class LinuxPing(LinuxApplication):
         count = Attribute("count",
             "Sets ping -c option. Determines the number of ECHO_REQUEST "
             "packates to send before stopping.",
+            type = Types.Integer,
             flags = Flags.ExecReadOnly)
 
         mark = Attribute("mark",
@@ -56,7 +57,7 @@ class LinuxPing(LinuxApplication):
 
         numeric = Attribute("numeric",
             "Sets ping -n option. Disables resolution of host addresses into "
-            "symbolic names ",
+            "symbolic names. ",
             type = Types.Bool,
             default = False,
             flags = Flags.ExecReadOnly)
@@ -183,16 +184,23 @@ class LinuxPing(LinuxApplication):
         super(LinuxPing, self).__init__(ec, guid)
         self._home = "ping-%s" % self.guid
 
-    def deploy(self):
+    def do_deploy(self):
         if not self.get("command"):
             self.set("command", self._start_command)
 
-        super(LinuxPing, self).deploy()
+        super(LinuxPing, self).do_deploy()
 
     @property
     def _start_command(self):
         args = []
 
+        args.append("echo 'Starting PING to %s' ;" % self.get("target"))
+
+        if self.get("printTimestamp") == True:
+            args.append("""echo "`date +'%Y%m%d%H%M%S'`";""")
+
+        args.append("ping ")
+        
         if self.get("count"):
             args.append("-c %s" % self.get("count"))
         if self.get("mark"):
@@ -207,8 +215,6 @@ class LinuxPing(LinuxApplication):
             args.append("-n")
         if self.get("pattern"):
             args.append("-p %s" % self.get("pattern"))
-        if self.get("printTimestamp") == True:
-            args.append("-D")
         if self.get("tos"):
             args.append("-Q %s" % self.get("tos"))
         if self.get("quiet"):
@@ -239,8 +245,7 @@ class LinuxPing(LinuxApplication):
             args.append("-W %s" % self.get("timeout"))
         args.append(self.get("target"))
 
-        command = " sudo -S ping "
-        command += " ".join(args)
+        command = " ".join(args)
 
         return command