initial commit

This commit is contained in:
Adam Gandelman 2011-07-13 17:12:43 -07:00
commit a60e6d4913
8 changed files with 133 additions and 0 deletions

1
hooks/install Symbolic link
View File

@ -0,0 +1 @@
swift-storage-node-relations

1
hooks/start Symbolic link
View File

@ -0,0 +1 @@
swift-storage-node-relations

1
hooks/stop Symbolic link
View File

@ -0,0 +1 @@
swift-storage-node-relations

View File

@ -0,0 +1 @@
swift-storage-node-relations

View File

@ -0,0 +1 @@
swift-storage-node-relations

73
hooks/swift-storage-node-common Executable file
View File

@ -0,0 +1,73 @@
#!/bin/bash
set -ue
DEFAULT_ETH=$(ip route | grep default | awk '{ print $5 }')
IP=$(ifconfig $DEFAULT_ETH | grep 'inet addr' | awk '{ print $2 }' | cut -d: -f2)
# TODO: Need to use different addresses for internal swift traffic
# as this the only security measure in place is network isolation
STORAGE_LOCAL_NET_IP=$IP
PACKAGES="swift swift-account swift-container swift-object xfsprogs"
function set_swift_hash {
# TODO: Do this with augeas and put in a utility function for use elsewhere
cat >/etc/swift/swift.conf <<EOF
[swift-hash]
# random unique string that can never change (DO NOT LOSE)
swift_hash_path_suffix = $1
EOF
}
function configure_rsyncd {
cat >/etc/rsyncd.conf <<EOF
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = $STORAGE_LOCAL_NET_IP
[account]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/account.lock
[container]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/container.lock
[object]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/object.lock
EOF
perl -pi -e 's/RSYNC_ENABLE=false/RSYNC_ENABLE=true/' /etc/default/rsync
service rsync start
}
function create_server_conf {
# $1 should be: account, container or object
case $1 in
"account") subconf="replicator auditor reaper" ;;
"object"|"container") subconf="replicator updater auditor" ;;
esac
cat >/etc/swift/$1-server.conf <<EOF
[DEFAULT]
bind_ip = $STORAGE_LOCAL_NET_IP
workers = 2
[pipeline:main]
pipeline = $1-server
[app:$1-server]
use = egg:swift#$1
EOF
for i in $subconf ; do
echo -e "[$1-$i]\n" >>/etc/swift/$1-server.conf
done
}

View File

@ -0,0 +1,43 @@
#!/bin/bash
set -ue
FORMULA_DIR=$(dirname $0)
ARG0=${0##*/}
echo $ENSEMBLE_UNIT_NAME >>/tmp/unit_name
if [[ -e $FORMULA_DIR/swift-storage-node-common ]] ; then
. $FORMULA_DIR/swift-storage-node-common
else
echo "ERROR: Could not load swift-storage-node-common from $FORMULA_DIR"
fi
function install_hook {
apt-get -y install python-software-properties || exit 1
add-apt-repository ppa:swift-core/milestone-proposed || exit 1
apt-get update
for i in $PACKAGES ; do
DEBIAN_FRONTEND=noninteractive apt-get -y install $i
done
[[ ! -d /etc/swift ]] && mkdir /etc/swift
configure_rsyncd
for i in account container object ; do create_server_conf $i ; done
set_swift_hash "TESTINGHASH"
}
function proxy_joined {
relation-set zone=1
relation-set ip=$IP
relation-set device=xvde2
}
function proxy_changed {
URL=`relation-get update_url`
[[ -z $URL ]] && exit 0
}
case $ARG0 in
"install") install_hook ;;
"start"|"stop") exit 0 ;;
"swift-proxy-relation-joined") proxy_joined ;;
"swift-proxy-relation-changed") proxy_changed ;;
esac

12
metadata.yaml Normal file
View File

@ -0,0 +1,12 @@
ensemble: formula
name: swift-storage
revision: 7
summary: "Swift storage node"
description: |
Contains swift-object, swift-container and swift-account servers.
provides:
swift-storage:
interface: swift
requires:
swift-proxy:
interface: swift