コード例 #1
0
    def test_create_wideip_with_pool(self, *args):
        set_module_args(
            dict(name='foo.baz.bar',
                 lb_method='round-robin',
                 type='a',
                 pools=[dict(name='foo', ratio=10)],
                 password='******',
                 server='localhost',
                 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
        tm = TypedManager(module=module, params=module.params)
        tm.exists = Mock(return_value=False)
        tm.create_on_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_12 = Mock(return_value=False)
        mm.get_manager = Mock(return_value=tm)

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['name'] == 'foo.baz.bar'
        assert results['state'] == 'present'
        assert results['lb_method'] == 'round-robin'
コード例 #2
0
    def test_update_wideip_with_pool(self, *args):
        set_module_args(
            dict(name='foo.bar.com',
                 lb_method='round-robin',
                 type='a',
                 pools=[
                     dict(name='baz', ratio=10),
                     dict(name='alec', ratio=100)
                 ],
                 password='******',
                 server='localhost',
                 user='******'))

        current = ApiParameters(
            params=load_fixture('load_gtm_wide_ip_with_pools.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
        tm = TypedManager(module=module, params=module.params)
        tm.exists = Mock(return_value=True)
        tm.read_current_from_device = Mock(return_value=current)
        tm.update_on_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_12 = Mock(return_value=False)
        mm.get_manager = Mock(return_value=tm)

        results = mm.exec_module()

        assert results['changed'] is True
        assert 'pools' in results
コード例 #3
0
    def test_create_wideip(self, *args):
        set_module_args(
            dict(name='foo.baz.bar',
                 lb_method='round-robin',
                 password='******',
                 server='localhost',
                 user='******'))

        client = AnsibleF5Client(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode,
            f5_product_name=self.spec.f5_product_name)

        # Override methods in the specific type of manager
        tm = UntypedManager(client)
        tm.exists = Mock(return_value=False)
        tm.create_on_device = Mock(return_value=True)

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

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['name'] == 'foo.baz.bar'
        assert results['state'] == 'present'
        assert results['lb_method'] == 'round-robin'