-
Notifications
You must be signed in to change notification settings - Fork 664
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 CLI for configuring synchronous mode #1094
Changes from 1 commit
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/python | ||
import argparse | ||
from swsscommon import swsscommon | ||
|
||
def main(): | ||
parser=argparse.ArgumentParser(description= | ||
'Configure enable or disable synchronous mode between orchagent and syncd', | ||
formatter_class=argparse.RawTextHelpFormatter, | ||
epilog= | ||
''' | ||
sudo needed for configuring synchronous mode | ||
swss restart required to apply the configuration | ||
Options to restart swss and apply the configuration: | ||
1. config save | ||
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.
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. Added |
||
config reload -y | ||
2. systemctl restart swss | ||
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.
Do you need 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. This is not needed, updated the help message to clarify the usage. |
||
''') | ||
parser.add_argument('mode', metavar='[enable|disable]', type=str, | ||
help='Configure enable or disable synchronous mode') | ||
args = parser.parse_args() | ||
|
||
if args.mode == 'enable' or args.mode == 'disable': | ||
config_db = swsscommon.DBConnector('CONFIG_DB', 0, False) | ||
table = swsscommon.Table(config_db, 'DEVICE_METADATA') | ||
fvs = swsscommon.FieldValuePairs([('synchronous_mode', args.mode)]) | ||
table.set('localhost', fvs) | ||
print('Wrote %s synchronous mode into CONFIG_DB, swss restart required to apply the configuration'%(args.mode)) | ||
else: | ||
print('Invalid argument: expect either enable or disable') | ||
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.
print to stderr, and return with non zero error code. #Closed 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. Updated as prescribed. |
||
parser.print_help() | ||
|
||
if __name__ == '__main__': | ||
main() | ||
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.
Do you have a plan to integrate into 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. Integrated this into |
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.
Enable #Closed
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.
Fixed.