Skip to content

Commit 261a29e

Browse files
committed
Add options to configure new NTP servers
When adding new NTP servers via the CLI, allow options such as iburst, version, and the association type to be specified. Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
1 parent 319f58d commit 261a29e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

config/main.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -7055,8 +7055,11 @@ def ntp(ctx):
70557055

70567056
@ntp.command('add')
70577057
@click.argument('ntp_ip_address', metavar='<ntp_ip_address>', required=True)
7058+
@click.option('--association-type', type=click.Choice(["server", "pool"], case_sensitive=False), default="server", help="Define the association type for this NTP server")
7059+
@click.option('--iburst', is_flag=True, help="Enable iburst for this NTP server")
7060+
@click.option('--version', type=int, help="Specify the version for this NTP server")
70587061
@click.pass_context
7059-
def add_ntp_server(ctx, ntp_ip_address):
7062+
def add_ntp_server(ctx, ntp_ip_address, association_type, iburst, version):
70607063
""" Add NTP server IP """
70617064
if ADHOC_VALIDATION:
70627065
if not clicommon.is_ipaddress(ntp_ip_address):
@@ -7067,10 +7070,15 @@ def add_ntp_server(ctx, ntp_ip_address):
70677070
click.echo("NTP server {} is already configured".format(ntp_ip_address))
70687071
return
70697072
else:
7073+
ntp_server_options = {}
7074+
if version:
7075+
ntp_server_options['version'] = version
7076+
if association_type != "server":
7077+
ntp_server_options['association_type'] = association_type
7078+
if iburst:
7079+
ntp_server_options['iburst'] = "on"
70707080
try:
7071-
db.set_entry('NTP_SERVER', ntp_ip_address,
7072-
{'resolve_as': ntp_ip_address,
7073-
'association_type': 'server'})
7081+
db.set_entry('NTP_SERVER', ntp_ip_address, ntp_server_options)
70747082
except ValueError as e:
70757083
ctx.fail("Invalid ConfigDB. Error: {}".format(e))
70767084
click.echo("NTP server {} added to configuration".format(ntp_ip_address))

0 commit comments

Comments
 (0)