Skip to content

Commit 648e8c3

Browse files
Addressed and updated n9300_switch_memory_check files
1 parent 827d36e commit 648e8c3

4 files changed

Lines changed: 130 additions & 62 deletions

File tree

aci-preupgrade-validation-script.py

Lines changed: 86 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -5877,67 +5877,6 @@ def isis_database_byte_check(tversion, **kwargs):
58775877
return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url)
58785878

58795879

5880-
@check_wrapper(check_title='N9300 Switch Memory')
5881-
def n9300_switch_memory_check(tversion, fabric_nodes, **kwargs):
5882-
result = PASS
5883-
headers = ["NodeId", "Name", "Model", "Memory Detected (GB)"]
5884-
data = []
5885-
recommended_action = 'Increase the switch memory to at least 24GB on affected N9300-series switches.'
5886-
doc_url = 'https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/#n9300-switch-memory'
5887-
min_memory_kb = 24 * 1024 * 1024
5888-
5889-
proc_mem_query = 'procMemUsage.json'
5890-
affected_nodes = [
5891-
node for node in fabric_nodes
5892-
if node.get('fabricNode', {}).get('attributes', {}).get('model', '').startswith('N9K-C93')
5893-
]
5894-
5895-
if not affected_nodes:
5896-
return Result(result=NA, msg='No N9300 switches found. Skipping.')
5897-
5898-
proc_mem_mos = icurl('class', proc_mem_query)
5899-
node_total_kb = {}
5900-
5901-
for memory_mo in proc_mem_mos:
5902-
attrs = memory_mo.get('procMemUsage', {}).get('attributes', {})
5903-
total = attrs.get('Total')
5904-
mem_dn = attrs.get('dn', '')
5905-
if not total or '/memusage-sup' not in mem_dn:
5906-
continue
5907-
dn_match = re.search(node_regex, mem_dn)
5908-
if not dn_match:
5909-
continue
5910-
try:
5911-
total_kb = int(total)
5912-
except ValueError:
5913-
continue
5914-
5915-
node_id = dn_match.group('node')
5916-
if node_id not in node_total_kb:
5917-
node_total_kb[node_id] = total_kb
5918-
5919-
for node in affected_nodes:
5920-
node_id = node['fabricNode']['attributes']['id']
5921-
total_kb = node_total_kb.get(node_id)
5922-
if total_kb is None:
5923-
continue
5924-
5925-
memory_in_gb = round(total_kb / 1048576, 2)
5926-
if total_kb < min_memory_kb:
5927-
result = FAIL_O
5928-
data.append([
5929-
node_id,
5930-
node['fabricNode']['attributes'].get('name', ''),
5931-
node['fabricNode']['attributes'].get('model', ''),
5932-
memory_in_gb,
5933-
])
5934-
5935-
if result == PASS:
5936-
return Result(result=result)
5937-
5938-
return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url)
5939-
5940-
59415880
# Subprocess check - cat + acidiag
59425881
@check_wrapper(check_title='APIC Database Size')
59435882
def apic_database_size_check(cversion, **kwargs):
@@ -6114,6 +6053,91 @@ def auto_firmware_update_on_switch_check(cversion, tversion, **kwargs):
61146053

61156054
return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url)
61166055

6056+
6057+
@check_wrapper(check_title='N9300 Switch Memory')
6058+
def n9300_switch_memory_check(tversion, fabric_nodes, **kwargs):
6059+
result = PASS
6060+
headers = ["NodeId", "Name", "Model", "Memory Detected (GB)"]
6061+
data = []
6062+
recommended_action = 'Increase the switch memory to at least 24GB on affected N9300-series switches.'
6063+
doc_url = 'https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/#n9300-switch-memory'
6064+
min_memory_kb = 24 * 1024 * 1024
6065+
6066+
affected_nodes = [
6067+
node for node in fabric_nodes
6068+
if node.get('fabricNode', {}).get('attributes', {}).get('model', '').startswith('N9K-C93')
6069+
]
6070+
6071+
if not affected_nodes:
6072+
return Result(result=NA, msg='No N9300 switches found. Skipping.')
6073+
6074+
proc_mem_mos = icurl('class', 'procMemUsage.json')
6075+
node_total_kb = {}
6076+
parse_errors = []
6077+
6078+
for memory_mo in proc_mem_mos:
6079+
attrs = memory_mo.get('procMemUsage', {}).get('attributes', {})
6080+
total = attrs.get('Total')
6081+
mem_dn = attrs.get('dn', '')
6082+
if not total or '/memusage-sup' not in mem_dn:
6083+
continue
6084+
dn_match = re.search(node_regex, mem_dn)
6085+
if not dn_match:
6086+
continue
6087+
try:
6088+
total_kb = int(total)
6089+
except (TypeError, ValueError):
6090+
parse_errors.append([mem_dn, total])
6091+
continue
6092+
6093+
node_id = dn_match.group('node')
6094+
if node_id not in node_total_kb:
6095+
node_total_kb[node_id] = total_kb
6096+
6097+
if parse_errors:
6098+
return Result(
6099+
result=ERROR,
6100+
msg='Failed to parse procMemUsage Total for one or more nodes.',
6101+
headers=['DN', 'Total'],
6102+
data=parse_errors,
6103+
)
6104+
6105+
missing_nodes = []
6106+
6107+
for node in affected_nodes:
6108+
node_id = node['fabricNode']['attributes']['id']
6109+
total_kb = node_total_kb.get(node_id)
6110+
if total_kb is None:
6111+
missing_nodes.append([
6112+
node_id,
6113+
node['fabricNode']['attributes'].get('name', ''),
6114+
node['fabricNode']['attributes'].get('model', ''),
6115+
])
6116+
continue
6117+
6118+
memory_in_gb = round(total_kb / 1048576, 2)
6119+
if total_kb < min_memory_kb:
6120+
result = FAIL_O
6121+
data.append([
6122+
node_id,
6123+
node['fabricNode']['attributes'].get('name', ''),
6124+
node['fabricNode']['attributes'].get('model', ''),
6125+
memory_in_gb,
6126+
])
6127+
6128+
if missing_nodes:
6129+
return Result(
6130+
result=ERROR,
6131+
msg='Missing procMemUsage data for one or more affected N9300 nodes.',
6132+
headers=['NodeId', 'Name', 'Model'],
6133+
data=missing_nodes,
6134+
)
6135+
6136+
if result == FAIL_O:
6137+
return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url)
6138+
6139+
return Result(result=result)
6140+
61176141
# ---- Script Execution ----
61186142

61196143

@@ -6275,9 +6299,9 @@ class CheckManager:
62756299
pbr_high_scale_check,
62766300
standby_sup_sync_check,
62776301
isis_database_byte_check,
6278-
n9300_switch_memory_check,
62796302
configpush_shard_check,
62806303
auto_firmware_update_on_switch_check,
6304+
n9300_switch_memory_check,
62816305

62826306
]
62836307
ssh_checks = [
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
{
3+
"procMemUsage": {
4+
"attributes": {
5+
"dn": "topology/pod-1/node-101/sys/procmem/memusage-sup",
6+
"Modname": "sup",
7+
"Total": "unknown"
8+
}
9+
}
10+
}
11+
]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
{
3+
"procMemUsage": {
4+
"attributes": {
5+
"dn": "topology/pod-1/node-201/sys/procmem/memusage-sup",
6+
"Modname": "sup",
7+
"Total": "26535444"
8+
}
9+
}
10+
}
11+
]

tests/checks/n9300_switch_memory_24g_check/test_n9300_switch_memory_24g_check.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,28 @@
6060
'',
6161
[],
6262
),
63+
# Invalid procMemUsage Total value
64+
(
65+
read_data(dir, "fabricNode_one.json"),
66+
{
67+
proc_mem_query: read_data(dir, "procMemUsage_invalid_total.json"),
68+
},
69+
"6.0(3c)",
70+
script.ERROR,
71+
'Failed to parse procMemUsage Total for one or more nodes.',
72+
[["topology/pod-1/node-101/sys/procmem/memusage-sup", "unknown"]],
73+
),
74+
# Missing procMemUsage data for affected node
75+
(
76+
read_data(dir, "fabricNode_one.json"),
77+
{
78+
proc_mem_query: read_data(dir, "procMemUsage_missing_affected_node.json"),
79+
},
80+
"6.0(3c)",
81+
script.ERROR,
82+
'Missing procMemUsage data for one or more affected N9300 nodes.',
83+
[["101", "leaf101", "N9K-C93180YC-FX3"]],
84+
),
6385
# N9300 node with <24GB memory
6486
(
6587
read_data(dir, "fabricNode_two.json"),

0 commit comments

Comments
 (0)