2 # NEPI, a framework to manage network experiments
3 # Copyright (C) 2013 INRIA
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;
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.
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/>.
17 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20 from optparse import OptionParser, SUPPRESS_HELP
23 usage = ("usage: %prog -a <action> -n <ip4-network> -p <ip4-prefix> "
24 "-g <gateway> -f <if-name-file>")
26 parser = OptionParser(usage = usage)
28 parser.add_option("-a", "--action", dest="action",
29 help = "Either add or del ", type="str")
31 parser.add_option("-n", "--ip4-network-address", dest="ip4_network",
32 help = "IPv4 address of the network ", type="str")
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. ",
39 parser.add_option("-g", "--ip4-gateway", dest="ip4_gateway",
40 help="IPv4 address of the gateway")
42 parser.add_option("-f", "--if-name", dest="if_name",
43 help = "Interface name assigned by the OS", type="str")
45 (options, args) = parser.parse_args()
47 return (options.action, options.ip4_network, options.ip4_prefix,
48 options.ip4_gateway, options.if_name)
50 if __name__ == '__main__':
52 (action, ip4_network, ip4_prefix, ip4_gateway, if_name) = get_options()
53 vsys.vroute(action, ip4_network, ip4_prefix, ip4_gateway, if_name)