Python Interface for ArubaCloud IaaS Service. This is an early-stage release, not every features has been covered.
This project is under development, the classes, methods and parameters might change over time. This README usually reflects the syntax of the latest version.
Python Package:
pip install pyarubacloud
Git Version:
git clone https://github.com/Arubacloud/pyArubaCloud.git pyArubaCloud
cd pyArubaCloud
python setup.py install
In the examples folder you can find some examples on various operations which can be done via API.
from ArubaCloud.PyArubaAPI import CloudInterface
ci = CloudInterface(dc=1)
ci.login(username="XXX-XXXX", password="XXXXXXXX", load=True)
Once you have instantiated CloudInterface object by specifying the number of the datacenter(1 to 6), keeping in mind this association:
You can login with your username and password (i.e. AWI-19054), load
parameter is used to cache all of the data related to the account (within the datacenter) at the login phase.
You have the following 4 types of hypervisors to choose from:
Assuming that we want to list every template that contains Debian in the Description for hypervisor 4 in Datacenter 2, the code will be the following:
from ArubaCloud.PyArubaAPI import CloudInterface
ci = CloudInterface(dc=1)
ci.login(username="XXX-XXXX", password="XXXXXXXX", load=True)
ci.get_hypervisors()
from pprint import pprint
pprint(ci.find_template(name='Debian', hv=4))
When you select a template to create a new machine the template has to be enabled. In the result of find_template you can check if a template is enabled.
[Template Name: Debian 5 32bit, Hypervisor: SMART, Id: 959, Enabled: False,
Template Name: Debian 5 64bit, Hypervisor: SMART, Id: 960, Enabled: False,
Template Name: Debian 6 32bit, Hypervisor: SMART, Id: 961, Enabled: False,
Template Name: Debian 6 64bit, Hypervisor: SMART, Id: 962, Enabled: False,
Template Name: Debian 7 64bit, Hypervisor: SMART, Id: 1114, Enabled: True,
Template Name: Debian 7 32bit, Hypervisor: SMART, Id: 1115, Enabled: True,
Template Name: Debian 8 64bit, Hypervisor: SMART, Id: 1723, Enabled: True]
In order to create a VM you have to instantiate the specific object exposed by the ArubaCloud.objects package:
About Pro VMs, you can choose from a large number of customizations, such as, number of cpu, ram quantity, number and size of virtual disks, public IPs, private IPs and so on.
Smart Servers are not customizable (this reflects the behaviour of the service itself), but you can choose 4 different sizes:
from ArubaCloud.PyArubaAPI import CloudInterface
from ArubaCloud.objects import ProVmCreator
ci = CloudInterface(dc=1)
ci.login(username="XXX-XXXX", password="XXXXXXXX", load=True)
ip = ci.purchase_ip()
# template_id: 1605 [Template Name: CentOS 7.x 64bit, Hypervisor: VW, Id: 1605, Enabled: True]
c = ProVmCreator(name='debian01', admin_password='MyStrongPassword', template_id='1605', auth_obj=ci.auth)
c.set_cpu_qty(2)
c.set_ram_qty(6)
c.add_public_ip(public_ip_address_resource_id=ip.resid)
c.add_virtual_disk(20)
c.add_virtual_disk(40)
print(c.commit(url=ci.wcf_baseurl, debug=True))
from ArubaCloud.PyArubaAPI import CloudInterface
from ArubaCloud.objects import SmartVmCreator
ci = CloudInterface(dc=1)
ci.login(username="XXX-XXXX", password="XXXXXXXX", load=True)
# template_id: 1114 [Hypervisor: SMART (Debian 7 - 64bit)]
c = SmartVmCreator(name='small01', admin_password='MyStrongPassword', template_id=1114, auth_obj=ci.auth)
c.set_type(ci.get_package_id('small'))
print(c.commit(url=ci.wcf_baseurl, debug=True))
c.set_ssh_key('your_public_key.pub')
from ArubaCloud.PyArubaAPI import CloudInterface
from ArubaCloud.ReverseDns import ReverseDns
ci = CloudInterface(dc=1)
rdns = ReverseDns.ReverseDns(username='XXXXXX', password='XXXXX', ws_uri=ci.wcf_baseurl)
# get configured reverse dns
print(rdns.get(addresses=['XXX.XXX.XXX.XXX']))
# set a new reverse dns with one or more PTR hosts
#print(rdns.set(address='XXX.XXX.XXX.XXX', host_name=['xxxx.domain.com', 'xxxx2.domain.com']))
# reset a reverse dns
#print(rdns.reset(addresses=['XXX.XXX.XXX.XXX']))
More examples can be found in the examples folder, following the complete list: