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 as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
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.
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/>.
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
21 from optparse import OptionParser, SUPPRESS_HELP
24 usage = ("usage: %prog -a <action> -n <ip4-network> -p <ip4-prefix> "
25 "-g <gateway> -f <if-name-file>")
27 parser = OptionParser(usage = usage)
29 parser.add_option("-a", "--action", dest="action",
30 help = "Either add or del ", type="str")
32 parser.add_option("-n", "--ip4-network-address", dest="ip4_network",
33 help = "IPv4 address of the network ", type="str")
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. ",
40 parser.add_option("-g", "--ip4-gateway", dest="ip4_gateway",
41 help="IPv4 address of the gateway")
43 parser.add_option("-f", "--if-name", dest="if_name",
44 help = "Interface name assigned by the OS", type="str")
46 (options, args) = parser.parse_args()
48 return (options.action, options.ip4_network, options.ip4_prefix,
49 options.ip4_gateway, options.if_name)
51 if __name__ == '__main__':
53 (action, ip4_network, ip4_prefix, ip4_gateway, if_name) = get_options()
54 vsys.vroute(action, ip4_network, ip4_prefix, ip4_gateway, if_name)