First version of glance

Change-Id: Ia03316620f9980b37554634be84aae2c76b65771
This commit is contained in:
Artur Zarzycki 2016-06-14 15:05:43 +02:00 committed by Proskurin Kirill
parent a6fa0b0edd
commit abfa4d10d8
12 changed files with 242 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.tox

View File

@ -0,0 +1,10 @@
FROM {{ namespace }}/glance-base:{{ tag }}
MAINTAINER {{ maintainer }}
COPY glance-service-registry.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/glance-service-registry.sh
#mysql-client only for provisioning need to be removed later
RUN apt-get install -y --no-install-recommends \
mysql-client \
&& apt-get clean

View File

@ -0,0 +1,22 @@
#!/bin/bash -ex
KEYSTONE_ADDRESS=${1}
KEYSTONE_ADMIN_PORT=${2}
export OS_USERNAME=${3}
export OS_PASSWORD=${4}
export OS_PROJECT_NAME=${5}
export OS_DOMAIN_NAME=${6}
GLANCE_USER=${7}
GLANCE_PASSWORD=${8}
export OS_AUTH_URL=http://${KEYSTONE_ADDRESS}:${KEYSTONE_ADMIN_PORT}/v3
export OS_IDENTITY_API_VERSION=3
openstack user create --domain default --password ${GLANCE_PASSWORD} ${GLANCE_USER}
openstack role add --project ${OS_PROJECT_NAME} --user ${GLANCE_USER} admin
openstack service create --name glance --description "OpenStack Image service" image
openstack endpoint create --region RegionOne image public http://glance-api:9292
openstack endpoint create --region RegionOne image internal http://glance-api:9292
openstack endpoint create --region RegionOne image admin http://glance-api:9292

View File

@ -0,0 +1,18 @@
FROM {{ namespace }}/openstack-base:{{ tag }}
MAINTAINER {{ maintainer }}
RUN curl -o glance-{{ branch }}.tar.gz http://tarballs.openstack.org/glance/glance-{{ branch }}.tar.gz \
&& tar -zxvf glance-{{ branch }}.tar.gz
RUN mv glance*/ glance-{{ branch }}/ \
&& ln -s glance-{{ branch }} /glance \
&& useradd --user-group glance \
&& /var/lib/microservices/venv/bin/pip --no-cache-dir install --upgrade -c /glance/requirements.txt /glance \
&& mkdir -p /var/lib/glance /etc/glance \
&& chown -R glance: /var/lib/glance \
&& cp -r /glance/etc/* /etc/glance
RUN apt-get -y install --no-install-recommends \
python-rbd \
python-rados \
&& apt-get clean

View File

@ -0,0 +1,2 @@
FROM {{ namespace }}/glance-base:{{ tag }}
MAINTAINER {{ maintainer }}

View File

@ -0,0 +1,14 @@
configs:
glance_api_port: 9292
glance_registry_port: 9191
glance_db_username: glance
glance_db_password: password
glance_db_name: glance
glance_user: glance
glance_password: password
glance_memcache_secret_key: secret_key
glance_debug: false

View File

@ -0,0 +1,43 @@
[DEFAULT]
debug = {{ glance_debug }}
use_syslog = False
use_stderr = True
use_forwarded_for = True
bind_host = {{ network_topology["private"]["address"] }}
bind_port = {{ glance_api_port }}
registry_host = glance-registry
cinder_catalog_info = volume:cinder:internalURL
[database]
connection = mysql+pymysql://{{ glance_db_username }}:{{ glance_db_password }}@mariadb/{{ glance_db_name }}
max_retries = -1
[keystone_authtoken]
auth_uri = http://keystone:{{ keystone_public_port }}
auth_url = http://keystone:{{ keystone_admin_port }}
auth_type = password
project_domain_id = default
user_domain_id = default
project_name = {{ openstack_project_name }}
username = {{ glance_user }}
password = {{ glance_password }}
memcache_security_strategy = ENCRYPT
memcache_secret_key = {{ glance_memcache_secret_key }}
memcached_servers = memcached:{{ memcached_port }}
[paste_deploy]
flavor = keystone
[glance_store]
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
[oslo_messaging_notifications]
driver = noop

View File

@ -0,0 +1,41 @@
[DEFAULT]
debug = {{ glance_debug }}
use_syslog = False
use_stderr = True
use_forwarded_for = True
bind_host = {{ network_topology["private"]["address"] }}
bind_port = {{ glance_registry_port }}
registry_host = glance-registry
cinder_catalog_info = volume:cinder:internalURL
[database]
connection = mysql+pymysql://{{ glance_db_username }}:{{ glance_db_password }}@mariadb/{{ glance_db_name }}
max_retries = -1
[keystone_authtoken]
auth_uri = http://keystone:{{ keystone_public_port }}
auth_url = http://keystone:{{ keystone_admin_port }}
auth_type = password
project_domain_id = default
user_domain_id = default
project_name = service
username = {{ glance_user }}
password = {{ glance_password }}
memcache_security_strategy = ENCRYPT
memcache_secret_key = {{ glance_memcache_secret_key }}
memcached_servers = memcached:{{ memcached_port }}
[paste_deploy]
flavor = keystone
[glance_store]
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
[oslo_messaging_notifications]
driver = noop

43
service/glance-api.yaml Normal file
View File

@ -0,0 +1,43 @@
service:
name: glance-api
ports:
- glance_api_port
# TODO(sreshetniak): add probes
container:
node-selector:
openstack-controller: "true"
probes:
readiness: "true"
liveness: "true"
pre:
- name: glance-db-create
dependencies:
- mariadb
type: single
command:
mysql -u root -p{{ db_root_password }} -h mariadb -e "create database {{ glance_db_name }};
grant all privileges on {{ glance_db_name }}.* to '{{ glance_db_username }}'@'%' identified by '{{ glance_db_password }}';"
- name: glance-db-sync
files:
- glance-api
dependencies:
- glance-db-create
type: single
command: glance-manage db_sync
- name: glance-service-registry
dependencies:
- keystone
type: single
command:
glance-service-registry.sh keystone {{ keystone_admin_port }} {{ openstack_user_name }} {{ openstack_user_password }}
{{ openstack_project_name }} default {{ glance_user }} {{ glance_password }}
daemon:
name: glance-api
files:
- glance-api
command: glance-api
files:
glance-api:
path: /etc/glance/glance-api.conf
content: glance-api.conf.j2

View File

@ -0,0 +1,23 @@
service:
name: glance-registry
ports:
- glance_registry_port
# TODO(sreshetniak): add probes
container:
node-selector:
openstack-controller: "true"
probes:
readiness: "true"
liveness: "true"
daemon:
name: glance-registry
files:
- glance-registry-conf
dependencies:
- glance-api
command: glance-registry
files:
glance-registry-conf:
path: /etc/glance/glance-registry.conf
content: glance-registry.conf.j2

View File

@ -0,0 +1,9 @@
#!/bin/bash
### Temp docker syntax checker script. Doesnt really check something...
set -e
for file in $(find . -name 'Dockerfile.j2')
do
fgrep -q FROM $file || echo 'Miss/ wrong FROM section in file' $file
fgrep -q MAINTAINER $file || echo 'Miss/ wrong MAINTAINER section in file' $file
done

16
tox.ini Normal file
View File

@ -0,0 +1,16 @@
[tox]
minversion = 1.6
envlist = py34,py27,pypy,pep8
skipsdist = True
[testenv:linters]
commands =
{toxinidir}/tools/run-check-docker-syntax.sh
[testenv:pep8]
commands =
{toxinidir}/tools/run-check-docker-syntax.sh
[testenv:bashate]
commands =
{toxinidir}/tools/run-check-docker-syntax.sh