Slide 1

Slide 1 text

Crash course in CloudSigma’s Python library

Slide 2

Slide 2 text

• Go to www.cloudsigma.com • Sign up. Step 0: Create an account

Slide 3

Slide 3 text

$ pip install cloudsigma $ wget http://goo.gl/fjdtQL -O ~/.cloudsigma.conf $ chmod 600 ~/.cloudsigma.conf $ vim ~/.cloudsigma.conf Add your credentials and the DC. Step 1: Installation

Slide 4

Slide 4 text

Let’s make it easier to work with bytes $ pip install bitmath Step 1: Installation (cont’d)

Slide 5

Slide 5 text

Import the library >>> import cloudsigma Import bitmath as well >>> import bitmath Access drive and server objects easier >>> drive = cloudsigma.resource.Drive() >>> server = cloudsigma.resource.Server() Step 2: The basics

Slide 6

Slide 6 text

Let’s create a 10GiB drive template >>> disk_template = { 'name': ‘Test Drive', 'size': bitmath.GiB(10).bytes, 'media': 'disk' } And then create it… >>> my_disk = drive.create(disk_template) Step 2: Create a drive API section: https://cloudsigma-docs.readthedocs.org/en/latest/drives.html

Slide 7

Slide 7 text

Let’s create a server template with the drive attached >>> server_template = { 'name': 'Test Server', 'cpu': 2000, 'mem': bitmath.GiB(2).bytes, 'vnc_password': 'test_server', 'drive': [{ 'boot_order': 1, 'dev_channel': '0:0', 'device': 'virtio', 'drive': my_disk['uuid'] }], 'nics': [{ 'ip_v4_conf': { 'conf': 'dhcp', 'ip': None }, 'model': 'virtio', 'vlan': None }] } Step 2: Create a server API section: https://cloudsigma-docs.readthedocs.org/en/latest/servers.html

Slide 8

Slide 8 text

Now create the server >>> test_server = server.create(server_template) Step 2: Create a server (cont’d) API section: https://cloudsigma-docs.readthedocs.org/en/latest/servers.html

Slide 9

Slide 9 text

Starting the server is a breeze >>> server.start(test_server[‘uuid’]) Please note that this server won’t get very far, since we’re booting off of an empty drive. You probably want to clone an existing marketplace drive (next slide) for your OS partition. Step 3: Start the server API section: https://cloudsigma-docs.readthedocs.org/en/latest/servers.html

Slide 10

Slide 10 text

Clone a drive >>> my_clone = drive.clone(uuid {'name': ‘Foobar’}) Resize a the clone to 20GiB >>> my_clone[‘size’] = bitmath.GiB(20).bytes >>> drive.update(my_clone[‘uuid’], my_clone) What’s next?

Slide 11

Slide 11 text

Documentation for the Python library can be found here: https://github.com/cloudsigma/pycloudsigma More examples are available here: https://gist.github.com/vpetersson/26472c0a78e78234bad0 The full API documentation is available here: https://cloudsigma-docs.readthedocs.org/en/latest/ More resources