Skip to content

Commit

Permalink
Merge branch 'master' into dev/mghoneim/groupings
Browse files Browse the repository at this point in the history
  • Loading branch information
ghooo committed Feb 18, 2022
2 parents 21b748e + 1723206 commit 873f8c3
Show file tree
Hide file tree
Showing 8 changed files with 3,181 additions and 44 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ stages:
- job:
displayName: "Python3"
variables:
DIFF_COVER_CHECK_THRESHOLD: 0
DIFF_COVER_CHECK_THRESHOLD: 50
DIFF_COVER_ENABLE: 'true'
pool:
vmImage: ubuntu-20.04
Expand Down
4 changes: 4 additions & 0 deletions config/vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def add_vlan(db, vid):
ctx.fail("Invalid VLAN ID {} (1-4094)".format(vid))

vlan = 'Vlan{}'.format(vid)

if vid == 1:
ctx.fail("{} is default VLAN".format(vlan))

if clicommon.check_if_vlanid_exist(db.cfgdb, vlan):
ctx.fail("{} already exists".format(vlan))

Expand Down
14 changes: 11 additions & 3 deletions generic_config_updater/gu_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,13 @@ def create_path(self, tokens):
return JsonPointer.from_parts(tokens).path

def has_path(self, doc, path):
return JsonPointer(path).get(doc, default=None) is not None
return self.get_from_path(doc, path) is not None

def get_from_path(self, doc, path):
return JsonPointer(path).get(doc, default=None)

def is_config_different(self, path, current, target):
return self.get_from_path(current, path) != self.get_from_path(target, path)

def get_xpath_tokens(self, xpath):
"""
Expand Down Expand Up @@ -558,7 +564,8 @@ def _get_xpath_tokens_from_leaf(self, model, token_index, path_tokens, config):
if uses_leaf_model:
return [token]

raise ValueError("Token not found")
raise ValueError(f"Path token not found.\n model: {model}\n token_index: {token_index}\n " + \
f"path_tokens: {path_tokens}\n config: {config}")

def _extractKey(self, tableKey, keys):
keyList = keys.split()
Expand Down Expand Up @@ -729,7 +736,8 @@ def _get_path_tokens_from_leaf(self, model, token_index, xpath_tokens, config):
if uses_leaf_model:
return [token]

raise Exception("no leaf")
raise ValueError(f"Xpath token not found.\n model: {model}\n token_index: {token_index}\n " + \
f"xpath_tokens: {xpath_tokens}\n config: {config}")

def _extract_key_dict(self, list_token):
# Example: VLAN_MEMBER_LIST[name='Vlan1000'][port='Ethernet8']
Expand Down
394 changes: 355 additions & 39 deletions generic_config_updater/patch_sorter.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"PORT": {
"Ethernet4": {
"admin_status": "up",
"alias": "fortyGigE0/4",
"description": "Servers0:eth0",
"index": "1",
"lanes": "29,30,31,32",
"mtu": "9100",
"pfc_asym": "off",
"speed": "40000"
},
"Ethernet8": {
"admin_status": "up",
"alias": "fortyGigE0/8",
"description": "Servers1:eth0",
"index": "2",
"lanes": "33,34,35,36",
"pfc_asym": "off",
"speed": "40000"
},
"Ethernet12": {
"admin_status": "down",
"alias": "fortyGigE0/12",
"description": "Servers2:eth0",
"index": "3",
"lanes": "37,38,39,40",
"mtu": "9100",
"pfc_asym": "off",
"speed": "40000"
},
"Ethernet16": {
"alias": "fortyGigE0/16",
"description": "Servers3:eth0",
"index": "4",
"lanes": "41,42,43,44",
"pfc_asym": "off",
"speed": "40000"
}
},
"BUFFER_PG": {
"Ethernet4|0": {
"profile": "ingress_lossy_profile"
},
"Ethernet12|0": {
"profile": "ingress_lossy_profile"
}
}
}

0 comments on commit 873f8c3

Please sign in to comment.