'Remove one or more subports from trunk.'

@db_base_plugin_common.convert_result_to_dict
def remove_subports(self, context, trunk_id, subports):

    subports = subports['sub_ports']
    with db_api.context_manager.writer.using(context):
        trunk = self._get_trunk(context, trunk_id)
        original_trunk = copy.deepcopy(trunk)
        rules.trunk_can_be_managed(context, trunk)
        subports_validator = rules.SubPortsValidator(self._segmentation_types, subports)
        subports = subports_validator.validate(context, basic_validation=True, trunk_validation=False)
        current_subports = {p.port_id: p for p in trunk.sub_ports}
        removed_subports = []
        for subport in subports:
            subport_obj = current_subports.pop(subport['port_id'], None)
            if (not subport_obj):
                raise trunk_exc.SubPortNotFound(trunk_id=trunk_id, port_id=subport['port_id'])
            subport_obj.delete()
            removed_subports.append(subport_obj)
        del trunk.sub_ports[:]
        trunk.sub_ports.extend(current_subports.values())
        trunk.update(status=constants.DOWN_STATUS)
        payload = callbacks.TrunkPayload(context, trunk_id, current_trunk=trunk, original_trunk=original_trunk, subports=removed_subports)
        if removed_subports:
            registry.notify(constants.SUBPORTS, events.PRECOMMIT_DELETE, self, payload=payload)
    if removed_subports:
        registry.notify(constants.SUBPORTS, events.AFTER_DELETE, self, payload=payload)
    return trunk
