Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fwutil Auto-update support #1165

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
8bf63af
initial commit
sujinmkang Oct 9, 2020
8a3a278
second commit
sujinmkang Oct 12, 2020
a71c72b
[show] Add 'show' CLI for system-health feature (#971)
shlomibitton Oct 12, 2020
aa119ff
auto_update_fix
sujinmkang Oct 13, 2020
b6af9f4
Fix expected neighbor when multiple ports connect to same neighbor (#…
lguohan Oct 13, 2020
3a7457c
[celestica] consutil to support customize tty device name (#1155)
sandycelestica Oct 13, 2020
921e89c
reboot_pluging for fwutil auto-update task
sujinmkang Oct 14, 2020
059cdca
Fix exception for ipaddress in python2 (#1164)
bingwang-ms Oct 14, 2020
a733df5
[watermarkstat] Add unit tests for watermarkstat show commands (#1157)
neethajohn Oct 14, 2020
e51d44f
[consutil] Fix issue where the show line command crash if no ttyUSB e…
Blueve Oct 15, 2020
c382d89
[config/console] Support update console configuration related command…
Blueve Oct 15, 2020
c395e14
Modify fast-reboot script to use BGP service script to stop bgp servi…
vaibhavhd Oct 19, 2020
510d0ad
[consutil] Add brief option to show line command (#1176)
Blueve Oct 20, 2020
59a511d
[config/show] Add CLI support for proxy arp (#1168)
theasianpianist Oct 20, 2020
13bd06b
Fixes the issue with show interface counters and for pfc and queue co…
abdosi Oct 20, 2020
ca92e36
[counterpoll] Disable Counter Poll When Entering Fast Reboot (#1174)
tahmed-dev Oct 21, 2020
0c3a97f
Remove stdeb.cfg; no longer used now that we build as wheel (#1182)
jleveque Oct 23, 2020
00a2570
fdbshow and nbrshow use SonicV2Connector with decode_responses=True, …
qiluo-msft Oct 24, 2020
f14bbe5
[CLI][show][platform] Added ASIC count in the output. (#1185)
smaheshm Oct 26, 2020
e889212
[fwutil]: Set min log priority to INFO. (#1191)
nazariig Oct 26, 2020
63c6733
Add license file, remove third-party licenses file (#1192)
jleveque Oct 27, 2020
1753f22
[show] remove 'device2interface_dict' in show interface neighbor expe…
lolyu Oct 27, 2020
8af9aee
Show FG_NHG CLI Commands Added (#1056)
kktheballer Oct 29, 2020
ef5f212
[sfputil] Display 'N/A' for non-SFP ports (#1078)
PJHsieh Nov 2, 2020
e3d3d92
[consutil] Store console port state in STATE_DB (#1208)
Blueve Nov 4, 2020
acfa824
Add a switch to route_check to control whether write log to syslog (#…
bingwang-ms Nov 4, 2020
061f428
[show/fgnhg.py] Fix whitespace issues (#1211)
jleveque Nov 4, 2020
42efc03
SONiC installer - fix string formatting during image type check (#1197)
vaibhavhd Nov 4, 2020
99de167
[Mellanox] SKU creator Tool (#1163)
madhanmellanox Nov 5, 2020
97dec12
[consutil][show] Remove root need from show line command (#1218)
Blueve Nov 5, 2020
927bf9b
[connect][clear] Support --devicename option for connect/clear line c…
Blueve Nov 5, 2020
e2ec825
support fwpackage option and fix modular chassis auto-update
sujinmkang Nov 5, 2020
ee6bc49
Copy missing values from INIT_CFG to config_db as part of db_migratio…
vaibhavhd Nov 6, 2020
0d49a85
Replace swsssdk.SonicV2Connector with swsscommon.SonicV2Connector (SW…
qiluo-msft Nov 6, 2020
11526df
add api to check missing api
sujinmkang Nov 6, 2020
673f98d
[sonic_sku_create] Move tests from sonic-utilities-tests/ folder to t…
madhanmellanox Nov 7, 2020
a9cdd27
[show] Fix `show ip bgp sum` (#1194)
lolyu Nov 9, 2020
12e1a0f
[show][techsupport][multi-ASIC] Add support to collect tech support o…
smaheshm Nov 9, 2020
b693cf6
Remove SKU create pytest output directory before execution of the scr…
madhanmellanox Nov 9, 2020
6cbec6b
[multi-ASIC] CRM show/config commands changes for multi-asic (#1127)
judyjoseph Nov 10, 2020
d5eb2f8
[consutil][connect] Remove root need from connect line command (#1225)
Blueve Nov 11, 2020
40377d3
[chassis]: Configure and show for platform chassis_modules (#1145)
mprabhu-nokia Nov 11, 2020
5f42bbe
add and address review comments
sujinmkang Nov 12, 2020
b226159
[CLI][PFCWD] Fix issue with specifying ports in pfcwd start on masic …
smaheshm Nov 12, 2020
dadfc18
Copp Changes (#1004)
Nov 12, 2020
3f15835
[sflow] Add mVRF support (#1230)
GarrickHe Nov 13, 2020
8f156df
Added 'import sys' in feature.py file (#1232)
AkhileshSamineni Nov 13, 2020
599b43a
[doc]: Update Command-Reference.md (#1231)
rdarbha Nov 13, 2020
939e331
[cli]: NAT show commands newline issue after migrated to Python3 (#1204)
AkhileshSamineni Nov 13, 2020
929ff7c
Updates to bgp config and show commands with BGP_INTERNAL_NEIGHBOR ta…
judyjoseph Nov 13, 2020
71aa221
[tests] Do not trim from PATH if we did not append to it; Clean up/fi…
jleveque Nov 13, 2020
f412e52
lgtm
sujinmkang Nov 13, 2020
8079558
Fix mock SonicV2Connector in python3: use decode_responses mode so ca…
qiluo-msft Nov 14, 2020
bd8d6c7
Convert to Python 3 (#1128)
jleveque Nov 15, 2020
f46c27e
Add 'requests' as install dependency in setup.py (#1240)
jleveque Nov 16, 2020
412cfa1
initial commit
sujinmkang Oct 9, 2020
bd32dbe
second commit
sujinmkang Oct 12, 2020
d0fc10c
auto_update_fix
sujinmkang Oct 13, 2020
05dbbb8
reboot_pluging for fwutil auto-update task
sujinmkang Oct 14, 2020
3f8db37
support fwpackage option and fix modular chassis auto-update
sujinmkang Nov 5, 2020
b657538
add api to check missing api
sujinmkang Nov 6, 2020
dfcf286
add and address review comments
sujinmkang Nov 12, 2020
cf81eb6
lgtm
sujinmkang Nov 13, 2020
e54cc58
Merge branch 'fwutil' of https://github.com/sujinmkang/sonic-utilitie…
sujinmkang Nov 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2016-2020 Microsoft, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ Currently, this list of dependencies is as follows:

- libyang_1.0.73_amd64.deb
- libyang-cpp_1.0.73_amd64.deb
- python2-yang_1.0.73_amd64.deb
- python3-yang_1.0.73_amd64.deb
- redis_dump_load-1.1-py2-none-any.whl
- swsssdk-2.0.1-py2-none-any.whl
- sonic_py_common-1.0-py2-none-any.whl
- sonic_config_engine-1.0-py2-none-any.whl
- sonic_yang_mgmt-1.0-py2-none-any.whl
- redis_dump_load-1.1-py3-none-any.whl
- swsssdk-2.0.1-py3-none-any.whl
- sonic_py_common-1.0-py3-none-any.whl
- sonic_config_engine-1.0-py3-none-any.whl
- sonic_yang_mgmt-1.0-py3-none-any.whl
- sonic_yang_models-1.0-py3-none-any.whl


Expand All @@ -43,7 +42,7 @@ A convenient alternative is to let the SONiC build system configure a build envi

2. Build the sonic-utilities Python wheel package inside the Buster slave container, and tell the build system to keep the container alive when finished
```
make NOJESSIE=1 NOSTRETCH=1 KEEP_SLAVE_ON=yes target/python-wheels/sonic_utilities-1.2-py2-none-any.whl
make NOJESSIE=1 NOSTRETCH=1 KEEP_SLAVE_ON=yes target/python-wheels/sonic_utilities-1.2-py3-none-any.whl
```

3. When the build finishes, your prompt will change to indicate you are inside the slave container. Change into the `src/sonic-utilities/` directory
Expand All @@ -56,13 +55,13 @@ A convenient alternative is to let the SONiC build system configure a build envi
#### To build

```
python2 setup.py bdist_wheel
python3 setup.py bdist_wheel
```

#### To run unit tests

```
python2 setup.py test
python3 setup.py test
```


Expand Down
30 changes: 0 additions & 30 deletions ThirdPartyLicenses.txt

This file was deleted.

57 changes: 29 additions & 28 deletions acl_loader/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import click
import ipaddr
import ipaddress
import json
import syslog

Expand All @@ -10,7 +10,8 @@
import pyangbind.lib.pybindJSON as pybindJSON
from natsort import natsorted
from sonic_py_common import device_info
from swsssdk import ConfigDBConnector, SonicV2Connector, SonicDBConfig
from swsssdk import ConfigDBConnector, SonicDBConfig
from swsscommon.swsscommon import SonicV2Connector


def info(msg):
Expand All @@ -29,7 +30,7 @@ def error(msg):


def deep_update(dst, src):
for key, value in src.iteritems():
for key, value in src.items():
if isinstance(value, dict):
node = dst.setdefault(key, {})
deep_update(node, value)
Expand Down Expand Up @@ -181,7 +182,7 @@ def read_policers_info(self):
# For multi-npu platforms we will read from any one of front asic namespace
# config db as the information should be same across all config db
if self.per_npu_configdb:
namespace_configdb = (self.per_npu_configdb.values())[0]
namespace_configdb = (list(self.per_npu_configdb.values()))[0]
self.policers_db_info = namespace_configdb.get_table(self.POLICER)
else:
self.policers_db_info = self.configdb.get_table(self.POLICER)
Expand All @@ -198,19 +199,19 @@ def read_sessions_info(self):
# For multi-npu platforms we will read from any one of front asic namespace
# config db as the information should be same across all config db
if self.per_npu_configdb:
namespace_configdb = (self.per_npu_configdb.values())[0]
namespace_configdb = (list(self.per_npu_configdb.values()))[0]
self.sessions_db_info = namespace_configdb.get_table(self.CFG_MIRROR_SESSION_TABLE)
else:
self.sessions_db_info = self.configdb.get_table(self.CFG_MIRROR_SESSION_TABLE)
for key in self.sessions_db_info.keys():
for key in list(self.sessions_db_info.keys()):
if self.per_npu_statedb:
# For multi-npu platforms we will read from all front asic name space
# statedb as the monitor port will be differnt for each asic
# and it's status also might be different (ideally should not happen)
# We will store them as dict of 'asic' : value
self.sessions_db_info[key]["status"] = {}
self.sessions_db_info[key]["monitor_port"] = {}
for namespace_key, namespace_statedb in self.per_npu_statedb.iteritems():
for namespace_key, namespace_statedb in self.per_npu_statedb.items():
state_db_info = namespace_statedb.get_all(self.statedb.STATE_DB, "{}|{}".format(self.STATE_MIRROR_SESSION_TABLE, key))
self.sessions_db_info[key]["status"][namespace_key] = state_db_info.get("status", "inactive") if state_db_info else "error"
self.sessions_db_info[key]["monitor_port"][namespace_key] = state_db_info.get("monitor_port", "") if state_db_info else ""
Expand Down Expand Up @@ -366,7 +367,7 @@ def validate_actions(self, table_name, action_props):
# For multi-npu we will read using anyone statedb connector for front asic namespace.
# Same information should be there in all state DB's
# as it is static information about switch capability
namespace_statedb = (self.per_npu_statedb.values())[0]
namespace_statedb = (list(self.per_npu_statedb.values()))[0]
capability = namespace_statedb.get_all(self.statedb.STATE_DB, "{}|switch".format(self.SWITCH_CAPABILITY_TABLE))
else:
capability = self.statedb.get_all(self.statedb.STATE_DB, "{}|switch".format(self.SWITCH_CAPABILITY_TABLE))
Expand Down Expand Up @@ -416,7 +417,7 @@ def convert_ip(self, table_name, rule_idx, rule):
# FIXME: 0 is a valid protocol number, but openconfig seems to use it as a default value,
# so there isn't currently a good way to check if the user defined proto=0 or not.
if rule.ip.config.protocol:
if self.ip_protocol_map.has_key(rule.ip.config.protocol):
if rule.ip.config.protocol in self.ip_protocol_map:
rule_props["IP_PROTOCOL"] = self.ip_protocol_map[rule.ip.config.protocol]
else:
try:
Expand All @@ -429,14 +430,14 @@ def convert_ip(self, table_name, rule_idx, rule):

if rule.ip.config.source_ip_address:
source_ip_address = rule.ip.config.source_ip_address.encode("ascii")
if ipaddr.IPNetwork(source_ip_address).version == 4:
if ipaddress.ip_network(source_ip_address).version == 4:
rule_props["SRC_IP"] = source_ip_address
else:
rule_props["SRC_IPV6"] = source_ip_address

if rule.ip.config.destination_ip_address:
destination_ip_address = rule.ip.config.destination_ip_address.encode("ascii")
if ipaddr.IPNetwork(destination_ip_address).version == 4:
if ipaddress.ip_network(destination_ip_address).version == 4:
rule_props["DST_IP"] = destination_ip_address
else:
rule_props["DST_IPV6"] = destination_ip_address
Expand Down Expand Up @@ -578,17 +579,17 @@ def full_update(self):
be removed and new rules in that table will be installed.
:return:
"""
for key in self.rules_db_info.keys():
for key in list(self.rules_db_info.keys()):
if self.current_table is None or self.current_table == key[0]:
self.configdb.mod_entry(self.ACL_RULE, key, None)
# Program for per front asic namespace also if present
for namespace_configdb in self.per_npu_configdb.values():
for namespace_configdb in list(self.per_npu_configdb.values()):
namespace_configdb.mod_entry(self.ACL_RULE, key, None)


self.configdb.mod_config({self.ACL_RULE: self.rules_info})
# Program for per front asic namespace also if present
for namespace_configdb in self.per_npu_configdb.values():
for namespace_configdb in list(self.per_npu_configdb.values()):
namespace_configdb.mod_config({self.ACL_RULE: self.rules_info})

def incremental_update(self):
Expand All @@ -604,10 +605,10 @@ def incremental_update(self):
# update on dataplane ACLs, and only perform an incremental update on
# control plane ACLs.

new_rules = set(self.rules_info.iterkeys())
new_rules = set(self.rules_info.keys())
new_dataplane_rules = set()
new_controlplane_rules = set()
current_rules = set(self.rules_db_info.iterkeys())
current_rules = set(self.rules_db_info.keys())
current_dataplane_rules = set()
current_controlplane_rules = set()

Expand All @@ -629,15 +630,15 @@ def incremental_update(self):
for key in current_dataplane_rules:
self.configdb.mod_entry(self.ACL_RULE, key, None)
# Program for per-asic namespace also if present
for namespace_configdb in self.per_npu_configdb.values():
for namespace_configdb in list(self.per_npu_configdb.values()):
namespace_configdb.mod_entry(self.ACL_RULE, key, None)


# Add all new dataplane rules
for key in new_dataplane_rules:
self.configdb.mod_entry(self.ACL_RULE, key, self.rules_info[key])
# Program for per-asic namespace corresponding to front asic also if present.
for namespace_configdb in self.per_npu_configdb.values():
for namespace_configdb in list(self.per_npu_configdb.values()):
namespace_configdb.mod_entry(self.ACL_RULE, key, self.rules_info[key])

added_controlplane_rules = new_controlplane_rules.difference(current_controlplane_rules)
Expand All @@ -648,22 +649,22 @@ def incremental_update(self):
self.configdb.mod_entry(self.ACL_RULE, key, self.rules_info[key])
# Program for per-asic namespace corresponding to front asic also if present.
# For control plane ACL it's not needed but to keep all db in sync program everywhere
for namespace_configdb in self.per_npu_configdb.values():
for namespace_configdb in list(self.per_npu_configdb.values()):
namespace_configdb.mod_entry(self.ACL_RULE, key, self.rules_info[key])

for key in removed_controlplane_rules:
self.configdb.mod_entry(self.ACL_RULE, key, None)
# Program for per-asic namespace corresponding to front asic also if present.
# For control plane ACL it's not needed but to keep all db in sync program everywhere
for namespace_configdb in self.per_npu_configdb.values():
for namespace_configdb in list(self.per_npu_configdb.values()):
namespace_configdb.mod_entry(self.ACL_RULE, key, None)

for key in existing_controlplane_rules:
if cmp(self.rules_info[key], self.rules_db_info[key]) != 0:
self.configdb.set_entry(self.ACL_RULE, key, self.rules_info[key])
# Program for per-asic namespace corresponding to front asic also if present.
# For control plane ACL it's not needed but to keep all db in sync program everywhere
for namespace_configdb in self.per_npu_configdb.values():
for namespace_configdb in list(self.per_npu_configdb.values()):
namespace_configdb.set_entry(self.ACL_RULE, key, self.rules_info[key])

def delete(self, table=None, rule=None):
Expand All @@ -672,12 +673,12 @@ def delete(self, table=None, rule=None):
:param rule:
:return:
"""
for key in self.rules_db_info.iterkeys():
for key in self.rules_db_info.keys():
if not table or table == key[0]:
if not rule or rule == key[1]:
self.configdb.set_entry(self.ACL_RULE, key, None)
# Program for per-asic namespace corresponding to front asic also if present.
for namespace_configdb in self.per_npu_configdb.values():
for namespace_configdb in list(self.per_npu_configdb.values()):
namespace_configdb.set_entry(self.ACL_RULE, key, None)

def show_table(self, table_name):
Expand All @@ -689,7 +690,7 @@ def show_table(self, table_name):
header = ("Name", "Type", "Binding", "Description", "Stage")

data = []
for key, val in self.get_tables_db_info().iteritems():
for key, val in self.get_tables_db_info().items():
if table_name and key != table_name:
continue

Expand Down Expand Up @@ -727,7 +728,7 @@ def show_session(self, session_name):

erspan_data = []
span_data = []
for key, val in self.get_sessions_db_info().iteritems():
for key, val in self.get_sessions_db_info().items():
if session_name and key != session_name:
continue

Expand Down Expand Up @@ -755,7 +756,7 @@ def show_policer(self, policer_name):
header = ("Name", "Type", "Mode", "CIR", "CBS")

data = []
for key, val in self.get_policers_db_info().iteritems():
for key, val in self.get_policers_db_info().items():
if policer_name and key != policer_name:
continue

Expand Down Expand Up @@ -806,7 +807,7 @@ def pop_matches(val):
return matches

raw_data = []
for (tname, rid), val in self.get_rules_db_info().iteritems():
for (tname, rid), val in self.get_rules_db_info().items():

if table_name and table_name != tname:
continue
Expand Down
21 changes: 8 additions & 13 deletions clear/main.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
#! /usr/bin/python -u

import click
import configparser
import os
import subprocess

try:
# noinspection PyPep8Naming
import ConfigParser as configparser
except ImportError:
# noinspection PyUnresolvedReferences
import configparser
import click


# This is from the aliases example:
Expand Down Expand Up @@ -84,6 +77,7 @@ def get_routing_stack():
proc = subprocess.Popen(command,
stdout=subprocess.PIPE,
shell=True,
text=True,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
Expand All @@ -101,7 +95,7 @@ def get_routing_stack():

def run_command(command, pager=False, return_output=False):
# Provide option for caller function to Process the output.
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
proc = subprocess.Popen(command, shell=True, text=True, stdout=subprocess.PIPE)
if return_output:
return proc.communicate()
elif pager:
Expand Down Expand Up @@ -368,10 +362,11 @@ def clear_vlan_fdb(vlanid):
# 'line' command
#
@cli.command('line')
@click.argument('linenum')
def line(linenum):
@click.argument('target')
@click.option('--devicename', '-d', is_flag=True, help="clear by name - if flag is set, interpret target as device name instead")
def line(target, devicename):
"""Clear preexisting connection to line"""
cmd = "consutil clear " + str(linenum)
cmd = "consutil clear {}".format("--devicename " if devicename else "") + str(target)
run_command(cmd)

#
Expand Down
9 changes: 0 additions & 9 deletions config/aaa.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#!/usr/bin/env python -u
# -*- coding: utf-8 -*-

import click

from swsssdk import ConfigDBConnector
import utilities_common.cli as clicommon

Expand Down Expand Up @@ -193,8 +189,3 @@ def delete(address):
config_db.connect()
config_db.set_entry('TACPLUS_SERVER', address, None)
tacacs.add_command(delete)


if __name__ == "__main__":
aaa()

Loading