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

Add CLI for configuring synchronous mode #1094

Merged
merged 4 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
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
33 changes: 33 additions & 0 deletions scripts/sonic-sync-mode
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',
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 4, 2020

Choose a reason for hiding this comment

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

Configure enable [](start = 11, length = 16)

Enable #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

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
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 4, 2020

Choose a reason for hiding this comment

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

config save [](start = 7, length = 11)

config save also has -y. Do you want using? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added -y in the comment

config reload -y
2. systemctl restart swss
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 4, 2020

Choose a reason for hiding this comment

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

systemctl restart swss [](start = 7, length = 22)

Do you need config save before restart? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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')
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 4, 2020

Choose a reason for hiding this comment

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

print [](start = 8, length = 5)

print to stderr, and return with non zero error code. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated as prescribed.

parser.print_help()

if __name__ == '__main__':
main()
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 4, 2020

Choose a reason for hiding this comment

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

main [](start = 4, length = 4)

Do you have a plan to integrate into config CLI? Need a design doc. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Integrated this into config CLI.

1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
'scripts/route_check.py',
'scripts/route_check_test.sh',
'scripts/sfpshow',
'scripts/sonic-sync-mode',
'scripts/syseeprom-to-json',
'scripts/tempershow',
'scripts/update_json.py',
Expand Down