├── powerstripflocker ├── __init__.py ├── test │ ├── __init__.py │ └── test_acceptance.py └── adapter.py ├── vagrant-aws ├── keygen.sh ├── bootstrap.sh ├── settings.yml.sample ├── create-pool.sh ├── stage1.sh ├── iptables.sh ├── stage2.sh ├── Vagrantfile ├── build.md ├── push-config.py ├── utils.py ├── README.md └── install.sh ├── requirements.txt ├── .gitmodules ├── resources └── flying_books.jpg ├── .gitignore ├── powerstripflocker.tac ├── Dockerfile ├── quick.sh ├── admin └── run-powerstrip-acceptance-tests ├── vagrant ├── Vagrantfile ├── insecure_private_key ├── README.md └── install.sh ├── setup.py ├── README.md └── LICENSE /powerstripflocker/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /powerstripflocker/test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vagrant-aws/keygen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ssh-keygen -f /root/.ssh/id_rsa -N "" 3 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | twisted==14.0.0 2 | treq==0.2.1 3 | service_identity 4 | pycrypto 5 | pyrsistent 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "flocker"] 2 | path = flocker 3 | url = https://github.com/clusterhq/flocker 4 | -------------------------------------------------------------------------------- /resources/flying_books.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClusterHQ/powerstrip-flocker/HEAD/resources/flying_books.jpg -------------------------------------------------------------------------------- /vagrant-aws/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ -x /vagrant ]; then 4 | cd /vagrant 5 | fi 6 | 7 | #./stage1.sh 8 | #./stage2.sh 9 | ./create-pool.sh 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS generated files # 2 | ###################### 3 | .DS_Store 4 | .DS_Store? 5 | ._* 6 | .Spotlight-V100 7 | .Trashes 8 | Icon? 9 | ehthumbs.db 10 | Thumbs.db 11 | 12 | # Vagrant # 13 | ########### 14 | .vagrant 15 | settings.yml 16 | vagrant-aws/master_address 17 | vagrant-aws/minions 18 | vagrant-aws/my_address 19 | Powerstrip_Flocker_Adapter.egg-info 20 | dist -------------------------------------------------------------------------------- /vagrant-aws/settings.yml.sample: -------------------------------------------------------------------------------- 1 | distribution: "ubuntu" # or "redhat" 2 | remote_server_username: "ubuntu" # user which you log in as 3 | provider: "aws" # or "vagrant" 4 | 5 | # some aws-specific settings 6 | aws_access_key_id: # aws access key 7 | aws_secret_access_key: # aws secret access key 8 | aws_keypair_name: # keypair name as it appears in aws console 9 | private_key_path: # absolute local path to .pem file for private key 10 | -------------------------------------------------------------------------------- /vagrant-aws/create-pool.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | zfs_pool_name="flocker" 4 | 5 | if [[ -b /dev/xvdb ]]; then 6 | echo "Detected EBS environment, setting up real zpool..." 7 | umount /mnt # this is where xvdb is mounted by default 8 | zpool create $zfs_pool_name /dev/xvdb 9 | elif [[ ! -b /dev/sdb ]]; then 10 | echo "Setting up a toy zpool..." 11 | truncate -s 10G /$zfs_pool_name-datafile 12 | zpool create $zfs_pool_name /$zfs_pool_name-datafile 13 | fi 14 | -------------------------------------------------------------------------------- /powerstripflocker.tac: -------------------------------------------------------------------------------- 1 | # Copyright ClusterHQ Limited. See LICENSE file for details. 2 | 3 | from twisted.web import server, resource 4 | from twisted.application import service, internet 5 | 6 | from powerstripflocker.adapter import AdapterResource 7 | 8 | def getAdapter(): 9 | root = resource.Resource() 10 | root.putChild("flocker-adapter", AdapterResource()) 11 | site = server.Site(root) 12 | return site 13 | 14 | application = service.Application("Powerstrip Flocker Adapter") 15 | 16 | adapterServer = internet.TCPServer(80, getAdapter(), interface='0.0.0.0') 17 | adapterServer.setServiceParent(application) 18 | -------------------------------------------------------------------------------- /vagrant-aws/stage1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | export DEBIAN_FRONTEND=noninteractive 4 | 5 | apt-get update 6 | 7 | echo "Installing ZFS from latest git HEAD" 8 | apt-get -y install build-essential gawk alien fakeroot linux-headers-$(uname -r) zlib1g-dev uuid-dev libblkid-dev libselinux-dev parted lsscsi dh-autoreconf linux-crashdump git 9 | 10 | # As of Apr 2 2015, recommended ZoL revisions from Richard Yao: 11 | good_zfs_version="7f3e466" 12 | good_spl_version="6ab0866" 13 | 14 | # Compile and install spl 15 | cd ~/ 16 | git clone https://github.com/zfsonlinux/spl 17 | cd spl 18 | git checkout $good_spl_version 19 | ./autogen.sh 20 | ./configure 21 | make 22 | make deb 23 | sudo dpkg -i *.deb 24 | 25 | # Compile and install zfs 26 | cd ~/ 27 | git clone https://github.com/zfsonlinux/zfs 28 | cd zfs 29 | git checkout $good_zfs_version 30 | ./autogen.sh 31 | ./configure 32 | make 33 | make deb 34 | sudo dpkg -i *.deb 35 | 36 | -------------------------------------------------------------------------------- /vagrant-aws/iptables.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | iptables-start() { 3 | iptables -F 4 | iptables -X 5 | # Setting default filter policy 6 | iptables -P INPUT DROP 7 | 8 | # Allow unlimited traffic on loopback 9 | iptables -A INPUT -i lo -j ACCEPT 10 | 11 | # Allow incoming ssh only 12 | iptables -A INPUT -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT 13 | iptables -A INPUT -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT 14 | iptables -A INPUT -m conntrack -j ACCEPT --ctstate RELATED,ESTABLISHED 15 | } 16 | 17 | iptables-middle() { 18 | local allowserver="$1"; 19 | if [[ -n "$allowserver" ]]; then 20 | iptables -A INPUT -p tcp -s $allowserver --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT 21 | iptables -A INPUT -p tcp -s $allowserver --dport 4524 -m state --state NEW,ESTABLISHED -j ACCEPT 22 | fi 23 | } 24 | iptables-finish() { 25 | # Disallow every other port 26 | iptables -A INPUT -j DROP 27 | } 28 | 29 | iptables-start 30 | for X in `cat /etc/flocker/minions`; do iptables-middle $X; done 31 | iptables-finish 32 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | 3 | # Last build date - this can be updated whenever there are security updates so 4 | # that everything is rebuilt 5 | ENV security_updates_as_of 2014-07-06 6 | 7 | # Install security updates and required packages 8 | RUN apt-get -qy update && \ 9 | apt-get -qy upgrade && \ 10 | apt-get -qy install python-pip && \ 11 | apt-get -qy install python-dev && \ 12 | apt-get -qy install python-pyasn1 && \ 13 | apt-get -qy install libyaml-dev && \ 14 | apt-get -qy install libffi-dev && \ 15 | apt-get -qy install libssl-dev && \ 16 | # Pre-install some requirements to make the next step hopefully faster 17 | pip install twisted==14.0.0 treq==0.2.1 service_identity pycrypto pyrsistent pyyaml==3.10 18 | 19 | ADD powerstripflocker.tac setup.py README.md /app/ 20 | ADD powerstripflocker/* /app/powerstripflocker/ 21 | 22 | WORKDIR /app 23 | 24 | # Install requirements from the project's setup.py 25 | RUN python setup.py install 26 | 27 | CMD ["twistd", "-noy", "powerstripflocker.tac"] 28 | -------------------------------------------------------------------------------- /quick.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash -e 2 | 3 | # First run (do this manually): 4 | # $ vagrant box add \ 5 | # http://build.clusterhq.com/results/vagrant/master/flocker-tutorial.json 6 | # $ admin/run-powerstrip-acceptance-tests \ 7 | # --keep --distribution=fedora-20 powerstripflocker.test.test_acceptance 8 | # This will set up some VMs, which will take a while. 9 | 10 | # Then you can run the following to do fast development cycles (replace 11 | # 'lmarsden' or 'clusterhq' with your own repo here and in test_acceptance.py 12 | # if necessary): 13 | 14 | # Run ./quick.sh --no-build to make it even quicker (if you've only changed the 15 | # acceptance test and not the actual adapter). 16 | 17 | # This should match up with DOCKER_PULL_REPO in powerstripflocker/test/test_acceptance.py 18 | DOCKER_PULL_REPO="lmarsden" 19 | 20 | # Optionally do a docker build and push. 21 | if [ "$1" != "--no-build" ]; then 22 | docker build -t ${DOCKER_PULL_REPO}/powerstrip-flocker . 23 | docker push ${DOCKER_PULL_REPO}/powerstrip-flocker 24 | fi 25 | 26 | # Run the tests. 27 | export FLOCKER_ACCEPTANCE_NODES="172.16.255.240:172.16.255.241" 28 | trial ${2:-powerstripflocker.test.test_acceptance} 29 | -------------------------------------------------------------------------------- /admin/run-powerstrip-acceptance-tests: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright Hybrid Logic Ltd. See LICENSE file for details. 3 | """ 4 | Run some powerstrip acceptance tests. 5 | """ 6 | # hack to get access to flocker module in submodule (rather than a version of 7 | # flocker that happens to be installed locally) 8 | import sys, os 9 | FLOCKER_PATH = os.path.dirname(os.path.realpath(__file__ + "/../")) + "/flocker" 10 | sys.path.insert(0, FLOCKER_PATH) 11 | 12 | # another hack - this time make the tests run faster by avoiding fetching lots 13 | # of docker images. 14 | from flocker.provision import _install 15 | del _install.ACCEPTANCE_IMAGES[:] 16 | 17 | from twisted.python.filepath import FilePath 18 | import sys 19 | 20 | path = BASEPATH = FilePath(sys.argv[0]) 21 | for parent in list(path.parents()) + [FilePath(FLOCKER_PATH)]: 22 | if parent.descendant(['flocker', '__init__.py']).exists(): 23 | TOPLEVEL = parent 24 | sys.path.insert(0, parent.path) 25 | break 26 | else: 27 | raise ImportError("Could not find top-level.") 28 | 29 | if __name__ == '__main__': 30 | from admin.acceptance import main 31 | main(sys.argv[1:] + ["powerstripflocker.test.test_acceptance"], 32 | top_level=TOPLEVEL, base_path=BASEPATH) 33 | -------------------------------------------------------------------------------- /vagrant-aws/stage2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | good_flocker_version="bcc7bb4280629a67b97da7750ca6e513767aad21" 4 | 5 | export DEBIAN_FRONTEND=noninteractive 6 | 7 | if [[ ! -x /vagrant ]]; then 8 | ln -s /root/ubuntu /vagrant 9 | fi 10 | 11 | echo "Cloning flocker..." 12 | cd /opt 13 | git clone https://github.com/clusterhq/flocker 14 | cd flocker 15 | git checkout $good_flocker_version 16 | 17 | apt-get -y install python-setuptools python-dev 18 | 19 | # uhhh.. hack 20 | cd ~/ 21 | wget https://pypi.python.org/packages/source/m/machinist/machinist-0.2.0.tar.gz 22 | tar zxfv machinist-0.2.0.tar.gz 23 | cd machinist-0.2.0 24 | python setup.py install 25 | 26 | # now install flocker 27 | cd /opt/flocker 28 | python setup.py install 29 | 30 | # now install docker 31 | apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 32 | 33 | echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list 34 | apt-get update 35 | apt-get -y install lxc-docker 36 | 37 | sed -i'backup' s/USE_KDUMP=0/USE_KDUMP=1/g /etc/default/kdump-tools 38 | 39 | apt-get -y install supervisor 40 | 41 | docker pull ubuntu:latest 42 | docker pull clusterhq/powerstrip-flocker:latest 43 | docker pull clusterhq/powerstrip:unix-socket 44 | -------------------------------------------------------------------------------- /vagrant/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # This requires Vagrant 1.6.2 or newer (earlier versions can't reliably 5 | # configure the Fedora 20 network stack). 6 | Vagrant.require_version ">= 1.6.2" 7 | 8 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 9 | VAGRANTFILE_API_VERSION = "2" 10 | 11 | ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox' 12 | 13 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 14 | config.vm.box = "vagrant-powerstrip-flocker-demo-pulled-images" 15 | config.vm.box_url = "http://storage.googleapis.com/experiments-clusterhq/powerstrip-flocker-demo/vagrant-powerstrip-flocker-demo.box" 16 | 17 | if Vagrant.has_plugin?("vagrant-cachier") 18 | config.cache.scope = :box 19 | end 20 | 21 | config.vm.define "node1" do |node1| 22 | node1.vm.network :private_network, :ip => "172.16.255.250" 23 | node1.vm.hostname = "node1" 24 | node1.vm.provision "shell", inline: <