Add freezer container

Change-Id: I9f95bac3f74827f0918f174fc0113736b92cbc0c
Partially-implements: bp freezer-container
This commit is contained in:
caowei 2016-11-06 11:11:51 +08:00
parent c12020618c
commit 51663a7c31
8 changed files with 134 additions and 3 deletions

View File

@ -0,0 +1,49 @@
FROM {{ namespace }}/{{ image_prefix }}freezer-base:{{ tag }}
MAINTAINER {{ maintainer }}
{% block freezer_api_header %}{% endblock %}
{% import "macros.j2" as macros with context %}
{% if install_type == 'binary' %}
RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
&& /bin/false
{% elif install_type == 'source' %}
{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %}
{% set freezer_api_packages = [
'mod_wsgi',
'httpd'
] %}
{{ macros.install_packages(freezer_api_packages | customizable("packages")) }}
RUN sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf
{% elif base_distro in ['ubuntu', 'debian'] %}
{% set freezer_api_packages = [
'libapache2-mod-wsgi',
'apache2'
] %}
{{ macros.install_packages(freezer_api_packages | customizable("packages")) }}
RUN echo > /etc/apache2/ports.conf
{% endif %}
ADD freezer-api-archive /freezer-api-source
RUN ln -s freezer-api-source/* freezer-api \
&& /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt /freezer-api \
&& cp -r /freezer-api/etc/freezer/* /etc/freezer/
{% endif %}
COPY extend_start.sh /usr/local/bin/kolla_freezer_extend_start
RUN chmod 755 /usr/local/bin/kolla_freezer_extend_start
{% block freezer_api_footer %}{% endblock %}
{% block footer %}{% endblock %}
{{ include_footer }}
USER freezer

View File

@ -0,0 +1,18 @@
#!/bin/bash
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
freezer-manage db update
exit 0
fi
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
rm -rf /var/run/apache2/*
APACHE_DIR="apache2"
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
APACHE_DIR="httpd"
fi

View File

@ -0,0 +1,34 @@
FROM {{ namespace }}/{{ image_prefix }}openstack-base:{{ tag }}
MAINTAINER {{ maintainer }}
{% block freezer_base_header %}{% endblock %}
{% import "macros.j2" as macros with context %}
{% if install_type == 'binary' %}
RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
&& /bin/false
{% elif install_type == 'source' %}
ADD freezer-base-archive /freezer-base-source
RUN ln -s freezer-base-source/* freezer \
&& useradd --user-group freezer \
&& mkdir -p /etc/freezer /home/freezer \
&& chown -R freezer: /etc/freezer /home/freezer \
&& /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt /freezer \
&& cp -r /freezer/etc/* /etc/freezer
{% endif %}
COPY freezer_sudoers /etc/sudoers.d/kolla_freezer_sudoers
COPY extend_start.sh /usr/local/bin/kolla_extend_start
RUN usermod -a -G kolla freezer \
&& chmod 750 /etc/sudoers.d \
&& chmod 640 /etc/sudoers.d/kolla_freezer_sudoers \
&& touch /usr/local/bin/kolla_freezer_extend_start \
&& chmod 755 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_freezer_extend_start
{% block freezer_base_footer %}{% endblock %}

View File

@ -0,0 +1,15 @@
#!/bin/bash
# Create log dir for freezer logs
LOG_DIR="/var/log/kolla/freezer"
if [[ ! -d "${LOG_DIR}" ]]; then
mkdir -p ${LOG_DIR}
fi
if [[ $(stat -c %U:%G ${LOG_DIR}) != "freezer:kolla" ]]; then
chown freezer:kolla ${LOG_DIR}
fi
if [[ $(stat -c %a ${LOG_DIR}) != "755" ]]; then
chmod 755 ${LOG_DIR}
fi
. /usr/local/bin/kolla_freezer_extend_start

View File

@ -0,0 +1 @@
%kolla ALL=(root) NOPASSWD: /usr/bin/chown -R freezer\: /var/lib/freezer/, /bin/chown -R freezer\: /var/lib/freezer/

View File

@ -190,6 +190,14 @@ SOURCES = {
'type': 'url',
'location': ('http://tarballs.openstack.org/designate/'
'designate-master.tar.gz')},
'freezer-api': {
'type': 'url',
'location': ('http://tarballs.openstack.org/freezer-api/'
'freezer-api-master.tar.gz')},
'freezer-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/freezer/'
'freezer-master.tar.gz')},
'glance-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/glance/'

View File

@ -0,0 +1,3 @@
---
features:
- Add freezer Dockerfile

View File

@ -75,7 +75,8 @@ class BuildTestCentosBinary(BuildTest, base.BaseTestCase):
"watcher-base",
"congress-base",
"bifrost-base",
"cloudkitty-base"]
"cloudkitty-base",
"freezer-base"]
def setUp(self):
super(BuildTestCentosBinary, self).setUp()
@ -103,7 +104,8 @@ class BuildTestUbuntuBinary(BuildTest, base.BaseTestCase):
"watcher-base",
"congress-base",
"bifrost-base",
"cloudkitty-base"]
"cloudkitty-base",
"freezer-base"]
def setUp(self):
super(BuildTestUbuntuBinary, self).setUp()
@ -131,7 +133,8 @@ class BuildTestOracleLinuxBinary(BuildTest, base.BaseTestCase):
"watcher-base",
"congress-base",
"bifrost-base",
"cloudkitty-base"]
"cloudkitty-base",
"freezer-base"]
def setUp(self):
super(BuildTestOracleLinuxBinary, self).setUp()