Upgrade to Pro — share decks privately, control downloads, hide ads and more …

DIY: your own PaaS using Python

SysFera
October 17, 2012

DIY: your own PaaS using Python

Talk presented during OSDC.fr 2012 (OpenWorld Forum).
Don't do that, just use an existing PaaS ;)

SysFera

October 17, 2012
Tweet

More Decks by SysFera

Other Decks in Programming

Transcript

  1. PaaS architecture Teh devlopment workflow 1. write code 2. test

    code 3. commit code 4. push code 5. QA test 6. tag release (production)
  2. 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
  3. DNS Server Bind dynamic DNS nsupdate update delete <my_app>.<my_domain> A

    update add <my_app>.<my_domain> 180 A <node_ip>
  4. SCM git gitolite Gitolite ? SSH proxy no real user,

    no shell access fine-grained control access to repository
  5. Applicative stack virtualenv pip WSGI ! virtualenv --no-site-packages <my_app> source

    bin/activate pip -r requirements.txt gunicorn <my_app>:app
  6. 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 <use>@<my_node> update
  7. RLY Thaz all ? Awsome ! can be used with

    command-line (auto-documented !) can be used in Python code Web API !
  8. Web API ! REST CRUD Twisted event-based network engine Easy

    to create web services ! a sample CRUD application
  9. 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 ?
  10. U no machines ? erm ... IaaS is in da

    place Boto fire new cloud instances very eazy
  11. very eazy import boto import boto.ec2 conn = boto.conn_ec2() reservations

    = conn.run_instances(**<dict_of_conf>) conn.terminate_instances(<list_of_ids>) Conclusion