Skip to content

Commit 3bbf7e6

Browse files
authored
Puv result cleanup (#269)
* 4 functions > neutral names * all data values to str + pytest case
1 parent a0dd999 commit 3bbf7e6

3 files changed

Lines changed: 44 additions & 24 deletions

File tree

aci-preupgrade-validation-script.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ def craftData(column, rows):
958958
raise ValueError("Row length ({}), data: {} does not match column length ({}).".format(r_len, rows[row_entry], c_len))
959959
entry = {}
960960
for col_pos in range(c_len):
961-
entry[column[col_pos]] = rows[row_entry][col_pos]
961+
entry[column[col_pos]] = str(rows[row_entry][col_pos])
962962
data.append(entry)
963963
return data
964964

@@ -1397,7 +1397,7 @@ def get_switch_version():
13971397
return None
13981398

13991399

1400-
@check_wrapper(check_title="APIC Cluster is Fully-Fit")
1400+
@check_wrapper(check_title="APIC Cluster Status")
14011401
def apic_cluster_health_check(cversion, **kwargs):
14021402
result = FAIL_UF
14031403
msg = ''
@@ -1431,7 +1431,7 @@ def apic_cluster_health_check(cversion, **kwargs):
14311431
return Result(result=result, msg=msg, headers=headers, data=data, unformatted_headers=unformatted_headers, unformatted_data=unformatted_data, recommended_action=recommended_action, doc_url=doc_url)
14321432

14331433

1434-
@check_wrapper(check_title="Switches are all in Active state")
1434+
@check_wrapper(check_title="Switch Fabric Membership Status")
14351435
def switch_status_check(**kwargs):
14361436
result = FAIL_UF
14371437
msg = ''
@@ -4004,15 +4004,15 @@ def vmm_active_uplinks_check(**kwargs):
40044004
return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url)
40054005

40064006

4007-
@check_wrapper(check_title="Fabric Port is Down (F1394 ethpm-if-port-down-fabric)")
4007+
@check_wrapper(check_title="Fabric Port Status (F1394 ethpm-if-port-down-fabric)")
40084008
def fabric_port_down_check(**kwargs):
40094009
result = FAIL_O
40104010
headers = ["Pod", "Node", "Int", "Reason", "Lifecycle"]
40114011
unformatted_headers = ['dn', 'Fault Description', 'Lifecycle']
40124012
unformatted_data = []
40134013
data = []
40144014
recommended_action = 'Identify if these ports are needed for redundancy and reason for being down'
4015-
doc_url = 'https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations#fabric-port-is-down'
4015+
doc_url = 'https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations#fabric-port-status'
40164016

40174017
fault_api = 'faultInst.json'
40184018
fault_api += '?&query-target-filter=and(eq(faultInst.code,"F1394")'
@@ -4925,15 +4925,15 @@ def standby_sup_sync_check(cversion, tversion, **kwargs):
49254925
return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url)
49264926

49274927

4928-
@check_wrapper(check_title='Equipment Disk Limits Exceeded')
4928+
@check_wrapper(check_title='Equipment Disk Limits')
49294929
def equipment_disk_limits_exceeded(**kwargs):
49304930
result = PASS
49314931
headers = ['Pod', 'Node', 'Code', '%', 'Description']
49324932
data = []
49334933
unformatted_headers = ['Fault DN', '%', 'Recommended Action']
49344934
unformatted_data = []
49354935
recommended_action = 'Review the reference document for commands to validate disk usage'
4936-
doc_url = 'https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/##equipment-disk-limits-exceeded'
4936+
doc_url = 'https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/#equipment-disk-limits'
49374937

49384938
usage_regex = r"avail \(New: (?P<avail>\d+)\).+used \(New: (?P<used>\d+)\)"
49394939
f182x_api = 'faultInst.json'

docs/docs/validations.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Items | This Script
2424
[Compatibility (Switch Hardware Gen1)][g4] | :white_check_mark: | :white_check_mark: 4.2(4) | :white_check_mark:
2525
[Compatibility (Remote Leaf Switch)][g5] | :white_check_mark: | :grey_exclamation: Except CSCvs16767 | :white_check_mark:
2626
[APIC Target version image and MD5 hash][g6] | :white_check_mark: | :white_check_mark: 5.2(3e)| :no_entry_sign:
27-
[APIC Cluster is Fully-Fit][g7] | :white_check_mark: | :white_check_mark: 4.2(6) | :white_check_mark:
28-
[Switches are all in Active state][g8] | :white_check_mark: | :no_entry_sign: | :white_check_mark:
27+
[APIC Cluster Status][g7] | :white_check_mark: | :white_check_mark: 4.2(6) | :white_check_mark:
28+
[Switch Fabric Membership Status][g8] | :white_check_mark: | :no_entry_sign: | :white_check_mark:
2929
[NTP Status][g9] | :white_check_mark: | :white_check_mark: 4.2(5) | :white_check_mark:
3030
[Firmware/Maintenance Groups when crossing 4.0 Release][g10] | :white_check_mark: | :no_entry_sign: | :white_check_mark:
3131
[Features that need to be disabled prior to Upgrade][g11] | :white_check_mark: | :grey_exclamation: 5.2(c)<br>Only AppCenter Apps | :white_check_mark:
@@ -43,8 +43,8 @@ Items | This Script
4343
[g4]: #compatibility-switch-hardware-gen1
4444
[g5]: #compatibility-remote-leaf-switch
4545
[g6]: #apic-target-version-image-and-md5-hash
46-
[g7]: #apic-cluster-is-fully-fit
47-
[g8]: #switches-are-all-in-active-state
46+
[g7]: #apic-cluster-status
47+
[g8]: #switch-fabric-membership-status
4848
[g9]: #ntp-status
4949
[g10]: #firmwaremaintenance-groups-when-crossing-40-release
5050
[g11]: #features-that-need-to-be-disabled-prior-to-upgrade
@@ -77,8 +77,8 @@ Items | Faults | This Script
7777
[Different infra VLAN via LLDP][f16] | F0454: infra-vlan-mismatch | :white_check_mark: | :white_check_mark: 4.2(4) | :white_check_mark:
7878
[HW Programming Failure][f17] | F3544: L3Out Prefixes<br>F3545: Contracts | :white_check_mark: | :white_check_mark: 5.1(1) | :white_check_mark:
7979
[Scalability (faults related to Capacity Dashboard)][f18] | TCA faults for eqptcapacityEntity | :white_check_mark: | :no_entry_sign: | :white_check_mark:
80-
[Fabric Port is Down][f19] | F1394: ethpm-if-port-down-fabric | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
81-
[Equipment Disk Limits Exceeded][f20] | F1820: 80% -minor<br>F1821: -major<br>F1822: -critical | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
80+
[Fabric Port Status][f19] | F1394: ethpm-if-port-down-fabric | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
81+
[Equipment Disk Limits][f20] | F1820: 80% -minor<br>F1821: -major<br>F1822: -critical | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
8282

8383

8484

@@ -100,8 +100,8 @@ Items | Faults | This Script
100100
[f16]: #different-infra-vlan-via-lldp
101101
[f17]: #hw-programming-failure
102102
[f18]: #scalability-faults-related-to-capacity-dashboard
103-
[f19]: #fabric-port-is-down
104-
[f20]: #equipment-disk-limits-exceeded
103+
[f19]: #fabric-port-status
104+
[f20]: #equipment-disk-limits
105105

106106

107107
### Configuration Checks
@@ -308,7 +308,7 @@ Upgrade Image transfer touchpoints:
308308
```
309309

310310

311-
### APIC Cluster is Fully-Fit
311+
### APIC Cluster Status
312312

313313
The script checks whether or not the APIC cluster is in the **Fully Fit** state.
314314

@@ -318,7 +318,7 @@ If your APICs are currently on release 4.2(1) or later, the command `acidiag clu
318318

319319

320320

321-
### Switches are all in Active state
321+
### Switch Fabric Membership Status
322322

323323
The script checks whether or not all ACI switches are in an **Active** state.
324324

@@ -1365,7 +1365,7 @@ Examples of what's monitored via `Operations > Capacity Dashboard > Leaf Capacit
13651365
```
13661366

13671367

1368-
### Fabric Port is Down
1368+
### Fabric Port Status
13691369

13701370
The script checks for fault code `F1394` with rule `ethpm-if-port-down-fabric`, which is raised against a fabric port that is admin up and used to be operaitonally up at some point in the past, but is now operationally down.
13711371

@@ -1461,7 +1461,7 @@ Failure to do so may lead to outages during switch upgrades due to leaf nodes no
14611461
```
14621462

14631463

1464-
### Equipment Disk Limits Exceeded
1464+
### Equipment Disk Limits
14651465

14661466
This fault occurs when the disk usage of a partiton increases beyond its threshold.
14671467

tests/test_AciResult.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22
import importlib
33
import json
4+
from six import string_types
45

56
script = importlib.import_module("aci-preupgrade-validation-script")
67

@@ -137,7 +138,7 @@
137138
"test reason",
138139
"https://test_doc_url.html",
139140
["col1", "col2", "col3"],
140-
[["row1", "row2", "row3"], ["row4", "row5", "row6"]],
141+
[["row1", None, 3], ["row4", None, 3]],
141142
[],
142143
[],
143144
True,
@@ -156,7 +157,7 @@
156157
[],
157158
[],
158159
["col1", "col2", "col3"],
159-
[["row1", "row2", "row3"], ["row4", "row5", "row6"]],
160+
[["row1", None, 3], ["row4", None, 3]],
160161
True,
161162
"critical",
162163
"failed"
@@ -188,7 +189,12 @@ def test_AciResult(
188189
assert data["showValidation"] == expected_show
189190
assert data["severity"] == expected_criticality
190191
assert data["ruleStatus"] == expected_passed
191-
192+
for entry in data["failureDetails"]["data"]:
193+
for vals in entry.values():
194+
assert isinstance(vals, string_types)
195+
for entry in data["failureDetails"]["unformatted_data"]:
196+
for vals in entry.values():
197+
assert isinstance(vals, string_types)
192198

193199
@pytest.mark.parametrize(
194200
"headers, data",
@@ -209,8 +215,22 @@ def test_invalid_headers_or_data(headers, data):
209215
@pytest.mark.parametrize(
210216
"headers, data",
211217
[
212-
(["col1", "col2"], [["row1"], ["row2"]]), # Rows are shorter
213-
(["col1"], [["row1", "row2"], ["row3", "row4"]]), # columns are shorter
218+
# Rows are shorter
219+
(
220+
["col1", "col2"],
221+
[
222+
["row1"],
223+
["row2"]
224+
]
225+
),
226+
# columns are shorter
227+
(
228+
["col1"],
229+
[
230+
["row1", "row2"],
231+
["row3", "row4"]
232+
]
233+
),
214234
]
215235
)
216236
def test_mismatched_lengths(headers, data):

0 commit comments

Comments
 (0)