コード例 #1
0
 def _unset_sub_ports(self, trunk_id, trunk_port, subports):
     ctx = n_ctx.get_admin_context()
     trunk_host = trunk_port.get(portbindings.HOST_ID)
     trunk_target_state = (t_consts.TRUNK_ACTIVE_STATUS
                           if trunk_host else t_consts.TRUNK_DOWN_STATUS)
     updated_ports = []
     for port in subports:
         LOG.debug('unset port id : %(id)s', {'id': port.port_id})
         try:
             updated_port = self.core_plugin.update_port(
                 ctx, port.port_id, {
                     'port': {
                         portbindings.HOST_ID: None,
                         portbindings.PROFILE: None,
                         'device_owner': '',
                         'device_id': ''
                     }
                 })
             vif_type = updated_port.get(portbindings.VIF_TYPE)
             if vif_type != portbindings.VIF_TYPE_UNBOUND:
                 raise t_exc.SubPortBindingError(port_id=port.port_id,
                                                 trunk_id=trunk_id)
             updated_ports.append(updated_port)
         except t_exc.SubPortBindingError as e:
             LOG.error("Failed to clear binding for subport: %s", e)
             self.set_trunk_status(ctx, trunk_id,
                                   t_consts.TRUNK_DEGRADED_STATUS)
         except Exception as e:
             LOG.error("Failed to clear binding for subport: %s", e)
     if len(subports) != len(updated_ports):
         self.set_trunk_status(ctx, trunk_id,
                               t_consts.TRUNK_DEGRADED_STATUS)
     else:
         self.set_trunk_status(ctx, trunk_id, trunk_target_state)
コード例 #2
0
 def _unset_sub_ports(self, trunk_id, subports):
     _vsdclient = self.plugin_driver.vsdclient
     ctx = n_ctx.get_admin_context()
     updated_ports = []
     for port in subports:
         LOG.debug('unset port id : %(id)s', {'id': port.port_id})
         try:
             updated_port = self.core_plugin.update_port(
                 ctx, port.port_id, {
                     'port': {
                         portbindings.HOST_ID: None,
                         portbindings.PROFILE: None,
                         'device_owner': '',
                         'device_id': ''
                     }
                 })
             vif_type = updated_port.get(portbindings.VIF_TYPE)
             if vif_type != portbindings.VIF_TYPE_UNBOUND:
                 raise t_exc.SubPortBindingError(port_id=port.port_id,
                                                 trunk_id=trunk_id)
             updated_ports.append(updated_port)
             subnet_mapping = db.get_subnet_l2dom_by_port_id(
                 ctx.session, port.port_id)
             _vsdclient.remove_subport(updated_port, subnet_mapping)
         except t_exc.SubPortBindingError as e:
             LOG.error("Failed to clear binding for subport: %s", e)
             self.set_trunk_status(ctx, trunk_id, t_consts.DEGRADED_STATUS)
         except Exception as e:
             LOG.error("Failed to clear binding for subport: %s", e)
     if len(subports) != len(updated_ports):
         self.set_trunk_status(ctx, trunk_id, t_consts.DEGRADED_STATUS)
コード例 #3
0
 def _process_binding(self, context, trunk, subports):
     updated_ports = []
     trunk_port_id = trunk.port_id
     trunk_port = self.core_plugin.get_port(context, trunk_port_id)
     trunk_host = trunk_port.get(portbindings.HOST_ID)
     trunk_profile = trunk_port.get(portbindings.PROFILE)
     trunk.update(status=t_consts.TRUNK_BUILD_STATUS)
     trunk_target_state = (t_consts.TRUNK_ACTIVE_STATUS if trunk_host else
                           t_consts.TRUNK_DOWN_STATUS)
     for port in subports:
         try:
             data = {'port': {portbindings.HOST_ID: trunk_host,
                              portbindings.PROFILE: trunk_profile,
                              'device_owner': t_consts.TRUNK_SUBPORT_OWNER}}
             LOG.info("updating port: %(data)s", {'data': data})
             updated_port = self.core_plugin.update_port(
                 context, port.port_id, data)
             vif_type = updated_port.get(portbindings.VIF_TYPE)
             if vif_type == portbindings.VIF_TYPE_BINDING_FAILED:
                 raise t_exc.SubPortBindingError(port_id=port.port_id,
                                                 trunk_id=trunk.id)
             updated_ports.append(updated_port)
         except t_exc.SubPortBindingError as e:
             LOG.error("Failed to bind subport: %s", e)
             trunk.update(status=t_consts.TRUNK_ERROR_STATUS)
             return []
         except Exception as e:
             LOG.error("Failed to bind subport: %s", e)
     if len(subports) != len(updated_ports):
         LOG.debug("Trunk: %s is degraded", trunk.id)
         trunk.update(status=t_consts.TRUNK_DEGRADED_STATUS)
     else:
         trunk.update(status=trunk_target_state)
     return updated_ports
コード例 #4
0
    def _handle_port_binding(self, context, port_id, trunk, trunk_host):
        """Bind the given port to the given host.

           :param context: The context to use for the operation
           :param port_id: The UUID of the port to be bound
           :param trunk: The trunk that the given port belongs to
           :param trunk_host: The host to bind the given port to
        """
        port = self.core_plugin.update_port(
            context, port_id,
            {'port': {portbindings.HOST_ID: trunk_host,
                      'device_owner': trunk_consts.TRUNK_SUBPORT_OWNER}})
        vif_type = port.get(portbindings.VIF_TYPE)
        if vif_type == portbindings.VIF_TYPE_BINDING_FAILED:
            raise trunk_exc.SubPortBindingError(port_id=port_id,
                                                trunk_id=trunk.id)
        return port