Skip to main content
Version: Next

Templater

The Templater handles the creation and deletion of virtual machine templates for the openstack environment from Template type Deputy packages.

Endpoints

The Templater has two gRPC endpoints:

create

Creates a template from a given Deputy package. Duplicate templates of the same Deputy source package are not uploaded. This is achieved by naming the templates after the checksum of the source package.

During the creation of the template the existing network devices are removed. It is still recommended to remove them by hand when before creating the VM Deputy package as it may be prone to errors depending on the openstack version.

note

If the template already exists in the openstack environment, the deputy package is not downloaded into the handler and the Accounts info is not extracted from it. The Accounts field will be empty in the response. The accounts information is stored on the Rangers database as well as in redis storage, if that is lost the template will need to be deleted and then reuploaded for it to populate the Database again.

Request

message Source {
string name = 1;
string version = 2;
}

Successful Response

message TemplateResponse {
Identifier identifier = 1;
repeated Account accounts = 2;
}

For reference, the Identifier and Account messages are defined as follows:

message Identifier {
string value = 1;
}

message Account {
string username = 1;
string password = 2;
string private_key = 3;
}

delete

Deletes a previously uploaded template.

Request

message Identifier {
string value = 1;
}

Successful Response

message Empty {}

Configuration

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

Global Settings

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

Service Ports

VariableMandatoryTypeDescription
TEMPLATER_PORTYesintegerPort where the Templater handler listens

DevStack Credentials

VariableMandatoryTypeDescription
AUTH_URLYesstringOpenStack authentication endpoint
CREDENTIAL_IDYesstringOpenStack credential username
CREDENTIAL_SECRETYesstringOpenStack credential password
DOMAINYesstringOpenStack domain (default: Default)
PROJECTYesstringOpenStack project name
GATEWAY_NETWORKYesstringGateway network for the OpenStack environment
REGIONYesstringRegion name for the OpenStack environment
HYPERVISORYesstringOpenStack hypervisor connection URL
HYPERVISOR_USERYesstringUsername for the OpenStack hypervisor
HYPERVISOR_PASSWORDYesstringPassword for the OpenStack hypervisor

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
TEMPLATER_PORT=8000

# DevStack Credentials
AUTH_URL=https://openstack-auth-url:5000/v3
CREDENTIAL_ID=openstack_client_id
CREDENTIAL_SECRET=openstack_application_secret
DOMAIN=openstack_domain
PROJECT=openstack_project
GATEWAY_NETWORK=openstack_gateway_network
REGION=openstack_region
HYPERVISOR=qemu+tcp://hostname/system
HYPERVISOR_USER=openstack_hypervisor_user
HYPERVISOR_PASSWORD=openstack_hypervisor_password

# 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