join relations and ring creation
This commit is contained in:
parent
4f38e93217
commit
aa4b9d04c6
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -ue
|
set -u
|
||||||
# For openssl cert generation
|
# For openssl cert generation
|
||||||
COUNTRY="US"
|
COUNTRY="US"
|
||||||
STATE="OR"
|
STATE="OR"
|
||||||
|
@ -13,10 +13,17 @@ IP=$(ifconfig $DEFAULT_ETH | grep 'inet addr' | awk '{ print $2 }' | cut -d: -f
|
||||||
# as this the only security measure in place is network isolation
|
# as this the only security measure in place is network isolation
|
||||||
PROXY_LOCAL_NET_IP=$IP
|
PROXY_LOCAL_NET_IP=$IP
|
||||||
|
|
||||||
PACKAGES="swift swift-proxy memcached"
|
# Use apache2 to distribute ring config until there is support
|
||||||
|
# for file xfer in ensemble
|
||||||
|
PACKAGES="swift swift-proxy memcached apache2"
|
||||||
|
WWW_DIR="/var/www/swift-rings"
|
||||||
SWIFT_HASH_FILE="/var/lib/ensemble/swift-hash-path.conf"
|
SWIFT_HASH_FILE="/var/lib/ensemble/swift-hash-path.conf"
|
||||||
|
|
||||||
|
# Ring configuration
|
||||||
|
PARTITION_POWER="18"
|
||||||
|
REPLICAS="3"
|
||||||
|
MIN_HOURS="24"
|
||||||
|
|
||||||
# generate the swift hash to be used for salting URLs of objects.
|
# generate the swift hash to be used for salting URLs of objects.
|
||||||
# TODO: its important this is never lost, find out some way of getting
|
# TODO: its important this is never lost, find out some way of getting
|
||||||
# it off the server and into a sys admins INBOX?
|
# it off the server and into a sys admins INBOX?
|
||||||
|
@ -62,3 +69,29 @@ use = egg:swift#memcache
|
||||||
memcache_servers = $PROXY_LOCAL_NET_IP:11211
|
memcache_servers = $PROXY_LOCAL_NET_IP:11211
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initialize_ring {
|
||||||
|
# $1 is ring name.
|
||||||
|
# $PARTITION_POWER, $REPLICAS, $MIN_HOURS from config above
|
||||||
|
swift-ring-builder /etc/swift/$1.builder \
|
||||||
|
create $PARTITION_POWER $REPLICAS $MIN_HOURS
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_to_ring {
|
||||||
|
# $1=ringname, $2=ZONE, $3=IP, $4=PORT, $5=device
|
||||||
|
# swift-ring-builder returns 1 for success, 2 for zero.
|
||||||
|
# TODO: File bug for return codes
|
||||||
|
echo "Updating $1 ring. Adding $3:$4, zone $2, device $5"
|
||||||
|
swift-ring-builder /etc/swift/$1.builder add \
|
||||||
|
z$2-$3:$4/$5 100
|
||||||
|
[[ $? == "1" ]] && return 0
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function rebalance_ring {
|
||||||
|
# This exists to make up for non-standard return codes
|
||||||
|
echo "Rebalancing ring $1"
|
||||||
|
swift-ring-builder /etc/swift/$i.builder rebalance
|
||||||
|
[[ $? == "1" ]] && return 0
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
swift-proxy-relations
|
|
@ -0,0 +1 @@
|
||||||
|
swift-proxy-relations
|
|
@ -1,17 +1,22 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -ue
|
set -u
|
||||||
FORMULA_DIR=$(dirname $0)
|
FORMULA_DIR=$(dirname $0)
|
||||||
ARG0=${0##*/}
|
ARG0=${0##*/}
|
||||||
|
|
||||||
if [[ -e $FORMULA_DIR/swift-proxy-common ]] ; then
|
if [[ -e $FORMULA_DIR/swift-proxy-common ]] ; then
|
||||||
. $FORMULA_DIR/swift-proxy-common
|
. $FORMULA_DIR/swift-proxy-common
|
||||||
else
|
else
|
||||||
echo "ERROR: Could nto load swift-proxy-common from $FORMULA_DIR"
|
echo "ERROR: Could not load swift-proxy-common from $FORMULA_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function install_hook {
|
function install_hook {
|
||||||
apt-get -y install $PACKAGES || exit 1
|
apt-get -y install python-software-properties || exit 1
|
||||||
[[ ! -d /etc/swift ]] && mkdir /etc/swift
|
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
|
||||||
|
mkdir -p /etc/swift
|
||||||
set_swift_hash || exit 1
|
set_swift_hash || exit 1
|
||||||
create_proxy_conf
|
create_proxy_conf
|
||||||
if [[ ! -e /etc/swift/cert.crt ]] ; then
|
if [[ ! -e /etc/swift/cert.crt ]] ; then
|
||||||
|
@ -22,10 +27,53 @@ function install_hook {
|
||||||
fi
|
fi
|
||||||
perl -pi -e "s/-l 127.0.0.1/-l $PROXY_LOCAL_NET_IP/" /etc/memcached.conf
|
perl -pi -e "s/-l 127.0.0.1/-l $PROXY_LOCAL_NET_IP/" /etc/memcached.conf
|
||||||
service memcached restart
|
service memcached restart
|
||||||
|
echo "swift-proxy-node - install: Initializing rings"
|
||||||
|
for i in account container object ; do initialize_ring $i ; done
|
||||||
|
mkdir -p $WWW_DIR
|
||||||
|
}
|
||||||
|
|
||||||
|
function proxy_joined {
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function proxy_changed {
|
||||||
|
ZONE=`relation-get zone`
|
||||||
|
IP=`relation-get ip`
|
||||||
|
DEVICE=`relation-get device`
|
||||||
|
[[ -z $ZONE ]] || [[ -z $IP ]] || [[ -z $DEVICE ]] && \
|
||||||
|
echo "ZONE|IP|DEVICE not set. Peer not ready? Exit 0 and wait." && exit 0
|
||||||
|
|
||||||
|
if [[ $ZONE -gt $REPLICAS ]] ; then
|
||||||
|
echo "ERROR: Peer $ENSEMBLE_REMOTE_UNIT attempting to join a non-existent zone!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
PORT=6000
|
||||||
|
RINGS="object container account"
|
||||||
|
|
||||||
|
# reinitialize rings if there are any missing
|
||||||
|
ring_missing=0
|
||||||
|
for i in $RINGS ; do
|
||||||
|
[[ ! -e /etc/swift/$i.builder ]] && ring_missing=1
|
||||||
|
done
|
||||||
|
[[ $ring_missing != "0" ]] && initialize_rings
|
||||||
|
|
||||||
|
for i in $RINGS ; do
|
||||||
|
add_to_ring $i $ZONE $IP $PORT $DEVICE || exit 1
|
||||||
|
done
|
||||||
|
for i in $RINGS ; do
|
||||||
|
rebalance_ring $i || exit 1
|
||||||
|
done
|
||||||
|
stamp=`date +%Y%M%d-%H%M%S`
|
||||||
|
export_dir="$WWW_DIR/$stamp"
|
||||||
|
mkdir $export_dir
|
||||||
|
echo "Copying rings to $export_dir for client consumption"
|
||||||
|
relation-set update_url="http://$IP/$stamp"
|
||||||
}
|
}
|
||||||
|
|
||||||
case $ARG0 in
|
case $ARG0 in
|
||||||
"install") install_hook ;;
|
"install") install_hook ;;
|
||||||
"start"|"stop") exit 0 ;;
|
"start"|"stop") exit 0 ;;
|
||||||
|
"swift-proxy-relation-joined") proxy_joined ;;
|
||||||
|
"swift-proxy-relation-changed") proxy_changed ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
ensemble: formula
|
ensemble: formula
|
||||||
name: swift-proxy
|
name: swift-proxy
|
||||||
revision: 7
|
revision: 23
|
||||||
summary: "Swift proxy node"
|
summary: "Swift proxy node"
|
||||||
description: |
|
description: |
|
||||||
Swift is a distributed virtual object store. This formula deploys the proxy node
|
Swift is a distributed virtual object store. This formula deploys the proxy node
|
||||||
to be related to storage nodes.
|
to be related to storage nodes.
|
||||||
provides:
|
provides:
|
||||||
proxy-node:
|
swift-proxy:
|
||||||
interface: swift
|
interface: swift
|
||||||
requires:
|
requires:
|
||||||
storage-node:
|
swift-storage:
|
||||||
interface: swift
|
interface: swift
|
||||||
|
|
Loading…
Reference in New Issue