lester
Lester
Lester is a low-level API client for LXD. It features an intuitive interface that maps directly to the LXD API.
Usage Examples
-
Create client:
lxd = Lester.new(socket: "/var/snap/lxd/common/lxd/unix.socket") # OR: # # lxd = Lester.new( # base_uri: "https://1.2.3.4:8443", # private_key: "priv.key", # certificate: "cert.pem", # # ca_certificates: "ca.pem", # # verify_mode: "none" # )
-
Add new trusted certificate:
lxd.certificates.add( certificate: "X509 PEM certificate...", name: "castiana", password: "secret", # ... ) do |response| return puts response.message unless response.success? puts response.type puts response.code end
-
List all images:
lxd.images.list(project: "default") do |response| return puts response.message unless response.success? response.metadata.try &.each do |image| puts image.architecture puts image.auto_update? puts image.cached? # ... end end
-
Download instance backup:
lxd.instances.backups.export( instance_name: "instance-04", name: "backup0", destination: "/home/user/Downloads/backup.zip" ) do |response| puts response.message end
-
Add new storage pool:
lxd.pools.create( project: "default", target: "lxd0", config: {"volume.block.filesystem": "ext4", "volume.size": "50GiB"}, description: "Local SSD pool", driver: "zfs", name: "local", # ... ) do |response| return puts response.message unless response.success? puts response.type puts response.code end
Documentation
Find the complete documentation in the docs/
directory of this repository.
Development
-
Create a
.env.sh
file:#!/bin/bash # export LXD_SOCKET='/var/snap/lxd/common/lxd/unix.socket' # Set these if you need to test against a remote LXD server export LXD_BASE_URI='https://1.2.3.4:8443' export LXD_TLS_KEY_PATH='priv.key' export LXD_TLS_CERT_PATH='cert.pem' export LXD_TLS_CA_PATH='' export LXD_TLS_VERIFY_MODE='none'
Update the file with your own details.
-
Run tests with
source .env.sh && crystal spec
.
Contributing
- Fork it
- Switch to the
master
branch:git checkout master
- Create your feature branch:
git checkout -b my-new-feature
- Make your changes, updating changelog and documentation as appropriate.
- Commit your changes:
git commit
- Push to the branch:
git push origin my-new-feature
- Submit a new Pull Request against the
GrottoPress:master
branch.
Repository
lester
Owner
Statistic
- 3
- 0
- 0
- 0
- 2
- 4 months ago
- October 15, 2021
License
MIT License
Links
Synced at
Sat, 21 Dec 2024 09:50:56 GMT
Languages