--- /dev/null
+#!/usr/bin/env python
+#
+# NEPI, a framework to manage network experiments
+# 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.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+
+# THIS IS A MAINTAINANCE SCRIPT!
+# Use this script only if you are getting the following error when using yum:
+#
+# Error: Cannot retrieve repository metadata (repomd.xml) for repository: fedora. Please verify its path and try again
+
+# Example of how to run this experiment (replace with your information):
+#
+# $ cd <path-to-nepi>
+# python examples/planetlab/update_fedora_repo.py -H <host1,host2,..> -s <pl-slice> -u <pl-user> -p <pl-password> -k <pl-ssh-key>
+
+from nepi.execution.ec import ExperimentController
+
+from optparse import OptionParser, SUPPRESS_HELP
+import os
+
+pl_slice = os.environ.get("PL_SLICE")
+pl_user = os.environ.get("PL_USER")
+pl_pass = os.environ.get("PL_PASS")
+identity = os.environ.get("PL_SSHKEY")
+
+usage = ("usage: %prog -H <hosts> -s <pl-slice> -u <pl-user> -p <pl-password> "
+ "-k <pl-ssh-key>")
+
+parser = OptionParser(usage = usage)
+parser.add_option("-H", "--hosts", dest="hosts",
+ help="Comma separated list of PlanetLab host to update", type="str")
+parser.add_option("-s", "--pl-slice", dest="pl_slice",
+ help="PlanetLab slicename", type="str", default=pl_slice)
+parser.add_option("-u", "--pl-user", dest="pl_user",
+ help="PlanetLab web username", type="str", default=pl_user)
+parser.add_option("-p", "--pl-password", dest="pl_password",
+ help="PlanetLab web password", type="str", default=pl_pass)
+parser.add_option("-k", "--pl-ssh-key", dest="pl_ssh_key",
+ help="Path to private SSH key associated with the PL account",
+ type="str", default=identity)
+
+(options, args) = parser.parse_args()
+
+proceed = raw_input ("Executing this script will modify the fedora yum repositories in the selected PlanetLab hosts. Are you sure to continue? [y/N] ")
+if proceed.lower() not in ['yes', 'y']:
+ os._exit(1)
+
+pl_slice = options.pl_slice
+pl_ssh_key = options.pl_ssh_key
+pl_user = options.pl_user
+pl_password = options.pl_password
+hosts = options.hosts
+
+hosts = map(str.strip, hosts.split(","))
+apps = []
+
+## Create the experiment controller
+ec = ExperimentController(exp_id = "pl_update_fedora_repo")
+
+for hostname in hosts:
+ # Register a Planetlab Node with no restrictions, it can be any node
+ node = ec.register_resource("planetlab::Node")
+ # The username in this case is the slice name, the one to use for login in
+ # via ssh into PlanetLab nodes. Replace with your own slice name.
+ ec.set(node, "hostname", hostname)
+ ec.set(node, "username", pl_slice)
+ ec.set(node, "identity", pl_ssh_key)
+ # The pluser and plpassword are the ones used to login in the PlanetLab web
+ # site. Replace with your own user and password account information.
+ ec.set(node, "pluser", pl_user)
+ ec.set(node, "plpassword", pl_password)
+ # Remove previous results
+ ec.set(node, "cleanExperiment", True)
+ ec.set(node, "cleanProcesses", True)
+
+ # Application to update fedora.repo
+ path_to_repo = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ "fedora.repo")
+
+ app = ec.register_resource("linux::Application")
+ ec.set(app, "sources", path_to_repo)
+ ec.set(app, "sudo", True)
+ ec.set(app, "command",
+ "cp /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/fedora.repo.old; "
+ "cp ${SRC}/fedora.repo /etc/yum.repos.d/fedora.repo")
+ ec.register_connection(node, app)
+
+ apps.append(app)
+
+ # Application to update fedora.repo
+ path_to_repo = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ "fedora-updates.repo")
+
+ app = ec.register_resource("linux::Application")
+ ec.set(app, "sources", path_to_repo)
+ ec.set(app, "sudo", True)
+ ec.set(app, "command",
+ "cp /etc/yum.repos.d/fedora-updates.repo /etc/yum.repos.d/fedora-updates.repo.old; "
+ "cp ${SRC}/fedora-updates.repo /etc/yum.repos.d/fedora-updates.repo")
+ ec.register_connection(node, app)
+
+ apps.append(app)
+
+
+ec.deploy()
+
+ec.wait_finished(apps)
+
+for app in apps:
+ print ec.trace(app, "stderr")
+
+ec.shutdown()
+