Add Servicetag parser ()

* Add Servicetag parser

* S4810s have stacknode numbers starting at 0

* linting

Co-authored-by: Bill Melvin <Bill.Melvin@esc.edu>
This commit is contained in:
bk2zsto 2021-02-09 14:47:06 -05:00 committed by GitHub
parent 6246104090
commit 01d73089ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -71,6 +71,10 @@ ansible_net_serialnum:
description: The serial number of the remote device
returned: always
type: str
ansible_net_servicetags:
description: The servicetags from remote device
returned: always
type: list
ansible_net_version:
description: The operating system version running on the remote device
returned: always
@ -164,6 +168,7 @@ class Default(FactsBase):
data = self.responses[1]
self.facts['serialnum'] = self.parse_serialnum(data)
self.facts['servicetags'] = self.parse_servicetags(data)
data = self.responses[2]
self.facts['hostname'] = self.parse_hostname(data)
@ -196,6 +201,14 @@ class Default(FactsBase):
if match:
return match.group(3)
def parse_servicetags(self, data):
tags = []
for line in data.split('\n'):
match = re.match(r'\**\s+[0-9]+\s+.*(\b[A-Z0-9]{7}\b)', line)
if match:
tags.append(match.group(1))
return tags
class Hardware(FactsBase):