Trying to adhere to python naming convention.

This commit is contained in:
Egon Rijpkema
2018-04-23 15:55:16 +02:00
parent 90a67e531d
commit 94113b8c25
38 changed files with 0 additions and 0 deletions

8
cinder_storage/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# ---> Vim
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~

35
cinder_storage/Dockerfile Normal file
View File

@ -0,0 +1,35 @@
FROM ubuntu:16.04
# install packages
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5EDB1B62EC4926EA
RUN set -x \
&& echo "deb http://ubuntu-cloud.archive.canonical.com/ubuntu xenial-updates/ocata main" > /etc/apt/sources.list.d/ocata.list \
&& apt-get -y update \
&& apt-get -y install ubuntu-cloud-keyring \
&& apt-get -y update \
&& apt-get -y install \
cinder-volume \
mysql-client \
python-mysqldb \
python-openstackclient \
python-oslo.cache \
lvm2 \
python-ceph \
python-rbd \
&& apt-get -y clean
EXPOSE 8776
#file that writes configs
COPY write_conf.sh /etc/write_conf.sh
# add bootstrap script and make it executable
COPY bootstrap.sh /etc/bootstrap.sh
COPY run.sh /etc/run.sh
RUN chown root.root /etc/bootstrap.sh && chmod a+x /etc/bootstrap.sh
RUN chown root.root /etc/run.sh && chmod a+x /etc/run.sh
CMD ["/etc/run.sh"]

41
cinder_storage/README.md Normal file
View File

@ -0,0 +1,41 @@
# How to build
```
docker build . -t hpc/openstack-cinder-storage
```
# Bootstrap
```
docker run --rm
-e "MY_IP={{ ansible_default_ipv4.address }}"
-e "CINDER_HOST={{ hostvars[groups['cinder-storage'][0]]['ansible_default_ipv4']['address'] }}"
-e "CINDER_PASSWORD={{ secrets['CINDER_PASSWORD'] }}"
-e "CINDER_USER=cinder"
-e "KEYSTONE_HOST={{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}"
-e "MYSQL_HOST={{ hostvars[groups['databases'][0]]['ansible_default_ipv4']['address'] }}"
-e "MYSQL_ROOT_PASSWORD={{ secrets['MYSQL_ROOT_PASSWORD'] }}"
-e "OS_PASSWORD={{ secrets['OS_PASSWORD'] }}"
-e "RABBIT_HOST={{ hostvars[groups['rabbitmq'][0]]['ansible_default_ipv4']['address'] }}"
-e "RABBIT_PASSWORD={{ secrets['RABBIT_PASSWORD'] }}"
-e "RABBIT_USER=openstack"
hpc/openstack-cinder /etc/bootstrap.sh
```
# Run an image
```
/usr/bin/docker run \
-e "MY_IP={{ ansible_default_ipv4.address }}"
-e "CINDER_HOST={{ hostvars[groups['cinder-storage'][0]]['ansible_default_ipv4']['address'] }}"
-e "CINDER_PASSWORD={{ secrets['CINDER_PASSWORD'] }}"
-e "CINDER_USER=cinder"
-e "KEYSTONE_HOST={{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}"
-e "MYSQL_HOST={{ hostvars[groups['databases'][0]]['ansible_default_ipv4']['address'] }}"
-e "MYSQL_ROOT_PASSWORD={{ secrets['MYSQL_ROOT_PASSWORD'] }}"
-e "OS_PASSWORD={{ secrets['OS_PASSWORD'] }}"
-e "RABBIT_HOST={{ hostvars[groups['rabbitmq'][0]]['ansible_default_ipv4']['address'] }}"
-e "RABBIT_PASSWORD={{ secrets['RABBIT_PASSWORD'] }}"
-e "RABBIT_USER=openstack"
-p 8776:8776 \
hpc/openstack-cinder-storage
```

View File

@ -0,0 +1,17 @@
#!/bin/bash
# a admin-openrc.sh file
export MYSQL_ROOT_PASSWORD="geheim"
# To create the Identity service credentials
GLANCE_USER_NAME=glance
GLANCE_PASSWORD=geheim
export OS_IDENTITY_API_VERSION=3
export OS_USERNAME=admin
export OS_PASSWORD=geheim
export OS_TENANT_NAME=admin
export OS_AUTH_URL=http://${KEYSTONE_HOST}:35357/v3
export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_NAME=admin
export OS_IMAGE_API_VERSION=2

27
cinder_storage/bootstrap.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
# Create admin-openrc.sh from secrets that are in the environment during bootstrap.
cat << EOF > /root/admin-openrc.sh
#!/bin/bash
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=${OS_PASSWORD}
export OS_AUTH_URL=http://${KEYSTONE_HOST}:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_NAME=admin
export OS_IMAGE_API_VERSION=2
EOF
source /root/admin-openrc.sh
# Write the config files
/etc/write_conf.sh
# create a LVM physical volume and volume group.
# This device should be available tpo the container
#pvcreate /dev/cinder_storage_volume
#vgcreate cinder-volumes /dev/cinder_storage_volume

1887
cinder_storage/lvm.conf Normal file

File diff suppressed because it is too large Load Diff

16
cinder_storage/run.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
# Write the config files
/etc/write_conf.sh
# start cinder processes.
cinder-volume -d &
sleep 5
cinder-volume -d &
# If any process fails, kill the rest.
# This ensures the container stops and systemd will restart it.
wait -n
pkill -P $$

40
cinder_storage/write_conf.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash
#
# Generate config files from environments values.
# These are to be passed to the docker container using -e
cat << EOF > /etc/cinder/cinder.conf
[database]
connection = mysql+pymysql://$CINDER_USER:$CINDER_PASSWORD@$MYSQL_HOST/cinder
[DEFAULT]
auth_strategy = keystone
transport_url = rabbit://$RABBIT_USER:$RABBIT_PASSWORD@$MY_IP
my_ip = $MY_IP
enabled_backends = RBD-backend
glance_api_servers = http://$GLANCE_HOST:9292
[keystone_authtoken]
auth_uri = http://$KEYSTONE_HOST:5000
auth_url = http://$KEYSTONE_HOST:35357
memcached_servers = $MEMCACHED_HOST:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = $CINDER_USER
password = $CINDER_PASSWORD
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
[RBD-backend]
volume_backend_name=RBD-backend
rbd_pool=volumes
rbd_user=volumes
rbd_secret_uuid=d0db6ba7-a0c9-4da6-b0bc-aa7846325333
volume_driver=cinder.volume.drivers.rbd.RBDDriver
rbd_ceph_conf=/etc/ceph/ceph.conf
EOF