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

chg: dev: Add check for ops-switchd to be active #9

Merged
merged 1 commit into from
Jul 5, 2016
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
16 changes: 15 additions & 1 deletion lib/topology_docker_openswitch/openswitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from os.path import exists, split
from json import dumps, loads
from shlex import split as shsplit
from subprocess import check_call, check_output
from subprocess import check_call, check_output, call
from socket import AF_UNIX, SOCK_STREAM, socket, gethostname

import yaml
Expand Down Expand Up @@ -152,6 +152,10 @@ def cur_cfg_is_set():
except IndexError:
return 0

def ops_switchd_is_active():
is_active = call(["systemctl", "is-active", "switchd.service"])
return is_active == 0

def main():

if '-d' in argv:
Expand Down Expand Up @@ -196,6 +200,16 @@ def main():
else:
raise Exception('Timed out while waiting for switchd pid.')

logging.info('Waiting for ops-switchd to become active...')
for i in range(0, config_timeout):
if not ops_switchd_is_active():
sleep(0.1)
else:
break
else:
raise Exception('Timed out while waiting for ops-switchd '
'to become active.')

logging.info('Wait for final hostname...')
for i in range(0, config_timeout):
if gethostname() != 'switch':
Expand Down