Exemplo n.º 1
0
    def delete_network(self, context, id):
        session = context.session
        with session.begin(subtransactions=True):
            segments = db.get_network_segments(session, id)
            super(Ml2Plugin, self).delete_network(context, id)
            for segment in segments:
                self.type_manager.release_segment(session, segment)
            # The segment records are deleted via cascade from the
            # network record, so explicit removal is not necessary.

        self.notifier.network_delete(context, id)
Exemplo n.º 2
0
 def _extend_network_dict_provider(self, context, network):
     id = network['id']
     segments = db.get_network_segments(context.session, id)
     if not segments:
         LOG.error(_("Network %s has no segments"), id)
         network[provider.NETWORK_TYPE] = None
         network[provider.PHYSICAL_NETWORK] = None
         network[provider.SEGMENTATION_ID] = None
     elif len(segments) > 1:
         network[provider.NETWORK_TYPE] = TYPE_MULTI_SEGMENT
         network[provider.PHYSICAL_NETWORK] = None
         network[provider.SEGMENTATION_ID] = None
     else:
         segment = segments[0]
         network[provider.NETWORK_TYPE] = segment[api.NETWORK_TYPE]
         network[provider.PHYSICAL_NETWORK] = segment[api.PHYSICAL_NETWORK]
         network[provider.SEGMENTATION_ID] = segment[api.SEGMENTATION_ID]
Exemplo n.º 3
0
 def _notify_port_updated(self, context, port):
     session = context.session
     with session.begin(subtransactions=True):
         network_id = port['network_id']
         segments = db.get_network_segments(session, network_id)
         if not segments:
             LOG.warning(_("In _notify_port_updated() for port %(port_id), "
                           "network %(network_id) has no segments"),
                         {'port_id': port['id'],
                          'network_id': network_id})
             return
         # TODO(rkukura): Use port binding to select segment.
         segment = segments[0]
     self.notifier.port_update(context, port,
                               segment[api.NETWORK_TYPE],
                               segment[api.SEGMENTATION_ID],
                               segment[api.PHYSICAL_NETWORK])
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 by agent "
                    "%(agent_id)s"),
                  {'device': device, 'agent_id': agent_id})
        port_id = self._device_to_port_id(device)

        session = db_api.get_session()
        with session.begin(subtransactions=True):
            port = db.get_port(session, port_id)
            if not port:
                LOG.warning(_("Device %(device)s requested by agent "
                              "%(agent_id)s not found in database"),
                            {'device': device, 'agent_id': agent_id})
                return {'device': device}
            segments = db.get_network_segments(session, port.network_id)
            if not segments:
                LOG.warning(_("Device %(device)s requested by agent "
                              "%(agent_id)s has network %(network_id) with "
                              "no segments"),
                            {'device': device,
                             'agent_id': agent_id,
                             'network_id': port.network_id})
                return {'device': device}
            #TODO(rkukura): Use/create port binding
            segment = segments[0]
            new_status = (q_const.PORT_STATUS_ACTIVE if port.admin_state_up
                          else q_const.PORT_STATUS_DOWN)
            if port.status != new_status:
                port.status = new_status
            entry = {'device': device,
                     'network_id': port.network_id,
                     'port_id': port.id,
                     'admin_state_up': port.admin_state_up,
                     'network_type': segment[api.NETWORK_TYPE],
                     'segmentation_id': segment[api.SEGMENTATION_ID],
                     'physical_network': segment[api.PHYSICAL_NETWORK]}
            LOG.debug(_("Returning: %s"), entry)
            return entry