Skip to content

Commit 477dd24

Browse files
Move n9300_switch_memory_check to bottom of check definitions
1 parent e68bdbe commit 477dd24

1 file changed

Lines changed: 81 additions & 81 deletions

File tree

aci-preupgrade-validation-script.py

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -6092,86 +6092,6 @@ def auto_firmware_update_on_switch_check(cversion, tversion, **kwargs):
60926092
return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url)
60936093

60946094

6095-
@check_wrapper(check_title='N9300 Switch Memory')
6096-
def n9300_switch_memory_check(tversion, fabric_nodes, **kwargs):
6097-
result = PASS
6098-
headers = ["NodeId", "Name", "Model", "Memory Detected (GB)"]
6099-
data = []
6100-
recommended_action = 'Increase the switch memory to at least 24GB on affected N9300-series switches.'
6101-
doc_url = 'https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/#n9300-switch-memory'
6102-
min_memory_kb = 24 * 1024 * 1024
6103-
msg = ''
6104-
6105-
affected_nodes = [
6106-
node for node in fabric_nodes
6107-
if node.get('fabricNode', {}).get('attributes', {}).get('model', '').startswith('N9K-C93')
6108-
]
6109-
6110-
if not affected_nodes:
6111-
result = NA
6112-
msg = 'No N9300 switches found. Skipping.'
6113-
else:
6114-
proc_mem_mos = icurl('class', 'procMemUsage.json')
6115-
node_total_kb = {}
6116-
parse_errors = []
6117-
6118-
for memory_mo in proc_mem_mos:
6119-
attrs = memory_mo.get('procMemUsage', {}).get('attributes', {})
6120-
total = attrs.get('Total')
6121-
mem_dn = attrs.get('dn', '')
6122-
if not total or '/memusage-sup' not in mem_dn:
6123-
continue
6124-
dn_match = re.search(node_regex, mem_dn)
6125-
if not dn_match:
6126-
continue
6127-
try:
6128-
total_kb = int(total)
6129-
except (TypeError, ValueError):
6130-
parse_errors.append([mem_dn, total])
6131-
continue
6132-
6133-
node_id = dn_match.group('node')
6134-
if node_id not in node_total_kb:
6135-
node_total_kb[node_id] = total_kb
6136-
6137-
if parse_errors:
6138-
result = ERROR
6139-
msg = 'Failed to parse procMemUsage Total for one or more nodes.'
6140-
headers = ['DN', 'Total']
6141-
data = parse_errors
6142-
else:
6143-
missing_nodes = []
6144-
6145-
for node in affected_nodes:
6146-
node_id = node['fabricNode']['attributes']['id']
6147-
total_kb = node_total_kb.get(node_id)
6148-
if total_kb is None:
6149-
missing_nodes.append([
6150-
node_id,
6151-
node['fabricNode']['attributes'].get('name', ''),
6152-
node['fabricNode']['attributes'].get('model', ''),
6153-
])
6154-
continue
6155-
6156-
if total_kb < min_memory_kb:
6157-
memory_in_gb = round(total_kb / 1048576, 2)
6158-
result = FAIL_O
6159-
data.append([
6160-
node_id,
6161-
node['fabricNode']['attributes'].get('name', ''),
6162-
node['fabricNode']['attributes'].get('model', ''),
6163-
memory_in_gb,
6164-
])
6165-
6166-
if missing_nodes:
6167-
result = ERROR
6168-
msg = 'Missing procMemUsage data for one or more affected N9300 nodes.'
6169-
headers = ['NodeId', 'Name', 'Model']
6170-
data = missing_nodes
6171-
6172-
return Result(result=result, msg=msg, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url)
6173-
6174-
61756095
@check_wrapper(check_title='Rogue EP Exception List missing on switches')
61766096
def rogue_ep_coop_exception_mac_check(cversion, tversion, **kwargs):
61776097
result = PASS
@@ -6373,6 +6293,86 @@ def multipod_modular_spine_bootscript_check(tversion, fabric_nodes, username, pa
63736293
return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url)
63746294

63756295

6296+
@check_wrapper(check_title='N9300 Switch Memory')
6297+
def n9300_switch_memory_check(tversion, fabric_nodes, **kwargs):
6298+
result = PASS
6299+
headers = ["NodeId", "Name", "Model", "Memory Detected (GB)"]
6300+
data = []
6301+
recommended_action = 'Increase the switch memory to at least 24GB on affected N9300-series switches.'
6302+
doc_url = 'https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/#n9300-switch-memory'
6303+
min_memory_kb = 24 * 1024 * 1024
6304+
msg = ''
6305+
6306+
affected_nodes = [
6307+
node for node in fabric_nodes
6308+
if node.get('fabricNode', {}).get('attributes', {}).get('model', '').startswith('N9K-C93')
6309+
]
6310+
6311+
if not affected_nodes:
6312+
result = NA
6313+
msg = 'No N9300 switches found. Skipping.'
6314+
else:
6315+
proc_mem_mos = icurl('class', 'procMemUsage.json')
6316+
node_total_kb = {}
6317+
parse_errors = []
6318+
6319+
for memory_mo in proc_mem_mos:
6320+
attrs = memory_mo.get('procMemUsage', {}).get('attributes', {})
6321+
total = attrs.get('Total')
6322+
mem_dn = attrs.get('dn', '')
6323+
if not total or '/memusage-sup' not in mem_dn:
6324+
continue
6325+
dn_match = re.search(node_regex, mem_dn)
6326+
if not dn_match:
6327+
continue
6328+
try:
6329+
total_kb = int(total)
6330+
except (TypeError, ValueError):
6331+
parse_errors.append([mem_dn, total])
6332+
continue
6333+
6334+
node_id = dn_match.group('node')
6335+
if node_id not in node_total_kb:
6336+
node_total_kb[node_id] = total_kb
6337+
6338+
if parse_errors:
6339+
result = ERROR
6340+
msg = 'Failed to parse procMemUsage Total for one or more nodes.'
6341+
headers = ['DN', 'Total']
6342+
data = parse_errors
6343+
else:
6344+
missing_nodes = []
6345+
6346+
for node in affected_nodes:
6347+
node_id = node['fabricNode']['attributes']['id']
6348+
total_kb = node_total_kb.get(node_id)
6349+
if total_kb is None:
6350+
missing_nodes.append([
6351+
node_id,
6352+
node['fabricNode']['attributes'].get('name', ''),
6353+
node['fabricNode']['attributes'].get('model', ''),
6354+
])
6355+
continue
6356+
6357+
if total_kb < min_memory_kb:
6358+
memory_in_gb = round(total_kb / 1048576, 2)
6359+
result = FAIL_O
6360+
data.append([
6361+
node_id,
6362+
node['fabricNode']['attributes'].get('name', ''),
6363+
node['fabricNode']['attributes'].get('model', ''),
6364+
memory_in_gb,
6365+
])
6366+
6367+
if missing_nodes:
6368+
result = ERROR
6369+
msg = 'Missing procMemUsage data for one or more affected N9300 nodes.'
6370+
headers = ['NodeId', 'Name', 'Model']
6371+
data = missing_nodes
6372+
6373+
return Result(result=result, msg=msg, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url)
6374+
6375+
63766376
# ---- Script Execution ----
63776377

63786378

@@ -6540,9 +6540,9 @@ class CheckManager:
65406540
isis_database_byte_check,
65416541
configpush_shard_check,
65426542
auto_firmware_update_on_switch_check,
6543-
n9300_switch_memory_check,
65446543
rogue_ep_coop_exception_mac_check,
65456544
n9k_c9408_model_lem_count_check,
6545+
n9300_switch_memory_check,
65466546
]
65476547
ssh_checks = [
65486548
# General

0 commit comments

Comments
 (0)