Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ def _is_neighbor_ipaddress(ipaddress):
"""
config_db = ConfigDBConnector()
config_db.connect()

# Convert the IP address to uppercase because IPv6 addresses are stored
# in ConfigDB with all uppercase alphabet characters
entry = config_db.get_entry('BGP_NEIGHBOR', ipaddress.upper())
entry = config_db.get_entry('BGP_NEIGHBOR', ipaddress)
return True if entry else False

def _get_all_neighbor_ipaddresses():
Expand Down Expand Up @@ -73,16 +70,17 @@ def _change_bgp_session_status_by_addr(ipaddress, status, verbose):
config_db = ConfigDBConnector()
config_db.connect()

# Convert the IP address to uppercase because IPv6 addresses are stored
# in ConfigDB with all uppercase alphabet characters
config_db.mod_entry('bgp_neighbor', ipaddress.upper(), {'admin_status': status})
config_db.mod_entry('bgp_neighbor', ipaddress, {'admin_status': status})

def _change_bgp_session_status(ipaddr_or_hostname, status, verbose):
"""Start up or shut down BGP session by IP address or hostname
"""
ip_addrs = []
if _is_neighbor_ipaddress(ipaddr_or_hostname):
ip_addrs.append(ipaddr_or_hostname)

# Convert the IP address to lowercase because IPv6 addresses will be stored
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change comment to If we were passed an IP address, convert it to lowercase because...

# in ConfigDB with all lowercase alphabet characters during minigraph parsing
if _is_neighbor_ipaddress(ipaddr_or_hostname.lower()):
ip_addrs.append(ipaddr_or_hostname.lower())
else:
# If <ipaddr_or_hostname> is not the IP address of a neighbor, check to see if it's a hostname
ip_addrs = _get_neighbor_ipaddress_list_by_hostname(ipaddr_or_hostname)
Expand Down