-
Notifications
You must be signed in to change notification settings - Fork 41
Added validation for HW_Changes_bit_check - CSCvv04251 #300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
asraf-khan
wants to merge
6
commits into
datacenter:master
Choose a base branch
from
asraf-khan:issue1-CSCvv04251
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ce1f777
Added Preupgrade-validation script with HW_Changes_bit_check - CSCvv0…
asraf-khan 920fbe5
Added proper variable Name
asraf-khan 4c77710
Updated comments for bind_ip and aligned result properly
asraf-khan 40ab968
Updated fetching APIC IP for bind IP
asraf-khan 56a5006
Added takuya changes on get_vpc_nodes function
asraf-khan 61c0541
Merge branch 'master' into issue1-CSCvv04251
asraf-khan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,6 +151,7 @@ def __init__(self, hostname): | |
| self._term_len = 0 # terminal length for cisco devices | ||
| self._login = False # set to true at first successful login | ||
| self._log = None # private variable for tracking logfile state | ||
| self.bind_ip = None # optional source IP to bind for SSH | ||
|
|
||
| def __connected(self): | ||
| # determine if a connection is already open | ||
|
|
@@ -207,6 +208,8 @@ def connect(self): | |
| "spawning new pexpect connection: ssh %s@%s -p %d" % (self.username, self.hostname, self.port)) | ||
| no_verify = " -o StrictHostKeyChecking=no -o LogLevel=ERROR -o UserKnownHostsFile=/dev/null" | ||
| if self.verify: no_verify = "" | ||
| if self.bind_ip: | ||
| no_verify += " -b %s" % self.bind_ip | ||
| self.child = pexpect.spawn("ssh %s %s@%s -p %d" % (no_verify, self.username, self.hostname, self.port), | ||
| searchwindowsize=self.searchwindowsize) | ||
| elif self.protocol.lower() == "telnet": | ||
|
|
@@ -5970,7 +5973,6 @@ def configpush_shard_check(tversion, **kwargs): | |
|
|
||
| return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url) | ||
|
|
||
|
|
||
| @check_wrapper(check_title='APIC VMM inventory sync fault (F0132)') | ||
| def apic_vmm_inventory_sync_faults_check(**kwargs): | ||
| result = PASS | ||
|
|
@@ -6007,6 +6009,108 @@ def apic_vmm_inventory_sync_faults_check(**kwargs): | |
| recommended_action=recommended_action, | ||
| doc_url=doc_url) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic is not following format of the old script. please follow the same structure |
||
| @check_wrapper(check_title="HW Changes bit check for specific node model") | ||
| def HW_changes_bit_check(tversion, username, password, fabric_nodes, **kwargs): | ||
| result = PASS | ||
| headers = ["Node", "Model", "HW Changes Bits", "Recommended Action"] | ||
| data = [] | ||
| recommended_action = "Contact Cisco TAC for Support before upgrade" | ||
| doc_url = "https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/#HW_changes_bit_check" | ||
|
|
||
| if not tversion: | ||
| return Result(result=MANUAL, msg=TVER_MISSING) | ||
| if not tversion.newer_than("14.2(4a)"): | ||
| return Result(result=NA, msg=VER_NOT_AFFECTED) | ||
|
|
||
| affected_models = {"N9K-C9316D-GX", "N9K-C93600CD-GX"} | ||
|
|
||
| node_found = any( | ||
| node["fabricNode"]["attributes"]["model"] in affected_models | ||
| for node in fabric_nodes | ||
| ) | ||
|
|
||
asraf-khan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if not node_found: | ||
| return Result(result=PASS, msg="No switch models found") | ||
|
|
||
| # Discover APIC IP (bind source) | ||
| try: | ||
| apic_hostname = run_cmd("bash -c \"hostname\"", splitlines=True)[0].strip() | ||
| if not apic_hostname: | ||
| return Result(result=ERROR, msg="Could not determine APIC hostname") | ||
|
|
||
| apic_ip = next( | ||
| (node["fabricNode"]["attributes"].get("address") | ||
| for node in fabric_nodes | ||
| if node["fabricNode"]["attributes"]["name"] == apic_hostname), | ||
| None | ||
| ) | ||
| except Exception as e: | ||
| return Result(result=ERROR, msg="Failed to get APIC IP: {}".format(e)) | ||
|
|
||
| if not apic_ip: | ||
| return Result(result=ERROR, msg="Could not determine APIC IP from fabricNode attributes") | ||
|
|
||
| hw_bits_re = re.compile(r"HW Changes Bits\s*:\s*(0x[0-9a-fA-F]+)") | ||
| has_error = False | ||
|
|
||
| # SSH directly to each switch hostname from APIC, binding source to APIC IP (-b <apic_ip>) | ||
| for node in fabric_nodes: | ||
| if node["fabricNode"]["attributes"]["model"] not in ["N9K-C9316D-GX", "N9K-C93600CD-GX"]: | ||
| continue | ||
| attr = node['fabricNode']['attributes'] | ||
| node_name = attr['name'] | ||
| node_model = attr['model'] | ||
|
|
||
| node_title = "Checking {} ({})...".format(node_name, node_model) | ||
| try: | ||
| c = Connection(node_name) | ||
| c.username = username | ||
| c.password = password | ||
| c.log = LOG_FILE | ||
| c.bind_ip = apic_ip # enables: ssh <hostname> -b <APIC_IP> | ||
| c.connect() | ||
| except Exception as e: | ||
| data.append([node_name, node_model, "-", "Connection Error: {}".format(str(e))]) | ||
| has_error = True | ||
| continue | ||
|
|
||
| try: | ||
| # Execute command to check HW Changes Bits | ||
| c.cmd("vsh -c 'show sprom cpu-info' | grep \"HW Changes Bits\"") | ||
| raw = c.output.strip() | ||
| match = hw_bits_re.search(raw) | ||
| if not match: | ||
| data.append([node_name, node_model, "Parse Error", "Unable to parse HW Changes Bits"]) | ||
| has_error = True | ||
| else: | ||
| hw_bits = match.group(1) | ||
| val = int(hw_bits, 16) | ||
| if val < 2: | ||
| result = FAIL_O | ||
| data.append([node_name, node_model, hw_bits, "This switch need Manual Upgrade (CSCvv04251). Contact TAC for Support"]) | ||
| except Exception as e: | ||
| data.append([ | ||
| node_name, | ||
| node_model, | ||
| '-', | ||
| 'Failed to check HW Changes Bits: {}. Please check MANUALLY.'.format(str(e)) | ||
| ]) | ||
| has_error = True | ||
| continue | ||
| finally: | ||
| try: | ||
| c.close() | ||
| except Exception: | ||
| pass | ||
|
|
||
| if has_error and result == PASS: | ||
| result = ERROR | ||
| elif not data: | ||
| result = PASS | ||
|
|
||
| return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url) | ||
|
|
||
|
|
||
| # ---- Script Execution ---- | ||
|
|
||
|
|
||
|
|
@@ -6168,6 +6272,7 @@ class CheckManager: | |
| standby_sup_sync_check, | ||
| isis_database_byte_check, | ||
| configpush_shard_check, | ||
| HW_changes_bit_check, | ||
|
|
||
| ] | ||
| ssh_checks = [ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.