Beispiel #1
0
    def setUp(self):
        super(QuantumMelangeTestCase, self).setUp()

        fc = fake_client.FakeClient(LOG)
        qc = quantum_connection.QuantumClientConnection(client=fc)

        self.net_man = quantum_manager.QuantumManager(
            ipam_lib="nova.network.quantum.nova_ipam_lib", q_conn=qc)
Beispiel #2
0
    def test_connection(self):
        fc = fake_client.FakeClient(LOG)
        qc = quantum_connection.QuantumClientConnection(client=fc)
        t = "tenant1"
        net1_name = "net1"
        net1_uuid = qc.create_network(t, net1_name)
        self.assertEquals(net1_name, qc.get_network_name(t, net1_uuid))
        self.assertTrue(qc.network_exists(t, net1_uuid))
        self.assertFalse(qc.network_exists(t, "fake-uuid"))
        self.assertFalse(qc.network_exists("fake-tenant", net1_uuid))

        nets = qc.get_networks(t)['networks']
        self.assertEquals(len(nets), 1)
        self.assertEquals(nets[0]['id'], net1_uuid)

        num_ports = 10
        for i in range(0, num_ports):
            qc.create_and_attach_port(t,
                                      net1_uuid,
                                      'iface' + str(i),
                                      state='ACTIVE')

        self.assertEquals(len(qc.get_attached_ports(t, net1_uuid)), num_ports)

        for i in range(0, num_ports):
            port_uuid = qc.get_port_by_attachment(t, net1_uuid,
                                                  'iface' + str(i))
            self.assertTrue(port_uuid)
            qc.detach_and_delete_port(t, net1_uuid, port_uuid)

        self.assertEquals(len(qc.get_attached_ports(t, net1_uuid)), 0)

        # test port not found
        qc.create_and_attach_port(t, net1_uuid, 'foo', state='ACTIVE')
        port_uuid = qc.get_port_by_attachment(t, net1_uuid, 'foo')
        qc.detach_and_delete_port(t, net1_uuid, port_uuid)
        self.assertRaises(quantum_client.QuantumNotFoundException,
                          qc.detach_and_delete_port, t, net1_uuid, port_uuid)

        qc.delete_network(t, net1_uuid)
        self.assertFalse(qc.network_exists(t, net1_uuid))
        self.assertEquals(len(qc.get_networks(t)['networks']), 0)

        self.assertRaises(quantum_client.QuantumNotFoundException,
                          qc.get_network_name, t, net1_uuid)
    def setUp(self):
        super(QuantumNovaTestCase, self).setUp()

        self.flags(quantum_use_dhcp=True)
        self.flags(l3_lib="nova.network.l3.LinuxNetL3")
        linuxdrv = "nova.network.linux_net.LinuxOVSInterfaceDriver"
        self.flags(linuxnet_interface_driver=linuxdrv)
        fc = fake_client.FakeClient(LOG)
        qc = quantum_connection.QuantumClientConnection(client=fc)

        self.net_man = quantum_manager.QuantumManager(
                ipam_lib="nova.network.quantum.nova_ipam_lib",
                q_conn=qc)

        def func(arg1, arg2):
            pass

        def func2(arg1, arg2, arg3):
            pass

        def func1(arg1):
            pass

        self.net_man.driver.update_dhcp_hostfile_with_text = func
        self.net_man.driver.restart_dhcp = func2
        self.net_man.driver.kill_dhcp = func1

        # Tests seem to create some networks by default, which
        # we don't want.  So we delete them.

        ctx = context.RequestContext('user1', 'fake_project1').elevated()
        for n in db.network_get_all(ctx):
            db.network_delete_safe(ctx, n['id'])

        # Other unit tests (e.g., test_compute.py) have a nasty
        # habit of of creating fixed IPs and not cleaning up, which
        # can confuse these tests, so we remove all existing fixed
        # ips before starting.
        session = sql_session.get_session()
        result = session.query(models.FixedIp).all()
        with session.begin():
            for fip_ref in result:
                session.delete(fip_ref)

        self.net_man.init_host()