示例#1
0
    def test_update_pool_member_exists(self, *args):
        set_module_args(dict(
            name='test_pool',
            partition='Common',
            host='1.1.1.1',
            port=80,
            server='localhost',
            password='******',
            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
        )
        mm = ModuleManager(client)

        current = (
            Parameters(
                load_fixture('load_ltm_pool.json')
            ),
            self.loaded_members,
            {},
        )

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

        results = mm.exec_module()

        assert results['changed'] is False
示例#2
0
    def test_update_monitors(self, *args):
        set_module_args(dict(
            name='test_pool',
            partition='Common',
            monitor_type='and_list',
            monitors=['/Common/http', '/Common/tcp'],
            server='localhost',
            password='******',
            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
        )
        mm = ModuleManager(client)

        current = (
            Parameters(
                load_fixture('load_ltm_pool.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['monitor_type'] == 'and_list'
        assert results['monitors'] == '/Common/http and /Common/tcp'
示例#3
0
 def test_unknown_api_lb_method(self):
     args = dict(
         loadBalancingMode='obscure_hypenated_fake_method'
     )
     with pytest.raises(F5ModuleError):
         p = Parameters(args)
         assert p.lb_method == 'foo'
示例#4
0
 def test_unknown_module_lb_method(self):
     args = dict(
         lb_method='obscure_hyphenated_fake_method',
     )
     with pytest.raises(F5ModuleError):
         p = Parameters(args)
         assert p.lb_method == 'foo'
示例#5
0
    def test_api_parameters(self):
        m = ['/Common/Fake', '/Common/Fake2']
        args = dict(monitor_type='and_list',
                    monitors=m,
                    slowRampTime=200,
                    reselectTries=5,
                    serviceDownAction='drop')

        p = Parameters(args)
        assert p.monitors == '/Common/Fake and /Common/Fake2'
        assert p.slow_ramp_time == 200
        assert p.reselect_tries == 5
        assert p.service_down_action == 'drop'
示例#6
0
    def test_module_parameters(self):
        args = dict(monitor_type='m_of_n',
                    monitors=['/Common/Fake', '/Common/Fake2'],
                    quorum=1,
                    slow_ramp_time=200,
                    reselect_tries=5,
                    service_down_action='drop',
                    host='192.168.1.1',
                    port=8080)

        p = Parameters(args)
        assert p.monitor_type == 'm_of_n'
        assert p.quorum == 1
        assert p.monitors == 'min 1 of { /Common/Fake /Common/Fake2 }'
        assert p.host == '192.168.1.1'
        assert p.port == 8080
        assert p.member_name == '192.168.1.1:8080'
        assert p.slow_ramp_time == 200
        assert p.reselect_tries == 5
        assert p.service_down_action == 'drop'