Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into syslog_telemetry_…
Browse files Browse the repository at this point in the history
…shared
  • Loading branch information
renukamanavalan committed Aug 18, 2022
2 parents ce3bcd8 + 46ebd06 commit 4743ca0
Show file tree
Hide file tree
Showing 13 changed files with 244 additions and 23 deletions.
2 changes: 1 addition & 1 deletion device/celestica/x86_64-cel_belgite-r0/installer.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CONSOLE_PORT=0x3f8
CONSOLE_DEV=0
CONSOLE_SPEED=9600
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off module_blacklist=gpio_ich crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog"
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off modprobe.blacklist=gpio_ich,i2c-ismt,i2c_ismt,i2c-i801,i2c_i801 crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog"
21 changes: 12 additions & 9 deletions files/scripts/gbsyncd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
. /usr/local/bin/syncd_common.sh

function startplatform() {
# Add gbsyncd to FEATURE table, if not in. It did have same config as syncd.
if [ -z $($SONIC_DB_CLI CONFIG_DB HGET 'FEATURE|gbsyncd' state) ]; then
local CMD="local r=redis.call('DUMP', KEYS[1]); redis.call('RESTORE', KEYS[2], 0, r)"
$SONIC_DB_CLI CONFIG_DB EVAL "$CMD" 2 'FEATURE|syncd' 'FEATURE|gbsyncd'
fi

declare -a DbCliArray=($SONIC_DB_CLI $SONIC_DB_NS_CLI)
for DB_CLI in ${DbCliArray[@]}; do
# Add gbsyncd to FEATURE table, if not in. It did have same config as syncd.
if [ -z $($DB_CLI CONFIG_DB HGET 'FEATURE|gbsyncd' state) ]; then
local CMD="local r=redis.call('DUMP', KEYS[1]); redis.call('RESTORE', KEYS[2], 0, r)"
$DB_CLI CONFIG_DB EVAL "$CMD" 2 'FEATURE|syncd' 'FEATURE|gbsyncd'
fi
done
}

function waitplatform() {
Expand All @@ -30,12 +34,11 @@ PEER="swss"
DEBUGLOG="/tmp/swss-$SERVICE-debug$DEV.log"
LOCKFILE="/tmp/swss-$SERVICE-lock$DEV"
NAMESPACE_PREFIX="asic"
SONIC_DB_CLI="sonic-db-cli"
SONIC_DB_NS_CLI="sonic-db-cli"
if [ "$DEV" ]; then
NET_NS="$NAMESPACE_PREFIX$DEV" #name of the network namespace
SONIC_DB_CLI="sonic-db-cli -n $NET_NS"
else
NET_NS=""
SONIC_DB_CLI="sonic-db-cli"
SONIC_DB_NS_CLI="sonic-db-cli -n $NET_NS"
fi

case "$1" in
Expand Down
2 changes: 1 addition & 1 deletion platform/broadcom/platform-modules-cel.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export CEL_BELGITE_PLATFORM_MODULE_VERSION

CEL_DX010_PLATFORM_MODULE = platform-modules-dx010_$(CEL_DX010_PLATFORM_MODULE_VERSION)_amd64.deb
$(CEL_DX010_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-cel
$(CEL_DX010_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
$(CEL_DX010_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) $(PDDF_PLATFORM_MODULE_SYM)
$(CEL_DX010_PLATFORM_MODULE)_PLATFORM = x86_64-cel_seastone-r0
SONIC_DPKG_DEBS += $(CEL_DX010_PLATFORM_MODULE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ Description: kernel modules for platform devices such as led, sfp.

Package: platform-modules-belgite
Architecture: amd64
Depends: linux-image-5.10.0-8-2-amd64-unsigned
Depends: linux-image-5.10.0-12-2-amd64-unsigned
Description: kernel modules for platform devices such as led, sfp
4 changes: 3 additions & 1 deletion platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
SX_PORT_MODULE_STATUS_UNPLUGGED = 2
SX_PORT_MODULE_STATUS_PLUGGED_WITH_ERROR = 3
SX_PORT_MODULE_STATUS_PLUGGED_DISABLED = 4
SX_PORT_ADMIN_STATUS_UP = True
SX_PORT_ADMIN_STATUS_DOWN = False
except KeyError:
pass

Expand Down Expand Up @@ -571,7 +573,7 @@ def _fetch_port_status(cls, sdk_handle, log_port):
@classmethod
def is_port_admin_status_up(cls, sdk_handle, log_port):
_, admin_state = cls._fetch_port_status(sdk_handle, log_port);
admin_state == SX_PORT_ADMIN_STATUS_UP
return admin_state == SX_PORT_ADMIN_STATUS_UP


@classmethod
Expand Down
8 changes: 8 additions & 0 deletions platform/mellanox/mlnx-platform-api/tests/test_sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,11 @@ def test_sfp_read_eeprom(self):
sfp = SFP(0)
assert output_sfp.y_cable_part_number == sfp.read_eeprom(offset, 16).decode()
MlxregManager.read_mlxred_eeprom.assert_called_with(132, 4, 16)

@mock.patch('sonic_platform.sfp.SFP._fetch_port_status')
def test_is_port_admin_status_up(self, mock_port_status):
mock_port_status.return_value = (0, True)
assert SFP.is_port_admin_status_up(None, None)

mock_port_status.return_value = (0, False)
assert not SFP.is_port_admin_status_up(None, None)
2 changes: 1 addition & 1 deletion src/linkmgrd
2 changes: 2 additions & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def run(self):
'./yang-models/sonic-route-map.yang',
'./yang-models/sonic-routing-policy-sets.yang',
'./yang-models/sonic-sflow.yang',
'./yang-models/sonic-snmp.yang',
'./yang-models/sonic-syslog.yang',
'./yang-models/sonic-system-aaa.yang',
'./yang-models/sonic-system-tacacs.yang',
Expand Down Expand Up @@ -190,6 +191,7 @@ def run(self):
'./cvlyang-models/sonic-route-map.yang',
'./cvlyang-models/sonic-routing-policy-sets.yang',
'./cvlyang-models/sonic-sflow.yang',
'./cvlyang-models/sonic-snmp.yang',
'./cvlyang-models/sonic-system-aaa.yang',
'./cvlyang-models/sonic-system-tacacs.yang',
'./cvlyang-models/sonic-telemetry.yang',
Expand Down
20 changes: 19 additions & 1 deletion src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1924,10 +1924,28 @@
]
}
},

"SNMP": {
"CONTACT": {
"Contact": "testuser@contoso.com"
},
"LOCATION": {
"Location": "SNMP Server Location"
}
},
"SNMP_COMMUNITY": {
"public": {
"TYPE": "RO"
},
"private": {
"TYPE": "RW"
}
},

"SYSTEM_DEFAULTS": {
"tunnel_qos_remap": {
"status": "enabled"
}
}
},
"LOSSLESS_TRAFFIC_PATTERN": {
"AZURE": {
Expand Down
28 changes: 28 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/snmp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"SNMP_SYSTEM_TEST": {
"desc": "Load SNMP sysContact and sysLocation."
},
"SNMP_SYSTEM_CONTACT_NEG_TEST": {
"desc": "Load SNMP sysContact with empty string",
"eStrKey": "Range"
},
"SNMP_SYSTEM_LOCATION_NEG_TEST": {
"desc": "Load SNMP sysContact with empty string",
"eStrKey": "Range"
},
"SNMP_COMMUNITY_TEST": {
"desc": "Load SNMP community string."
},
"SNMP_COMMUNITY_MIN_NEG_TEST": {
"desc": "Load SNMP community string of length < 3.",
"eStrKey": "Range"
},
"SNMP_COMMUNITY_MAX_NEG_TEST": {
"desc": "Load SNMP community string of lenth > 32.",
"eStrKey": "Range"
},
"SNMP_COMMUNITY_WRONG_TYPE_TEST": {
"desc": "Load SNMP community string with un supported type.",
"eStrKey": "InvalidValue"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"SNMP_SYSTEM_TEST": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP": {
"CONTACT": {
"Contact": "support@xyz.com"
},
"LOCATION": {
"Location": "Test location"
}
}
}
},
"SNMP_SYSTEM_CONTACT_NEG_TEST": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP": {
"CONTACT": {
"Contact": ""
}
}
}
},
"SNMP_SYSTEM_LOCATION_NEG_TEST": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP": {
"LOCATION": {
"Location": ""
}
}
}
},

"SNMP_COMMUNITY_TEST": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP_COMMUNITY": {
"SNMP_COMMUNITY_LIST": [
{
"name": "sonicSnmp",
"TYPE": "RO"
},
{
"name": "sonicSnmpRW",
"TYPE": "RW"
}
]
}
}
},
"SNMP_COMMUNITY_MIN_NEG_TEST": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP_COMMUNITY": {
"SNMP_COMMUNITY_LIST": [
{
"name": "abc"
}
]
}
}
},
"SNMP_COMMUNITY_MAX_NEG_TEST": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP_COMMUNITY": {
"SNMP_COMMUNITY_LIST": [
{
"name": "01234567890123456789012345678901234"
}
]
}
}
},
"SNMP_COMMUNITY_WRONG_TYPE_TEST": {
"sonic-snmp:sonic-snmp": {
"sonic-snmp:SNMP_COMMUNITY": {
"SNMP_COMMUNITY_LIST": [
{
"name": "sonicSnmp",
"TYPE": "RR"
}
]
}
}
}
}
74 changes: 74 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-snmp.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
module sonic-snmp {
namespace "http://github.com/Azure/sonic-snmp";
prefix ssnmp;
yang-version 1.1;


organization
"SONiC";

contact
"SONiC";

description
"SONIC SNMP";

revision 2022-05-13 {
description
"Initial revision.";
}


container sonic-snmp {

container SNMP {
container CONTACT {
leaf Contact {
type string {
length "1..255";
}
description
"SNMP System Contact.";
}
}
container LOCATION {
leaf Location {
type string {
length "1..255";
}
description
"SNMP System Location.";
}

}
}

container SNMP_COMMUNITY {
list SNMP_COMMUNITY_LIST {
key name;
description
"List of communities.";

leaf name {
type string {
length "4..32";
pattern '[^ @,\\' +"']*" {
error-message 'Invalid snmp community string (Valid chars are ASCII printable except SPACE, single quote,"@", "," and "\")';
}
}
description
"Index into the community list which must be the community name.";
}

leaf TYPE {
type enumeration {
enum RO;
enum RW;
}
description
"Type of community, read-only or read-write.";
}
}
}
}
}
19 changes: 11 additions & 8 deletions src/systemd-sonic-generator/systemd-sonic-generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ static int get_install_targets_from_line(char* target_string, char* install_type
***/
char* token;
char* target;
char* saveptr;
char final_target[PATH_MAX];
int num_targets = 0;

Expand All @@ -135,8 +136,8 @@ static int get_install_targets_from_line(char* target_string, char* install_type
strip_trailing_newline(target);

if (strstr(target, "%") != NULL) {
char* prefix = strtok(target, ".");
char* suffix = strtok(NULL, ".");
char* prefix = strtok_r(target, ".", &saveptr);
char* suffix = strtok_r(NULL, ".", &saveptr);
int prefix_len = strlen(prefix);

strncpy(final_target, prefix, prefix_len - 2);
Expand Down Expand Up @@ -516,6 +517,7 @@ int get_num_of_asic() {
char *line = NULL;
char* token;
char* platform;
char* saveptr;
size_t len = 0;
ssize_t nread;
bool ans;
Expand All @@ -534,8 +536,8 @@ int get_num_of_asic() {
while ((nread = getline(&line, &len, fp)) != -1) {
if ((strstr(line, "onie_platform") != NULL) ||
(strstr(line, "aboot_platform") != NULL)) {
token = strtok(line, "=");
platform = strtok(NULL, "=");
token = strtok_r(line, "=", &saveptr);
platform = strtok_r(NULL, "=", &saveptr);
strip_trailing_newline(platform);
break;
}
Expand All @@ -547,8 +549,8 @@ int get_num_of_asic() {
if (fp != NULL) {
while ((nread = getline(&line, &len, fp)) != -1) {
if (strstr(line, "NUM_ASIC") != NULL) {
token = strtok(line, "=");
str_num_asic = strtok(NULL, "=");
token = strtok_r(line, "=", &saveptr);
str_num_asic = strtok_r(NULL, "=", &saveptr);
strip_trailing_newline(str_num_asic);
if (str_num_asic != NULL){
sscanf(str_num_asic, "%d",&num_asic);
Expand All @@ -571,6 +573,7 @@ int ssg_main(int argc, char **argv) {
char* unit_instance;
char* prefix;
char* suffix;
char* saveptr;
int num_unit_files;
int num_targets;
int r;
Expand All @@ -589,8 +592,8 @@ int ssg_main(int argc, char **argv) {
for (int i = 0; i < num_unit_files; i++) {
unit_instance = strdup(unit_files[i]);
if ((num_asics == 1) && strstr(unit_instance, "@") != NULL) {
prefix = strtok(unit_instance, "@");
suffix = strtok(NULL, "@");
prefix = strtok_r(unit_instance, "@", &saveptr);
suffix = strtok_r(NULL, "@", &saveptr);

strcpy(unit_instance, prefix);
strcat(unit_instance, suffix);
Expand Down

0 comments on commit 4743ca0

Please sign in to comment.