04b42fab537a64509bef0efca6910a21e6d7b8fd
[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 as published by
7 #    the Free Software Foundation, either version 3 of the License, or
8 #    (at your option) any later version.
9 #
10 #    This program is distributed in the hope that it will be useful,
11 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #    GNU General Public License for more details.
14 #
15 #    You should have received a copy of the GNU General Public License
16 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 #
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
19
20 import vsys
21 from optparse import OptionParser, SUPPRESS_HELP
22
23 def get_options():
24     usage = ("usage: %prog -a <action> -n <ip4-network> -p <ip4-prefix> "
25         "-g <gateway> -f <if-name-file>")
26     
27     parser = OptionParser(usage = usage)
28
29     parser.add_option("-a", "--action", dest="action",
30         help = "Either add or del ", type="str")
31
32     parser.add_option("-n", "--ip4-network-address", dest="ip4_network",
33         help = "IPv4 address of the network ", type="str")
34
35     parser.add_option("-p", "--ip4-prefix", dest="ip4_prefix",
36         help = "IPv4 network prefix for the interface. It must be the one "
37             "given by the slice's vsys_vnet tag. ",
38         type="int")
39
40     parser.add_option("-g", "--ip4-gateway", dest="ip4_gateway",
41         help="IPv4 address of the gateway")
42
43     parser.add_option("-f", "--if-name", dest="if_name",
44         help = "Interface name assigned by the OS", type="str")
45
46     (options, args) = parser.parse_args()
47
48     return (options.action, options.ip4_network, options.ip4_prefix,
49             options.ip4_gateway, options.if_name)
50
51 if __name__ == '__main__':
52
53     (action, ip4_network, ip4_prefix, ip4_gateway, if_name) = get_options()
54     vsys.vroute(action, ip4_network, ip4_prefix, ip4_gateway, if_name)
55     
56