blob: 0f7e32a598399b6a2c66a8b1c2727d3abdfed8f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
##############################################################################
# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import yaml
import netaddr
import os
import log as logging
LOG = logging.getLogger("net-recover-odl-l3")
config_path = os.path.join(os.path.dirname(__file__), "network.cfg")
def setup_bondings(bond_mappings):
print bond_mappings
def setup_ips_new(config):
LOG.info("setup_ips_new enter")
network = netaddr.IPNetwork(config["ip_settings"]["br-prv"]["cidr"])
# intf_name = config["provider_net_mappings"][0]["interface"]
cmd = "ip link set br-ex up;"
cmd += "ip addr add %s/%s brd %s dev %s;" \
% (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), 'br-ex') # noqa
cmd += "route del default;"
cmd += "ip route add default via %s dev %s" % (
config["ip_settings"]["br-prv"]["gw"], 'br-ex')
LOG.info("setup_ips_new: cmd=%s" % cmd)
os.system(cmd)
def main(config):
setup_ips_new(config)
if __name__ == "__main__":
os.system("service openvswitch-switch status|| service openvswitch-switch start") # noqa
config = yaml.load(open(config_path))
main(config)
|