Slide 1

Slide 1 text

Do It Yourself: Your Own PaaS in Python whoami

Slide 2

Slide 2 text

Wuts teh PaaS ting ?

Slide 3

Slide 3 text

Dis ar teh Clown Computin U sign ? U haz providerz ?

Slide 4

Slide 4 text

Y mak ur pwn PaaS ? self-hosting ! better understanding of PaaS platforms It's fun !

Slide 5

Slide 5 text

PaaS architecture Teh devlopment workflow 1. write code 2. test code 3. commit code 4. push code 5. QA test 6. tag release (production)

Slide 6

Slide 6 text

Y U LIE ? Points 2. & 5. from previous slides are obvious lies because it looks good and it pleases managers ! Wat do u ned ? machines applicative stack DNS server orchestration framework SCM API

Slide 7

Slide 7 text

Git Ur Toolbox RDY !

Slide 8

Slide 8 text

DNS Server Bind dynamic DNS nsupdate update delete . A update add . 180 A

Slide 9

Slide 9 text

SCM git gitolite Gitolite ? SSH proxy no real user, no shell access fine-grained control access to repository

Slide 10

Slide 10 text

Applicative stack virtualenv pip WSGI ! virtualenv --no-site-packages source bin/activate pip -r requirements.txt gunicorn :app

Slide 11

Slide 11 text

Orchestration install/remove/update packages edit configuration files upload/download files start/stop/monitor services etc ... many choices CFEngine/Puppet/Chef/Salt/Ansible etc. Fabric !

Slide 12

Slide 12 text

Fabric Wut Wut ? Python module command-line tool: fab SSH-based Principels tasks hosts

Slide 13

Slide 13 text

I CAN HAZ ? from fabric.api import * def update(): """ update machine using yum """ with settings(hide('running', 'stdout', 'stderr', 'warnings'), warn_only=True): sudo("yum -y update") fab -H @ update

Slide 14

Slide 14 text

RLY Thaz all ? Awsome ! can be used with command-line (auto-documented !) can be used in Python code Web API !

Slide 15

Slide 15 text

Web API ! REST CRUD Twisted event-based network engine Easy to create web services ! a sample CRUD application

Slide 16

Slide 16 text

a sample CRUD application import sys from twisted.internet import reactor, server, resource, http class Persona(resource.Resource): def __init__(): pass def render_GET(self, request): # request contains all parameters # you crunch it and return res return res def render_PUT(self, request): pass a sample CRUD application def render_DELETE(self, request): pass def render_POST(self, request): pass def render_UPDATE(self, request): pass if __name__ == "__main___"": root = resource.Resource() persona = Persona() root.putChild('persona', persona) reactor.listenTCP(80, server.Site(root) U no machines ?

Slide 17

Slide 17 text

U no machines ? erm ... IaaS is in da place Boto fire new cloud instances very eazy

Slide 18

Slide 18 text

very eazy import boto import boto.ec2 conn = boto.conn_ec2() reservations = conn.run_instances(**) conn.terminate_instances() Conclusion