Skip to content

Commit

Permalink
Return correct version on installed VyOS (ansible#39115)
Browse files Browse the repository at this point in the history
* Return correct version on installed VyOS

Previously existing regexp will shows only "VyOS" without numeric output of router version.
For example: from  "Version:      VyOS 1.1.6" only VyOS will be written in ansible_net_version variable
For more informative output numeric value should be returned as well

* Fixed unittests

(cherry picked from commit 235b11f)
  • Loading branch information
maugli13 authored and NilashishC committed Oct 10, 2018
1 parent 4dee2c6 commit 63df30a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/ansible/modules/network/vyos/vyos_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def populate(self):
self.facts['hostname'] = self.responses[1]

def parse_version(self, data):
match = re.search(r'Version:\s*(\S+)', data)
match = re.search(r'Version:\s*(.*)', data)
if match:
return match.group(1)

Expand Down
6 changes: 3 additions & 3 deletions test/units/modules/network/vyos/test_vyos_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ def test_vyos_facts_default(self):
facts = result.get('ansible_facts')
self.assertEqual(len(facts), 5)
self.assertEqual(facts['ansible_net_hostname'].strip(), 'vyos01')
self.assertEqual(facts['ansible_net_version'], 'VyOS')
self.assertEqual(facts['ansible_net_version'], 'VyOS 1.1.7')

def test_vyos_facts_not_all(self):
set_module_args(dict(gather_subset='!all'))
result = self.execute_module()
facts = result.get('ansible_facts')
self.assertEqual(len(facts), 5)
self.assertEqual(facts['ansible_net_hostname'].strip(), 'vyos01')
self.assertEqual(facts['ansible_net_version'], 'VyOS')
self.assertEqual(facts['ansible_net_version'], 'VyOS 1.1.7')

def test_vyos_facts_exclude_most(self):
set_module_args(dict(gather_subset=['!neighbors', '!config']))
result = self.execute_module()
facts = result.get('ansible_facts')
self.assertEqual(len(facts), 5)
self.assertEqual(facts['ansible_net_hostname'].strip(), 'vyos01')
self.assertEqual(facts['ansible_net_version'], 'VyOS')
self.assertEqual(facts['ansible_net_version'], 'VyOS 1.1.7')

def test_vyos_facts_invalid_subset(self):
set_module_args(dict(gather_subset='cereal'))
Expand Down

0 comments on commit 63df30a

Please sign in to comment.