Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving get_routing_stack() to a centralized location to avoid code dups #1714

Merged
merged 2 commits into from
Aug 7, 2018
Merged
Changes from all commits
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
23 changes: 22 additions & 1 deletion src/sonic-config-engine/sonic_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_system_mac():
proc = subprocess.Popen("ip link show eth0 | grep ether | awk '{print $2}'", shell=True, stdout=subprocess.PIPE)
(mac, err) = proc.communicate()
mac = mac.strip()

# Align last byte of MAC if necessary
version_info = get_sonic_version_info()
if version_info and (version_info['asic_type'] == 'mellanox' or version_info['asic_type'] == 'centec'):
Expand All @@ -53,3 +53,24 @@ def get_system_mac():
mac = mac[:-2] + aligned_last_byte
return mac

#
# Function to obtain the routing-stack being utilized. Function is not
# platform-specific; it's being placed in this file temporarily till a more
# suitable location is identified as part of upcoming refactoring efforts.
#
def get_system_routing_stack():
command = "sudo docker ps | grep bgp | awk '{print$2}' | cut -d'-' -f3 | cut -d':' -f1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

ps | grep [](start = 27, length = 9)

pgrep


try:
proc = subprocess.Popen(command,
stdout=subprocess.PIPE,
shell=True,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
result = stdout.rstrip('\n')

except OSError, e:
raise OSError("Cannot detect routing-stack")

return result