Ejemplo n.º 1
0
def api_introspection_abort(node_id):
    client = rpc.get_client()
    client.call({},
                'do_abort',
                node_id=node_id,
                token=flask.request.headers.get('X-Auth-Token'))
    return '', 202
Ejemplo n.º 2
0
def api_introspection(node_id):
    if flask.request.method == 'POST':
        args = flask.request.args

        manage_boot = args.get('manage_boot', 'True')
        try:
            manage_boot = strutils.bool_from_string(manage_boot, strict=True)
        except ValueError:
            raise utils.Error(_('Invalid boolean value for manage_boot: %s') %
                              manage_boot,
                              code=400)

        if manage_boot and not CONF.can_manage_boot:
            raise utils.Error(_('Managed boot is requested, but this '
                                'installation cannot manage boot ('
                                '(can_manage_boot set to False)'),
                              code=400)
        client = rpc.get_client()
        client.call({},
                    'do_introspection',
                    node_id=node_id,
                    manage_boot=manage_boot,
                    token=flask.request.headers.get('X-Auth-Token'))
        return '', 202
    else:
        node_info = node_cache.get_node(node_id)
        return flask.json.jsonify(generate_introspection_status(node_info))
Ejemplo n.º 3
0
def api_introspection_reapply(node_id):
    if flask.request.content_length:
        return error_response(_('User data processing is not '
                                'supported yet'),
                              code=400)

    client = rpc.get_client()
    client.call({}, 'do_reapply', node_id=node_id)
    return '', 202
Ejemplo n.º 4
0
def api_introspection(node_id):
    if flask.request.method == 'POST':
        client = rpc.get_client()
        client.call({},
                    'do_introspection',
                    node_id=node_id,
                    token=flask.request.headers.get('X-Auth-Token'))
        return '', 202
    else:
        node_info = node_cache.get_node(node_id)
        return flask.json.jsonify(generate_introspection_status(node_info))
Ejemplo n.º 5
0
def api_introspection_reapply(node_id):
    if flask.request.content_length:
        return error_response(_('User data processing is not '
                                'supported yet'),
                              code=400)

    if CONF.processing.store_data == 'swift':
        client = rpc.get_client()
        client.call({}, 'do_reapply', node_id=node_id)
        return '', 202
    else:
        return error_response(_('Inspector is not configured to store'
                                ' data. Set the [processing] '
                                'store_data configuration option to '
                                'change this.'),
                              code=400)
Ejemplo n.º 6
0
def api_introspection_reapply(node_id):
    data = None
    if flask.request.content_length:
        try:
            data = flask.request.get_json(force=True)
        except Exception:
            raise utils.Error(
                _('Invalid data: expected a JSON object, got %s') % data)
        if not isinstance(data, dict):
            raise utils.Error(
                _('Invalid data: expected a JSON object, got %s') %
                data.__class__.__name__)
        LOG.debug("Received reapply data from request", data=data)

    if not uuidutils.is_uuid_like(node_id):
        node = ir_utils.get_node(node_id, fields=['uuid'])
        node_id = node.uuid

    client = rpc.get_client()
    client.call({}, 'do_reapply', node_uuid=node_id, data=data)
    return '', 202
Ejemplo n.º 7
0
def get_client_compat():
    if CONF.standalone:
        return rpc.get_client()

    topic = get_random_topic()
    return rpc.get_client(topic)