예제 #1
0
    def test_empty_methods(self):
        m_nc = mock.create_autospec(driver_context.NetworkContext)
        m_nc.current = ml2_utils.get_test_network()

        m_pc = mock.create_autospec(driver_context.PortContext)
        m_pc.current = ml2_utils.get_test_port(network_id=m_nc.current['id'])
        m_pc.network = m_nc.current

        m_sc = mock.create_autospec(driver_context.SubnetContext)
        m_sc.current = ml2_utils.get_test_subnet(
            network_id=m_nc.current['id'])
        m_sc.network = m_nc

        self.driver.create_network_precommit(m_nc)
        self.driver.create_network_postcommit(m_nc)
        self.driver.update_network_precommit(m_nc)
        self.driver.update_network_postcommit(m_nc)
        self.driver.delete_network_precommit(m_nc)
        self.driver.delete_network_postcommit(m_nc)
        self.driver.create_subnet_precommit(m_sc)
        self.driver.create_subnet_postcommit(m_sc)
        self.driver.update_subnet_precommit(m_sc)
        self.driver.update_subnet_postcommit(m_sc)
        self.driver.delete_subnet_precommit(m_sc)
        self.driver.delete_subnet_postcommit(m_sc)
        self.driver.create_port_precommit(m_pc)
        self.driver.create_port_postcommit(m_pc)
        self.driver.update_port_precommit(m_pc)
        self.driver.update_port_postcommit(m_pc)
        self.driver.delete_port_precommit(m_pc)
        self.driver.delete_port_postcommit(m_pc)
예제 #2
0
 def test__is_bound(self):
     m_pc = mock.create_autospec(driver_context.PortContext)
     m_pc.current = ml2_utils.get_test_port(
         network_id='network-id',
         vnic_type=portbindings.VNIC_BAREMETAL,
         vif_type=None)
     self.assertFalse(self.driver._is_bound(m_pc.current))
     m_pc.current[portbindings.VIF_TYPE] = portbindings.VIF_TYPE_OTHER
     self.assertTrue(self.driver._is_bound(m_pc.current))
예제 #3
0
    def test_update_port_postcommit_not_bound(self, mpb_pc):
        m_nc = mock.create_autospec(driver_context.NetworkContext)
        m_nc.current = ml2_utils.get_test_network()

        m_pc = mock.create_autospec(driver_context.PortContext)
        m_pc.current = ml2_utils.get_test_port(network_id=m_nc.current['id'])
        m_pc.network = m_nc

        self.driver.update_port_postcommit(m_pc)
        self.assertFalse(mpb_pc.called)
예제 #4
0
 def test_port_unbound_unplug_port(self):
     m_nc = mock.create_autospec(driver_context.NetworkContext)
     m_nc.current = ml2_utils.get_test_network()
     m_nc.original = ml2_utils.get_test_network()
     m_pc = mock.create_autospec(driver_context.PortContext)
     m_pc.current = ml2_utils.get_test_port(
         network_id=m_nc.current['id'],
         vnic_type=None,
         vif_type=None)
     m_pc.original = ml2_utils.get_test_port(
         network_id=m_nc.current['id'],
         vnic_type=portbindings.VNIC_BAREMETAL,
         vif_type=portbindings.VIF_TYPE_OTHER)
     m_pc.network = m_nc
     self.driver.update_port_postcommit(m_pc)
     self.mock_manager.assert_called_once_with('foo')
     self.mock_driver.delete_port.assert_called_once_with(
         m_pc, m_pc.current['binding:profile']['local_link_information'],
         current=False)
예제 #5
0
    def test_update_port_postcommit_unsupported_vnic_type_not_bound(
            self, mpb_pc):
        m_nc = mock.create_autospec(driver_context.NetworkContext)
        m_nc.current = ml2_utils.get_test_network()

        m_pc = mock.create_autospec(driver_context.PortContext)
        m_pc.current = ml2_utils.get_test_port(
            network_id=m_nc.current['id'], vnic_type=portbindings.VNIC_MACVTAP,
            vif_type=portbindings.VIF_TYPE_OTHER)
        m_pc.network = m_nc

        self.driver.update_port_postcommit(m_pc)
        self.assertFalse(mpb_pc.called)
예제 #6
0
    def test_bind_port_unsupported_vnic_type(self, mpb_pc):
        m_nc = mock.create_autospec(driver_context.NetworkContext)
        m_nc.current = ml2_utils.get_test_network(
            network_type=n_const.TYPE_FLAT)

        m_pc = mock.create_autospec(driver_context.PortContext)
        m_pc.current = ml2_utils.get_test_port(
            network_id=m_nc.current['id'], vnic_type='unsupported')
        m_pc.network = m_nc
        m_pc.segments_to_bind = [
            ml2_utils.get_test_segment(network_type=n_const.TYPE_FLAT)]

        self.driver.bind_port(m_pc)
        self.assertFalse(mpb_pc.called)
예제 #7
0
    def test_update_port_postcommit_supported_vnic_type_bound(self, mpb_pc):
        m_nc = mock.create_autospec(driver_context.NetworkContext)
        m_nc.current = ml2_utils.get_test_network()

        m_pc = mock.create_autospec(driver_context.PortContext)
        m_pc.current = ml2_utils.get_test_port(
            network_id=m_nc.current['id'],
            vnic_type=portbindings.VNIC_BAREMETAL,
            vif_type=portbindings.VIF_TYPE_OTHER)
        m_pc._plugin_context = 'plugin_context'
        m_pc.network = m_nc

        self.driver.update_port_postcommit(m_pc)
        mpb_pc.assert_called_once_with('plugin_context', m_pc.current['id'],
                                       'port', 'BAREMETAL_DRV_ENTITIY')
예제 #8
0
    def test_bind_port_unsupported_network_type(self, mpb_pc):
        m_nc = mock.create_autospec(driver_context.NetworkContext)
        m_nc.current = ml2_utils.get_test_network(
            network_type=n_const.TYPE_VXLAN)

        m_pc = mock.create_autospec(driver_context.PortContext)
        m_pc.current = ml2_utils.get_test_port(
            network_id=m_nc.current['id'],
            vnic_type=portbindings.VNIC_BAREMETAL,
            vif_type=portbindings.VIF_TYPE_OTHER)
        m_pc.network = m_nc
        m_pc.segments_to_bind = [
            ml2_utils.get_test_segment(network_type=n_const.TYPE_VXLAN)]

        self.driver.bind_port(m_pc)
        self.assertFalse(mpb_pc.called)