aboutsummaryrefslogtreecommitdiff
path: root/docker/swift/swift-base
diff options
context:
space:
mode:
authorSam Yaple <sam@yaple.net>2015-08-28 12:16:53 +0000
committerSam Yaple <sam@yaple.net>2015-08-28 13:33:50 +0000
commitcbd42ca6e90cca2ff4b84f5e4e46224e6455e8b2 (patch)
tree2e4256b6b7b8339da11b1d17250378596e61605b /docker/swift/swift-base
parent3b5380ade021c9884551f427441cbfc0122eb0f0 (diff)
downloadkolla-cbd42ca6e90cca2ff4b84f5e4e46224e6455e8b2.tar.gz
kolla-cbd42ca6e90cca2ff4b84f5e4e46224e6455e8b2.zip
Move docker_templates to docker dir
Updated build.py to reflect this change. Deprecate --template option and make it a noop. Change-Id: I7cd98d1ee684a4c64984a49597159868152683b2 Partially-Implements: blueprint remove-docker-dir
Diffstat (limited to 'docker/swift/swift-base')
-rw-r--r--docker/swift/swift-base/Dockerfile.j229
-rw-r--r--docker/swift/swift-base/build-swift-ring.py93
-rwxr-xr-xdocker/swift/swift-base/config-swift.sh3
3 files changed, 125 insertions, 0 deletions
diff --git a/docker/swift/swift-base/Dockerfile.j2 b/docker/swift/swift-base/Dockerfile.j2
new file mode 100644
index 000000000..7102916f1
--- /dev/null
+++ b/docker/swift/swift-base/Dockerfile.j2
@@ -0,0 +1,29 @@
+FROM {{ namespace }}/{{ base_distro }}-{{ install_type }}-base:{{ tag }}
+MAINTAINER Kolla Project (https://launchpad.net.kolla)
+
+{% if install_type == 'binary' %}
+ {% if base_distro in ['centos', 'fedora', 'oraclelinux'] %}
+
+RUN yum -y install openstack-swift && yum clean all
+
+ {% elif base_distro in ['ubuntu', 'debian'] %}
+
+RUN echo '{{ install_type}} not yet available for {{ base_distro }}' \
+ && /bin/false
+
+ {% endif %}
+
+{% elif install_type == 'source' %}
+
+ADD swift.tar /
+RUN ln -s /swift-* swift \
+ && useradd --user-group swift \
+ && pip --no-cache-dir install /swift \
+ && mkdir -p /etc/swift /var/log/swift /home/swift \
+ && cp -r /swift/etc/* /etc/swift/ \
+ && chown -R swift: /etc/swift /var/log/swift /home/swift
+
+{% endif %}
+
+COPY config-swift.sh build-swift-ring.py /opt/kolla/
+RUN mkdir /opt/swift
diff --git a/docker/swift/swift-base/build-swift-ring.py b/docker/swift/swift-base/build-swift-ring.py
new file mode 100644
index 000000000..d7386392d
--- /dev/null
+++ b/docker/swift/swift-base/build-swift-ring.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+
+# Copyright 2015 Paul Bourke
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+This script is a simple wrapper used to create and rebalance Swift ring files.
+"""
+
+import argparse
+import subprocess
+import sys
+
+
+def setup_args():
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-f", "--ring-file",
+ required=True,
+ help="Path to ring file")
+ parser.add_argument("-p", "--part-power",
+ required=True,
+ help="Part power")
+ parser.add_argument("-r", "--num-replicas",
+ required=True,
+ help="Number of replicas")
+ parser.add_argument("-m", "--min-part-hours",
+ required=True,
+ help="Min part hours")
+ parser.add_argument("-H", "--hosts",
+ required=True,
+ help="Hosts in the ring, comma delimited")
+ parser.add_argument("-w", "--weights",
+ required=True,
+ help="Weight of each host, comma delimited")
+ parser.add_argument("-d", "--devices",
+ required=True,
+ help="Device on each host, comma delimited")
+ parser.add_argument("-z", "--zones",
+ required=True,
+ help="Zone of each host, comma delimited")
+ return parser.parse_args()
+
+
+def run_cmd(cmd):
+ print(' '.join(cmd))
+ subprocess.call(cmd)
+
+
+def run(args):
+ hosts = args.hosts.split(',')
+ weights = args.weights.split(',')
+ zones = args.zones.split(',')
+ devices = args.devices.split(',')
+ if not (len(hosts) == len(weights) == len(zones) == len(devices)):
+ print('Error: an equal amount of hosts, devices, weights, '
+ 'and zones are required')
+ sys.exit(1)
+
+ run_cmd(['/usr/bin/swift-ring-builder',
+ args.ring_file,
+ 'create',
+ args.part_power,
+ args.num_replicas,
+ args.min_part_hours])
+
+ for i in xrange(len(hosts)):
+ run_cmd(['/usr/bin/swift-ring-builder',
+ args.ring_file,
+ 'add',
+ 'z{}-{}/{}'.format(zones[i], hosts[i], devices[i]),
+ weights[i]])
+
+ run_cmd(['/usr/bin/swift-ring-builder', args.ring_file, 'rebalance'])
+
+
+def main():
+ args = setup_args()
+ run(args)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/docker/swift/swift-base/config-swift.sh b/docker/swift/swift-base/config-swift.sh
new file mode 100755
index 000000000..b101b4e69
--- /dev/null
+++ b/docker/swift/swift-base/config-swift.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+chown -R swift: /srv/node