Skip to content

Commit

Permalink
Merge branch 'master' into db_migrator-general
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenxs authored Aug 10, 2020
2 parents e256e93 + fa7fb3a commit 488173d
Show file tree
Hide file tree
Showing 76 changed files with 1,951 additions and 1,153 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ If this is a bug fix, make sure your description includes "closes #xxxx",
issue when the PR is merged.
If you are adding/modifying/removing any command or utility script, please also
make sure to add/modify/remove any unit tests from the sonic-utilities-tests
make sure to add/modify/remove any unit tests from the tests
directory as appropriate.
If you are modifying or removing an existing 'show', 'config' or 'sonic-clear'
Expand Down
12 changes: 5 additions & 7 deletions acl_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
import ipaddr
import json
import syslog
import tabulate
from natsort import natsorted
import sonic_device_util

import openconfig_acl
import tabulate
import pyangbind.lib.pybindJSON as pybindJSON
from swsssdk import ConfigDBConnector
from swsssdk import SonicV2Connector
from swsssdk import SonicDBConfig
from natsort import natsorted
from sonic_py_common import device_info
from swsssdk import ConfigDBConnector, SonicV2Connector, SonicDBConfig


def info(msg):
Expand Down Expand Up @@ -142,7 +140,7 @@ def __init__(self):

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

namespaces = sonic_device_util.get_all_namespaces()
namespaces = device_info.get_all_namespaces()
for front_asic_namespaces in namespaces['front_ns']:
self.per_npu_configdb[front_asic_namespaces] = ConfigDBConnector(use_unix_socket_path=True, namespace=front_asic_namespaces)
self.per_npu_configdb[front_asic_namespaces].connect()
Expand Down
2 changes: 1 addition & 1 deletion config/config_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(self, source="configDB", debug=False, allowTablesWithoutYang=True):
def __del__(self):
pass

def tablesWithoutYang(self):
def tablesWithOutYang(self):
'''
Return tables loaded in config for which YANG model does not exist.
Expand Down
48 changes: 48 additions & 0 deletions config/feature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import click

from utilities_common.cli import AbbreviationGroup, pass_db

#
# 'feature' group ('config feature ...')
#
@click.group(cls=AbbreviationGroup, name='feature', invoke_without_command=False)
def feature():
"""Configure features"""
pass

#
# 'state' command ('config feature state ...')
#
@feature.command('state', short_help="Enable/disable a feature")
@click.argument('name', metavar='<feature-name>', required=True)
@click.argument('state', metavar='<state>', required=True, type=click.Choice(["enabled", "disabled"]))
@pass_db
def feature_state(db, name, state):
"""Enable/disable a feature"""
state_data = db.cfgdb.get_entry('FEATURE', name)

if not state_data:
click.echo("Feature '{}' doesn't exist".format(name))
sys.exit(1)

db.cfgdb.mod_entry('FEATURE', name, {'state': state})

#
# 'autorestart' command ('config feature autorestart ...')
#
@feature.command(name='autorestart', short_help="Enable/disable autosrestart of a feature")
@click.argument('name', metavar='<feature-name>', required=True)
@click.argument('autorestart', metavar='<autorestart>', required=True, type=click.Choice(["enabled", "disabled"]))
@pass_db
def feature_autorestart(db, name, autorestart):
"""Enable/disable autorestart of a feature"""
feature_table = db.cfgdb.get_table('FEATURE')
if not feature_table:
click.echo("Unable to retrieve feature table from Config DB.")
sys.exit(1)

if not feature_table.has_key(name):
click.echo("Unable to retrieve feature '{}'".format(name))
sys.exit(1)

db.cfgdb.mod_entry('FEATURE', name, {'auto_restart': autorestart})
Loading

0 comments on commit 488173d

Please sign in to comment.