Trying to adhere to python naming convention.
This commit is contained in:
32
nova_service/Dockerfile
Normal file
32
nova_service/Dockerfile
Normal file
@ -0,0 +1,32 @@
|
||||
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 \
|
||||
mysql-client \
|
||||
python-mysqldb \
|
||||
python-openstackclient \
|
||||
python-oslo.cache \
|
||||
nova-api \
|
||||
nova-conductor \
|
||||
nova-consoleauth \
|
||||
nova-novncproxy \
|
||||
nova-scheduler \
|
||||
nova-placement-api \
|
||||
&& apt-get -y clean
|
||||
|
||||
EXPOSE 8774
|
||||
EXPOSE 8778
|
||||
|
||||
# add bootstrap script and make it executable
|
||||
COPY bootstrap.sh /etc/bootstrap.sh
|
||||
COPY run.sh /etc/run.sh
|
||||
COPY write_conf.sh /etc/write_conf.sh
|
||||
|
||||
CMD ["/etc/run.sh"]
|
24
nova_service/README.md
Normal file
24
nova_service/README.md
Normal file
@ -0,0 +1,24 @@
|
||||
# ubuntu 16.04 openstack ocata nova controler node
|
||||
|
||||
# How to build the docker image.
|
||||
```
|
||||
docker build . -t="hpc/openstack-nova-service"
|
||||
```
|
||||
|
||||
# How to bootstrap the service.
|
||||
Before we can take the container into service we need accounts in keystone.
|
||||
We also need an initial database. Both of these tasks are performed by the bootstrap script.
|
||||
```
|
||||
docker run --rm --it --add-host="controller:<keystone_ip>" hpc/novacontroler /etc/bootstrap.sh
|
||||
```
|
||||
|
||||
# How to run
|
||||
```
|
||||
docker run --rm --add-host="controller:<keystone_ip>" --privileged -p 8774:8774 -p 8778:8778 hpc/novacontroler /etc/run.sh
|
||||
```
|
||||
|
||||
Where keystone_ip is the ip of the docker host where our keystone service is running.
|
||||
|
||||
# Notes
|
||||
This image is designed to be deployed from the [hpc-cloud repo](https://git.webhosting.rug.nl/HPC/hpc-cloud)
|
||||
The -p option is added to the run command to make the container accessible from (containers on ) other hosts than the container host.
|
116
nova_service/bootstrap.sh
Executable file
116
nova_service/bootstrap.sh
Executable file
@ -0,0 +1,116 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This script sets up the openstack users and regions..
|
||||
# as well as the database for the nova controller.
|
||||
# This guide was used:
|
||||
# https://docs.openstack.org/ocata/install-guide-ubuntu/nova-controller-install.
|
||||
|
||||
# write the configuration files with values from the environment.
|
||||
/etc/write_conf.sh
|
||||
|
||||
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
|
||||
|
||||
# create database for nova
|
||||
mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -h "$MYSQL_HOST" << EOF
|
||||
|
||||
DROP DATABASE IF EXISTS nova;
|
||||
DROP DATABASE IF EXISTS nova_compute; -- db for nova compute service
|
||||
DROP DATABASE IF EXISTS nova_api;
|
||||
DROP DATABASE IF EXISTS nova_cell0;
|
||||
CREATE DATABASE nova;
|
||||
CREATE DATABASE nova_compute;
|
||||
CREATE DATABASE nova_api;
|
||||
CREATE DATABASE nova_cell0;
|
||||
|
||||
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' \
|
||||
IDENTIFIED BY "${NOVA_PASSWORD}";
|
||||
|
||||
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' \
|
||||
IDENTIFIED BY "${NOVA_PASSWORD}";
|
||||
|
||||
GRANT ALL PRIVILEGES ON nova_compute.* TO 'nova_compute'@'localhost' \
|
||||
IDENTIFIED BY "${NOVA_PASSWORD}";
|
||||
|
||||
GRANT ALL PRIVILEGES ON nova_compute.* TO 'nova_compute'@'%' \
|
||||
IDENTIFIED BY "${NOVA_PASSWORD}";
|
||||
|
||||
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' \
|
||||
IDENTIFIED BY "${NOVA_PASSWORD}";
|
||||
|
||||
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' \
|
||||
IDENTIFIED BY "${NOVA_PASSWORD}";
|
||||
|
||||
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' \
|
||||
IDENTIFIED BY "${NOVA_PASSWORD}";
|
||||
|
||||
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' \
|
||||
IDENTIFIED BY "${NOVA_PASSWORD}";
|
||||
|
||||
EOF
|
||||
|
||||
openstack user create nova --domain default --password "$NOVA_PASSWORD"
|
||||
openstack role add --project service --user nova admin
|
||||
openstack service create --name nova --description "OpenStack Compute" compute
|
||||
|
||||
# compute endpoints
|
||||
openstack endpoint create --region RegionOne \
|
||||
compute public http://"$MY_IP":8774/v2.1
|
||||
|
||||
openstack endpoint create --region RegionOne \
|
||||
compute internal http://"$MY_IP":8774/v2.1
|
||||
|
||||
openstack endpoint create --region RegionOne \
|
||||
compute admin http://"$MY_IP":8774/v2.1
|
||||
|
||||
openstack user create --domain default --password "$NOVA_PLACEMENT_PASSWORD" placement
|
||||
openstack role add --project service --user placement admin
|
||||
|
||||
openstack service create --name placement --description "Placement API" placement
|
||||
|
||||
# placement endpoints
|
||||
openstack endpoint create --region RegionOne placement public http://"$MY_IP":8778
|
||||
openstack endpoint create --region RegionOne placement internal http://"$MY_IP":8778
|
||||
openstack endpoint create --region RegionOne placement admin http://"$MY_IP":8778
|
||||
|
||||
#Populate the nova-api database
|
||||
nova-manage api_db sync
|
||||
|
||||
# Register the cell0 database:
|
||||
nova-manage cell_v2 map_cell0
|
||||
|
||||
# Create the cel1 cell
|
||||
nova-manage cell_v2 create_cell --name=cell1 --verbose
|
||||
|
||||
# sync the database
|
||||
nova-manage db sync
|
||||
|
||||
e nova_api;
|
||||
|
||||
# Prevent crashes when nova api server tries to insert None in config_drive
|
||||
mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -h "$MYSQL_HOST" << EOF
|
||||
|
||||
alter table nova_api.build_requests drop constraint CONSTRAINT_1;
|
||||
|
||||
EOF
|
||||
|
||||
# https://bugs.launchpad.net/packstack/+bug/1673305
|
||||
# discover compute hosts.
|
||||
nova-manage cell_v2 discover_hosts
|
||||
|
||||
# Verify nova cell0 and cell1 are registered correctly:
|
||||
nova-manage cell_v2 list_cells
|
23
nova_service/run.sh
Executable file
23
nova_service/run.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
# start nova service
|
||||
|
||||
# write the configuration files with values from the environment.
|
||||
/etc/write_conf.sh
|
||||
|
||||
nova-api -v -d &
|
||||
sleep 3
|
||||
nova-consoleauth -v -d &
|
||||
sleep 3
|
||||
nova-scheduler -v -d &
|
||||
sleep 3
|
||||
nova-conductor -v -d &
|
||||
sleep 3
|
||||
nova-novncproxy -v -d &
|
||||
# start the placement api
|
||||
apachectl -DFOREGROUND &
|
||||
|
||||
# If any process fails, kill the rest.
|
||||
# This insures the container stops and systemd will restart it.
|
||||
|
||||
wait -n
|
||||
pkill -P $$
|
75
nova_service/write_conf.sh
Executable file
75
nova_service/write_conf.sh
Executable file
@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Generate config files from environments values.
|
||||
# These are to be passed to the docker container using -e
|
||||
|
||||
cat << EOF > /etc/nova/nova.conf
|
||||
|
||||
[api_database]
|
||||
connection = mysql+pymysql://$NOVA_USER:$NOVA_PASSWORD@mariadb/nova_api
|
||||
|
||||
[database]
|
||||
connection = mysql+pymysql://$NOVA_USER:$NOVA_PASSWORD@mariadb/nova
|
||||
|
||||
[DEFAULT]
|
||||
use_neutron = True
|
||||
my_ip = $MY_IP
|
||||
transport_url = rabbit://$RABBIT_USER:$RABBIT_PASSWORD@$MY_IP
|
||||
scheduler_default_filters = AllHostsFilter
|
||||
allow_migrate_to_same_host = True
|
||||
allow_resize_to_same_host = True
|
||||
firewall_driver = nova.virt.firewall.NoopFirewallDriver
|
||||
enabled_apis=osapi_compute,metadata
|
||||
|
||||
[neutron]
|
||||
url = http://$NEUTRON_CONTROLLER_HOST:9696
|
||||
auth_url = http://$KEYSTONE_HOST:35357
|
||||
auth_type = password
|
||||
project_domain_name = Default
|
||||
user_domain_name = Default
|
||||
region_name = RegionOne
|
||||
project_name = service
|
||||
username = $NEUTRON_USER
|
||||
password = $NEUTRON_PASSWORD
|
||||
service_metadata_proxy = True
|
||||
metadata_proxy_shared_secret = $METADATA_SECRET
|
||||
|
||||
[api]
|
||||
auth_strategy = keystone
|
||||
|
||||
[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 = $NOVA_USER
|
||||
password = $NOVA_PASSWORD
|
||||
|
||||
[vnc]
|
||||
enabled = true
|
||||
vncserver_listen = $MY_IP
|
||||
vncserver_proxyclient_address = $MY_IP
|
||||
|
||||
[glance]
|
||||
api_servers = http://$GLANCE_CONTROLLER_HOST:9292
|
||||
|
||||
[oslo_concurrency]
|
||||
lock_path = /var/lib/nova/tmp
|
||||
|
||||
[placement]
|
||||
os_region_name = RegionOne
|
||||
project_domain_name = Default
|
||||
project_name = service
|
||||
auth_type = password
|
||||
user_domain_name = Default
|
||||
auth_url = http://$KEYSTONE_HOST:35357/v3
|
||||
username = $NOVA_PLACEMENT_USER
|
||||
password = $NOVA_PLACEMENT_PASSWORD
|
||||
|
||||
[cinder]
|
||||
os_region_name = RegionOne
|
||||
|
||||
EOF
|
Reference in New Issue
Block a user