def system_update(request_data, tenant_auth_token, is_jwt_token):
    """Request handler for system update operation.

    :return: Dictionary with system update status.
    """
    required = [RequestKey.SERVER_ACTION]
    req_utils.validate_payload(request_data, required)

    # Telemetry data preparation
    if request_data.get(RequestKey.SERVER_ACTION) == 'enable':
        cse_operation = CseOperation.SYSTEM_ENABLE
    elif request_data.get(RequestKey.SERVER_ACTION) == 'disable':
        cse_operation = CseOperation.SYSTEM_DISABLE
    elif request_data.get(RequestKey.SERVER_ACTION) == 'stop':
        cse_operation = CseOperation.SYSTEM_STOP
    else:
        cse_operation = CseOperation.SYSTEM_UNKNOWN

    try:
        # TODO: circular dependency with request_processor.py
        import container_service_extension.service as service
        status = service.Service().update_status(tenant_auth_token,
                                                 is_jwt_token, request_data)
        # Record telemetry data on successful system update
        record_user_action(cse_operation=cse_operation)

        return status
    except Exception as err:
        # Record telemetry data on failure
        record_user_action(cse_operation=cse_operation,
                           status=OperationStatus.FAILED)
        raise err
def system_update(request_data, op_ctx: ctx.OperationContext):
    """Request handler for system update operation.

    :return: Dictionary with system update status.
    """
    required = [RequestKey.SERVER_ACTION]
    req_utils.validate_payload(request_data, required)

    # Telemetry data preparation
    server_action = request_data.get(RequestKey.SERVER_ACTION)
    cse_operation = server_action or 'invalid server action'
    if server_action == 'enable':
        cse_operation = CseOperation.SYSTEM_ENABLE
    elif server_action == 'disable':
        cse_operation = CseOperation.SYSTEM_DISABLE
    elif server_action == 'stop':
        cse_operation = CseOperation.SYSTEM_STOP

    status = OperationStatus.FAILED
    if op_ctx.client.is_sysadmin:
        # circular dependency between request_processor.py and service.py
        import container_service_extension.service as service
        try:
            result = service.Service().update_status(
                request_data.get(RequestKey.SERVER_ACTION))
            status = OperationStatus.SUCCESS
            return result
        finally:
            record_user_action(cse_operation=cse_operation, status=status)

    record_user_action(cse_operation=cse_operation, status=status)
    raise e.UnauthorizedRequestError(
        error_message='Unauthorized to update CSE')
Exemplo n.º 3
0
def system_info(request_data, tenant_auth_token):
    """Request handler for system info operation.

    :return: Dictionary with system info data.
    """
    # TODO: circular dependency with request_processor.py
    import container_service_extension.service as service
    return service.Service().info(tenant_auth_token)
def system_info(request_data, op_ctx: ctx.OperationContext):
    """Request handler for system info operation.

    :return: Dictionary with system info data.
    """
    # TODO: circular dependency with request_processor.py
    import container_service_extension.service as service
    return service.Service().info(
        get_sysadmin_info=op_ctx.client.is_sysadmin())
Exemplo n.º 5
0
def system_update(request_data, tenant_auth_token):
    """Request handler for system update operation.

    :return: Dictionary with system update status.
    """
    required = [RequestKey.SERVER_ACTION]
    req_utils.validate_payload(request_data, required)

    # TODO: circular dependency with request_processor.py
    import container_service_extension.service as service
    return service.Service().update_status(tenant_auth_token, request_data)
def system_update(request_data, tenant_auth_token):
    """Request handler for system update operation.

    :return: Dictionary with system update status.
    """
    # TODO: circular dependency with request_processor.py
    import container_service_extension.service as service
    return {
        'message': service.Service().update_status(tenant_auth_token,
                                                   request_data)
    }
def get_server_runtime_config():
    import container_service_extension.service as cse_service
    return cse_service.Service().get_service_config()