def test_add_network_binding(self):
     with self.network() as network:
         TEST_NETWORK_ID = network['network']['id']
         self.assertIsNone(lb_db.get_network_binding(self.session,
                                                     TEST_NETWORK_ID))
         lb_db.add_network_binding(self.session, TEST_NETWORK_ID, PHYS_NET,
                                   1234)
         binding = lb_db.get_network_binding(self.session, TEST_NETWORK_ID)
         self.assertIsNotNone(binding)
         self.assertEqual(binding.network_id, TEST_NETWORK_ID)
         self.assertEqual(binding.physical_network, PHYS_NET)
         self.assertEqual(binding.vlan_id, 1234)
Exemplo n.º 2
0
 def test_add_network_binding(self):
     with self.network() as network:
         TEST_NETWORK_ID = network['network']['id']
         self.assertIsNone(
             lb_db.get_network_binding(self.session, TEST_NETWORK_ID))
         lb_db.add_network_binding(self.session, TEST_NETWORK_ID, PHYS_NET,
                                   1234)
         binding = lb_db.get_network_binding(self.session, TEST_NETWORK_ID)
         self.assertIsNotNone(binding)
         self.assertEqual(binding.network_id, TEST_NETWORK_ID)
         self.assertEqual(binding.physical_network, PHYS_NET)
         self.assertEqual(binding.vlan_id, 1234)
Exemplo n.º 3
0
 def get_device_details(self, rpc_context, **kwargs):
     """Agent requests device details."""
     agent_id = kwargs.get("agent_id")
     device = kwargs.get("device")
     LOG.debug(_("Device %(device)s details requested from %(agent_id)s"), {"device": device, "agent_id": agent_id})
     port = self.get_port_from_device(device)
     if port:
         binding = db.get_network_binding(db_api.get_session(), port["network_id"])
         (network_type, segmentation_id) = constants.interpret_vlan_id(binding.vlan_id)
         entry = {
             "device": device,
             "network_type": network_type,
             "physical_network": binding.physical_network,
             "segmentation_id": segmentation_id,
             "network_id": port["network_id"],
             "port_id": port["id"],
             "admin_state_up": port["admin_state_up"],
         }
         if cfg.CONF.AGENT.rpc_support_old_agents:
             entry["vlan_id"] = binding.vlan_id
         new_status = q_const.PORT_STATUS_ACTIVE if port["admin_state_up"] else q_const.PORT_STATUS_DOWN
         if port["status"] != new_status:
             db.set_port_status(port["id"], new_status)
     else:
         entry = {"device": device}
         LOG.debug(_("%s can not be found in database"), device)
     return entry
Exemplo n.º 4
0
 def get_device_details(self, rpc_context, **kwargs):
     """Agent requests device details."""
     agent_id = kwargs.get('agent_id')
     device = kwargs.get('device')
     LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
               {'device': device, 'agent_id': agent_id})
     port = self.get_port_from_device(device)
     if port:
         binding = db.get_network_binding(db_api.get_session(),
                                          port['network_id'])
         (network_type,
          segmentation_id) = constants.interpret_vlan_id(binding.vlan_id)
         entry = {'device': device,
                  'network_type': network_type,
                  'physical_network': binding.physical_network,
                  'segmentation_id': segmentation_id,
                  'network_id': port['network_id'],
                  'port_id': port['id'],
                  'admin_state_up': port['admin_state_up']}
         if cfg.CONF.AGENT.rpc_support_old_agents:
             entry['vlan_id'] = binding.vlan_id
         new_status = (q_const.PORT_STATUS_ACTIVE if port['admin_state_up']
                       else q_const.PORT_STATUS_DOWN)
         if port['status'] != new_status:
             db.set_port_status(port['id'], new_status)
     else:
         entry = {'device': device}
         LOG.debug(_("%s can not be found in database"), device)
     return entry
Exemplo n.º 5
0
 def get_device_details(self, rpc_context, **kwargs):
     """Agent requests device details."""
     agent_id = kwargs.get('agent_id')
     device = kwargs.get('device')
     LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
               {'device': device, 'agent_id': agent_id})
     port = self.get_port_from_device(device)
     if port:
         binding = db.get_network_binding(db_api.get_session(),
                                          port['network_id'])
         (network_type,
          segmentation_id) = constants.interpret_vlan_id(binding.vlan_id)
         entry = {'device': device,
                  'network_type': network_type,
                  'physical_network': binding.physical_network,
                  'segmentation_id': segmentation_id,
                  'network_id': port['network_id'],
                  'port_id': port['id'],
                  'admin_state_up': port['admin_state_up']}
         if cfg.CONF.AGENT.rpc_support_old_agents:
             entry['vlan_id'] = binding.vlan_id
         new_status = (q_const.PORT_STATUS_ACTIVE if port['admin_state_up']
                       else q_const.PORT_STATUS_DOWN)
         if port['status'] != new_status:
             db.set_port_status(port['id'], new_status)
     else:
         entry = {'device': device}
         LOG.debug(_("%s can not be found in database"), device)
     return entry
Exemplo n.º 6
0
 def delete_network(self, context, id):
     session = context.session
     with session.begin(subtransactions=True):
         binding = db.get_network_binding(session, id)
         super(LinuxBridgePluginV2, self).delete_network(context, id)
         if binding.vlan_id != constants.LOCAL_VLAN_ID:
             db.release_network(session, binding.physical_network, binding.vlan_id, self.network_vlan_ranges)
         # the network_binding record is deleted via cascade from
         # the network record, so explicit removal is not necessary
     self.notifier.network_delete(context, id)
Exemplo n.º 7
0
 def delete_network(self, context, id):
     session = context.session
     with session.begin(subtransactions=True):
         binding = db.get_network_binding(session, id)
         super(LinuxBridgePluginV2, self).delete_network(context, id)
         if binding.vlan_id != constants.LOCAL_VLAN_ID:
             db.release_network(session, binding.physical_network,
                                binding.vlan_id, self.network_vlan_ranges)
         # the network_binding record is deleted via cascade from
         # the network record, so explicit removal is not necessary
     self.notifier.network_delete(context, id)
Exemplo n.º 8
0
 def test_add_network_binding(self):
     params = {'provider:network_type': 'vlan',
               'provider:physical_network': PHYS_NET,
               'provider:segmentation_id': 1234}
     params['arg_list'] = tuple(params.keys())
     with self.network(**params) as network:
         TEST_NETWORK_ID = network['network']['id']
         binding = lb_db.get_network_binding(self.session, TEST_NETWORK_ID)
         self.assertIsNotNone(binding)
         self.assertEqual(binding.network_id, TEST_NETWORK_ID)
         self.assertEqual(binding.physical_network, PHYS_NET)
         self.assertEqual(binding.vlan_id, 1234)
Exemplo n.º 9
0
 def test_add_network_binding(self):
     params = {'provider:network_type': 'vlan',
               'provider:physical_network': PHYS_NET,
               'provider:segmentation_id': 1234}
     params['arg_list'] = tuple(params.keys())
     with self.network(**params) as network:
         TEST_NETWORK_ID = network['network']['id']
         binding = lb_db.get_network_binding(self.session, TEST_NETWORK_ID)
         self.assertIsNotNone(binding)
         self.assertEqual(binding.network_id, TEST_NETWORK_ID)
         self.assertEqual(binding.physical_network, PHYS_NET)
         self.assertEqual(binding.vlan_id, 1234)
Exemplo n.º 10
0
 def _extend_network_dict_provider(self, context, network):
     binding = db.get_network_binding(context.session, network["id"])
     if binding.vlan_id == constants.FLAT_VLAN_ID:
         network[provider.NETWORK_TYPE] = constants.TYPE_FLAT
         network[provider.PHYSICAL_NETWORK] = binding.physical_network
         network[provider.SEGMENTATION_ID] = None
     elif binding.vlan_id == constants.LOCAL_VLAN_ID:
         network[provider.NETWORK_TYPE] = constants.TYPE_LOCAL
         network[provider.PHYSICAL_NETWORK] = None
         network[provider.SEGMENTATION_ID] = None
     else:
         network[provider.NETWORK_TYPE] = constants.TYPE_VLAN
         network[provider.PHYSICAL_NETWORK] = binding.physical_network
         network[provider.SEGMENTATION_ID] = binding.vlan_id
Exemplo n.º 11
0
 def _extend_network_dict_provider(self, context, network):
     binding = db.get_network_binding(context.session, network['id'])
     if binding.vlan_id == constants.FLAT_VLAN_ID:
         network[provider.NETWORK_TYPE] = constants.TYPE_FLAT
         network[provider.PHYSICAL_NETWORK] = binding.physical_network
         network[provider.SEGMENTATION_ID] = None
     elif binding.vlan_id == constants.LOCAL_VLAN_ID:
         network[provider.NETWORK_TYPE] = constants.TYPE_LOCAL
         network[provider.PHYSICAL_NETWORK] = None
         network[provider.SEGMENTATION_ID] = None
     else:
         network[provider.NETWORK_TYPE] = constants.TYPE_VLAN
         network[provider.PHYSICAL_NETWORK] = binding.physical_network
         network[provider.SEGMENTATION_ID] = binding.vlan_id
Exemplo n.º 12
0
 def test_add_network_binding(self):
     params = {
         "provider:network_type": "vlan",
         "provider:physical_network": PHYS_NET,
         "provider:segmentation_id": 1234,
     }
     params["arg_list"] = tuple(params.keys())
     with self.network(**params) as network:
         TEST_NETWORK_ID = network["network"]["id"]
         binding = lb_db.get_network_binding(self.session, TEST_NETWORK_ID)
         self.assertIsNotNone(binding)
         self.assertEqual(binding.network_id, TEST_NETWORK_ID)
         self.assertEqual(binding.physical_network, PHYS_NET)
         self.assertEqual(binding.vlan_id, 1234)
Exemplo n.º 13
0
 def _notify_port_updated(self, context, port):
     binding = db.get_network_binding(context.session, port["network_id"])
     self.notifier.port_update(context, port, binding.physical_network, binding.vlan_id)
Exemplo n.º 14
0
 def _notify_port_updated(self, context, port):
     binding = db.get_network_binding(context.session,
                                      port['network_id'])
     self.notifier.port_update(context, port,
                               binding.physical_network,
                               binding.vlan_id)