mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-23 04:24:00 -07:00
nos_facts module and tests (#44094)
This commit is contained in:
parent
b0a25d321d
commit
bec0a1ceb3
5 changed files with 541 additions and 0 deletions
|
@ -0,0 +1,3 @@
|
|||
NAME: Chassis DESCR:System Chassis
|
||||
SID:BR-VDX6740 SwitchType:131
|
||||
PN:40-1000927-06 SN:CPL2541K01E
|
|
@ -0,0 +1 @@
|
|||
switch-attributes host-name LEAF4
|
|
@ -0,0 +1,17 @@
|
|||
Network Operating System Software
|
||||
Network Operating System Version: 7.2.0
|
||||
Copyright (c) 1995-2017 Brocade Communications Systems, Inc.
|
||||
Firmware name: 7.2.0
|
||||
Build Time: 10:52:47 Jul 10, 2017
|
||||
Install Time: 01:32:03 Jan 5, 2018
|
||||
Kernel: 2.6.34.6
|
||||
|
||||
BootProm: 1.0.1
|
||||
Control Processor: e500mc with 4096 MB of memory
|
||||
|
||||
Slot Name Primary/Secondary Versions Status
|
||||
---------------------------------------------------------------------------
|
||||
SW/0 NOS 7.2.0 ACTIVE*
|
||||
7.2.0
|
||||
SW/1 NOS 7.2.0 STANDBY
|
||||
7.2.0
|
61
test/units/modules/network/nos/test_nos_facts.py
Normal file
61
test/units/modules/network/nos/test_nos_facts.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
#
|
||||
# (c) 2018 Extreme Networks Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.nos import nos_facts
|
||||
from units.modules.utils import set_module_args
|
||||
from .nos_module import TestNosModule, load_fixture
|
||||
|
||||
|
||||
class TestNosFactsModule(TestNosModule):
|
||||
|
||||
module = nos_facts
|
||||
|
||||
def setUp(self):
|
||||
super(TestNosFactsModule, self).setUp()
|
||||
self.mock_run_commands = patch('ansible.modules.network.nos.nos_facts.run_commands')
|
||||
self.run_commands = self.mock_run_commands.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestNosFactsModule, self).tearDown()
|
||||
self.mock_run_commands.stop()
|
||||
|
||||
def load_fixtures(self, commands=None):
|
||||
def load_from_file(*args, **kwargs):
|
||||
commands = args[1]
|
||||
output = list()
|
||||
|
||||
for command in commands:
|
||||
filename = str(command).split(' | ')[0].replace(' ', '_')
|
||||
output.append(load_fixture('nos_facts_%s' % filename))
|
||||
return output
|
||||
|
||||
self.run_commands.side_effect = load_from_file
|
||||
|
||||
def test_nos_facts(self):
|
||||
set_module_args(dict(gather_subset='default'))
|
||||
result = self.execute_module()
|
||||
self.assertEqual(
|
||||
result['ansible_facts']['ansible_net_model'], 'BR-VDX6740'
|
||||
)
|
||||
self.assertEqual(
|
||||
result['ansible_facts']['ansible_net_serialnum'], 'CPL2541K01E'
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue