Your First Request
A minimal end-to-end example against a running service
This guide walks you through making your first requests to Trilio Site Recovery for OpenStack: registering two sites, creating a protection group, adding a VM to it, and verifying replication health. By the end you will have a working protection group and a working mental model of the CLI, REST API, and Python client — the three interfaces the service exposes. The service must already be deployed and registered in Keystone before you begin; if it is not, complete the deployment guide first.
Before starting:
- Trilio Site Recovery deployed on both sites (Juju, Kolla-Ansible, or OpenShift) with
protector-apiandprotector-enginerunning - The service registered in Keystone with service type
disaster-recoveryand an endpoint on port 8788 - Keystone roles
dr_operatoranddr_site_admincreated on both sites - Your shell sourced with OpenStack credentials for the primary site (
OS_AUTH_URL,OS_PROJECT_NAME, etc.) python3-triliositerecoveryinstalled on the machine where you run the CLI — this provides theopenstack drsubcommand familypython3-keystoneclientandpython3-keystoneauth1available for the Python client examples- At least one VM booted from a Cinder volume on the primary site (LUKS-encrypted volumes are not supported and will be rejected)
- Network connectivity from your workstation to port 8788 on the primary site's controller
- The
dr_site_adminrole granted on the admin project — site registration requires it
The openstack dr commands come from the python3-triliositerecovery package. If the Juju charm manages your node, the package is already present. On any other machine — including a bastion or a developer laptop — install it from the Trilio apt repository:
1. Add the Trilio repository
echo 'deb [trusted=yes] https://apt.fury.io/trilio-os-site-recovery-master/ /' \
| sudo tee /etc/apt/sources.list.d/trilio-site-recovery.list
sudo apt-get update
2. Install the CLI package
sudo apt-get install python3-triliositerecovery
3. Verify the plugin loaded
openstack help dr
You should see the full list of dr subcommands. If the command is not found, ensure python3-openstackclient is installed and that the entry point cache is current (hash -r in bash).
4. Source your credentials
source ~/cluster1-openrc.sh
Use non-admin credentials scoped to the project you are protecting. The service is designed to work without admin rights for all tenant-facing operations; using admin credentials masks Cinder policy issues that real tenants will hit.
The CLI reads standard OpenStack environment variables (OS_AUTH_URL, OS_PROJECT_NAME, OS_USERNAME, OS_PASSWORD, and so on) and discovers the protector endpoint from the Keystone service catalogue under service type disaster-recovery.
No additional client-side configuration file is required. The following environment variable can pin the API microversion if needed:
export OS_PROTECTOR_API_VERSION=1
On the server side, the service reads /etc/protector/protector.conf. The options most relevant to your first request are in the [DEFAULT] section:
| Option | Type | Default | Purpose |
|---|---|---|---|
local_site | string | (unset) | Name of the DR site this instance belongs to. Must be set before the service can participate in any DR operation. |
use_mock_storage | boolean | false | When true, uses an in-memory storage backend — no FlashArray required. Useful for initial validation. |
And in [storage]:
| Option | Type | Default | Purpose |
|---|---|---|---|
storage_driver | string | mock | Storage backend: mock, pure, drbd, or a full class path. |
If local_site is not set, the service will block DR operations and return an error. On a Juju-managed unit, set it with:
juju config trilio-site-recovery local-site=cluster1
All CLI commands live under the openstack dr namespace. The workflow for protecting a set of VMs is:
- Register both sites
- Create a protection group naming both sites
- Add VMs to the group
- (Optional) Check replication health
- (When needed) Execute failover
Register the two sites
Site registration requires the dr_site_admin role. Run these commands while scoped to the admin project:
openstack dr site create cluster1 \
--auth-url https://cluster1-keystone:5000 \
--region RegionOne
openstack dr site create cluster2 \
--auth-url https://cluster2-keystone:5000 \
--region RegionOne
Note that openstack dr site create takes the site name as a positional argument and has no --site-type flag — primary and secondary are roles a protection group assigns to sites, not properties of the site itself.
List registered sites
openstack dr site list
Create a protection group
Switch back to your tenant credentials, then:
openstack dr protection group create prod-pg \
--primary-site cluster1 \
--secondary-site cluster2 \
--replication-type async \
--volume-type cinder-repl-type
--volume-type is required when --replication-type async is used. For active_dr replication it is not required. Capture the returned ID for subsequent commands:
PG_ID=$(openstack dr protection group create prod-pg \
--primary-site cluster1 \
--secondary-site cluster2 \
--replication-type async \
--volume-type cinder-repl-type \
-f value -c id)
Add a VM to the group
openstack dr protection group member add "$PG_ID" \
--instance <vm-uuid>
The VM must boot from a Cinder volume. LUKS-encrypted volumes are rejected at this step.
Check replication health
openstack dr replication health "$PG_ID"
Add --probe to also ask the recovery site whether the group's networks, security groups, and flavors resolve there within the project it would recover into. --probe does not test the storage backend or replication lag — it queries the recovery site's Neutron and Nova through the same trust-scoped session a real recovery would use.
Execute a planned failover
OP_ID=$(openstack dr failover "$PG_ID" \
--failover-type planned \
--wait \
-f value -c id)
--wait polls the operation until it settles. Without it the command returns immediately with status pending. Monitor progress any time with:
openstack dr operation show "$OP_ID"
The output includes a progress field (0–100%) and source_site / target_site columns showing site names. There is no estimated completion time — progress percentage is the only indicator.
After a successful failover, recovered instances are named <original-name>-failover on the recovery site. Failback creates them as <original-name>-restored. Neither round-trip returns workloads to their original name.
Example 1 — End-to-end setup (bash)
# 1. Source admin credentials for site registration
source ~/admin-openrc.sh
# 2. Register both sites
SITE1_ID=$(openstack dr site create cluster1 \
--auth-url https://cluster1-keystone:5000 \
--region RegionOne \
-f value -c id)
SITE2_ID=$(openstack dr site create cluster2 \
--auth-url https://cluster2-keystone:5000 \
--region RegionOne \
-f value -c id)
echo "Site 1: $SITE1_ID"
echo "Site 2: $SITE2_ID"
# 3. Switch to tenant credentials
source ~/cluster1-openrc.sh
# 4. Create a protection group (async replication requires --volume-type)
PG_ID=$(openstack dr protection group create prod-pg \
--primary-site cluster1 \
--secondary-site cluster2 \
--replication-type async \
--volume-type cinder-repl-type \
-f value -c id)
echo "Protection group: $PG_ID"
# 5. Add a VM
VM_ID=$(openstack server list -f value -c ID | head -1)
openstack dr protection group member add "$PG_ID" --instance "$VM_ID"
# 6. List members
openstack dr protection group member list "$PG_ID"
# 7. Check replication health (--probe validates recovery-site resources)
openstack dr replication health "$PG_ID" --probe
Example 2 — Planned failover with network mapping
Use = as the separator between source and destination. The left side must be the source network name as it appears in operation metadata, not the UUID:
OP_ID=$(openstack dr failover "$PG_ID" \
--failover-type planned \
--network-mapping internal-net=dr-internal-net \
--flavor-mapping m1.medium=m1.medium-dr \
--wait \
-f value -c id)
openstack dr operation show "$OP_ID"
Example 3 — REST API: register a site
Acquire a Keystone token first:
TOKEN=$(openstack token issue -f value -c id)
TENANT=$(openstack token issue -f value -c project_id)
API=https://cluster1-controller:8788
Register a site:
curl -s -X POST \
-H "X-Auth-Token: $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"site": {
"name": "cluster1",
"auth_url": "https://cluster1-keystone:5000",
"region": "RegionOne"
}
}' \
"$API/v1/$TENANT/sites"
Create a protection group:
curl -s -X POST \
-H "X-Auth-Token: $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"protection_group": {
"name": "prod-pg",
"primary_site_id": "'$SITE1_ID'",
"secondary_site_id": "'$SITE2_ID'",
"replication_type": "async",
"volume_type_id": "<cinder-volume-type-uuid>"
}
}' \
"$API/v1/$TENANT/protection-groups"
Trigger a failover via the action endpoint:
curl -s -X POST \
-H "X-Auth-Token: $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"failover": {
"failover_type": "planned"
}
}' \
"$API/v1/$TENANT/protection-groups/$PG_ID/action"
The action endpoint accepts failover, failback, failback_plan, test_failover, test_cleanup, and reconcile as top-level keys.
Example 4 — Python client
from keystoneauth1 import loading, session
from keystoneauth1.identity import v3
from keystoneauth1 import adapter
from triliositerecovery.v1.client import Client
# Build a keystoneauth1 session
auth = v3.Password(
auth_url='https://cluster1-keystone:5000/v3',
username='myuser',
password='mypassword',
project_name='myproject',
user_domain_name='Default',
project_domain_name='Default',
)
sess = session.Session(auth=auth)
# Wrap in an Adapter and discover the endpoint
adp = adapter.Adapter(
session=sess,
service_type='disaster-recovery',
interface='public',
region_name='RegionOne',
)
endpoint = adp.get_endpoint()
# Instantiate the client — both session and endpoint are required
client = Client(session=adp, endpoint=endpoint, region_name='RegionOne')
# List sites — returns a list of plain dicts; use site['id'], never site.id
sites = client.sites.list()
for site in sites:
print(site['id'], site['name'])
# Create a protection group
pg = client.protection_groups.create(
name='prod-pg',
primary_site_id=sites[0]['id'],
secondary_site_id=sites[1]['id'],
replication_type='async',
volume_type_id='<cinder-volume-type-uuid>',
)
print('Created PG:', pg['id'])
# Add a member
client.protection_groups.add_member(pg['id'], instance_id='<vm-uuid>')
# Trigger failover — DR operation methods are on client.operations
# Pass pg_id positionally; network_mapping is a dict, not a string
operation = client.operations.failover(
pg['id'],
failover_type='planned',
network_mapping={'src-net-name': 'dst-net-id'},
)
print('Operation:', operation['id'], operation['status'])
# Poll the operation
import time
while True:
op = client.operations.get(operation['id'])
print(op['status'], str(op.get('progress', 0)) + '%')
if op['status'] in ('completed', 'failed', 'cancelled', 'error'):
break
time.sleep(5)
Key conventions:
- Every manager returns parsed JSON — plain
dictorlistobjects. Usesite['id'], neversite.id. - The protection group ID is always the first positional argument to operation methods such as
failover(pg_id, ...)andreplication_health(pg_id, ...). - Network and flavor mappings are Python
dictobjects at the library level — thesrc=dststring syntax is argparse-only and belongs to the CLI layer.
openstack: 'dr' is not an openstack command
Cause: The python3-triliositerecovery package is not installed or its entry point was not registered.
Fix:
sudo apt-get install python3-triliositerecovery
hash -r
openstack help dr
If you are on a Juju-managed unit, the charm installs the package automatically. On any other machine you must install it separately.
SiteNotFound or 404 when referencing a site by name
Cause: The site name is case-sensitive and must match exactly what was registered. Some commands also accept the site UUID.
Fix: Run openstack dr site list to confirm the exact registered name, then rerun your command with that string.
InvalidState 409 when creating a protection group or adding a member
Cause: The protection group or a related resource is in a state that does not allow the requested operation (for example, an interrupted failover left it in FAILING_OVER).
Fix: Check the current state:
openstack dr protection group show "$PG_ID"
If the group is stuck after an interrupted operation, use reconcile to repair it:
openstack dr protection group reconcile "$PG_ID"
Reconcile inspects storage, VMs, and operation history to fix the group's status and works even when the primary site is unreachable. Each reconcile run is recorded in the operation list.
LocalSiteNotConfigured 500 on any DR operation
Cause: The local_site option in [DEFAULT] of protector.conf is not set on this instance.
Fix (Juju):
juju config trilio-site-recovery local-site=cluster1
After a charm upgrade to 1.0.20 or later the unit lands in BLOCKED with the message set local-site, pure-primary-site-name, pure-secondary-site-name until this is set. This is expected behaviour, not a failed upgrade.
Fix (Kolla / bare-metal): Edit /etc/protector/protector.conf:
[DEFAULT]
local_site = cluster1
Then restart the engine and API containers.
Forbidden 403 / Policy doesn't allow volume_extension:volume_manage
Cause: Cinder's default policy restricts volume manage/unmanage operations to admins. Failover imports replicated volumes through Cinder's manage API running as a tenant trust, so it fails with HTTP 403 when these rules are not relaxed.
Fix: On both sites, add or update the following five rules in Cinder's policy.yaml:
"volume_extension:volume_manage": "rule:admin_or_owner"
"volume_extension:volume_unmanage": "rule:admin_or_owner"
"volume_extension:services:index": "rule:admin_or_owner"
"volume_extension:type_get": "rule:admin_or_owner"
"volume_extension:type_get_all": "rule:admin_or_owner"
All five are required. The absence of type_get and type_get_all is a common miss because some Cinder versions leave them open by default, so a lab environment passes while a customer cloud fails partway through its first failover.
InstanceNotCinderBoot 422 when adding a member
Cause: The VM does not boot from a Cinder volume. The service can only protect and replicate Cinder-backed root volumes.
Fix: Migrate the instance to boot from a Cinder volume before adding it to a protection group.
InvalidInput 400 when adding a member with an encrypted volume
Cause: LUKS-encrypted volumes are not supported. The service cannot associate Barbican encryption keys on the recovery site, so encrypted volumes can never be recovered.
Fix: Use array-side encryption (Pure Storage data-at-rest encryption) instead of host-side LUKS. Remove the LUKS encryption from the volume before adding the instance to a protection group.
--network-mapping has no effect; failover uses the wrong network
Cause: A colon (:) was used as the separator instead of an equals sign (=). Argparse accepts the colon-separated value as one opaque string, so the mapping is silently ignored.
Fix: Use = as the separator:
--network-mapping internal-net=dr-internal-net
Also confirm that the left side is the source network name as it appears in openstack dr operation show output, not the network UUID. Instance metadata carries network names, so a source UUID matches nothing.
operation show shows blank source_site and target_site columns
Cause: You are running a version of the service prior to the fix that added site name resolution to the operations API. Earlier versions emitted only source_site_id and target_site_id, leaving the name columns structurally empty.
Fix: Upgrade trilio-site-recovery and python3-triliositerecovery to the current release. After upgrading, both columns show the site name (falling back to the site ID if the name cannot be resolved).
Python client raises AttributeError: 'dict' object has no attribute 'id'
Cause: Manager methods return plain Python dicts, not resource objects.
Fix: Use dict access instead of attribute access:
# Wrong
site.id
# Correct
site['id']
Python client request URLs begin with None/
Cause: The Client was instantiated without the endpoint argument.
Fix: Discover the endpoint from the Keystone catalogue and pass it explicitly:
endpoint = adp.get_endpoint()
client = Client(session=adp, endpoint=endpoint, region_name='RegionOne')