# Copyright (C) 2013 INRIA
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation;
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
class PlanetlabVroute(LinuxApplication):
_rtype = "planetlab::Vroute"
_help = "Creates a Vroute on a PlanetLab host"
- _backend = "planetlab"
+ _platform = "planetlab"
@classmethod
def _register_attributes(cls):
action = Attribute("action", "Either add or del",
allowed = ["add", "del"],
+ default = "add",
+ flags = Flags.Design)
+
+ prefix = Attribute("prefix", "IPv4 Prefix",
+ flags = Flags.Design)
+
+ nexthop = Attribute("nexthop", "IPv4 Address of the next hop",
flags = Flags.Design)
network = Attribute("network", "IPv4 Network Address",
flags = Flags.Design)
cls._register_attribute(action)
+ cls._register_attribute(prefix)
+ cls._register_attribute(nexthop)
cls._register_attribute(network)
def __init__(self, ec, guid):
def upload_sources(self):
# upload vif-creation python script
- pl_vroute = os.path.join(os.path.dirname(__file__), "scripts",
+ pl_vroute = os.path.join(os.path.dirname(__file__),
+ "scripts",
"pl-vroute.py")
self.node.upload(pl_vroute,
# Overwrite file every time.
# The stop.sh has the path to the socket, wich should change
# on every experiment run.
- super(PlanetlabVroute, self).upload_start_command(overwrite = True)
-
- (out, err), proc = self.execute_command(self.get("command"), blocking = True)
-
+ command = self.get("command")
+ shfile = os.path.join(self.app_home, "start.sh")
+ self.node.run_and_wait(command, self.run_home,
+ shfile=shfile,
+ overwrite=True)
+
def do_deploy(self):
if not self.tap or self.tap.state < ResourceState.PROVISIONED:
self.ec.schedule(self.reschedule_delay, self.deploy)
else:
msg = " Failed to execute command '%s'" % command
self.error(msg, out, err)
- raise RuntimeError, msg
+ raise RuntimeError(msg)
def do_stop(self):
command = ["sudo -S python ${SRC}/pl-vroute.py"]
command.append("-a %s" % self.get("action"))
command.append("-n %s" % self.get("network"))
- command.append("-p %s" % self.tap.get("prefix"))
+ command.append("-p %s" % self.get("prefix"))
command.append("-g %s" % self.tap.get("pointopoint"))
command.append("-f %s" % self.tap.get("deviceName"))
- return " ".join(command)
+ command = " ".join(command)
+
+ command = self.replace_paths(command)
+ return command
@property
def _stop_command(self):
command = ["sudo -S python ${SRC}/pl-vroute.py"]
command.append("-a %s" % "del")
command.append("-n %s" % self.get("network"))
- command.append("-p %s" % self.tap.get("prefix"))
- command.append("-g %s" % self.tap.get("pointopoint"))
+ command.append("-p %s" % self.get("prefix"))
+ command.append("-g %s" % self.get("nexthop"))
command.append("-f %s" % self.tap.get("deviceName"))
- return " ".join(command)
+ command = " ".join(command)
+
+ command = self.replace_paths(command)
+ return command
def valid_connection(self, guid):
# TODO: Validate!