Skip to content

Commit 5ed1006

Browse files
Merge branch 'master' into route-flow-counter
2 parents c826391 + 576c9ef commit 5ed1006

File tree

85 files changed

+6536
-1744
lines changed

Some content is hidden

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

85 files changed

+6536
-1744
lines changed

.azure-pipelines/build-docker-sonic-vs-template.yml

-65
This file was deleted.

.azure-pipelines/test-docker-sonic-vs-template.yml

-92
This file was deleted.

azure-pipelines.yml

-16
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,3 @@ stages:
125125
- publish: '$(System.DefaultWorkingDirectory)/dist/'
126126
artifact: wheels
127127
displayName: "Publish Python wheels"
128-
129-
- stage: BuildDocker
130-
dependsOn: Build
131-
condition: succeeded('Build')
132-
jobs:
133-
- template: .azure-pipelines/build-docker-sonic-vs-template.yml
134-
parameters:
135-
artifact_name: docker-sonic-vs
136-
137-
- stage: Test
138-
dependsOn: BuildDocker
139-
condition: succeeded('BuildDocker')
140-
jobs:
141-
- template: .azure-pipelines/test-docker-sonic-vs-template.yml
142-
parameters:
143-
log_artifact_name: log

clear/main.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from flow_counter_util.route import exit_if_route_flow_counter_not_support
1111
from utilities_common import util_base
1212
from show.plugins.pbh import read_pbh_counters
13+
from config.plugins.pbh import serialize_pbh_counters
1314
from . import plugins
1415

1516

@@ -475,14 +476,8 @@ def statistics(db):
475476
pbh_rules = db.cfgdb.get_table("PBH_RULE")
476477
pbh_counters = read_pbh_counters(pbh_rules)
477478

478-
try:
479-
with open('/tmp/.pbh_counters.txt', 'w') as fp:
480-
json.dump(remap_keys(pbh_counters), fp)
481-
except IOError as err:
482-
pass
479+
serialize_pbh_counters(pbh_counters)
483480

484-
def remap_keys(dict):
485-
return [{'key': k, 'value': v} for k, v in dict.items()]
486481

487482
# ("sonic-clear flowcnt-trap")
488483
@cli.command()

config/config_mgmt.py

+21
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,27 @@ def _recurCreateConfig(diff, inp, outp, config):
872872
# we do not allow updates right now
873873
if isinstance(diff, list) and isinstance(outp, dict):
874874
return changed
875+
'''
876+
libYang converts ietf yang types to lower case internally, which
877+
creates false config diff for us while DPB.
878+
879+
Example:
880+
For DEVICE_METADATA['localhost']['mac'] type is yang:mac-address.
881+
Libyang converts from 'XX:XX:XX:E4:B3:DD' -> 'xx:xx:xx:e4:b3:dd'
882+
so args for this functions will be:
883+
884+
diff = DEVICE_METADATA['localhost']['mac']
885+
where DEVICE_METADATA': {'localhost': {'mac': ['XX:XX:XX:E4:B3:DD', 'xx:xx:xx:e4:b3:dd']}}}
886+
Note: above dict is representation of diff in config given by diffJson
887+
library.
888+
out = 'XX:XX:XX:e4:b3:dd'
889+
inp = 'xx:xx:xx:E4:B3:DD'
890+
891+
With below check, we will avoid processing of such config diff for DPB.
892+
'''
893+
if isinstance(diff, list) and isinstance(outp, str) and \
894+
inp.lower() == outp.lower():
895+
return changed
875896

876897
idx = -1
877898
for key in diff:

config/main.py

+25-10
Original file line numberDiff line numberDiff line change
@@ -636,21 +636,23 @@ def _clear_cbf():
636636

637637
def _clear_qos():
638638
QOS_TABLE_NAMES = [
639+
'PORT_QOS_MAP',
640+
'QUEUE',
639641
'TC_TO_PRIORITY_GROUP_MAP',
640642
'MAP_PFC_PRIORITY_TO_QUEUE',
641643
'TC_TO_QUEUE_MAP',
642644
'DSCP_TO_TC_MAP',
643645
'MPLS_TC_TO_TC_MAP',
644646
'SCHEDULER',
645647
'PFC_PRIORITY_TO_PRIORITY_GROUP_MAP',
646-
'PORT_QOS_MAP',
647648
'WRED_PROFILE',
648-
'QUEUE',
649649
'CABLE_LENGTH',
650-
'BUFFER_POOL',
651-
'BUFFER_PROFILE',
652650
'BUFFER_PG',
653651
'BUFFER_QUEUE',
652+
'BUFFER_PORT_INGRESS_PROFILE_LIST',
653+
'BUFFER_PORT_EGRESS_PROFILE_LIST',
654+
'BUFFER_PROFILE',
655+
'BUFFER_POOL',
654656
'DEFAULT_LOSSLESS_BUFFER_PARAMETER',
655657
'LOSSLESS_TRAFFIC_PATTERN']
656658

@@ -1025,6 +1027,19 @@ def validate_ipv4_address(ctx, param, ip_addr):
10251027
except ValueError as e:
10261028
raise click.UsageError(str(e))
10271029

1030+
def validate_gre_type(ctx, _, value):
1031+
"""A validator for validating input gre_type
1032+
"""
1033+
try:
1034+
base = 10
1035+
if value.lower().startswith('0x'):
1036+
base = 16
1037+
gre_type_value = int(value, base)
1038+
if gre_type_value < GRE_TYPE_RANGE.min or gre_type_value > GRE_TYPE_RANGE.max:
1039+
raise click.UsageError("{} is not a valid GRE type".format(value))
1040+
return gre_type_value
1041+
except ValueError:
1042+
raise click.UsageError("{} is not a valid GRE type".format(value))
10281043

10291044
# This is our main entrypoint - the main 'config' command
10301045
@click.group(cls=clicommon.AbbreviationGroup, context_settings=CONTEXT_SETTINGS)
@@ -1792,11 +1807,11 @@ def add_portchannel_member(ctx, portchannel_name, port_name):
17921807
ctx.fail("{} is not present.".format(portchannel_name))
17931808

17941809
# Dont allow a port to be member of port channel if it is configured with an IP address
1795-
for key in db.get_table('INTERFACE').keys():
1796-
if type(key) != tuple:
1810+
for key,value in db.get_table('INTERFACE').items():
1811+
if type(key) == tuple:
17971812
continue
1798-
if key[0] == port_name:
1799-
ctx.fail(" {} has ip address {} configured".format(port_name, key[1]))
1813+
if key == port_name:
1814+
ctx.fail(" {} has ip address configured".format(port_name))
18001815
return
18011816

18021817
# Dont allow a port to be member of port channel if it is configured as a VLAN member
@@ -1895,7 +1910,7 @@ def mirror_session():
18951910
@click.argument('dst_ip', metavar='<dst_ip>', callback=validate_ipv4_address, required=True)
18961911
@click.argument('dscp', metavar='<dscp>', type=DSCP_RANGE, required=True)
18971912
@click.argument('ttl', metavar='<ttl>', type=TTL_RANGE, required=True)
1898-
@click.argument('gre_type', metavar='[gre_type]', type=GRE_TYPE_RANGE, required=False)
1913+
@click.argument('gre_type', metavar='[gre_type]', callback=validate_gre_type, required=False)
18991914
@click.argument('queue', metavar='[queue]', type=QUEUE_RANGE, required=False)
19001915
@click.option('--policer')
19011916
def add(session_name, src_ip, dst_ip, dscp, ttl, gre_type, queue, policer):
@@ -1919,7 +1934,7 @@ def erspan(ctx):
19191934
@click.argument('dst_ip', metavar='<dst_ip>', callback=validate_ipv4_address,required=True)
19201935
@click.argument('dscp', metavar='<dscp>', type=DSCP_RANGE, required=True)
19211936
@click.argument('ttl', metavar='<ttl>', type=TTL_RANGE, required=True)
1922-
@click.argument('gre_type', metavar='[gre_type]', type=GRE_TYPE_RANGE, required=False)
1937+
@click.argument('gre_type', metavar='[gre_type]', callback=validate_gre_type, required=False)
19231938
@click.argument('queue', metavar='[queue]', type=QUEUE_RANGE, required=False)
19241939
@click.argument('src_port', metavar='[src_port]', required=False)
19251940
@click.argument('direction', metavar='[direction]', required=False)

config/mclag.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def is_ipv4_addr_valid(addr):
8585

8686

8787
def check_if_interface_is_valid(db, interface_name):
88-
from main import interface_name_is_valid
88+
from .main import interface_name_is_valid
8989
if interface_name_is_valid(db,interface_name) is False:
9090
ctx.fail("Interface name is invalid. Please enter a valid interface name!!")
9191

0 commit comments

Comments
 (0)