示例#1
0
 def test_distributed_port_binding_deleted_by_port_deletion(self):
     network_id = uuidutils.generate_uuid()
     network_obj.Network(self.ctx, id=network_id).create()
     with db_api.context_manager.writer.using(self.ctx):
         device_owner = constants.DEVICE_OWNER_DVR_INTERFACE
         port = models_v2.Port(id='port_id',
                               network_id=network_id,
                               mac_address='00:11:22:33:44:55',
                               admin_state_up=True,
                               status=constants.PORT_STATUS_ACTIVE,
                               device_id='device_id',
                               device_owner=device_owner)
         self.ctx.session.add(port)
         binding_kwarg = {
             'port_id': 'port_id',
             'host': 'host',
             'vif_type': portbindings.VIF_TYPE_UNBOUND,
             'vnic_type': portbindings.VNIC_NORMAL,
             'router_id': 'router_id',
             'status': constants.PORT_STATUS_DOWN
         }
         self.ctx.session.add(
             models.DistributedPortBinding(**binding_kwarg))
         binding_kwarg['host'] = 'another-host'
         self.ctx.session.add(
             models.DistributedPortBinding(**binding_kwarg))
     with warnings.catch_warnings(record=True) as warning_list:
         with db_api.context_manager.writer.using(self.ctx):
             self.ctx.session.delete(port)
         self.assertEqual([], warning_list)
     ports = ml2_db.get_distributed_port_bindings(self.ctx, 'port_id')
     self.assertEqual(0, len(ports))
示例#2
0
 def test_distributed_port_binding_deleted_by_port_deletion(self):
     with self.ctx.session.begin(subtransactions=True):
         self.ctx.session.add(models_v2.Network(id='network_id'))
         device_owner = constants.DEVICE_OWNER_DVR_INTERFACE
         port = models_v2.Port(
             id='port_id',
             network_id='network_id',
             mac_address='00:11:22:33:44:55',
             admin_state_up=True,
             status=constants.PORT_STATUS_ACTIVE,
             device_id='device_id',
             device_owner=device_owner)
         self.ctx.session.add(port)
         binding_kwarg = {
             'port_id': 'port_id',
             'host': 'host',
             'vif_type': portbindings.VIF_TYPE_UNBOUND,
             'vnic_type': portbindings.VNIC_NORMAL,
             'router_id': 'router_id',
             'status': constants.PORT_STATUS_DOWN
         }
         self.ctx.session.add(models.DistributedPortBinding(
             **binding_kwarg))
         binding_kwarg['host'] = 'another-host'
         self.ctx.session.add(models.DistributedPortBinding(
             **binding_kwarg))
     with warnings.catch_warnings(record=True) as warning_list:
         with self.ctx.session.begin(subtransactions=True):
             self.ctx.session.delete(port)
         self.assertEqual([], warning_list)
     ports = ml2_db.get_distributed_port_bindings(self.ctx,
                                                  'port_id')
     self.assertEqual(0, len(ports))
示例#3
0
文件: test_db.py 项目: thh/neutron
 def test_distributed_port_binding_deleted_by_port_deletion(self):
     network_id = uuidutils.generate_uuid()
     network_obj.Network(self.ctx, id=network_id).create()
     device_owner = constants.DEVICE_OWNER_DVR_INTERFACE
     port = port_obj.Port(self.ctx,
                          id=uuidutils.generate_uuid(),
                          network_id=network_id,
                          mac_address=netaddr.EUI('00-11-22-33-44-55'),
                          admin_state_up=True,
                          status=constants.PORT_STATUS_ACTIVE,
                          device_id='device_id',
                          device_owner=device_owner)
     port.create()
     port_obj.DistributedPortBinding(
         self.ctx,
         port_id=port.id,
         host='host',
         vif_type=portbindings.VIF_TYPE_UNBOUND,
         vnic_type=portbindings.VNIC_NORMAL,
         router_id='router_id',
         status=constants.PORT_STATUS_DOWN).create()
     port_obj.DistributedPortBinding(
         self.ctx,
         port_id=port.id,
         host='another-host',
         vif_type=portbindings.VIF_TYPE_UNBOUND,
         vnic_type=portbindings.VNIC_NORMAL,
         router_id='router_id',
         status=constants.PORT_STATUS_DOWN).create()
     with warnings.catch_warnings(record=True) as warning_list:
         port.delete()
         self.assertEqual([], warning_list, 'Warnings: %s' %
                          ';'.join([str(w) for w in warning_list]))
     ports = ml2_db.get_distributed_port_bindings(self.ctx, port.id)
     self.assertEqual(0, len(ports))
示例#4
0
 def test_get_distributed_port_bindings(self):
     network_id = uuidutils.generate_uuid()
     port_id_1 = uuidutils.generate_uuid()
     port_id_2 = uuidutils.generate_uuid()
     self._setup_neutron_network(network_id, [port_id_1, port_id_2])
     router = self._setup_neutron_router()
     self._setup_distributed_binding(network_id, port_id_1, router.id,
                                     'foo_host_id_1')
     self._setup_distributed_binding(network_id, port_id_1, router.id,
                                     'foo_host_id_2')
     ports = ml2_db.get_distributed_port_bindings(self.ctx, port_id_1)
     self.assertEqual(2, len(ports))
示例#5
0
 def test_get_distributed_port_bindings(self):
     network_id = 'foo_network_id'
     port_id_1 = 'foo_port_id_1'
     port_id_2 = 'foo_port_id_2'
     self._setup_neutron_network(network_id, [port_id_1, port_id_2])
     router = self._setup_neutron_router()
     self._setup_distributed_binding(network_id, port_id_1, router.id,
                                     'foo_host_id_1')
     self._setup_distributed_binding(network_id, port_id_1, router.id,
                                     'foo_host_id_2')
     ports = ml2_db.get_distributed_port_bindings(self.ctx, 'foo_port_id')
     self.assertEqual(2, len(ports))
示例#6
0
 def test_get_distributed_port_bindings(self):
     network_id = uuidutils.generate_uuid()
     port_id_1 = uuidutils.generate_uuid()
     port_id_2 = uuidutils.generate_uuid()
     self._setup_neutron_network(network_id, [port_id_1, port_id_2])
     router = self._setup_neutron_router()
     self._setup_distributed_binding(
         network_id, port_id_1, router.id, 'foo_host_id_1')
     self._setup_distributed_binding(
         network_id, port_id_1, router.id, 'foo_host_id_2')
     ports = ml2_db.get_distributed_port_bindings(self.ctx,
                                                  port_id_1)
     self.assertEqual(2, len(ports))
示例#7
0
 def test_get_distributed_port_bindings(self):
     network_id = 'foo_network_id'
     port_id_1 = 'foo_port_id_1'
     port_id_2 = 'foo_port_id_2'
     self._setup_neutron_network(network_id, [port_id_1, port_id_2])
     router = self._setup_neutron_router()
     self._setup_distributed_binding(
         network_id, port_id_1, router.id, 'foo_host_id_1')
     self._setup_distributed_binding(
         network_id, port_id_1, router.id, 'foo_host_id_2')
     ports = ml2_db.get_distributed_port_bindings(self.ctx.session,
                                                  'foo_port_id')
     self.assertEqual(2, len(ports))
示例#8
0
 def test_distributed_port_binding_deleted_by_port_deletion(self):
     network_id = uuidutils.generate_uuid()
     network_obj.Network(self.ctx, id=network_id).create()
     device_owner = constants.DEVICE_OWNER_DVR_INTERFACE
     port = port_obj.Port(
         self.ctx,
         id=uuidutils.generate_uuid(),
         network_id=network_id,
         mac_address=netaddr.EUI('00-11-22-33-44-55'),
         admin_state_up=True,
         status=constants.PORT_STATUS_ACTIVE,
         device_id='device_id',
         device_owner=device_owner)
     port.create()
     port_obj.DistributedPortBinding(
         self.ctx,
         port_id=port.id,
         host='host',
         vif_type=portbindings.VIF_TYPE_UNBOUND,
         vnic_type=portbindings.VNIC_NORMAL,
         router_id='router_id',
         status=constants.PORT_STATUS_DOWN).create()
     port_obj.DistributedPortBinding(
         self.ctx,
         port_id=port.id,
         host='another-host',
         vif_type=portbindings.VIF_TYPE_UNBOUND,
         vnic_type=portbindings.VNIC_NORMAL,
         router_id='router_id',
         status=constants.PORT_STATUS_DOWN).create()
     with warnings.catch_warnings(record=True) as warning_list:
         port.delete()
         self.assertEqual(
             [], warning_list,
             'Warnings: %s' % ';'.join([str(w) for w in warning_list]))
     ports = ml2_db.get_distributed_port_bindings(self.ctx,
                                                  port.id)
     self.assertEqual(0, len(ports))
示例#9
0
 def test_distributed_port_binding_deleted_by_port_deletion(self):
     network_id = uuidutils.generate_uuid()
     network_obj.Network(self.ctx, id=network_id).create()
     with db_api.context_manager.writer.using(self.ctx):
         device_owner = constants.DEVICE_OWNER_DVR_INTERFACE
         port = models_v2.Port(
             id='port_id',
             network_id=network_id,
             mac_address='00:11:22:33:44:55',
             admin_state_up=True,
             status=constants.PORT_STATUS_ACTIVE,
             device_id='device_id',
             device_owner=device_owner)
         self.ctx.session.add(port)
         binding_kwarg = {
             'port_id': 'port_id',
             'host': 'host',
             'vif_type': portbindings.VIF_TYPE_UNBOUND,
             'vnic_type': portbindings.VNIC_NORMAL,
             'router_id': 'router_id',
             'status': constants.PORT_STATUS_DOWN
         }
         self.ctx.session.add(models.DistributedPortBinding(
             **binding_kwarg))
         binding_kwarg['host'] = 'another-host'
         self.ctx.session.add(models.DistributedPortBinding(
             **binding_kwarg))
     with warnings.catch_warnings(record=True) as warning_list:
         with db_api.context_manager.writer.using(self.ctx):
             self.ctx.session.delete(port)
         self.assertEqual(
             [], warning_list,
             'Warnings: %s' % ';'.join([str(w) for w in warning_list]))
     ports = ml2_db.get_distributed_port_bindings(self.ctx,
                                                  'port_id')
     self.assertEqual(0, len(ports))
示例#10
0
 def test_get_distributed_port_bindings_not_found(self):
     port = ml2_db.get_distributed_port_bindings(self.ctx, 'foo_port_id')
     self.assertFalse(len(port))
示例#11
0
 def test_get_distributed_port_bindings_not_found(self):
     port = ml2_db.get_distributed_port_bindings(self.ctx,
                                                 'foo_port_id')
     self.assertFalse(len(port))
示例#12
0
 def test_get_distributed_port_bindings_not_found(self):
     port = ml2_db.get_distributed_port_bindings(self.ctx,
                                                 uuidutils.generate_uuid())
     self.assertEqual(0, len(port))