Support retrieving Facts about Fibre Channel resource of HPE OneView (#28608)

* Added FcNetworkFactsModule to query FC Network Resources in HPE OneView

- Added unit tests

* Removing unnecessary quotes from example and documentation
This commit is contained in:
Felipe Garcia Bulsoni
2017-08-26 19:46:35 -03:00
committed by Dag Wieers
parent a1876bac9c
commit 978c64afc5
3 changed files with 156 additions and 0 deletions

View File

@@ -31,4 +31,5 @@ from ansible.module_utils.oneview import (OneViewModuleException,
from ansible.modules.remote_management.oneview.oneview_ethernet_network import EthernetNetworkModule
from ansible.modules.remote_management.oneview.oneview_fc_network import FcNetworkModule
from ansible.modules.remote_management.oneview.oneview_fc_network_facts import FcNetworkFactsModule
from ansible.modules.remote_management.oneview.oneview_fcoe_network import FcoeNetworkModule

View File

@@ -0,0 +1,57 @@
# Copyright (c) 2016-2017 Hewlett Packard Enterprise Development LP
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from ansible.compat.tests import unittest
from oneview_module_loader import FcNetworkFactsModule
from hpe_test_utils import FactsParamsTestCase
ERROR_MSG = 'Fake message error'
PARAMS_GET_ALL = dict(
config='config.json',
name=None
)
PARAMS_GET_BY_NAME = dict(
config='config.json',
name="Test FC Network"
)
PRESENT_NETWORKS = [{
"name": "Test FC Network",
"uri": "/rest/fc-networks/c6bf9af9-48e7-4236-b08a-77684dc258a5"
}]
class FcNetworkFactsSpec(unittest.TestCase,
FactsParamsTestCase):
def setUp(self):
self.configure_mocks(self, FcNetworkFactsModule)
self.fc_networks = self.mock_ov_client.fc_networks
FactsParamsTestCase.configure_client_mock(self, self.fc_networks)
def test_should_get_all_fc_networks(self):
self.fc_networks.get_all.return_value = PRESENT_NETWORKS
self.mock_ansible_module.params = PARAMS_GET_ALL
FcNetworkFactsModule().run()
self.mock_ansible_module.exit_json.assert_called_once_with(
changed=False,
ansible_facts=dict(fc_networks=PRESENT_NETWORKS)
)
def test_should_get_fc_network_by_name(self):
self.fc_networks.get_by.return_value = PRESENT_NETWORKS
self.mock_ansible_module.params = PARAMS_GET_BY_NAME
FcNetworkFactsModule().run()
self.mock_ansible_module.exit_json.assert_called_once_with(
changed=False,
ansible_facts=dict(fc_networks=PRESENT_NETWORKS)
)
if __name__ == '__main__':
unittest.main()