예제 #1
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)
예제 #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, segment_uuid)
        # Get segment and verify its empty
        net_segment = segments_db.get_segment_by_id(self.ctx,
                                                    segment_uuid)
        self.assertIsNone(net_segment)
예제 #3
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)
예제 #4
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)
예제 #5
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)
 def rest_delete_network(self, mech_context):
     try:
         from neutron.db import segments_db as db
     except Exception:
         from neutron.plugins.ml2 import db
     session = mech_context._plugin_context.session
     network_id = mech_context.current['id']
     if self.hierarchical == "True":
         dynamic_segment = db.get_dynamic_segment(session, network_id)
         LOG.info(_("delete_network dynamic_segment = %s"), dynamic_segment)
         if dynamic_segment:
             db.delete_network_segment(session,
                                       dynamic_segment[api.SEGMENTATION_ID])
     data = self.construct_network_info(mech_context, 'DELETE')
     resource = 'del-' + NETWORK
     err_str = _("Unable to delete remote network: %s")
     self.rest_action('POST', resource, data, err_str)