diff --git a/files/scripts/startup_tsa_tsb.py b/files/scripts/startup_tsa_tsb.py index 563a509184bf..5d0495ead601 100644 --- a/files/scripts/startup_tsa_tsb.py +++ b/files/scripts/startup_tsa_tsb.py @@ -48,14 +48,14 @@ def get_tsa_config(asic_ns): def get_tsa_status(num_asics): if num_asics > 1: counter = 0 - for asic_id in range(int(asic_num)): + for asic_id in range(int(num_asics)): asic_ns = 'asic{}'.format(asic_id) sub_role = get_sub_role(asic_ns) if sub_role == 'FrontEnd': tsa_enabled = get_tsa_config(asic_ns) if tsa_enabled == 'false': counter += 1 - if counter == int(asic_num): + if counter == int(num_asics): return True; else: tsa_enabled = get_tsa_config("") diff --git a/platform/broadcom/platform-modules-nokia.mk b/platform/broadcom/platform-modules-nokia.mk index 52f08a91a5f2..6a355d17b3aa 100644 --- a/platform/broadcom/platform-modules-nokia.mk +++ b/platform/broadcom/platform-modules-nokia.mk @@ -12,7 +12,7 @@ $(NOKIA_IXR7250_PLATFORM_MODULE)_PLATFORM = x86_64-nokia_ixr7250e_sup-r0 $(NOKIA_IXR7250_PLATFORM_MODULE)_PLATFORM += x86_64-nokia_ixr7250e_36x400g-r0 SONIC_DPKG_DEBS += $(NOKIA_IXR7250_PLATFORM_MODULE) -NDK_VERSION = 22.9.25 +NDK_VERSION = 22.9.26 NOKIA_NDK_DEBIAN = ndk_$(NDK_VERSION)_amd64.deb $(NOKIA_NDK_DEBIAN)_URL = "https://github.com/Nokia-ION/ndk-releases/releases/download/v$(NDK_VERSION)/$(NOKIA_NDK_DEBIAN)" SONIC_ONLINE_DEBS += $(NOKIA_NDK_DEBIAN) diff --git a/src/sonic-config-engine/portconfig.py b/src/sonic-config-engine/portconfig.py index e0fb8253a797..f1bb80460e34 100644 --- a/src/sonic-config-engine/portconfig.py +++ b/src/sonic-config-engine/portconfig.py @@ -72,12 +72,7 @@ def db_connect_configdb(namespace=None): """ Connect to configdb """ - try: - if namespace is not None: - swsscommon.SonicDBConfig.load_sonic_global_db_config(namespace=namespace) - config_db = swsscommon.ConfigDBConnector(use_unix_socket_path=True, namespace=namespace) - except Exception as e: - return None + config_db = swsscommon.ConfigDBConnector(use_unix_socket_path=True, namespace=namespace) if config_db is None: return None try: diff --git a/src/sonic-config-engine/sonic-cfggen b/src/sonic-config-engine/sonic-cfggen index 0e53e6309325..4fd5bc2763db 100755 --- a/src/sonic-config-engine/sonic-cfggen +++ b/src/sonic-config-engine/sonic-cfggen @@ -31,7 +31,7 @@ from config_samples import generate_sample_config, get_available_config from functools import partial from minigraph import minigraph_encoder, parse_xml, parse_device_desc_xml, parse_asic_sub_role, parse_asic_switch_type from portconfig import get_port_config, get_breakout_mode -from sonic_py_common.multi_asic import get_asic_id_from_name, get_asic_device_id +from sonic_py_common.multi_asic import get_asic_id_from_name, get_asic_device_id, is_multi_asic from sonic_py_common import device_info from swsscommon.swsscommon import ConfigDBConnector, SonicDBConfig, ConfigDBPipeConnector @@ -137,6 +137,14 @@ def ip_network(value): return "Invalid ip address %s" % value return r_v.network +def load_namespace_config(): + if is_multi_asic(): + if not SonicDBConfig.isGlobalInit(): + SonicDBConfig.initializeGlobalConfig() + else: + if not SonicDBConfig.isInit(): + SonicDBConfig.initialize() + class FormatConverter: """Convert config DB based schema to legacy minigraph based schema for backward capability. We will move to DB schema and remove this class when the config templates are modified. @@ -301,6 +309,7 @@ def main(): deep_update(data, hardware_data) if args.port_config is None: args.port_config = device_info.get_path_to_port_config_file(hwsku) + load_namespace_config() (ports, _, _) = get_port_config(hwsku, platform, args.port_config, asic_id) if ports is None: print('Failed to get port config', file=sys.stderr) @@ -326,6 +335,7 @@ def main(): if args.minigraph is not None: minigraph = args.minigraph + load_namespace_config() if platform: if args.port_config is not None: deep_update(data, parse_xml(minigraph, platform, args.port_config, asic_name=asic_name, hwsku_config_file=args.hwsku_config)) @@ -353,7 +363,7 @@ def main(): if args.namespace is None: configdb = ConfigDBPipeConnector(use_unix_socket_path=use_unix_sock, **db_kwargs) else: - SonicDBConfig.load_sonic_global_db_config(namespace=args.namespace) + load_namespace_config() configdb = ConfigDBPipeConnector(use_unix_socket_path=use_unix_sock, namespace=args.namespace, **db_kwargs) configdb.connect() @@ -425,7 +435,7 @@ def main(): if args.namespace is None: configdb = ConfigDBPipeConnector(use_unix_socket_path=True, **db_kwargs) else: - SonicDBConfig.load_sonic_global_db_config(namespace=args.namespace) + load_namespace_config() configdb = ConfigDBPipeConnector(use_unix_socket_path=True, namespace=args.namespace, **db_kwargs) configdb.connect(False) diff --git a/src/sonic-utilities b/src/sonic-utilities index c6ac5556f3fa..26f49f4d72c3 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit c6ac5556f3faa693b5d545b54fdc8c0d00b2eb3c +Subproject commit 26f49f4d72c3687cb033947ac8507c13f4fcaf46 diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index bda1af49ed93..da6f1e2173ea 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -20,6 +20,7 @@ Table of Contents * [Cable length](#cable-length) * [Chassis module](#chassis-module) * [COPP_TABLE](#copp_table) + * [Console](#console) * [CRM](#crm) * [Data Plane L3 Interfaces](#data-plane-l3-interfaces) * [DEFAULT_LOSSLESS_BUFFER_PARAMETER](#DEFAULT_LOSSLESS_BUFFER_PARAMETER) @@ -51,7 +52,8 @@ Table of Contents * [Scheduler](#scheduler) * [Port QoS Map](#port-qos-map) * [Queue](#queue) - * [Sflow](#sflow) + * [Sflow](#sflow) + * [Restapi](#restapi) * [Tacplus Server](#tacplus-server) * [TC to Priority group map](#tc-to-priority-group-map) * [TC to Queue map](#tc-to-queue-map) @@ -714,6 +716,29 @@ It currently allows user to administratively bring down a line-card or fabric-ca } ``` +### Console + +``` +{ +"CONSOLE_PORT": { + "1": { + "baud_rate": "115200", + "flow_control": "0", + "remote_device": "host-1" + }, + "2": { + "baud_rate": "9600", + "flow_control": "1" + } + }, +"CONSOLE_SWITCH": { + "console_mgmt": { + "enabled": "yes" + } + } +} +``` + ### CRM ``` @@ -1509,6 +1534,25 @@ name as object key and member list as attribute. } ``` +### Restapi +``` +{ +"RESTAPI": { + "certs": { + "ca_crt": "/etc/sonic/credentials/ame_root.pem", + "server_key": "/etc/sonic/credentials/restapiserver.key", + "server_crt": "/etc/sonic/credentials/restapiserver.crt", + "client_crt_cname": "client.sonic.net" + }, + "config": { + "client_auth": "true", + "log_level": "trace", + "allow_insecure": "false" + } +} + +``` + ### Sflow The below are the tables and their schema for SFLOW feature diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 0dbbd91154aa..986a5635c548 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -99,6 +99,7 @@ def run(self): './yang-models/sonic-cable-length.yang', './yang-models/sonic-chassis-module.yang', './yang-models/sonic-copp.yang', + './yang-models/sonic-console.yang', './yang-models/sonic-crm.yang', './yang-models/sonic-default-lossless-buffer-parameter.yang', './yang-models/sonic-device_metadata.yang', @@ -130,6 +131,7 @@ def run(self): './yang-models/sonic-policer.yang', './yang-models/sonic-portchannel.yang', './yang-models/sonic-pfcwd.yang', + './yang-models/sonic-restapi.yang', './yang-models/sonic-route-common.yang', './yang-models/sonic-route-map.yang', './yang-models/sonic-routing-policy-sets.yang', diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 93fe09c0ca59..c2d76a7ded5e 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1122,6 +1122,19 @@ "lanes": "1" } }, + "RESTAPI": { + "certs": { + "ca_crt": "/etc/sonic/credentials/ame_root.pem", + "server_key": "/etc/sonic/credentials/restapiserver.key", + "server_crt": "/etc/sonic/credentials/restapiserver.crt", + "client_crt_cname": "client.sonic.net" + }, + "config": { + "client_auth": "true", + "log_level": "trace", + "allow_insecure": "false" + } + }, "FLEX_COUNTER_TABLE": { "PFCWD": { "FLEX_COUNTER_STATUS": "enable" @@ -2036,6 +2049,22 @@ "default_dynamic_th": "0", "over_subscribe_ratio": "0" } + }, + "CONSOLE_PORT": { + "1": { + "baud_rate": "115200", + "flow_control": "0", + "remote_device": "host-1" + }, + "2": { + "baud_rate": "9600", + "flow_control": "1" + } + }, + "CONSOLE_SWITCH": { + "console_mgmt": { + "enabled": "yes" + } } }, "SAMPLE_CONFIG_DB_UNKNOWN": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/console.json b/src/sonic-yang-models/tests/yang_model_tests/tests/console.json new file mode 100644 index 000000000000..cd305e4a2086 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/console.json @@ -0,0 +1,40 @@ +{ + "CONSOLE_DISABLED": { + "desc": "Verifying CONSOLE_SWITCH configuration." + }, + "CONSOLE_DEFAULT_CONSOLE_MGMT": { + "desc": "CONSOLE_SWITCH default value for console_mgmt enabled field.", + "eStrKey": "Verify", + "verify": { + "xpath": "/sonic-console:sonic-console/CONSOLE_SWITCH/console_mgmt/enabled", + "key": "sonic-console:enabled", + "value": "no" + } + }, + "CONSOLE_DISABLED_INCORRECT_PATTERN": { + "desc": "CONSOLE_SWITCH configuration pattern failure.", + "eStrKey": "Pattern" + }, + "CONSOLE_PORT_DEFAULT_FLOW_CONTROL": { + "desc": "CONSOLE_PORT default value for flow_control field.", + "eStrKey": "Verify", + "verify": { + "xpath": "/sonic-console:sonic-console/CONSOLE_PORT/CONSOLE_PORT_LIST[name='1']/flow_control", + "key": "sonic-console:flow_control", + "value": "0" + } + }, + "CONSOLE_PORT_INVALID_NAME": { + "desc": "CONSOLE_PORT invalid name failure.", + "eStrKey": "InvalidValue", + "eStr": ["name"] + }, + "CONSOLE_PORT_INVALID_BAUD": { + "desc": "CONSOLE_PORT invalid baud failure.", + "eStrKey": "InvalidValue", + "eStr": ["baud"] + }, + "CONSOLE_PORT_VALID": { + "desc": "Verifying CONSOLE_PORT configuration no failure." + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/restapi.json b/src/sonic-yang-models/tests/yang_model_tests/tests/restapi.json new file mode 100644 index 000000000000..42ce64ba330f --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/restapi.json @@ -0,0 +1,16 @@ +{ + "RESTAPI_TABLE_WITH_INCORRECT_CERT": { + "desc": "RESTAPI TABLE_WITH_INCORRECT_CERT failure.", + "eStr": ["Value", "does not satisfy the constraint"] + }, + "RESTAPI_TABLE_WITH_INCORRECT_CLIENT": { + "desc": "RESTAPI TABLE_WITH_INCORRECT_CLIENT failure.", + "eStr": ["Value", "does not satisfy the constraint"] + }, + "RESTAPI_TABLE_WITH_VALID_CONFIG": { + "desc": "RESTAPI TABLE WITH VALID CONFIG." + }, + "RESTAPI_TABLE_WITH_MULTIPLE_CERTS": { + "desc": "RESTAPI TABLE WITH MULTIPLE CERTS." + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/console.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/console.json new file mode 100644 index 000000000000..1ccfb4a3ae11 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/console.json @@ -0,0 +1,88 @@ +{ + "CONSOLE_DISABLED": { + "sonic-console:sonic-console": { + "sonic-console:CONSOLE_SWITCH": { + "sonic-console:console_mgmt": { + "enabled": "no" + } + } + } + }, + "CONSOLE_DEFAULT_CONSOLE_MGMT": { + "sonic-console:sonic-console": { + "sonic-console:CONSOLE_SWITCH": { + "sonic-console:console_mgmt": { + } + } + } + }, + "CONSOLE_DISABLED_INCORRECT_PATTERN": { + "sonic-console:sonic-console": { + "sonic-console:CONSOLE_SWITCH": { + "sonic-console:console_mgmt": { + "enabled": "false" + } + } + } + }, + "CONSOLE_PORT_DEFAULT_FLOW_CONTROL": { + "sonic-console:sonic-console": { + "sonic-console:CONSOLE_PORT": { + "CONSOLE_PORT_LIST": [ + { + "name": "1", + "baud_rate": "9600" + } + ] + } + } + }, + "CONSOLE_PORT_INVALID_NAME": { + "sonic-console:sonic-console": { + "sonic-console:CONSOLE_PORT": { + "CONSOLE_PORT_LIST": [ + { + "name": "invalid", + "baud_rate": "9600" + } + ] + } + } + }, + "CONSOLE_PORT_INVALID_BAUD": { + "sonic-console:sonic-console": { + "sonic-console:CONSOLE_PORT": { + "CONSOLE_PORT_LIST": [ + { + "name": "1", + "baud_rate": "invalid" + } + ] + } + } + }, + "CONSOLE_PORT_VALID": { + "sonic-console:sonic-console": { + "sonic-console:CONSOLE_PORT": { + "CONSOLE_PORT_LIST": [ + { + "name": "1", + "baud_rate": "9600", + "flow_control": "1", + "remote_device": "remote_host_1" + }, + { + "name": "2", + "baud_rate": "9600", + "flow_control": "0", + "remote_device": "remote_host_2" + }, + { + "name": "3", + "baud_rate": "9600" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/restapi.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/restapi.json new file mode 100644 index 000000000000..f2a3b15643c6 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/restapi.json @@ -0,0 +1,50 @@ +{ + "RESTAPI_TABLE_WITH_INCORRECT_CERT": { + "sonic-restapi:sonic-restapi": { + "sonic-restapi:RESTAPI": { + "certs": { + "ca_crt": "/etc/sonic/credentials/ame_root.pem", + "server_crt": "a/b/c", + "server_key": "/etc/sonic/credentials/restapiserver.key", + "client_crt_cname": "client" + } + } + } + }, + "RESTAPI_TABLE_WITH_INCORRECT_CLIENT": { + "sonic-restapi:sonic-restapi": { + "sonic-restapi:RESTAPI": { + "certs": { + "ca_crt": "/etc/sonic/credentials/ame_root.pem", + "server_crt": "/etc/sonic/credentials/restapiserver.crt", + "server_key": "/etc/sonic/credentials/restapiserver.key", + "client_crt_cname": "/client" + } + } + } + }, + "RESTAPI_TABLE_WITH_VALID_CONFIG": { + "sonic-restapi:sonic-restapi": { + "sonic-restapi:RESTAPI": { + "certs": { + "ca_crt": "/etc/sonic/credentials/ame_root.pem", + "server_crt": "/etc/sonic/credentials/restapiserver.crt", + "server_key": "/etc/sonic/credentials/restapiserver.key", + "client_crt_cname": "client.sonic.net" + } + } + } + }, + "RESTAPI_TABLE_WITH_MULTIPLE_CERTS": { + "sonic-restapi:sonic-restapi": { + "sonic-restapi:RESTAPI": { + "certs": { + "ca_crt": "/etc/sonic/credentials/ame_root.pem", + "server_crt": "/etc/sonic/credentials/restapiserver.crt", + "server_key": "/etc/sonic/credentials/restapiserver.key", + "client_crt_cname": "client.sonic.net,clientds.prod.net" + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-console.yang b/src/sonic-yang-models/yang-models/sonic-console.yang new file mode 100644 index 000000000000..341abaf8d26a --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-console.yang @@ -0,0 +1,76 @@ +module sonic-console { + yang-version 1.1; + namespace "http://github.com/sonic-net/sonic-console"; + prefix console; + + import sonic-types { + prefix stypes; + } + + description "SONiC CONSOLE"; + + revision 2022-08-22 { + description "First Revision"; + } + + typedef console-mgmt-enabled { + description "configuration to set if console switch is enabled or not"; + type string { + pattern "yes|no"; + } + } + + typedef console-flow-control { + description "configuration to set if enable flow control on a console port"; + type string { + pattern "0|1"; + } + } + + container sonic-console { + container CONSOLE_PORT { + description "CONSOLE_PORT part of config_db.json"; + + list CONSOLE_PORT_LIST { + key "name"; + + leaf name { + description "Configure console port name"; + type uint16; + } + + leaf baud_rate { + description "Configure baud rate"; + type uint32; + } + + leaf flow_control { + description "Configure if enable/disable flow control"; + type console-flow-control; + default "0"; + } + + leaf remote_device { + description "Configure the remote device name"; + type stypes:hostname; + } + } + + } /* end of container CONSOLE_PORT */ + + container CONSOLE_SWITCH { + description "CONSOLE_SWITCH part of config_db.json"; + + container console_mgmt { + leaf enabled { + description "This configuration indicate if enable console management feature on SONiC"; + type console-mgmt-enabled; + default "no"; + } + } + + } /* end of container CONSOLE_SWITCH */ + + } /* end of top level container */ + +} /* end of module sonic-console */ diff --git a/src/sonic-yang-models/yang-models/sonic-restapi.yang b/src/sonic-yang-models/yang-models/sonic-restapi.yang new file mode 100644 index 000000000000..094ed18eb7bd --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-restapi.yang @@ -0,0 +1,85 @@ +module sonic-restapi { + + yang-version 1.1; + + namespace "http://github.com/sonic-net/sonic-restapi"; + prefix restapi; + + import ietf-inet-types { + prefix inet; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description "RESTAPI YANG Module for SONiC OS"; + + revision 2022-10-05 { + description "First Revision"; + } + + container sonic-restapi { + + container RESTAPI { + + description "RESTAPI TABLE part of config_db.json"; + + container certs { + + leaf ca_crt { + type string { + pattern '(/[a-zA-Z0-9_-]+)*/([a-zA-Z0-9_-]+).([a-z]+)'; + } + description "Local path for ca_crt."; + } + + leaf server_crt { + type string { + pattern '(/[a-zA-Z0-9_-]+)*/([a-zA-Z0-9_-]+).crt'; + } + description "Local path for server_crt."; + } + + leaf client_crt_cname { + type string { + pattern '([a-zA-Z0-9_\-\.]+,)*([a-zA-Z0-9_\-\.]+)'; + } + description "Client cert name."; + } + + leaf server_key { + type string { + pattern '(/[a-zA-Z0-9_-]+)*/([a-zA-Z0-9_-]+).key'; + } + description "Local path for server_key."; + } + + } + + container config { + + leaf client_auth { + type boolean; + default true; + description "Enable client authentication"; + } + + leaf log_level { + type string { + pattern "trace|info"; + } + description "container log level for restapi"; + } + + leaf allow_insecure { + type boolean; + default false; + description "Allow insecure connection"; + } + } + } + } +}