diff --git a/examples/oneview_appliance_device_snmp_v1_trap_destinations.yml b/examples/oneview_appliance_device_snmp_v1_trap_destinations.yml index 27b176782..dab2a9b79 100644 --- a/examples/oneview_appliance_device_snmp_v1_trap_destinations.yml +++ b/examples/oneview_appliance_device_snmp_v1_trap_destinations.yml @@ -18,7 +18,7 @@ - hosts: all vars: config: "{{ playbook_dir }}/oneview_config.json" - destination_address: "" + destination_address: "1.1.1.2" tasks: - name: Create or Update an Appliance Device SNMPv1 Trap Destination by Destination Address oneview_appliance_device_snmp_v1_trap_destinations: diff --git a/examples/oneview_appliance_device_snmp_v1_trap_destinations_facts.yml b/examples/oneview_appliance_device_snmp_v1_trap_destinations_facts.yml index a10c5781d..43a97c383 100644 --- a/examples/oneview_appliance_device_snmp_v1_trap_destinations_facts.yml +++ b/examples/oneview_appliance_device_snmp_v1_trap_destinations_facts.yml @@ -52,6 +52,7 @@ config: "{{ config }}" uri: "{{ appliance_device_snmp_v1_trap_destinations['uri'] }}" delegate_to: localhost + when: appliance_device_snmp_v1_trap_destinations == True - debug: var: appliance_device_snmp_v1_trap_destinations diff --git a/examples/oneview_appliance_device_snmp_v3_trap_destinations.yml b/examples/oneview_appliance_device_snmp_v3_trap_destinations.yml index 0d1339666..8ede7ad50 100644 --- a/examples/oneview_appliance_device_snmp_v3_trap_destinations.yml +++ b/examples/oneview_appliance_device_snmp_v3_trap_destinations.yml @@ -18,7 +18,7 @@ - hosts: all vars: config: "{{ playbook_dir }}/oneview_config.json" - destination_address: "" + destination_address: "1.1.1.1" tasks: - name: Ensure that the SNMPv3 Trap Destination is present oneview_appliance_device_snmp_v3_trap_destinations: @@ -28,7 +28,7 @@ data: destinationAddress: "{{ destination_address }}" port: 162 - userName: "test1" + userName: "user123456" delegate_to: localhost - debug: @@ -42,7 +42,7 @@ data: destinationAddress: "{{ destination_address }}" port: 162 - userName: "test1" + userName: "user123456" delegate_to: localhost - name: Update the userId of specified SNMPv3 Trap Destination @@ -71,3 +71,14 @@ state: absent name: "{{ destination_address }}" delegate_to: localhost + + - name: Creating the SNMPv3 Trap Destination for automation + oneview_appliance_device_snmp_v3_trap_destinations: + config: "{{ config }}" + state: present + name: "1.1.1.1" + data: + destinationAddress: "{{ destination_address }}" + port: 162 + userName: "user123456" + delegate_to: localhost diff --git a/examples/oneview_appliance_device_snmp_v3_trap_destinations_facts.yml b/examples/oneview_appliance_device_snmp_v3_trap_destinations_facts.yml index 88ccdbb1e..5c51c8aa5 100644 --- a/examples/oneview_appliance_device_snmp_v3_trap_destinations_facts.yml +++ b/examples/oneview_appliance_device_snmp_v3_trap_destinations_facts.yml @@ -53,6 +53,3 @@ config: "{{ config }}" uri: "{{ appliance_device_snmp_v3_trap_destinations['uri'] }}" delegate_to: localhost - - - debug: - var: appliance_device_snmp_v3_trap_destinations \ No newline at end of file diff --git a/examples/oneview_appliance_device_snmp_v3_users.yml b/examples/oneview_appliance_device_snmp_v3_users.yml index 2bfe0f016..6a6303ef4 100644 --- a/examples/oneview_appliance_device_snmp_v3_users.yml +++ b/examples/oneview_appliance_device_snmp_v3_users.yml @@ -57,3 +57,23 @@ data: userName: "testUser" delegate_to: localhost + + - name: Creating the SNMPv3 user for automation + oneview_appliance_device_snmp_v3_users: + config: "{{ config }}" + state: present + name: "user123456" + data: + type: "Users" + userName: "user123456" + delegate_to: localhost + + - name: Creating another SNMPv3 user for automation + oneview_appliance_device_snmp_v3_users: + config: "{{ config }}" + state: present + name: "test2" + data: + type: "Users" + userName: "test2" + delegate_to: localhost diff --git a/examples/oneview_appliance_device_snmp_v3_users_facts.yml b/examples/oneview_appliance_device_snmp_v3_users_facts.yml index 687224ae1..b2f8db5b8 100644 --- a/examples/oneview_appliance_device_snmp_v3_users_facts.yml +++ b/examples/oneview_appliance_device_snmp_v3_users_facts.yml @@ -43,7 +43,6 @@ config: "{{ config }}" name: "user123456" delegate_to: localhost - - debug: var: appliance_device_snmp_v3_users @@ -52,6 +51,4 @@ config: "{{ config }}" uri: "{{ appliance_device_snmp_v3_users['uri'] }}" delegate_to: localhost - - - debug: - var: appliance_device_snmp_v3_users \ No newline at end of file + when: appliance_device_snmp_v3_users == True diff --git a/examples/oneview_fc_network_facts.yml b/examples/oneview_fc_network_facts.yml index 34ce5a545..cf1b3daf7 100644 --- a/examples/oneview_fc_network_facts.yml +++ b/examples/oneview_fc_network_facts.yml @@ -40,5 +40,6 @@ config: "{{ config }}" name: "{{ fc_networks[0]['name'] }}" delegate_to: localhost + when: fc_networks == True - debug: var=fc_networks diff --git a/examples/oneview_id_pools_ipv4_range.yml b/examples/oneview_id_pools_ipv4_range.yml index e9b599eb4..a36733f4e 100644 --- a/examples/oneview_id_pools_ipv4_range.yml +++ b/examples/oneview_id_pools_ipv4_range.yml @@ -17,10 +17,10 @@ - hosts: all vars: config: "{{ playbook_dir }}/oneview_config.json" - subnet_name: Range Test IPv4 Subnet + subnet_name: IPV4Subnet range_name: Experts Range disabled_range_name: DISABLED - Experts Range - subnet_uri: "/rest/id-pools/ipv4/subnets/8e382eba-6731-4980-88de-ef1278eaf8d6" + subnet_uri: "/rest/id-pools/ipv4/subnets/eb77fe62-5066-492f-8e12-d3a66b2f757d" tasks: - name: Ensure the IPV4 Range '{{ range_name }}' exists oneview_id_pools_ipv4_range: @@ -35,7 +35,7 @@ endAddress: 192.168.1.54 delegate_to: localhost - - set_fact: uri="{{ id_pool_ipv4_range['uri'] }}" + - set_fact: uri="{{ id_pools_ipv4_range['uri'] }}" - name: Update the ID Pools IPV4 Range with end address 101 oneview_id_pools_ipv4_range: @@ -64,7 +64,7 @@ config: "{{ config }}" state: present data: - uri: "" + uri: "{{ uri }}" count: 2 update_allocator: True idList: @@ -76,13 +76,12 @@ config: "{{ config }}" state: present data: - uri: "" + uri: "{{ uri }}" update_collector: True idList: - "" delegate_to: localhost - - name: Ensure the IPV4 Range is disabled with DISABLED tag in the name oneview_id_pools_ipv4_range: config: "{{ config }}" diff --git a/examples/oneview_id_pools_ipv4_range_facts.yml b/examples/oneview_id_pools_ipv4_range_facts.yml index 9ba45267d..c35531a47 100644 --- a/examples/oneview_id_pools_ipv4_range_facts.yml +++ b/examples/oneview_id_pools_ipv4_range_facts.yml @@ -17,13 +17,13 @@ - hosts: all vars: config: "{{ playbook_dir }}/oneview_config.json" - subnet_name: subnet + subnet_name: 10.1.0.0 range_name: 10.1.0.0 Range 1 tasks: - name: Get facts about the IPv4 Subnet oneview_id_pools_ipv4_subnet_facts: config: "{{ config }}" - name: '{{ subnet_name }}' + networkId: '{{ subnet_name }}' delegate_to: localhost - debug: var=id_pools_ipv4_subnets @@ -62,12 +62,14 @@ - debug: var=id_pools_ipv4_ranges - set_fact: range_uri='{{ id_pools_ipv4_ranges[0]['uri'] }}' + when: id_pools_ipv4_ranges == True - name: Get facts about the range '{{ range_uri }}' oneview_id_pools_ipv4_range_facts: config: "{{ config }}" uri: '{{ range_uri }}' delegate_to: localhost + when: range_uri is defined - debug: var=id_pools_ipv4_ranges @@ -79,6 +81,7 @@ - allocatedFragments uri: '{{ range_uri }}' delegate_to: localhost + when: range_uri is defined - debug: var=id_pools_ipv4_ranges - debug: var=id_pools_ipv4_ranges_free_fragments diff --git a/examples/oneview_id_pools_ipv4_subnet.yml b/examples/oneview_id_pools_ipv4_subnet.yml index d75d07fb7..ba63e6eca 100644 --- a/examples/oneview_id_pools_ipv4_subnet.yml +++ b/examples/oneview_id_pools_ipv4_subnet.yml @@ -18,7 +18,7 @@ vars: config: "{{ playbook_dir }}/oneview_config.json" subnet_name: IPV4Subnet - networkId: '10.1.0.0' + network_id: '10.1.0.0' tasks: - name: Ensure the ID Pools IPV4 Subnet exists oneview_id_pools_ipv4_subnet: @@ -27,9 +27,9 @@ data: name: '{{ subnet_name }}' type: Subnet - networkId: 10.10.1.0 - subnetmask: 255.255.255.0 - gateway: 10.10.1.1 + networkId: '{{ network_id }}' + subnetmask: 255.255.192.0 + gateway: '10.1.0.1' domain: example.com dnsServers: - 10.10.10.215 diff --git a/library/oneview_appliance_time_and_locale_configuration_facts.py b/library/oneview_appliance_time_and_locale_configuration_facts.py index 19a47411e..cfeb08154 100644 --- a/library/oneview_appliance_time_and_locale_configuration_facts.py +++ b/library/oneview_appliance_time_and_locale_configuration_facts.py @@ -63,7 +63,7 @@ def __init__(self): def execute_module(self): appliance_time_and_locale_configuration = self.resource_client.get_all() return dict(changed=False, - ansible_facts=dict(appliance_time_and_locale_configuration=appliance_time_and_locale_configuration)) + ansible_facts=dict(appliance_time_and_locale_configuration=appliance_time_and_locale_configuration.data)) def main(): diff --git a/library/oneview_id_pools_ipv4_range.py b/library/oneview_id_pools_ipv4_range.py index e2966ebe0..f20f2b968 100644 --- a/library/oneview_id_pools_ipv4_range.py +++ b/library/oneview_id_pools_ipv4_range.py @@ -101,8 +101,8 @@ def execute_module(self): self.current_resource = self.resource_client.get_by_uri(self.data.get('uri')) # Do preliminary check before creating a new range elif self.data.get('subnetUri') and self.data.get('name'): - subnet = self.oneview_client.id_pools_ipv4_subnets.get(self.data.get('subnetUri')) - for range_uri in subnet['rangeUris']: + subnet = self.oneview_client.id_pools_ipv4_subnets.get_by_uri(self.data.get('subnetUri')) + for range_uri in subnet.data['rangeUris']: maybe_resource = self.resource_client.get_by_uri(range_uri) if maybe_resource.data['name'] == self.data['name']: self.current_resource = maybe_resource diff --git a/library/oneview_id_pools_ipv4_range_facts.py b/library/oneview_id_pools_ipv4_range_facts.py index 5a3baf35e..e37178695 100644 --- a/library/oneview_id_pools_ipv4_range_facts.py +++ b/library/oneview_id_pools_ipv4_range_facts.py @@ -146,16 +146,16 @@ def execute_module(self): if self.module.params.get('uri'): id_pools_ipv4_ranges = self.resource_client.get_by_uri(self.module.params['uri']).data elif self.module.params.get('subnetUri'): - subnet = self.oneview_client.id_pools_ipv4_subnets.get(self.module.params.get('subnetUri')) + subnet = self.oneview_client.id_pools_ipv4_subnets.get_by_uri(self.module.params.get('subnetUri')) if self.module.params.get('name'): - for range_uri in subnet['rangeUris']: + for range_uri in subnet.data['rangeUris']: maybe_resource = self.resource_client.get_by_uri(range_uri).data if maybe_resource['name'] == self.module.params.get('name'): id_pools_ipv4_ranges = maybe_resource break else: is_specific_resource = False - for range_uri in subnet['rangeUris']: + for range_uri in subnet.data['rangeUris']: id_pools_ipv4_ranges.append(self.resource_client.get_by_uri(range_uri).data) else: is_specific_resource = False diff --git a/test/test_oneview_appliance_time_and_locale_configuration_facts.py b/test/test_oneview_appliance_time_and_locale_configuration_facts.py index 5bd90bd08..4993a84c2 100644 --- a/test/test_oneview_appliance_time_and_locale_configuration_facts.py +++ b/test/test_oneview_appliance_time_and_locale_configuration_facts.py @@ -35,7 +35,8 @@ @pytest.mark.resource(TestApplianceTimeAndLocaleConfigurationFactsModule='appliance_time_and_locale_configuration') class TestApplianceTimeAndLocaleConfigurationFactsModule(OneViewBaseTest): def test_should_get_appliance_time_and_locale_configuration(self): - self.resource.get_all.return_value = PRESENT_CONFIGURATION + self.resource.get_all.return_value = self.resource + self.resource.data = PRESENT_CONFIGURATION self.mock_ansible_module.params = PARAMS_GET ApplianceTimeAndLocaleConfigurationFactsModule().run() diff --git a/test/test_oneview_id_pools_ipv4_range.py b/test/test_oneview_id_pools_ipv4_range.py index 0d912d284..4314239cd 100644 --- a/test/test_oneview_id_pools_ipv4_range.py +++ b/test/test_oneview_id_pools_ipv4_range.py @@ -17,6 +17,7 @@ ### import pytest +import mock from hpe_test_utils import OneViewBaseTest from oneview_module_loader import IdPoolsIpv4RangeModule @@ -236,9 +237,11 @@ def test_should_allocate_id_to_ip_range(self): ) def test_should_delete_the_ipv4_range_when_it_exists(self): - self.mock_ov_client.id_pools_ipv4_subnets.get.return_value = DEFAULT_SUBNET_TEMPLATE - self.resource.get_by_uri().data = DEFAULT_RANGE_TEMPLATE - self.resource.delete.return_value = None + self.resource.get_by_uri.return_value = self.resource + self.resource.data = DEFAULT_SUBNET_TEMPLATE + obj = mock.Mock() + obj.data = DEFAULT_RANGE_TEMPLATE + self.mock_ov_client.id_pools_ipv4_subnets.get_by_uri.return_value = self.resource self.mock_ansible_module.params = PARAMS_FOR_ABSENT IdPoolsIpv4RangeModule().run() @@ -249,8 +252,9 @@ def test_should_delete_the_ipv4_range_when_it_exists(self): ) def test_should_not_delete_when_id_pools_ipv4_range_do_not_exist(self): - self.mock_ov_client.id_pools_ipv4_subnets.get.return_value = DEFAULT_SUBNET_TEMPLATE - self.resource.get.side_effect = [DEFAULT_NOT_RANGE_TEMPLATE, DEFAULT_NOT_RANGE_TEMPLATE] + self.resource.get_by_uri.return_value = DEFAULT_SUBNET_TEMPLATE + self.resource.data = DEFAULT_SUBNET_TEMPLATE + self.resource.get_by_uri.side_effect = [DEFAULT_NOT_RANGE_TEMPLATE, DEFAULT_NOT_RANGE_TEMPLATE] self.mock_ansible_module.params = PARAMS_FOR_ABSENT IdPoolsIpv4RangeModule().run() diff --git a/test/test_oneview_id_pools_ipv4_range_facts.py b/test/test_oneview_id_pools_ipv4_range_facts.py index 0aeb8c289..3645da2ad 100644 --- a/test/test_oneview_id_pools_ipv4_range_facts.py +++ b/test/test_oneview_id_pools_ipv4_range_facts.py @@ -17,6 +17,7 @@ ### import pytest +import mock from hpe_test_utils import OneViewBaseTest from oneview_module_loader import IdPoolsIpv4RangeFactsModule @@ -115,11 +116,14 @@ def test_should_get_all_id_pools_ipv4_ranges(self): ) def test_should_get_all_id_pools_ipv4_ranges_from_subnet(self): - self.mock_ov_client.id_pools_ipv4_subnets.get.return_value = DEFAULT_SUBNET_TEMPLATE_2 + obj = mock.Mock() + obj.data = DEFAULT_SUBNET_TEMPLATE_2 + self.mock_ov_client.id_pools_ipv4_subnets.get_by_uri.return_value = obj range_1 = DEFAULT_RANGE_TEMPLATE.copy() range_4 = DEFAULT_RANGE_TEMPLATE.copy() ranges = [range_1, range_4] - self.resource.get_by_uri().data = range_1 + self.resource.get_by_uri.return_value = self.resource + self.resource.data = range_1 self.mock_ansible_module.params = PARAMS_GET_ALL_FROM_SUBNET IdPoolsIpv4RangeFactsModule().run() @@ -130,10 +134,13 @@ def test_should_get_all_id_pools_ipv4_ranges_from_subnet(self): ) def test_should_get_id_pools_ipv4_range_from_subnet_and_name(self): - self.mock_ov_client.id_pools_ipv4_subnets.get.return_value = DEFAULT_SUBNET_TEMPLATE_2 + obj = mock.Mock() + obj.data = DEFAULT_SUBNET_TEMPLATE_2 + self.mock_ov_client.id_pools_ipv4_subnets.get_by_uri.return_value = obj range_1 = DEFAULT_RANGE_TEMPLATE.copy() - self.resource.get_by_uri().data = range_1 + self.resource.get_by_uri.return_value = self.resource + self.resource.data = range_1 self.mock_ansible_module.params = PARAMS_GET_BY_NAME_AND_SUBNET_URI IdPoolsIpv4RangeFactsModule().run() @@ -145,7 +152,8 @@ def test_should_get_id_pools_ipv4_range_from_subnet_and_name(self): def test_should_get_id_pools_ipv4_range_from_uri(self): - self.resource.get_by_uri().data = DEFAULT_RANGE_TEMPLATE.copy() + self.resource.get_by_uri.return_value = self.resource + self.resource.data = DEFAULT_RANGE_TEMPLATE.copy() self.mock_ansible_module.params = PARAMS_GET_BY_URI IdPoolsIpv4RangeFactsModule().run()