Skip to content

Commit

Permalink
[config and sonic-installer] Support bgp admin state preserving (soni…
Browse files Browse the repository at this point in the history
…c-net#66)

* [sonic-installer] cp all config instead of only minigraph
* [config] Modify bgp admin state when calling config bgp
  • Loading branch information
taoyl-ms authored Jun 20, 2017
1 parent a215c47 commit 0ad5280
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion config/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/sbin/env python

import sys
import os
import click
import json
Expand Down Expand Up @@ -118,7 +119,12 @@ def neighbor(ipaddr_or_hostname):

command = "vtysh -c 'configure terminal' -c 'router bgp {}' -c 'neighbor {} shutdown'".format(bgp_asn, ipaddress)
run_command(command)

# Remove existing item in bgp_admin.yml about the admin state of this neighbor
command = 'sed -i "/^\s*{}:/d" /etc/sonic/bgp_admin.yml'.format(ipaddress)
run_command(command)
# and add a new line mark it as off
command = 'echo " {}: off" >> /etc/sonic/bgp_admin.yml'.format(ipaddress)
run_command(command)

@bgp.group()
def startup():
Expand All @@ -145,6 +151,12 @@ def neighbor(ipaddr_or_hostname):

command = "vtysh -c 'configure terminal' -c 'router bgp {}' -c 'no neighbor {} shutdown'".format(bgp_asn, ipaddress)
run_command(command)
# Remove existing item in bgp_admin.yml about the admin state of this neighbor
command = 'sed -i "/^\s*{}:/d" /etc/sonic/bgp_admin.yml'.format(ipaddress)
run_command(command)
# and add a new line mark it as on
command = 'echo " {}: on" >> /etc/sonic/bgp_admin.yml'.format(ipaddress)
run_command(command)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion sonic_installer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def install(url):
else:
os.chmod(image_path, stat.S_IXUSR)
run_command(image_path)
run_command("cp /etc/sonic/minigraph.xml /host/")
run_command("cp -r /etc/sonic /host/old_config")
run_command('grub-set-default --boot-directory=' + HOST_PATH + ' 0')
click.echo('Done')

Expand Down

0 comments on commit 0ad5280

Please sign in to comment.