-
Notifications
You must be signed in to change notification settings - Fork 666
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
add support for MCLAG #453
Changes from all commits
946a02a
c7f65a0
2dcf086
758d033
3d6db7a
c8dd172
796786c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -313,6 +313,14 @@ def _abort_if_false(ctx, param, value): | |
if not value: | ||
ctx.abort() | ||
|
||
def _get_optional_services(): | ||
config_db = ConfigDBConnector() | ||
config_db.connect() | ||
optional_services_dict = config_db.get_table('FEATURE') | ||
if not optional_services_dict: | ||
return None | ||
return optional_services_dict.keys() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this function could return the entire dictionary, then the consumers below can determine whether or not to stop/start the service based on whether it is enabled or disabled in the DB, in conjunction with the result of running Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If out of sync I prefer the result from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jleveque any comment? If no could you approve this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am fine with this approach. I will approve the PR, but I would also like to get @lguohan's approval before merging. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks |
||
|
||
def _stop_services(): | ||
services_to_stop = [ | ||
'swss', | ||
|
@@ -331,6 +339,17 @@ def _stop_services(): | |
log_error("Stopping {} failed with error {}".format(service, e)) | ||
raise | ||
|
||
# For optional services they don't start by default | ||
for service in _get_optional_services(): | ||
(out, err) = run_command("systemctl status {}".format(service), return_output = True) | ||
if not err and 'Active: active (running)' in out: | ||
try: | ||
click.echo("Stopping service {} ...".format(service)) | ||
run_command("systemctl stop {}".format(service)) | ||
except SystemExit as e: | ||
log_error("Stopping {} failed with error {}".format(service, e)) | ||
raise | ||
|
||
def _reset_failed_services(): | ||
services_to_reset = [ | ||
'bgp', | ||
|
@@ -357,6 +376,17 @@ def _reset_failed_services(): | |
log_error("Failed to reset failed status for service {}".format(service)) | ||
raise | ||
|
||
# For optional services they don't start by default | ||
for service in _get_optional_services(): | ||
(out, err) = run_command("systemctl is-enabled {}".format(service), return_output = True) | ||
if not err and 'enabled' in out: | ||
try: | ||
click.echo("Resetting failed status for service {} ...".format(service)) | ||
run_command("systemctl reset-failed {}".format(service)) | ||
except SystemExit as e: | ||
log_error("Failed to reset failed status for service {}".format(service)) | ||
raise | ||
|
||
def _restart_services(): | ||
services_to_restart = [ | ||
'hostname-config', | ||
|
@@ -378,6 +408,17 @@ def _restart_services(): | |
log_error("Restart {} failed with error {}".format(service, e)) | ||
raise | ||
|
||
# For optional services they don't start by default | ||
for service in _get_optional_services(): | ||
(out, err) = run_command("systemctl is-enabled {}".format(service), return_output = True) | ||
if not err and 'enabled' in out: | ||
try: | ||
click.echo("Restarting service {} ...".format(service)) | ||
run_command("systemctl restart {}".format(service)) | ||
except SystemExit as e: | ||
log_error("Restart {} failed with error {}".format(service, e)) | ||
raise | ||
|
||
def is_ipaddress(val): | ||
""" Validate if an entry is a valid IP """ | ||
if not val: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shine4chen please fix a bug:
@qiluo-msft / @yxieca FYI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems github website has some error that we can't open PRs now. I will fix it after github service recover.