示例#1
0
    def _create_delete_port(self, port_config):
        """Tests creation and deletion of a virtual port."""
        nexus_ip_addr = port_config.nexus_ip_addr
        host_name = port_config.host_name
        nexus_port = port_config.nexus_port
        instance_id = port_config.instance_id
        vlan_id = port_config.vlan_id

        network_context = FakeNetworkContext(vlan_id)
        port_context = FakePortContext(instance_id, host_name,
                                       network_context)

        self._cisco_mech_driver.update_port_postcommit(port_context)
        bindings = nexus_db_v2.get_nexusport_binding(nexus_port,
                                                     vlan_id,
                                                     nexus_ip_addr,
                                                     instance_id)
        self.assertEqual(len(bindings), 1)

        self._cisco_mech_driver.delete_port_precommit(port_context)
        with testtools.ExpectedException(exceptions.NexusPortBindingNotFound):
            nexus_db_v2.get_nexusport_binding(nexus_port,
                                              vlan_id,
                                              nexus_ip_addr,
                                              instance_id)
示例#2
0
    def _create_delete_port(self, port_config):
        """Tests creation and deletion of a virtual port."""
        nexus_ip_addr = port_config.nexus_ip_addr
        host_name = port_config.host_name
        nexus_port = port_config.nexus_port
        instance_id = port_config.instance_id
        vlan_id = port_config.vlan_id

        network_context = FakeNetworkContext(vlan_id)
        port_context = FakePortContext(instance_id, network_context)

        with mock.patch.object(mech_cisco_nexus.CiscoNexusMechanismDriver,
                               '_get_instance_host') as mock_host:
            mock_host.return_value = host_name

            self._cisco_mech_driver.create_port_postcommit(port_context)
            bindings = nexus_db_v2.get_nexusport_binding(nexus_port,
                                                         vlan_id,
                                                         nexus_ip_addr,
                                                         instance_id)
            self.assertEqual(len(bindings), 1)

            self._cisco_mech_driver.delete_port_precommit(port_context)
            with testtools.ExpectedException(
                    exceptions.NexusPortBindingNotFound):
                nexus_db_v2.get_nexusport_binding(nexus_port,
                                                  vlan_id,
                                                  nexus_ip_addr,
                                                  instance_id)
示例#3
0
    def test_nexusportbinding_get(self):
        """Tests get of specific port bindings from the database."""
        npb11 = self._npb_test_obj(10, 100)
        npb21 = self._npb_test_obj(20, 100)
        npb22 = self._npb_test_obj(20, 200)
        self._add_bindings_to_db([npb11, npb21, npb22])

        npb = self._get_nexusport_binding(npb11)
        self.assertEqual(len(npb), 1)
        self._assert_bindings_match(npb[0], npb11)
        npb = self._get_nexusport_binding(npb21)
        self.assertEqual(len(npb), 1)
        self._assert_bindings_match(npb[0], npb21)
        npb = self._get_nexusport_binding(npb22)
        self.assertEqual(len(npb), 1)
        self._assert_bindings_match(npb[0], npb22)

        with testtools.ExpectedException(exceptions.NexusPortBindingNotFound):
            nexus_db_v2.get_nexusport_binding(
                npb21.port, npb21.vlan, npb21.switch, "dummyInstance")
示例#4
0
    def _create_delete_port(self, port_config):
        """Tests creation and deletion of a virtual port."""
        nexus_ip_addr = port_config.nexus_ip_addr
        host_name = port_config.host_name
        nexus_port = port_config.nexus_port
        instance_id = port_config.instance_id
        vlan_id = port_config.vlan_id

        network_context = FakeNetworkContext(vlan_id)
        port_context = FakePortContext(instance_id, host_name, network_context)

        self._cisco_mech_driver.update_port_postcommit(port_context)
        bindings = nexus_db_v2.get_nexusport_binding(nexus_port, vlan_id,
                                                     nexus_ip_addr,
                                                     instance_id)
        self.assertEqual(len(bindings), 1)

        self._cisco_mech_driver.delete_port_precommit(port_context)
        with testtools.ExpectedException(exceptions.NexusPortBindingNotFound):
            nexus_db_v2.get_nexusport_binding(nexus_port, vlan_id,
                                              nexus_ip_addr, instance_id)
示例#5
0
 def _get_nexusport_binding(self, npb):
     """Gets a port binding based on port, vlan, switch, and instance."""
     return nexus_db_v2.get_nexusport_binding(
         npb.port, npb.vlan, npb.switch, npb.instance)