Add Servicetag parser (#16)
* 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:
parent
6246104090
commit
01d73089ed
1 changed files with 13 additions and 0 deletions
|
@ -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):
|
||||
|
||||
|
|
Loading…
Reference in a new issue