From f038321fa0c66c5b4769f328b80dd77b931280eb Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Fri, 27 Feb 2015 18:59:51 +0000 Subject: Add openstack.configure --- openstack.configure | 76 +++++++++++++++++++++++++++++++++++ openstack/etc/swift/proxy-server.conf | 4 +- 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 openstack.configure diff --git a/openstack.configure b/openstack.configure new file mode 100644 index 00000000..b50d2946 --- /dev/null +++ b/openstack.configure @@ -0,0 +1,76 @@ +#!/bin/bash +# +# Copyright © 2015 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +set +e +set -u + +# COMPUTE_HOSTS, OBJECT_STORAGE_HOSTS and BLOCK_STORAGE_HOSTS +# are a list of 'name,ip' strings +# +# CONTROLLER HOST is a single 'name,ip' string +# +# TODO: ipv6 + +octet='\(\(2[0-5]\?[0-5]\?\)\|\(1[0-9]\?[0-9]\?\)\|\([0-9]\)\)' + +valid_ip() { + echo -n "$1" | grep -xq $octet.$octet.$octet.$octet +} + +valid_hostname() { + echo -n "$1" | grep -xq '[a-zA-Z0-9.-]\+' +} + +append_host() { + # Validate ip and hostname and append to /etc/hosts + + ip="$1" + hostname="$2" + + if ! valid_ip "$ip"; then echo "ip, $ip" is malformed >&2; exit 1; fi + if ! valid_hostname "$hostname"; then echo "hostname, $hostname" is malformed >&2; exit 1; fi + + echo "$ip" "$hostname" >> /etc/hosts +} + +add_hosts() { + # Creates a host to ip mapping for a set of ips and adds them to /etc/hosts + # Each ip is assigned a hostname based on a prefix + # starting from prefix1.$STACK_ID up to prefixN.$STACK_ID + # + # STACK_ID is a unique suffix used to prevent hostname collisions + + if [[ -z "$1" || -z "$2" ]]; then return; fi + + ips="$1" + prefix="$2" + + i=0 + for ip in $ips + do + ((i += 1)) + append_host "$ip" "$prefix$i.$STACK_ID" + done +} + +echo >> /etc/hosts # insert line break + +append_host "$CONTROLLER_NODE_IP" "controller.$STACK_ID" + +add_hosts "$COMPUTE_NODE_IPS" "compute" +add_hosts "$OBJECT_STORAGE_NODE_IPS" "object" +add_hosts "$BLOCK_STORAGE_NODE_IPS" "block" diff --git a/openstack/etc/swift/proxy-server.conf b/openstack/etc/swift/proxy-server.conf index 7399175d..c2c1285a 100644 --- a/openstack/etc/swift/proxy-server.conf +++ b/openstack/etc/swift/proxy-server.conf @@ -4,7 +4,7 @@ bind_port = 8080 # bind_timeout = 30 # backlog = 4096 swift_dir = /etc/swift -user = swift +user = ##SWIFT_ADMIN_USER## # Enables exposing configuration settings via HTTP GET /info. # expose_info = true @@ -274,7 +274,7 @@ paste.filter_factory = keystonemiddleware.auth_token:filter_factory # auth_uri = http://keystonehost:5000/ #auth_uri = http://controller:5000/v2.0 auth_uri = ##KEYSTONE_INTERNAL_URL## -#identity_uri = http://controller:35357 +identity_uri = http://controller:35357 admin_tenant_name = service admin_user = ##SWIFT_ADMIN_USER## admin_password = ##SWIFT_ADMIN_PASSWORD## -- cgit v1.2.1