def test_update(self):
     self.a.vip.update(None, fake_objs.FakeVIP(), fake_objs.FakeVIP())
     self.print_mocks()
     s = str(self.a.last_client.mock_calls)
     self.assertTrue('vport.update' in s)
     self.assertTrue('id1' in s)
     self.assertTrue('UP' in s)
     self.a.openstack_driver.plugin.get_pool.assert_called_with(
         None, 'pool1')
     self.assertTrue('HTTP' in s)
 def test_update_delete_pers(self):
     vip_id = "id2"
     self.a.vip.update(None, fake_objs.FakeVIP('SOURCE_IP', vip_id=vip_id), fake_objs.FakeVIP())
     self.print_mocks()
     s = str(self.a.last_client.mock_calls)
     self.assertTrue('vport.update' in s)
     self.assertTrue('id1' in s)
     self.assertTrue('UP' in s)
     self.a.openstack_driver.plugin.get_pool.assert_called_with(None, 'pool1')
     z = self.a.last_client.slb.template.src_ip_persistence.delete
     z.assert_called_with(vip_id)
     self.assertTrue('HTTP' in s)
    def _test_create_default_vrid(self, api_ver=None, default_vrid=None):

        """
        Due to how the config is pulled in, we override the config
        for all of the devices.
        """

        for k, v in self.a.config.get_devices().items():
            v['api_version'] = api_ver
            v['default_virtual_server_vrid'] = default_vrid

        vip = fake_objs.FakeVIP()
        self.a.vip.create(None, vip)

        create = self.a.last_client.slb.virtual_server.create
        create.assert_has_calls([mock.ANY])
        calls = create.call_args_list

        if default_vrid is not None:
            self.assertIn('vrid=%s' % default_vrid, str(calls))
        if default_vrid is None:
            foundVrid = any(
                'vrid' in x.get('axapi_args', {}).get('virtual_server', {})
                for (_, x) in calls)
            self.assertFalse(
                foundVrid,
                'Expected to find no vrid in {0}'.format(str(calls)))
 def test_create(self):
     self.a.vip.create(None, fake_objs.FakeVIP())
     s = str(self.a.last_client.mock_calls)
     self.assertTrue('virtual_server.create' in s)
     self.assertTrue('1.1.1.1' in s)
     self.assertTrue('vport.create' in s)
     self.assertTrue('id1' in s)
     self.assertTrue('UP' in s)
     self.a.openstack_driver.plugin.get_pool.assert_called_with(
         None, 'pool1')
     self.assertTrue('HTTP' in s)
    def _test_create_ipinip(self, ip_in_ip=False, api_ver="3.0"):
        vip = fake_objs.FakeVIP()

        for k, v in self.a.config.devices.items():
            v['ipinip'] = ip_in_ip
            v['api_version'] = api_ver

        self.a.vip.create(None, vip)
        s = str(self.a.last_client.mock_calls)
        self.assertIn('vport.create', s)
        self.assertIn('ipinip=%s' % ip_in_ip, s)
    def _test_create_autosnat(self, api_ver=None, autosnat=None, key="auto"):

        """
        Due to how the config is pulled in, we can't override the config
        version here and just expect it to work.
        """
        for k, v in self.a.config.get_devices().items():
            v['api_version'] = api_ver
            v['autosnat'] = autosnat

        vip = fake_objs.FakeVIP()

        self.a.vip.create(None, vip)
        s = str(self.a.last_client.mock_calls)
        self.assertTrue('virtual_server.create' in s)
        self.assertIn('autosnat=%s' % autosnat, s)
    def _test_create_source_nat_pool(self, source_nat_pool):
        vip = fake_objs.FakeVIP()

        if source_nat_pool:
            for k, v in self.a.config.devices.items():
                v['source_nat_pool'] = source_nat_pool

        self.a.vip.create(None, vip)
        s = str(self.a.last_client.mock_calls)

        self.assertIn("vport.create", s)

        if source_nat_pool:
            expected = "source_nat_pool='{0}'".format(source_nat_pool)
            self.assertIn(expected, s)
        else:
            self.assertIn("source_nat_pool=None", s)

        s = str(self.a.last_client.mock_calls)
 def test_create_unsupported(self):
     try:
         self.a.vip.create(None, fake_objs.FakeVIP('APP_COOKIE'))
     except a10_ex.UnsupportedFeature:
         pass
 def test_create_adds_slb(self):
     self.a.vip.create(None, fake_objs.FakeVIP())
 def test_create_pers(self):
     self.a.vip.create(None, fake_objs.FakeVIP('HTTP_COOKIE'))
     s = str(self.a.last_client.mock_calls)
     self.assertTrue("c_pers_name='id1'" in s)
 def test_delete_pers(self):
     vip_id = "idx"
     self.a.vip.delete(None, fake_objs.FakeVIP('SOURCE_IP', vip_id=vip_id))
     self.a.last_client.slb.virtual_server.delete.assert_called_with(vip_id)
     z = self.a.last_client.slb.template.src_ip_persistence.delete
     z.assert_called_with(vip_id)
 def test_delete_removes_slb(self):
     self.a.vip.delete(None, fake_objs.FakeVIP())
 def test_delete(self):
     self.a.vip.delete(None, fake_objs.FakeVIP())
     self.a.last_client.slb.virtual_server.delete.assert_called_with('id1')