Binary Lane servers can be controlled using the OpenStack Compute API. This article will walk through the process of using the "nova" command-line client.


Install Python


The nova command-line client is a Python application, so if you are running Windows you will first need to install Python itself. You can get Python here:


Download the 32-bit or 64-bit version as appropriate and run the installer. Once its finished, open a Windows command prompt ("cmd").


Install python-novaclient


With python installed, you can use "pip" - the python package manager - to install novaclient. The python installer should have placed pip in your PATH already, so simply run:

     

pip install python-novaclient==4.0.0

    

Wait a few minutes while it downloads and installs. You may see some errors about unable to compile various things - this is an optional optimization and is harmless.


Setting up your environment


The nova commandline client requires that you set four environment variables. The variables are:


Variable Value Description
OS_AUTH_URL https://api.binarylane.com.au/v2.0 This tells nova where the API server is located.
OS_USERNAME Your Binary Lane email address This is the username that is authenticated against the API.
OS_PASSWORD Your Binary Lane account password or API key This is the secret used to authenticate against the API. While you can use the password that you login to mPanel with, the preferred option is to go to https://www.binarylane.com.au/mpanel/profile/overview and obtain your API key.
OS_TENANT_NAME binarylane This is used for multi-tenant private clouds. As Binary Lane is a public cloud we have a single tenant, "binarylane".


These variables need to be set within a Windows command prompt using the SET command. A good approach to avoid redoing this each time you want to use nova is to create a shortcut to cmd.exe that sets the values for you. To do so, right-click your desktop and select "New shortcut". Enter the location as: 

    

cmd /k "mode con: cols=150 lines=50&& set OS_AUTH_URL=https://api.binarylane.com.au/v2.0&& set OS_TENANT_NAME=binarylane&& set OS_USERNAME=user@example.com&& set OS_PASSWORD=32characterapikey"

   

Just edit the line to contain your email and API key (be careful not to add a space before the && , as that would add a space to the end of environment variable.). Name your new shortcut "Binary Lane" and double-click to open Command Prompt. Check your environment is working:

 

C:\>echo "%OS_AUTH_URL%"
"https://api.binarylane.com.au/v2.0"

C:\>echo "%OS_TENANT_NAME%"
"binarylane"

C:\>echo "%OS_USERNAME%"
"user@example.com"

C:\>echo "%OS_PASSWORD%"
"1234567890abcdefghijklmnopqrstuv"

 

Double-check the values are correct and that there is no space between the value and the terminating quotation mark.


Using the nova client


With the environment setup, you can now use Nova. (All of the above is a once off; in the future you can just open the "Binary Lane" command prompt and start working)


Server list


Start by seeing what servers you have:

  

nova list

+--------------------------------------+------------------------+--------+------------+-------------+----------------------+
| ID                                   | Name                   | Status | Task State | Power State | Networks             |
+--------------------------------------+------------------------+--------+------------+-------------+----------------------+
| 56cd309d-028c-41b5-afca-a2d000ed6cb2 | linux.local            | ACTIVE | N/A        | N/A         | public=103.16.128.27 |
+--------------------------------------+------------------------+--------+------------+-------------+----------------------+

  

Here I have a single cloud VPS, and its permanent ID is 56cd309d-028c-41b5-afca-a2d000ed6cb2 


Reboot a server


This ID can be used with other nova commands: for example, if I want to reboot my linux.local server:

  

C:\>nova reboot 56cd309d-028c-41b5-afca-a2d000ed6cb2

  

If you have mPanel open, you should see your cloud server reboot.  If the server is not responding to the reboot request (perhaps because its run out of memory), then you can force a reboot with:

  

C:\>nova reboot 56cd309d-028c-41b5-afca-a2d000ed6cb2 --hard

  

This is equivalent to the "Power-cycle" button in mPanel.


Create a new server


New servers are created with nova using the "boot" command, but before doing so we need to select a plan and an operating system which nova refers to as "flavor" and "image" respectively. These can be listed with flavor-list and image-list respectively:

  

C:\>nova flavor-list
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID                                   | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 002c3b0c-fa4e-4685-a4cc-2156bf7a210b | Apartment | 512       | 20   | 0         |      | 1     |             | N/A       |
| df2e07c7-a221-4193-a398-5bc385912d20 | Mansion   | 4096      | 80   | 0         |      | 4     |             | N/A       |
| de0a40f5-65ef-4b89-aeda-df9707689b24 | Castle    | 8192      | 100  | 0         |      | 8     |             | N/A       |
| 002c3b0c-fa4e-4685-a4cc-2156bf7a210c | Townhouse | 1024      | 40   | 0         |      | 1     |             | N/A       |
| 002c3b0c-fa4e-4685-a4cc-2156bf7a210d | House     | 2048      | 60   | 0         |      | 2     |             | N/A       |
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+ 

 

 

C:\>nova image-list
+--------------------------------------+--------------------------+--------+--------+
| ID                                   | Name                     | Status | Server |
+--------------------------------------+--------------------------+--------+--------+
| 9310ba82-31c5-4cd3-add3-d7dfc6fc86a1 | CentOS 6.5 (32bit)       | active |        |
| 9310ba82-31c5-4cd3-add3-d7dfc6fc86a2 | CentOS 6.5 (64bit)       | active |        |
| 07140ec2-335c-49f3-b9e8-10c1c0ad1001 | Debian 7 (32bit)         | active |        |
| 07140ec2-335c-49f3-b9e8-10c1c0ad1002 | Debian 7 (64bit)         | active |        |
| 07140ec2-335c-49f3-b9e8-10c1c0ad3375 | Ubuntu 12.04 LTS (32bit) | active |        |
| 07140ec2-335c-49f3-b9e8-10c1c0ad3376 | Ubuntu 12.04 LTS (64bit) | active |        |
| d91a14c9-e057-40ce-8c8c-4ad7ea48dcc3 | Windows 2008 R2 (64bit)  | active |        |
| 002c3b0c-fa4e-4685-a4cc-2156bf7a221f | Windows 2012 R2 (64bit)  | active |        |
+--------------------------------------+--------------------------+--------+--------+

 

As with the "list" command, you need to grab the ID for each that you want. For my example I'm going to create an Ubuntu 12.04 64-bit server on the 512MB memory plan named "test.example.com".

 

C:\>nova boot --flavor 002c3b0c-fa4e-4685-a4cc-2156bf7a210b --image 07140ec2-335c-49f3-b9e8-10c1c0ad3376 text.example.com
+----------------+-----------------------------------------------------------------+
| Property       | Value                                                           |
+----------------+-----------------------------------------------------------------+
| accessIPv4     | 103.16.128.123                                                  |
| accessIPv6     | 2404:9400:1:0:216:3eff:fef0:154                                 |
| adminPass      | BuUHrcV4                                                        |
| created        | -                                                               |
| flavor         | Apartment (002c3b0c-fa4e-4685-a4cc-2156bf7a210b)                |
| hostId         | bnecompute3                                                     |
| id             | f827d5a3-326d-431c-9649-a2e000f55074                            |
| image          | Ubuntu 12.04 LTS (64bit) (07140ec2-335c-49f3-b9e8-10c1c0ad3376) |
| metadata       | -                                                               |
| name           | text.example.com                                                |
| progress       | -                                                               |
| public network | 103.16.128.123                                                  |
| status         | ERROR                                                           |
| tenant_id      | -                                                               |
| updated        | -                                                               |
| user_id        | -                                                               |
+----------------+-----------------------------------------------------------------+


Check mPanel's service list at https://www.binarylane.com.au/mpanel/list (or run "nova list") and you will find you have a second server. The adminPass line tells you the root password which you can SSH to your server with.

Cancelling a server


Once you are finished with a server, you can cancel it which will mark the end of your hourly usage. To do so, use nova's "delete" command using the server's ID. (Use "nova list" to get the ID again if necessary):

 

nova delete f827d5a3-326d-431c-9649-a2e000f55074

 

This is equivalent to selecting "Cancel Service" within mPanel; the instance will soon be suspended and an invoice generated for the hours used:

 

C:\>nova list
+--------------------------------------+------------------------+-----------+------------+-------------+-----------------------+
| ID                                   | Name                   | Status    | Task State | Power State | Networks              |
+--------------------------------------+------------------------+-----------+------------+-------------+-----------------------+
| 56cd309d-028c-41b5-afca-a2d000ed6cb2 | linux.local            | ACTIVE    | N/A        | N/A         | public=103.16.128.27  |
| f827d5a3-326d-431c-9649-a2e000f55074 | text.example.com       | SUSPENDED | N/A        | N/A         | public=103.16.128.123 |
+--------------------------------------+------------------------+-----------+------------+-------------+-----------------------+

 

Further exploration


In this article I've demonstrated the basics of listing your cloud servers, creating a new VPS, rebooting it and finally destroying it. However, this is just the tip of the iceberg - some of the other more useful nova commands include:

  • nova rebuild - equivalent to "Reinstall" in mPanel, deletes all the data puts a fresh copy of the operating system in place
  • nova resize - equivalent to "Change Plan" in mPanel, allows you to size an existing server up or down
  • nova root-password - equivalent to "Reset Password" in mPanel, if you have lost the password for the VPS