Skip to content

Instantly share code, notes, and snippets.

View djoreilly's full-sized avatar

Darragh O'Reilly djoreilly

View GitHub Profile
@djoreilly
djoreilly / devstack_options.md
Last active August 29, 2015 14:03
Misc devstack options

Keystone

Keystone uses PKI tokens by default, but they are very long and make the logs harder to read. Use the shorter UUID tokens instead:

KEYSTONE_TOKEN_FORMAT=UUID

Logging

To log to /opt/stack/logs/screen/

@djoreilly
djoreilly / vagrant.md
Last active August 29, 2015 14:03
Using Vagrant

#Using Vagrant Vagrant does the grunt work of creating VirtualBox VMs.

Install Vagrant

sudo apt-get install vagrant

Create a Vagrant Box

@djoreilly
djoreilly / Vagrantfile
Last active August 29, 2015 14:03
Vagrantfile with extra nets, disks and proxies
# -*- mode: ruby -*-
# vi: set ft=ruby :
# increment this so it is unique
$eth1_ip = "192.168.2.2"
def add_disk(vb, vm_id, port_num, size)
# sata port_num should be unique > 0
# size is in GB
# notes: will only work if the image uses a sata controller.
@djoreilly
djoreilly / fact.yaml
Created March 10, 2015 13:52
howto augment ansible facts
# http://jpmens.net/2012/07/15/ansible-it-s-a-fact/
#$ cat count_users
##!/bin/sh
#COUNT=`who | wc -l`
#cat <<EOF
#{
# "ansible_facts" : {
# "users_logged_in" : $COUNT
@djoreilly
djoreilly / paste.ini
Created March 20, 2013 21:59
simple pastedeploy config
[pipeline:main]
pipeline = auth hello
[app:hello]
paste.app_factory = app_layer:app_factory
[filter:auth]
paste.filter_factory = auth_layer:filter_factory
@djoreilly
djoreilly / app_layer.py
Last active December 15, 2015 05:29
application layer
from webob import Response
from webob.dec import wsgify
@wsgify
def application(request):
return Response('Hello, welcome to paste \n')
def app_factory(global_config, **local_config):
return application
@djoreilly
djoreilly / auth_layer.py
Created March 20, 2013 22:04
webob middleware layer
from webob.dec import wsgify
from webob import exc
@wsgify.middleware
def auth_filter(request, app):
if request.headers.get('X-Auth-Token') != 'open-sesame':
return exc.HTTPForbidden()
return app(request)
def filter_factory(global_config, **local_config):
from paste import httpserver
from paste.deploy import loadapp
wsgi_app = loadapp('config:' + '/etc/example/paste.ini')
httpserver.serve(wsgi_app, host='127.0.0.1', port=8080)
import sys
import urllib2
req = urllib2.Request('http://127.0.0.1:8080')
req.add_header('X-Auth-Token', sys.argv[1])
try:
res = urllib2.urlopen(req)
print res.read()
except urllib2.HTTPError as e:
$ python start_app.py
serving on http://127.0.0.1:8080
$ python do_get.py wrong-token
HTTP Error 403: Forbidden
$ py do_get.py open-sesame
Hello, welcome to paste