Giter Club home page Giter Club logo

pyarubacloud's Introduction

Code Climate

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.

#Getting Started

Installation

Python Package:

pip install pyarubacloud

Git Version:

git clone https://github.com/Arubacloud/pyArubaCloud.git pyArubaCloud
cd pyArubaCloud
python setup.py install

##Usage In the examples folder you can find some examples on various operations which can be done via API.

###Log in to the service

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:

  • 1 -> DC1 -> Italy
  • 2 -> DC2 -> Italy
  • 3 -> DC3 -> Czech Republic
  • 4 -> DC4 -> France
  • 5 -> DC5 -> Germany
  • 6 -> DC6 -> UK

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.

###Retrieve all templates related to a hypervisor You have the following 4 types of hypervisors to choose from:

  • 1 -> Microsoft Hyper-V - Cloud Pro
  • 2 -> VMWare - Cloud Pro
  • 3 -> Microsoft Hyper-V Low Cost - Cloud Pro
  • 4 -> VMWare - Cloud Smart

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))

Create a new VM

In order to create a VM you have to instantiate the specific object exposed by the ArubaCloud.objects package:

  • ProVmCreator
  • SmartVmCreator

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:

  • Small
  • Medium
  • Large
  • Extra Large

Example of how to create a Pro VM

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: 5 [Hypervisor: VMware (Linux Centos 5.6 - 64bit)]
c = ProVmCreator(name='debian01', admin_password='MyStrongPassword', template_id='5', 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))

Example of how to create a Smart VM

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(size='small')

print(c.commit(url=ci.wcf_baseurl, debug=True))

Example to use ReverseDns

from ArubaCloud.ReverseDns import ReverseDns

ci = CloudInterface(dc=1)
rdns = ReverseDns(username='XXX-XXXX', password='XXXXXXX', ws_uri=ci.wcf_baseurl)

# get configured reverse dns
print(rdns.get())

# set a new reverse dns with one or more PTR hosts
print(rdns.set(address='XXX.XXX.XXX.XXX', host_name=['rhost1', 'rhost2']

# reset a reverse dns
print(rdns.reset(address='XXX.XXX.XXX.XXX')

More examples can be found in the examples folder, following the complete list:

pyarubacloud's People

Contributors

aledesimone avatar alexandernst avatar arubalucalasagni avatar blackms avatar lu-zero avatar mattiascibien avatar mikamakusa avatar szepeviktor avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.