コード例 #1
0
    def test_get_segment_by_id(self):
        segment = {api.NETWORK_TYPE: "vlan", api.PHYSICAL_NETWORK: "physnet1", api.SEGMENTATION_ID: 1}

        net_segment = self._create_segments([segment])[0]
        segment_uuid = net_segment[api.ID]

        net_segment = segments_db.get_segment_by_id(self.ctx.session, segment_uuid)
        self.assertEqual(segment, net_segment)
コード例 #2
0
    def test_delete_network_segment(self):
        segment = {api.NETWORK_TYPE: "vlan", api.PHYSICAL_NETWORK: "physnet1", api.SEGMENTATION_ID: 1}

        net_segment = self._create_segments([segment])[0]
        segment_uuid = net_segment[api.ID]

        segments_db.delete_network_segment(self.ctx.session, segment_uuid)
        # Get segment and verify its empty
        net_segment = segments_db.get_segment_by_id(self.ctx.session, segment_uuid)
        self.assertIsNone(net_segment)
コード例 #3
0
    def test_get_segment_by_id(self):
        segment = {api.NETWORK_TYPE: 'vlan',
                   api.PHYSICAL_NETWORK: 'physnet1',
                   api.SEGMENTATION_ID: 1}

        net_segment = self._create_segments([segment])[0]
        segment_uuid = net_segment[api.ID]

        net_segment = segments_db.get_segment_by_id(self.ctx,
                                                    segment_uuid)
        self.assertEqual(segment, net_segment)
コード例 #4
0
ファイル: driver_context.py プロジェクト: mmidolesov2/neutron
 def _expand_segment(self, segment_id):
     for s in self.network.network_segments:
         if s['id'] == segment_id:
             return s
     # TODO(kevinbenton): eliminate the query below. The above should
     # always return since the port is bound to a network segment. Leaving
     # in for now for minimally invasive change for back-port.
     segment = segments_db.get_segment_by_id(self._plugin_context,
                                             segment_id)
     if not segment:
         LOG.warning("Could not expand segment %s", segment_id)
     return segment
コード例 #5
0
ファイル: driver_context.py プロジェクト: cubeek/neutron
 def _expand_segment(self, segment_id):
     for s in self.network.network_segments:
         if s['id'] == segment_id:
             return s
     # TODO(kevinbenton): eliminate the query below. The above should
     # always return since the port is bound to a network segment. Leaving
     # in for now for minimally invasive change for back-port.
     segment = segments_db.get_segment_by_id(self._plugin_context,
                                             segment_id)
     if not segment:
         LOG.warning("Could not expand segment %s", segment_id)
     return segment
コード例 #6
0
    def test_delete_network_segment(self):
        segment = {api.NETWORK_TYPE: 'vlan',
                   api.PHYSICAL_NETWORK: 'physnet1',
                   api.SEGMENTATION_ID: 1}

        net_segment = self._create_segments([segment])[0]
        segment_uuid = net_segment[api.ID]

        segments_db.delete_network_segment(self.ctx, segment_uuid)
        # Get segment and verify its empty
        net_segment = segments_db.get_segment_by_id(self.ctx,
                                                    segment_uuid)
        self.assertIsNone(net_segment)
コード例 #7
0
ファイル: managers.py プロジェクト: annp/neutron
 def release_dynamic_segment(self, session, segment_id):
     """Delete a dynamic segment."""
     segment = segments_db.get_segment_by_id(session, segment_id)
     if segment:
         driver = self.drivers.get(segment.get(api.NETWORK_TYPE))
         if driver:
             driver.obj.release_segment(session, segment)
             segments_db.delete_network_segment(session, segment_id)
         else:
             LOG.error(_LE("Failed to release segment '%s' because "
                           "network type is not supported."), segment)
     else:
         LOG.debug("No segment found with id %(segment_id)s", segment_id)
コード例 #8
0
 def release_dynamic_segment(self, session, segment_id):
     """Delete a dynamic segment."""
     segment = segments_db.get_segment_by_id(session, segment_id)
     if segment:
         driver = self.drivers.get(segment.get(api.NETWORK_TYPE))
         if driver:
             driver.obj.release_segment(session, segment)
             segments_db.delete_network_segment(session, segment_id)
         else:
             LOG.error(_LE("Failed to release segment '%s' because "
                           "network type is not supported."), segment)
     else:
         LOG.debug("No segment found with id %(segment_id)s", segment_id)
コード例 #9
0
 def release_dynamic_segment(self, context, segment_id):
     """Delete a dynamic segment."""
     segment = segments_db.get_segment_by_id(context, segment_id)
     if segment:
         driver = self.drivers.get(segment.get(ml2_api.NETWORK_TYPE))
         if driver:
             if isinstance(driver.obj, api.TypeDriver):
                 driver.obj.release_segment(context.session, segment)
             else:
                 driver.obj.release_segment(context, segment)
             segments_db.delete_network_segment(context, segment_id)
         else:
             LOG.error("Failed to release segment '%s' because "
                       "network type is not supported.", segment)
     else:
         LOG.debug("No segment found with id %(segment_id)s", segment_id)
コード例 #10
0
 def get_segment_id(self, context, port_id, agent_hosts):
     try:
         segment = None
         if agent_hosts:
             for host_id in agent_hosts:
                 levels = db.get_binding_levels(context, port_id, host_id)
                 if levels:
                     LOG.debug('levels: %s binding host_id: %s' %
                               (levels, host_id))
                     for level in levels:
                         if level.driver in ('f5networks', 'huawei_ac_ml2'):
                             LOG.debug('level with driver f5networks')
                             segment = segments_db.get_segment_by_id(
                                 context, level.segment_id)
                             LOG.debug(
                                 'vxlan 2 vlan seg id %s: segment %s' %
                                 (level.segment_id, segment))
                             if segment:
                                 break
         return segment
     except Exception as exc:
         LOG.error("could not get segment id by port %s and host %s, %s" %
                   (port_id, agent_hosts, exc.message))
コード例 #11
0
ファイル: test_db.py プロジェクト: sld880311/openstack
 def test_get_segment_by_id_result_not_found(self):
     segment_uuid = uuidutils.generate_uuid()
     net_segment = segments_db.get_segment_by_id(self.ctx, segment_uuid)
     self.assertIsNone(net_segment)
コード例 #12
0
ファイル: db_lib.py プロジェクト: sapcc/networking-arista
 def get_segment_by_id(self, context, segment_id):
     return segments_db.get_segment_by_id(context, segment_id)
コード例 #13
0
ファイル: test_db.py プロジェクト: 21atlas/neutron
 def test_get_segment_by_id_result_not_found(self):
     segment_uuid = uuidutils.generate_uuid()
     net_segment = segments_db.get_segment_by_id(self.ctx.session,
                                                 segment_uuid)
     self.assertIsNone(net_segment)
コード例 #14
0
ファイル: driver_context.py プロジェクト: rohitmalaga/neutron
 def _expand_segment(self, segment_id):
     segment = segments_db.get_segment_by_id(self._plugin_context,
                                             segment_id)
     if not segment:
         LOG.warning(_LW("Could not expand segment %s"), segment_id)
     return segment
コード例 #15
0
 def _expand_segment(self, segment_id):
     segment = segments_db.get_segment_by_id(self._plugin_context,
                                             segment_id)
     if not segment:
         LOG.warning(_LW("Could not expand segment %s"), segment_id)
     return segment