Libra Command Line Client¶
Introduction¶
Libra Client is a Python command line client which is used to manipulate Atlas API compatible OpenStack Load Balancer as a Service installations.
It is designed to be similar to the Python Nova client and in fact uses this as a common base code.
Installation¶
From Ubuntu Package via PPA¶
- Install utility
sudo apt-get install python-software-properties
- Add the PPA
sudo apt-add-repository ppa:libra-core/ppa
- Update the package indexes
sudo apt-get update
- Install packages
sudo apt-get install python-libraclient
From PyPI¶
The python-libraclient package is published on PyPI and so can be installed using the pip tool, which will manage installing all python dependencies.
Note
The pip tool isn’t bundled by default with some versions of the different distributions, please install it typically using a package manager for the platform you use.
Note
Needs to be done in a Virtual Environment or as root.
pip install python-libraclient
Warning
The packages on PyPI may lag behind the git repo in functionality.
Setup the client from source¶
If you want the latest version, straight from github:
git clone git@github.com:stackforge/python-libraclient.git
cd python-libraclient
virtualenv .venv
source .venv/bin/activate
pip install -r requirements.txt -r test-requirements.txt
python setup.py install
Setup the client in development mode¶
Installing in development mode allows your to make changes to the source code & test directly without having to re-run the “python setup.py install” step. You can find out more about this in the Development Mode online docs.
git clone git@github.com:stackforge/python-libraclient.git
cd python-libraclient
virtualenv .venv
source .venv/bin/activate
pip install -r requirements.txt -r test-requirements.txt
python setup.py develop
Usage¶
Synopsis¶
libra [GENERAL OPTIONS] [COMMAND] [COMMAND_OPTIONS]
Description¶
libra is a utility designed to communicate with Atlas API based Load Balancer as a Service systems.
Global Options¶
-
--help
,
-h
¶
Show help message and exit
-
--debug
¶
Turn on HTTP debugging for requests
-
--insecure
¶
Don’t validate SSL certs
-
--os_bypass_url
<os_bypass-url>
¶ URL to use as an endpoint instead of the one specified by the Service Catalog
-
--service_type
<service-type>
¶ Alternative service type to use for your cloud provider (default is ‘hpext:lbaas’)
-
--os_auth_url
<auth-url>
¶ The OpenStack authentication URL. Default is
OS_AUTH_URL
orLIBRA_URL
environment variables
-
--os_username
<auth-user-name>
¶ The user name to use for authentication. Default is
OS_USERNAME
orLIBRA_USERNAME
environment variables
-
--os_password
<auth-password>
¶ The password to use for authentication. Default is
OS_PASSWORD
orLIBRA_PASSWORD
environment variables
-
--os_tenant_name
<auth-tenant-name>
¶ The tenant to authenticate to. Default is
OS_TENANT_NAME
orLIBRA_PROJECT_ID
environment variables
-
--os_region_name
<region-name>
¶ The region the load balancer is located. Default is
OS_REGION_NAME
orLIBRA_REGION_NAME
environment variables
Client Commands¶
algorithms¶
Gets a list of supported algorithms
create¶
Create a load balancer
-
--name
<name>
¶ The name of the node to be created
-
--port
<port>
¶ The port the load balancer will listen on
-
--protocol
<protocol>
¶ The protocol type for the load balancer (HTTP, TCP or GALERA). The Galera option adds support for deadlock avoidance in Galera clusters, see Serveral Nine’s Blog on this.
-
--node
<ip:port:option=value:...>
¶ The IP and port for a load balancer node (can be used multiple times to add multiple nodes). Additional node options may be specified after the ip:port portion in a option=value format.
-
--vip
<vip>
¶ The virtual IP ID of an existing load balancer to attach to
limits¶
Show the API limits for the user
logs¶
Send a snapshot of logs to an object store
-
<id>
The ID of the load balancer
-
--storage
<store>
¶ Storage type
-
--endpoint
<endpoint>
¶ Object store endpoint to use
-
--basepath
<basepath>
¶ Object store based directory
-
--token
<token>
¶ Object store authentication token
update¶
Update a load balancer’s configuration
-
<id>
The ID of the load balancer
-
--name
<name>
¶ A new name for the load balancer
-
--algorithm
<algorithm>
¶ A new algorithm for the load balancer
node-add¶
Add a node to a load balancer
-
<id>
The ID of the load balancer
-
--node
<ip:port:option=value:...>
¶ The node address in ip:port format (can be used multiple times to add multiple nodes). Additional node options may be specified after the ip:port portion in a option=value format.
node-delete¶
Delete a node from the load balancer
-
<id>
The ID of the load balancer
-
<nodeid>
The ID of the node to be removed
node-update¶
Update a node’s state in a load balancer
-
<id>
The ID of the load balancer
-
<nodeid>
The ID of the node to be updated
-
--condition
<condition>
¶ The new state of the node (either ENABLED or DISABLED)
node-show¶
Get the status of a node in a load balancer
-
<id>
The ID of the load balancer
-
<nodeid>
The ID of the node in the load balancer
protocols¶
Gets a list of supported protocols
Examples¶
Create Load Balancer¶
libra --os_auth_url=https://company.com/openstack/auth/url \
--os_username=username --os_password=pasword --os_tenant_name=tenant \
--os_region_name=region create --name=my_load_balancer \
--node 192.168.1.1:80 --node 192.168.1.2:80
This example will create a basic load balancer which will listen on port 80 and direct traffic in a round-robin fashion to two nodes, 192.168.1.1 and 192.168.1.2. Both these nodes are web servers listening on port 80. The Libra Client will then return a table similar to the below:
Property | Value |
status updated protocol name algorithm created virtualIps port nodes id |
BUILD 2013-10-31T11:59:24 HTTP test ROUND_ROBIN 2013-10-31T11:59:24 <VIP: 359 - PUBLIC IPV4 15.125.20.157> 80 <Node: 15.126.201.193:80> <Node: 15.126.201.70:80> 80303 |
Create a Load Balancer with Node Options¶
libra --os_auth_url=https://company.com/openstack/auth/url \
--os_username=username --os_password=pasword --os_tenant_name=tenant \
--os_region_name=region create --name=my_load_balancer \
--node 192.168.1.1:80:weight=1 --node 192.168.1.2:80:weight=2
Nearly identical to the above example, this creates a new load balancer with two nodes, but one is more heavily weighted than the other, causing it to accept more traffic.
Add a Node¶
libra --os_auth_url=https://company.com/openstack/auth/url \
--os_username=username --os_password=pasword --os_tenant_name=tenant \
--os_region_name=region node-add 158 --node=192.168.1.3:443
In this example we have take the ID of the load balancer of the previos example to add a web server to. The result should look something like this:
ID | Address | Port | Condition | Status |
192.168.1.3 | 443 |