def test_plug_vip(self):
     lb = dmh.generate_load_balancer_tree()
     show_subnet = self.driver.neutron_client.show_subnet
     show_subnet.return_value = {
         'subnet': {
             'id': lb.vip.subnet_id
         }
     }
     interface_attach = self.driver.nova_client.servers.interface_attach
     interface_attach.return_value = n_constants.MOCK_NOVA_INTERFACE
     list_security_groups = self.driver.neutron_client.list_security_groups
     list_security_groups.return_value = {
         'security_groups': [
             {'id': 'lb-sec-grp1'}
         ]
     }
     update_port = self.driver.neutron_client.update_port
     expected_aap = {'port': {'allowed_address_pairs':
                              [{'ip_address': lb.vip.ip_address}]}}
     interface_list = self.driver.nova_client.servers.interface_list
     if1 = n_constants.MOCK_NOVA_INTERFACE
     if2 = n_constants.MockNovaInterface()
     if2.net_id = '3'
     if2.port_id = '4'
     if2.fixed_ips = [{'ip_address': '10.0.0.2'}]
     if1.fixed_ips = [{'ip_address': n_constants.MOCK_IP_ADDRESS,
                       'subnet_id': lb.vip.subnet_id}]
     interface_list.return_value = [if1, if2]
     amps = self.driver.plug_vip(lb, lb.vip)
     self.assertEqual(5, update_port.call_count)
     update_port.assert_any_call(if1.port_id, expected_aap)
     for amp in amps:
         self.assertEqual(n_constants.MOCK_IP_ADDRESS, amp.vrrp_ip)
         self.assertEqual(lb.vip.ip_address, amp.ha_ip)
         self.assertIn(amp.id, [lb.amphorae[0].id, lb.amphorae[1].id])
Beispiel #2
0
 def test__nova_interface_to_octavia_interface(self):
     nova_interface = n_constants.MockNovaInterface()
     nova_interface.net_id = '1'
     nova_interface.port_id = '2'
     nova_interface.fixed_ips = [{'ip_address': '10.0.0.1'}]
     interface = self.driver._nova_interface_to_octavia_interface(
         '3', nova_interface)
     self.assertEqual('1', interface.network_id)
     self.assertEqual('2', interface.port_id)
     ips = [fixed_ip.ip_address for fixed_ip in interface.fixed_ips]
     self.assertIn('10.0.0.1', ips)