Leostream Admin CLI
A command line interface for the Leostream Connection Broker REST API. Written in Go and compiled to a single binary, it provides full CRUD (Create, Read, Update, Delete) operations for Leostream resources and database backup/restore capabilities.
Supported Resources
| Resource |
Commands |
| pools |
list, get, create, update, delete |
| centers |
list, get, create, update, delete |
| gateways |
list, get, create, update, delete |
| gatewayclusters |
list, get, create, update, delete |
| policies |
list, get, create, update, delete |
| poolassignments |
list, get, create, update, delete |
| vm |
list, get |
Additional commands:
- backup — Backup the Leostream PostgreSQL database
- restore — Restore the Leostream PostgreSQL database
Installation
From Go
go install gitlab.com/hocmodo/leostream-admin-cli@latest
The binary will be installed in your GOPATH/bin/ directory. Add it to your PATH:
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
Building from source
go build -o leostream-admin-cli main.go
Usage
Step 1: Set environment variables
Your Leostream user needs API access permissions. Create a user with appropriate permissions in the Leostream Connection Broker web interface, then set the following environment variables:
export LEOSTREAM_API_HOSTNAME=https://<leostream-host>
export LEOSTREAM_API_USERNAME=<username>
export LEOSTREAM_API_PASSWORD=<password>
export LEOSTREAM_API_SSL_INSECURE=true # Set to true if using a self-signed certificate
Step 2: Run a command
leostream-admin-cli <resource> <command> [flags]
Common flags
All commands support the --json flag to output results as JSON instead of a table. This is useful for piping to tools like jq:
leostream-admin-cli pool list --json
Examples
List pools
leostream-admin-cli pool list
Get a pool by ID
leostream-admin-cli pool get --pool_id 1
Create a pool
leostream-admin-cli pool create --name "My Pool" --display_name "My Pool" --center_id 1 --center_type vmware
Update a pool
leostream-admin-cli pool update --pool_id 1 --name "Updated Pool" --display_name "Updated Pool"
Delete a pool
leostream-admin-cli pool delete --pool_id 1
List VMs
leostream-admin-cli vm list
Get a VM
leostream-admin-cli vm get --desktop_id 1
Backup database
leostream-admin-cli backup --host localhost --port 5432 --db leostream --username leostream --password <password> --path backup.sql.tar.gz
Restore database
leostream-admin-cli restore --host localhost --port 5432 --db leostream --username leostream --password <password> --path backup.sql.tar.gz
Architecture
The CLI is built with Cobra for the CLI framework and uses the Leostream Go client library for API communication. The center, gateway, gatewaycluster, policy, and poolassignment commands all require a --policy_id flag where applicable, as the Leostream API structures pool assignments under policies.
Development
Running tests
go test ./...
Linting
golangci-lint run ./...