Skip to main content

A lightweight wrapper for the SolusVM client API.

Project description

https://img.shields.io/pypi/status/beam.svg https://img.shields.io/pypi/v/beam.svg https://img.shields.io/pypi/pyversions/beam.svg https://travis-ci.org/gebn/beam.svg?branch=master https://coveralls.io/repos/github/gebn/beam/badge.svg?branch=master

A lightweight wrapper for the SolusVM client API.

Features

  • Query a host’s memory, bandwidth, IP addresses and storage usage.

  • Boot, reboot and shutdown machines.

  • Configurable to work with any SolusVM provider.

  • Command line client and intuitive Python module for your own scripts.

Setup

  1. Run pip install beam to download the module.

  2. Create your .beam.ini inventory file as below.

Inventory

The inventory file holds information about your hosting provider(s) and host(s), so beam knows how to contact the relevant API endpoints and what credentials to use. Here’s a sample file:

[special:vendors]
ramnode = https://vpscp.ramnode.com
vendor2 = https://vendor2-panel.com
default = ramnode

[nyc-1]
key = nyc-1_host_key
hash = nyc-1_host_hash

[ams-1]
key = ams-1_host_key
hash = ams-1_host_hash
vendor = vendor2

This file defines two hosts, nyc-1, hosted with RamNode, and ams-1, hosted with FlipHost. At the top are the vendor names in a special vendors section (all other sections are assumed to represent hosts). The format maps a vendor name to their base endpoint for the SolusVM API. The default directive indicates the implicit vendor of every host, and must be specified if more than one vendor is defined.

Each host has its own section. The correct key and hash values can be optained from the SolusVM control panel used by your vendor. If a host is not provided by the default vendor, a vendor directive specifies the correct one.

Usage

Beam provides both a Python library for programmatic access to your hosts, and a simple CLI that wraps it in a couple of lines of code.

CLI

The CLI client can be used to find information about a single host.

$ beam --help
usage: beam [-h] [-V]
            (-A {boot,reboot,shutdown} | -a ATTRIBUTES [ATTRIBUTES ...])
            [host]

A lightweight wrapper for the SolusVM client API.

positional arguments:
  host                  the identifier of the host whose information to
                        retrieve

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  -A {boot,reboot,shutdown}, --action {boot,reboot,shutdown}
                        an action to execute against the host
  -a ATTRIBUTES [ATTRIBUTES ...], --attributes ATTRIBUTES [ATTRIBUTES ...]
                        one or more attributes of the host to retrieve
$ beam -a bandwidth.free_percentage
0.4983459835
$ beam nyc-1 -a primary_ip
2604:180:2:32b::498b
$ beam ams-1 -a is_online memory.used_bytes
True
34578234983
$ beam nyc-1 -A shutdown
OK

Library

import beam

# shutdown a specific host
host = beam.host('nyc-1')  # name, key or hash
if host.is_online:
    host.shutdown()

# boot all offline hosts
[host.boot() for host in beam.hosts() if not host.is_online]

# get a list of hosts using above 90% of their memory
hosts = [host for host in beam.hosts()
         if host.memory.used_percentage > .9]

# get a list of hosts with less than 10 GiB of storage left
hosts = [host for host in beam.hosts()
         if host.storage.free_bytes < 1024 ** 3 * 10]

Roadmap

  • Generate documentation.

  • Increase unit test coverage to 100%, and implement some integration tests.

Etymology

Although “solus” means alone, that’s a tad depressing. Solus also conjures up images of the sun for me. The sun beams down - and the name was available on PyPI - so beam it was.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beam-0.4.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

beam-0.4.0-py2.py3-none-any.whl (20.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file beam-0.4.0.tar.gz.

File metadata

  • Download URL: beam-0.4.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for beam-0.4.0.tar.gz
Algorithm Hash digest
SHA256 330a193d01a67c79b1a001d6d5ec97a8a70ba7ac108df84d2521fa64bcd6669b
MD5 9bbd9f755bedd278592576dc1a7ab59d
BLAKE2b-256 f01bca092b9f9ee9e22227edfce4d318eaf17919a547e7d07ef526a1feff2d5c

See more details on using hashes here.

File details

Details for the file beam-0.4.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for beam-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 54cde176c66b66ccb159f0fee31d1d16f5c6e0a545c2bc552f008a055ba70575
MD5 b4d52d461521069bc87eacd1c5233c83
BLAKE2b-256 9d37c13c4a6850c8937c0e13af9018adf55e49cce85b57c885c0db3abd673239

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page