#!/bin/bash set -ue CHARM="swift-storage" HOOKS_DIR="$CHARM_DIR/hooks" CONF_DIR="/etc/swift" if [[ -e "$HOOKS_DIR/lib/openstack-common" ]] ; then . $HOOKS_DIR/lib/openstack-common else juju-log "ERROR: Couldn't load $HOOKS_DIR/lib/openstack-common." && exit 1 fi 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 gdisk" OPENSTACK_ORIGIN="$(config-get openstack-origin)" src=$(get_os_codename_install_source "$OPENSTACK_ORIGIN") # Install python-swiftclient for Folsom and beyond. if dpkg --compare-versions $(get_os_version_codename "$src") gt \ $(get_os_version_codename "essex") ; then PACKAGES="$PACKAGES python-swiftclient" fi function set_swift_hash { # TODO: Do this with augeas and put in a utility function for use elsewhere cat >/etc/swift/swift.conf </etc/rsyncd.conf </etc/swift/$1-server.conf <>/etc/swift/$1-server.conf done } function determine_block_devs { juju-log "determine_block_devs: $@" local devices=$(config-get block-device) if [ "$devices" = "guess" ]; then # This should be more smart devices=$(awk '($4 ~ /^(sd[a-z]|vd[a-z]|cciss\/c[0-9]d[0-9])$/) && ($4 != "sda") && ($4 != "vda") && ($4 != "cciss/c0d0") {print $4}' >/etc/fstab fi mkdir -p /srv/node/$nodename mount $dev /srv/node/$nodename done chown -R swift:swift /srv/node } function do_openstack_upgrade { # update openstack components to those provided by a new installation source # it is assumed the calling hook has confirmed that the upgrade is sane. local rel="$1" shift local packages=$@ # Backup the config directory. local stamp=$(date +"%Y%m%d%M%S") tar -pcf /var/lib/juju/$CHARM-backup-$stamp.tar $CONF_DIR configure_install_source "$rel" apt-get update DEBIAN_FRONTEND=noninteractive apt-get \ --option Dpkg::Options::=--force-confnew -y \ install --no-install-recommends $packages swift-init all restart || true }