Skip to content

Commit b77f2ac

Browse files
committed
Merge remote-tracking branch 'arlakshm/master' into masic_teamshow
2 parents 194b619 + 8768580 commit b77f2ac

File tree

118 files changed

+6259
-3331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+6259
-3331
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ If this is a bug fix, make sure your description includes "closes #xxxx",
99
issue when the PR is merged.
1010
1111
If you are adding/modifying/removing any command or utility script, please also
12-
make sure to add/modify/remove any unit tests from the sonic-utilities-tests
12+
make sure to add/modify/remove any unit tests from the tests
1313
directory as appropriate.
1414
1515
If you are modifying or removing an existing 'show', 'config' or 'sonic-clear'

acl_loader/main.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
import ipaddr
55
import json
66
import syslog
7-
import tabulate
8-
from natsort import natsorted
9-
import sonic_device_util
107

118
import openconfig_acl
9+
import tabulate
1210
import pyangbind.lib.pybindJSON as pybindJSON
13-
from swsssdk import ConfigDBConnector
14-
from swsssdk import SonicV2Connector
15-
from swsssdk import SonicDBConfig
11+
from natsort import natsorted
12+
from sonic_py_common import device_info
13+
from swsssdk import ConfigDBConnector, SonicV2Connector, SonicDBConfig
1614

1715

1816
def info(msg):
@@ -142,7 +140,7 @@ def __init__(self):
142140

143141
# Getting all front asic namespace and correspding config and state DB connector
144142

145-
namespaces = sonic_device_util.get_all_namespaces()
143+
namespaces = device_info.get_all_namespaces()
146144
for front_asic_namespaces in namespaces['front_ns']:
147145
self.per_npu_configdb[front_asic_namespaces] = ConfigDBConnector(use_unix_socket_path=True, namespace=front_asic_namespaces)
148146
self.per_npu_configdb[front_asic_namespaces].connect()

config/aaa.py

+8-19
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
import click
5-
import netaddr
6-
from swsssdk import ConfigDBConnector
7-
8-
9-
def is_ipaddress(val):
10-
if not val:
11-
return False
12-
try:
13-
netaddr.IPAddress(str(val))
14-
except ValueError:
15-
return False
16-
return True
175

6+
from swsssdk import ConfigDBConnector
7+
import utilities_common.cli as clicommon
188

199
def add_table_kv(table, entry, key, val):
2010
config_db = ConfigDBConnector()
@@ -31,7 +21,6 @@ def del_table_key(table, entry, key):
3121
del data[key]
3222
config_db.set_entry(table, entry, data)
3323

34-
3524
@click.group()
3625
def aaa():
3726
"""AAA command line"""
@@ -81,7 +70,7 @@ def fallback(option):
8170
def login(auth_protocol):
8271
"""Switch login authentication [ {tacacs+, local} | default ]"""
8372
if len(auth_protocol) is 0:
84-
print 'Not support empty argument'
73+
click.echo('Argument "auth_protocol" is required')
8574
return
8675

8776
if 'default' in auth_protocol:
@@ -118,7 +107,7 @@ def timeout(ctx, second):
118107
elif second:
119108
add_table_kv('TACPLUS', 'global', 'timeout', second)
120109
else:
121-
click.echo('Not support empty argument')
110+
click.echo('Argument "second" is required')
122111
tacacs.add_command(timeout)
123112
default.add_command(timeout)
124113

@@ -133,7 +122,7 @@ def authtype(ctx, type):
133122
elif type:
134123
add_table_kv('TACPLUS', 'global', 'auth_type', type)
135124
else:
136-
click.echo('Not support empty argument')
125+
click.echo('Argument "type" is required')
137126
tacacs.add_command(authtype)
138127
default.add_command(authtype)
139128

@@ -148,7 +137,7 @@ def passkey(ctx, secret):
148137
elif secret:
149138
add_table_kv('TACPLUS', 'global', 'passkey', secret)
150139
else:
151-
click.echo('Not support empty argument')
140+
click.echo('Argument "secret" is required')
152141
tacacs.add_command(passkey)
153142
default.add_command(passkey)
154143

@@ -164,7 +153,7 @@ def passkey(ctx, secret):
164153
@click.option('-m', '--use-mgmt-vrf', help="Management vrf, default is no vrf", is_flag=True)
165154
def add(address, timeout, key, auth_type, port, pri, use_mgmt_vrf):
166155
"""Specify a TACACS+ server"""
167-
if not is_ipaddress(address):
156+
if not clicommon.is_ipaddress(address):
168157
click.echo('Invalid ip address')
169158
return
170159

@@ -196,7 +185,7 @@ def add(address, timeout, key, auth_type, port, pri, use_mgmt_vrf):
196185
@click.argument('address', metavar='<ip_address>')
197186
def delete(address):
198187
"""Delete a TACACS+ server"""
199-
if not is_ipaddress(address):
188+
if not clicommon.is_ipaddress(address):
200189
click.echo('Invalid ip address')
201190
return
202191

config/config_mgmt.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(self, source="configDB", debug=False, allowTablesWithoutYang=True):
8383
def __del__(self):
8484
pass
8585

86-
def tablesWithoutYang(self):
86+
def tablesWithOutYang(self):
8787
'''
8888
Return tables loaded in config for which YANG model does not exist.
8989

config/feature.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import click
2+
3+
from utilities_common.cli import AbbreviationGroup, pass_db
4+
5+
#
6+
# 'feature' group ('config feature ...')
7+
#
8+
@click.group(cls=AbbreviationGroup, name='feature', invoke_without_command=False)
9+
def feature():
10+
"""Configure features"""
11+
pass
12+
13+
#
14+
# 'state' command ('config feature state ...')
15+
#
16+
@feature.command('state', short_help="Enable/disable a feature")
17+
@click.argument('name', metavar='<feature-name>', required=True)
18+
@click.argument('state', metavar='<state>', required=True, type=click.Choice(["enabled", "disabled"]))
19+
@pass_db
20+
def feature_state(db, name, state):
21+
"""Enable/disable a feature"""
22+
state_data = db.cfgdb.get_entry('FEATURE', name)
23+
24+
if not state_data:
25+
click.echo("Feature '{}' doesn't exist".format(name))
26+
sys.exit(1)
27+
28+
db.cfgdb.mod_entry('FEATURE', name, {'state': state})
29+
30+
#
31+
# 'autorestart' command ('config feature autorestart ...')
32+
#
33+
@feature.command(name='autorestart', short_help="Enable/disable autosrestart of a feature")
34+
@click.argument('name', metavar='<feature-name>', required=True)
35+
@click.argument('autorestart', metavar='<autorestart>', required=True, type=click.Choice(["enabled", "disabled"]))
36+
@pass_db
37+
def feature_autorestart(db, name, autorestart):
38+
"""Enable/disable autorestart of a feature"""
39+
feature_table = db.cfgdb.get_table('FEATURE')
40+
if not feature_table:
41+
click.echo("Unable to retrieve feature table from Config DB.")
42+
sys.exit(1)
43+
44+
if not feature_table.has_key(name):
45+
click.echo("Unable to retrieve feature '{}'".format(name))
46+
sys.exit(1)
47+
48+
db.cfgdb.mod_entry('FEATURE', name, {'auto_restart': autorestart})

0 commit comments

Comments
 (0)