Hopp til hovedinnholdet
Versjon: Neste

General

The General handler aides Ranger with preparation of certain Deputy package types such as Event and allows Ranger to query the Deputy package repository. Currently the General handler supports two types of gRpc services, Event and DeputyQuery.

Services

Event

Event package types are used to display additional information to the participant in the Ranger environment in the form of a custom HTML page.

create

The Event create gRPC endpoint is used to convert the Markdown pages to HTML and prepare them for Ranger to use. Redis is used to keep track of the created files and their metadata.

message Source {
string name = 1;
string version = 2;
}
Successful Response
message EventCreateResponse {
string id = 1;
string checksum = 2;
string filename = 3;
int64 size = 4;
}

stream

The previously prepared HTML pages are streamed to Ranger through the stream gRPC endpoint.

Request
message Identifier {
string value = 1;
}
Successful Response
stream message EventStreamResponse {
bytes chunk = 1;
}

delete

Delete is used to remove a previously created HTML file from the General handler.

Request
message Identifier {
string value = 1;
}
Successful Response
message Empty {}

DeputyQuery

DeputyQuery currently has two gRPC endpoints, GetPackagesByType and GetScenario.

GetPackagesByType

GetPackagesByType is used to query the Deputy package repository for packages of a specific type.

Request
message GetPackagesQuery {
string package_type = 1;
}
Successful Response
message GetPackagesResponse {
repeated Package packages = 1;
}

For reference, the Package message is defined as follows:

message Package {
string name = 1;
string version = 2;
string type = 3;
}

GetScenario

GetScenario is used to extract the SDL from a given Deputy package of type Exercise.

Request
message Source {
string name = 1;
string version = 2;
}
Successful Response
message GetScenarioResponse {
string sdl = 1;
}

Configuration

The following environment variables are available for the General handler configuration:

Global Settings

VariableMandatoryTypeDescription
GLOBAL_HOSTYesstringAddress where the General handler listens
GLOBAL_INSECUREYesboolEnables or disables SSL certificate verification

Service Ports

VariableMandatoryTypeDescription
GENERAL_PORTYesintegerPort where the General handler listens

Logging Configuration

VariableMandatoryTypeDescription
LOG_LEVELNostringLogging level (e.g., INFO, DEBUG, WARN)
LOG_DIRNostringDirectory where logs are stored
LOG_FILE_NAMENostringName of the log file

Redis Configuration

VariableMandatoryTypeDescription
REDIS_HOSTYesstringRedis server address
REDIS_PORTYesintegerPort where the Redis server is running
REDIS_PASSWORDYesstringPassword for Redis authentication

Optional Environment Variables

VariableMandatoryTypeDescription
HYPERVISOR_WAIT_TIMEOUTNointegerTimeout in seconds for the hypervisor to be ready
HYPERVISOR_WAIT_INTERVALNointegerInterval in seconds to check if the hypervisor is ready

Example .env Configuration

# Global Settings
GLOBAL_HOST=0.0.0.0
GLOBAL_INSECURE=True

# Service Ports
GENERAL_PORT=5000

# Logging Configuration
LOG_LEVEL=INFO
LOG_DIR=/var/log
LOG_FILE_NAME=ocr_openstack_plugin

# Redis Configuration
REDIS_HOST=redis-host
REDIS_PORT=6379
REDIS_PASSWORD=redis_password

# Optional
HYPERVISOR_WAIT_TIMEOUT=300
HYPERVISOR_WAIT_INTERVAL=5