예제 #1
0
    def test_update_vlan_description(self, *args):
        set_module_args(
            dict(name='somevlan',
                 description='changed_that',
                 partition='Common',
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode,
            mutually_exclusive=self.spec.mutually_exclusive)

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)

        current = ApiParameters(
            params=load_fixture('update_vlan_description.json'))

        mm.update_on_device = Mock(return_value=True)
        mm.exists = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['description'] == 'changed_that'
    def test_update_interval_larger_than_new_timeout(self, *args):
        set_module_args(
            dict(name='foo',
                 interval=10,
                 timeout=5,
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        current = Parameters(
            params=load_fixture('load_ltm_monitor_tcp_half_open.json'))
        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)

        # Override methods in the specific type of manager
        mm = ModuleManager(module=module)
        mm.exists = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)
        mm.update_on_device = Mock(return_value=True)

        with pytest.raises(F5ModuleError) as ex:
            mm.exec_module()

        assert "must be less than" in str(ex.value)
    def test_update_issue_00522_as_list(self, *args):
        set_module_args(
            dict(
                ssl_cipher_suite=[
                    'ECDHE-RSA-AES128-GCM-SHA256',
                    'ECDHE-RSA-AES256-GCM-SHA384'
                ],
                provider=dict(
                    server='localhost',
                    password='******',
                    user='******'
                )
            )
        )

        current = Parameters(params=load_fixture('load_sys_httpd.json'))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode
        )
        mm = ModuleManager(module=module)

        # Override methods to force specific logic in the module to happen
        mm.update_on_device = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)

        results = mm.exec_module()
        assert results['changed'] is True
        assert results['ssl_cipher_suite'] == 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384'
예제 #4
0
    def test_create_virtual_address(self, *args):
        set_module_args(dict(
            state='present',
            address='1.1.1.1',
            netmask='2.2.2.2',
            connection_limit='10',
            arp='yes',
            auto_delete='yes',
            icmp_echo='enabled',
            advertise_route='always',
            provider=dict(
                server='localhost',
                password='******',
                user='******'
            )
        ))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode,
            required_one_of=self.spec.required_one_of
        )
        mm = ModuleManager(module=module)

        # Override methods to force specific logic in the module to happen
        mm.exists = Mock(side_effect=[False, True])
        mm.create_on_device = Mock(return_value=True)

        results = mm.exec_module()
        assert results['changed'] is True
    def test_create_policy_rule_no_existence(self, *args):
        set_module_args(
            dict(name="rule1",
                 state='present',
                 policy='policy1',
                 actions=[dict(type='forward', pool='baz')],
                 conditions=[
                     dict(type='http_uri', path_begins_with_any=['/ABC'])
                 ],
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)
        mm.exists = Mock(return_value=False)
        mm.publish_on_device = Mock(return_value=True)
        mm.draft_exists = Mock(return_value=False)
        mm._create_existing_policy_draft_on_device = Mock(return_value=True)
        mm.create_on_device = Mock(return_value=True)

        results = mm.exec_module()

        assert results['changed'] is True
예제 #6
0
    def test_update_hostname(self, *args):
        set_module_args(dict(
            hostname='foo2.internal.com',
            provider=dict(
                server='localhost',
                password='******',
                user='******'
            )
        ))

        # Configure the parameters that would be returned by querying the
        # remote device
        current = ApiParameters(
            params=dict(
                hostname='foo.internal.com'
            )
        )
        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode
        )

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)
        mm.update_on_device = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['hostname'] == 'foo2.internal.com'
    def test_create_enabled_datacenter(self, *args):
        set_module_args(dict(
            name='foo',
            state='enabled',
            provider=dict(
                server='localhost',
                password='******',
                user='******'
            )

        ))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode
        )
        mm = ModuleManager(module=module)

        # Override methods to force specific logic in the module to happen
        mm.exists = Mock(side_effect=[False, True])
        mm.create_on_device = Mock(return_value=True)
        mm.module_provisioned = Mock(return_value=True)

        results = mm.exec_module()
        assert results['changed'] is True
        assert results['enabled'] is True
        assert results['disabled'] is False
    def test_create_monitor(self, *args):
        set_module_args(
            dict(name='foo',
                 parent='parent',
                 ip='10.10.10.10',
                 port=80,
                 interval=20,
                 timeout=30,
                 partition='Common',
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)

        # Override methods in the specific type of manager
        mm = ModuleManager(module=module)
        mm.exists = Mock(side_effect=[False, True])
        mm.create_on_device = Mock(return_value=True)

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['parent'] == '/Common/parent'
예제 #9
0
    def test_create(self, *args):
        set_module_args(
            dict(name='foo',
                 description='my description',
                 service_environment='bar',
                 servers=[
                     dict(address='1.2.3.4', port=8080),
                     dict(address='5.6.7.8', port=8000)
                 ],
                 inbound_virtual=dict(address='2.2.2.2',
                                      netmask='255.255.255.255',
                                      port=80),
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)
        mm.check_bigiq_version = Mock(return_value=True)
        mm.has_no_service_environment = Mock(return_value=False)
        mm.wait_for_apply_template_task = Mock(return_value=True)

        mm.create_on_device = Mock(return_value=True)
        mm.exists = Mock(side_effect=[False, True])

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['description'] == 'my description'
예제 #10
0
    def test_ucs_absent_exists(self, *args):
        set_module_args(dict(
            ucs="/root/bigip.localhost.localdomain.ucs",
            state='absent',
            provider=dict(
                server='localhost',
                password='******',
                user='******'
            )
        ))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode
        )

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)
        mm.is_version_v1 = Mock(return_value=False)

        vm = V1Manager(module=module)
        vm.remove_from_device = Mock(return_value=True)
        vm.exists = Mock(side_effect=[True, False])

        results = vm.exec_module()

        assert results['changed'] is True
예제 #11
0
    def test_ucs_absent_fails(self, *args):
        set_module_args(dict(
            ucs="/root/bigip.localhost.localdomain.ucs",
            state='absent',
            provider=dict(
                server='localhost',
                password='******',
                user='******'
            )
        ))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode
        )

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)
        mm.is_version_v1 = Mock(return_value=False)

        vm = V1Manager(module=module)
        vm.remove_from_device = Mock(return_value=True)
        vm.exists = Mock(side_effect=[True, True])

        with pytest.raises(F5ModuleError) as ex:
            vm.exec_module()
        assert 'Failed to delete' in str(ex.value)
    def test_update_ntp_servers(self, *args):
        ntp = ['10.1.1.1', '10.1.1.2']
        set_module_args(
            dict(ntp_servers=ntp,
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        # Configure the parameters that would be returned by querying the
        # remote device
        current = Parameters(params=load_fixture('load_ntp.json'))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode,
            required_one_of=self.spec.required_one_of)
        mm = ModuleManager(module=module)

        # Override methods to force specific logic in the module to happen
        mm.update_on_device = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)

        results = mm.exec_module()
        assert results['changed'] is True
        assert results['ntp_servers'] == ntp
예제 #13
0
    def test_create(self, *args):
        # Configure the arguments that would be sent to the Ansible module
        set_module_args(
            dict(name='foo',
                 source='file.txt',
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode,
            required_if=self.spec.required_if)

        tm = IFileManager(module=module)
        tm.exists = Mock(return_value=False)
        tm.create_on_device = Mock(return_value=True)
        tm.upload_to_device = Mock(return_value=True)
        tm.remove_uploaded_file_from_device = Mock(return_value=True)

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)
        mm.get_manager = Mock(return_value=tm)

        results = mm.exec_module()

        assert results['changed'] is True
    def test_create(self, *args):
        set_module_args(
            dict(name='foo',
                 agent_type='UCD',
                 community='public',
                 cpu_coefficient='1.5',
                 cpu_threshold='80',
                 parent='/Common/snmp_dca',
                 disk_coefficient='2.0',
                 disk_threshold='90',
                 memory_coefficient='1.0',
                 memory_threshold='70',
                 version='v1',
                 interval=20,
                 timeout=30,
                 time_until_up=60,
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)

        # Override methods in the specific type of manager
        mm = ModuleManager(module=module)
        mm.exists = Mock(side_effect=[False, True])
        mm.create_on_device = Mock(return_value=True)

        results = mm.exec_module()

        assert results['changed'] is True
예제 #15
0
    def test_modify_ha_order(self, *args):
        set_module_args(
            dict(name='traffic-group-2',
                 ha_order=['v12-2.ansible.local', 'v12-1.ansible.local'],
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode,
        )

        current = ApiParameters(params=load_fixture('load_tg_ha_order.json'))

        mm = ModuleManager(module=module)
        mm.exists = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)
        mm.update_on_device = Mock(return_value=True)

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['ha_order'] == [
            '/Common/v12-2.ansible.local', '/Common/v12-1.ansible.local'
        ]
예제 #16
0
    def setUp(self):
        self.spec = ArgumentSpec()
        self.patcher1 = patch('time.sleep')
        self.patcher1.start()

        self.p1 = patch(
            'ansible_collections.f5networks.f5_modules.plugins.modules.bigiq_application_http.bigiq_version'
        )
        self.p2 = patch(
            'ansible_collections.f5networks.f5_modules.plugins.modules.bigiq_application_http.ModuleParameters.template_reference'
        )
        self.p3 = patch(
            'ansible_collections.f5networks.f5_modules.plugins.modules.bigiq_application_http.ModuleParameters.ssg_reference'
        )
        self.p4 = patch(
            'ansible_collections.f5networks.f5_modules.plugins.modules.bigiq_application_http.ModuleParameters.default_device_reference'
        )

        self.m1 = self.p1.start()
        self.m2 = self.p2.start()
        self.m3 = self.p3.start()
        self.m4 = self.p4.start()

        self.m1.return_value = '6.1.0'
        self.m2.return_value = Mock(
            return_value='https://localhost/mgmt/foobar1')
        self.m3.return_value = Mock(
            return_value='https://localhost/mgmt/foobar2')
        self.m4.return_value = Mock(
            return_value='https://localhost/mgmt/foobar3')
예제 #17
0
    def test_create_dns(self, *args):
        set_module_args(
            dict(name='aaaa',
                 state='mitigate',
                 profile='foo',
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)

        m1 = ProtocolDnsManager(module=module)
        m1.read_current_from_device = Mock(return_value=[])
        m1.update_on_device = Mock(return_value=True)

        mm = ModuleManager(module=module)
        mm.get_manager = Mock(return_value=m1)
        mm.exists = Mock(side_effect=[False, True])
        mm.create_on_device = Mock(return_value=True)

        results = mm.exec_module()

        assert results['changed'] is True
    def test_deactivate_policy_exists_inactive(self, *args):
        set_module_args(
            dict(name='fake_policy',
                 state='present',
                 active='no',
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        current = V1ModuleParameters(
            params=load_fixture('load_asm_policy_inactive.json'))
        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)

        # Override methods to force specific logic in the module to happen
        v1 = V1Manager(module=module)
        v1.exists = Mock(return_value=True)
        v1.read_current_from_device = Mock(return_value=current)

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)
        mm.version_is_less_than_13 = Mock(return_value=False)
        mm.get_manager = Mock(return_value=v1)

        results = mm.exec_module()

        assert results['changed'] is False
예제 #19
0
    def test_create(self, *args):
        # Configure the arguments that would be sent to the Ansible module
        set_module_args(dict(
            name='foo',
            parent='bar',
            provider=dict(
                server='localhost',
                password='******',
                user='******'
            )
        ))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode
        )
        mm = ModuleManager(module=module)

        # Override methods to force specific logic in the module to happen
        mm.exists = Mock(return_value=False)
        mm.create_on_device = Mock(return_value=True)

        results = mm.exec_module()

        assert results['changed'] is True
    def test_create_by_name(self, *args):
        set_module_args(
            dict(name='fake_policy',
                 state='present',
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        current = V1ModuleParameters(
            params=load_fixture('load_asm_policy_inactive.json'))
        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)

        v1 = V1Manager(module=module)
        v1.exists = Mock(return_value=False)
        v1.import_to_device = Mock(return_value=True)
        v1.wait_for_task = Mock(side_effect=[True, True])
        v1.create_on_device = Mock(return_value=True)
        v1.create_blank = Mock(return_value=True)
        v1.read_current_from_device = Mock(return_value=current)
        v1.apply_on_device = Mock(return_value=True)
        v1._file_is_missing = Mock(return_value=False)

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)
        mm.version_is_less_than_13 = Mock(return_value=False)
        mm.get_manager = Mock(return_value=v1)

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['name'] == 'fake_policy'
    def test_idempotent_disable_datacenter(self, *args):
        set_module_args(dict(
            name='foo',
            state='disabled',
            provider=dict(
                server='localhost',
                password='******',
                user='******'
            )

        ))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode
        )

        current = ApiParameters(params=load_fixture('load_gtm_datacenter_disabled.json'))

        mm = ModuleManager(module=module)

        # Override methods to force specific logic in the module to happen
        mm.exists = Mock(return_value=True)
        mm.update_on_device = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)
        mm.module_provisioned = Mock(return_value=True)

        results = mm.exec_module()
        assert results['changed'] is False
    def test_delete_policy(self, *args):
        set_module_args(
            dict(name='fake_policy',
                 state='absent',
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)

        # Override methods to force specific logic in the module to happen
        v1 = V1Manager(module=module)
        v1.exists = Mock(side_effect=[True, False])
        v1.remove_from_device = Mock(return_value=True)

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)
        mm.version_is_less_than_13 = Mock(return_value=False)
        mm.get_manager = Mock(return_value=v1)

        results = mm.exec_module()

        assert results['changed'] is True
예제 #23
0
    def test_cli_command(self, *args):
        set_module_args(
            dict(commands=["show sys version"],
                 provider=dict(server='localhost',
                               password='******',
                               user='******',
                               transport='cli')))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)

        m1 = V1Manager(module=module)
        m1.execute_on_device = Mock(return_value=['resp1', 'resp2', 'resp3'])

        mm = ModuleManager(module=module)
        mm._run_commands = Mock(return_value=[])
        mm.get_manager = Mock(return_value=m1)

        results = mm.exec_module()

        assert results['changed'] is False

        # call count is two on CLI transport because we must first
        # determine if the remote CLI is in tmsh mode or advanced shell
        # (bash) mode.
        #
        # 1 call for the shell check
        # 1 call for the command in the "commands" list above
        #
        # Can we change this in the future by making the terminal plugin
        # find this out ahead of time?
        assert m1.execute_on_device.call_count == 3
    def test_delete_policy_raises(self, *args):
        set_module_args(
            dict(name='fake_policy',
                 state='absent',
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)
        msg = 'Failed to delete ASM policy: fake_policy'
        # Override methods to force specific logic in the module to happen
        v1 = V1Manager(module=module)
        v1.exists = Mock(side_effect=[True, True])
        v1.remove_from_device = Mock(return_value=True)

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)
        mm.version_is_less_than_13 = Mock(return_value=False)
        mm.get_manager = Mock(return_value=v1)

        with pytest.raises(F5ModuleError) as err:
            mm.exec_module()
        assert str(err.value) == msg
    def test_create_monitor_idempotent(self, *args):
        set_module_args(
            dict(name='foo',
                 ip='10.10.10.10',
                 port=80,
                 interval=20,
                 timeout=30,
                 time_until_up=60,
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        current = Parameters(
            params=load_fixture('load_ltm_monitor_tcp_half_open.json'))
        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)

        # Override methods in the specific type of manager
        mm = ModuleManager(module=module)
        mm.exists = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)

        results = mm.exec_module()

        assert results['changed'] is False
예제 #26
0
    def update(self, *args):
        set_module_args(
            dict(synchronization="yes",
                 synchronization_group_name='foo',
                 synchronize_zone_files="yes",
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        current = ApiParameters(
            params=load_fixture('load_gtm_global_settings_general_1.json'))
        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)

        # Override methods in the specific type of manager
        mm = ModuleManager(module=module)
        mm.update_on_device = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['synchronization'] == 'yes'
        assert results['synchronization_group_name'] == 'foo'
        assert results['synchronize_zone_files'] == 'yes'
예제 #27
0
    def test_update_allowed_addresses_empty(self, *args):
        set_module_args(
            dict(allowed_addresses=[''],
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        # Configure the parameters that would be returned by querying the
        # remote device
        current = ApiParameters(params=dict(allowed_addresses=['10.0.0.0']))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)
        mm = ModuleManager(module=module)

        # Override methods to force specific logic in the module to happen
        mm.update_on_device = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)

        results = mm.exec_module()

        assert results['changed'] is True
        assert len(results['allowed_addresses']) == 1
        assert results['allowed_addresses'] == ['127.0.0.0/8']
    def test_disabled_vlans(self, *args):
        set_module_args(
            dict(name='test-dns-listener',
                 address='10.0.1.0',
                 mask='255.255.255.0',
                 port=53,
                 advertise='no',
                 state='present',
                 description='this is description',
                 ip_protocol='tcp',
                 translate_address='yes',
                 translate_port='no',
                 disabled_vlans='all',
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode)

        current = ApiParameters(dict(agent_status_traps='disabled'))

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)
        mm.exists = Mock(return_value=True)
        mm.update_on_device = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)

        with pytest.raises(F5ModuleError) as ex:
            mm.exec_module()
        assert 'You cannot disable all VLANs. You must name them individually.' in str(
            ex.value)
    def test_update_issue_00587_default(self, *args):
        set_module_args(
            dict(
                ssl_protocols='default',
                provider=dict(
                    server='localhost',
                    password='******',
                    user='******'
                )
            )
        )

        current = Parameters(params=load_fixture('load_sys_httpd_non_default.json'))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode
        )
        mm = ModuleManager(module=module)

        # Override methods to force specific logic in the module to happen
        mm.update_on_device = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)

        results = mm.exec_module()
        assert results['changed'] is True
        assert results['ssl_protocols'] == 'default'
예제 #30
0
    def test_create_vlan_tagged_interfaces(self, *args):
        set_module_args(
            dict(name='somevlan',
                 tagged_interface=['2.1', '1.1'],
                 tag=213,
                 partition='Common',
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode,
            mutually_exclusive=self.spec.mutually_exclusive)

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)
        mm.create_on_device = Mock(return_value=True)
        mm.exists = Mock(return_value=False)

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['tagged_interfaces'] == ['1.1', '2.1']
        assert results['tag'] == 213