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
Variable | Mandatory | Type | Description |
---|---|---|---|
GLOBAL_HOST | Yes | string | Address where the General handler listens |
GLOBAL_INSECURE | Yes | bool | Enables or disables SSL certificate verification |
Service Ports
Variable | Mandatory | Type | Description |
---|---|---|---|
GENERAL_PORT | Yes | integer | Port where the General handler listens |
Logging Configuration
Variable | Mandatory | Type | Description |
---|---|---|---|
LOG_LEVEL | No | string | Logging level (e.g., INFO, DEBUG, WARN) |
LOG_DIR | No | string | Directory where logs are stored |
LOG_FILE_NAME | No | string | Name of the log file |
Redis Configuration
Variable | Mandatory | Type | Description |
---|---|---|---|
REDIS_HOST | Yes | string | Redis server address |
REDIS_PORT | Yes | integer | Port where the Redis server is running |
REDIS_PASSWORD | Yes | string | Password for Redis authentication |
Optional Environment Variables
Variable | Mandatory | Type | Description |
---|---|---|---|
HYPERVISOR_WAIT_TIMEOUT | No | integer | Timeout in seconds for the hypervisor to be ready |
HYPERVISOR_WAIT_INTERVAL | No | integer | Interval 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