示例#1
0
    def test_update_pool(self, *args):
        set_module_args(
            dict(name='foo',
                 preferred_lb_method='topology',
                 alternate_lb_method='drop-packet',
                 fallback_lb_method='cpu',
                 type='a',
                 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)

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

        # Override methods in the specific type of manager
        mm = ModuleManager(module=module)
        mm.module_provisioned = Mock(return_value=True)
        mm.exists = Mock(side_effect=[True, True])
        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['preferred_lb_method'] == 'topology'
        assert results['alternate_lb_method'] == 'drop-packet'
        assert results['fallback_lb_method'] == 'cpu'
示例#2
0
    def test_delete_pool(self, *args):
        set_module_args(
            dict(name='foo',
                 type='a',
                 state='absent',
                 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)

        # Override methods in the specific type of manager
        tm = TypedManager(module=module)
        tm.exists = Mock(side_effect=[True, False])
        tm.version_is_less_than_12 = Mock(return_value=False)
        tm.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_12 = Mock(return_value=False)
        mm.get_manager = Mock(return_value=tm)
        mm.gtm_provisioned = Mock(return_value=True)
        mm.module_provisioned = Mock(return_value=True)

        results = mm.exec_module()

        assert results['changed'] is True
示例#3
0
    def test_create_pool(self, *args):
        set_module_args(
            dict(name='foo',
                 preferred_lb_method='round-robin',
                 type='a',
                 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)

        # Override methods in the specific type of manager
        mm = ModuleManager(module=module)
        mm.module_provisioned = Mock(return_value=True)
        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['preferred_lb_method'] == 'round-robin'