README moves to markdown
[nepi.git] / src / nepi / resources / planetlab / scripts / pl-vroute.py
1 #
2 #    NEPI, a framework to manage network experiments
3 #    Copyright (C) 2013 INRIA
4 #
5 #    This program is free software: you can redistribute it and/or modify
6 #    it under the terms of the GNU General Public License version 2 as
7 #    published by the Free Software Foundation;
8 #
9 #    This program is distributed in the hope that it will be useful,
10 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #    GNU General Public License for more details.
13 #
14 #    You should have received a copy of the GNU General Public License
15 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 #
17 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
18
19 import vsys
20 from optparse import OptionParser, SUPPRESS_HELP
21
22 def get_options():
23     usage = ("usage: %prog -a <action> -n <ip4-network> -p <ip4-prefix> "
24         "-g <gateway> -f <if-name-file>")
25     
26     parser = OptionParser(usage = usage)
27
28     parser.add_option("-a", "--action", dest="action",
29         help = "Either add or del ", type="str")
30
31     parser.add_option("-n", "--ip4-network-address", dest="ip4_network",
32         help = "IPv4 address of the network ", type="str")
33
34     parser.add_option("-p", "--ip4-prefix", dest="ip4_prefix",
35         help = "IPv4 network prefix for the interface. It must be the one "
36             "given by the slice's vsys_vnet tag. ",
37         type="int")
38
39     parser.add_option("-g", "--ip4-gateway", dest="ip4_gateway",
40         help="IPv4 address of the gateway")
41
42     parser.add_option("-f", "--if-name", dest="if_name",
43         help = "Interface name assigned by the OS", type="str")
44
45     (options, args) = parser.parse_args()
46
47     return (options.action, options.ip4_network, options.ip4_prefix,
48             options.ip4_gateway, options.if_name)
49
50 if __name__ == '__main__':
51
52     (action, ip4_network, ip4_prefix, ip4_gateway, if_name) = get_options()
53     vsys.vroute(action, ip4_network, ip4_prefix, ip4_gateway, if_name)
54     
55