From 1182e060cb721db124e825e2447d0a27b9946bc9 Mon Sep 17 00:00:00 2001
From: Daneyon Hansen <danehans@cisco.com>
Date: Tue, 24 Mar 2015 18:29:30 +0000
Subject: [PATCH] Extends Nova Metadata Service Parameterization and
 Composition

Previously, nova enabled_apis was hard coded and metdata_host
was using PUBLIC_IP param instead of exposing an individual
param.

Extending these params and creating a separate compose yml that
includes compute/libvirt/network/api is required to support
nova network multi_host.

Additional details can be found here:

http://docs.openstack.org/admin-guide-cloud/content/section_metadata-service.html

Change-Id: I5d417a0ee460f8ad9b2982fe83d63ab57013918e
---
 compose/nova-api-compute-network.yml | 59 ++++++++++++++++++++++++++++
 docker/nova-base/config-nova.sh      |  6 ++-
 docs/integration-guide.md            |  2 +
 tools/genenv                         |  4 ++
 4 files changed, 69 insertions(+), 2 deletions(-)
 create mode 100644 compose/nova-api-compute-network.yml

diff --git a/compose/nova-api-compute-network.yml b/compose/nova-api-compute-network.yml
new file mode 100644
index 0000000000..8e0c4c08f8
--- /dev/null
+++ b/compose/nova-api-compute-network.yml
@@ -0,0 +1,59 @@
+computedata:
+   image: kollaglue/centos-rdo-nova-compute-data
+   name: computedata
+
+libvirt:
+   image: kollaglue/centos-rdo-nova-libvirt
+   name: libvirt
+   net: host
+   pid: host
+   privileged: true
+   restart: always
+   env_file:
+    - openstack.env
+   volumes:
+    - /run:/run
+    - /sys/fs/cgroup:/sys/fs/cgroup
+   volumes_from:
+    - computedata
+
+novanetwork:
+   image: kollaglue/centos-rdo-nova-network
+   name: nova-network
+   net: host
+   privileged: true
+   restart: always
+   env_file:
+    - openstack.env
+   volumes:
+    - /run:/run
+    - /sys/fs/cgroup:/sys/fs/cgroup
+   volumes_from:
+    - computedata
+
+# Unfortunately nova api needs to be privileged as it wants to run
+# a firewall command.
+# nova-metadata api is required in multi_host nova network mode.
+# http://docs.openstack.org/admin-guide-cloud/content/section_metadata-service.html
+novaapi:
+  image: kollaglue/centos-rdo-nova-api:latest
+  name: nova-api
+  privileged: True
+  net: "host"
+  restart: always
+  env_file:
+   - openstack.env
+
+novacompute:
+   image: kollaglue/centos-rdo-nova-compute
+   name: nova-compute
+   net: host
+   privileged: true
+   restart: always
+   env_file:
+    - openstack.env
+   volumes:
+    - /run:/run
+    - /sys/fs/cgroup:/sys/fs/cgroup
+   volumes_from:
+    - computedata
diff --git a/docker/nova-base/config-nova.sh b/docker/nova-base/config-nova.sh
index e756a21ffb..0764964d58 100755
--- a/docker/nova-base/config-nova.sh
+++ b/docker/nova-base/config-nova.sh
@@ -12,6 +12,8 @@
 : ${NETWORK_MANAGER:=nova}
 : ${FLAT_NETWORK:=eth1}
 : ${PUBLIC_NETWORK:=eth0}
+: ${ENABLED_APIS:=ec2,osapi_compute,metadata}
+: ${METADATA_HOST:=$PUBLIC_IP}
 
 check_required_vars KEYSTONE_ADMIN_TOKEN NOVA_DB_PASSWORD \
                     RABBITMQ_SERVICE_HOST GLANCE_API_SERVICE_HOST \
@@ -30,10 +32,11 @@ crudini --set $cfg DEFAULT rabbit_password "${RABBIT_PASSWORD}"
 crudini --set $cfg DEFAULT rabbit_virtual_host /
 crudini --set $cfg DEFAULT rabbit_ha_queues False
 crudini --set $cfg DEFAULT rpc_backend nova.openstack.common.rpc.impl_kombu
-crudini --set $cfg DEFAULT enabled_apis ec2,osapi_compute,metadata
+crudini --set $cfg DEFAULT enabled_apis ${ENABLED_APIS}
 crudini --set $cfg DEFAULT ec2_listen 0.0.0.0
 crudini --set $cfg DEFAULT osapi_compute_listen 0.0.0.0
 crudini --set $cfg DEFAULT osapi_compute_workers 8
+crudini --set $cfg DEFAULT metadata_host ${METADATA_HOST}
 crudini --set $cfg DEFAULT metadata_listen 0.0.0.0
 crudini --set $cfg DEFAULT metadata_workers 8
 crudini --set $cfg DEFAULT service_down_time 60
@@ -43,7 +46,6 @@ crudini --set $cfg DEFAULT use_forwarded_for False
 crudini --set $cfg DEFAULT novncproxy_host 0.0.0.0
 crudini --set $cfg DEFAULT novncproxy_port 6080
 crudini --set $cfg DEFAULT glance_api_servers ${GLANCE_API_SERVICE_HOST}:9292
-crudini --set $cfg DEFAULT metadata_host ${PUBLIC_IP}
 crudini --set $cfg DEFAULT cpu_allocation_ratio 16.0
 crudini --set $cfg DEFAULT ram_allocation_ratio 1.5
 crudini --set $cfg DEFAULT scheduler_default_filters RetryFilter,AvailabilityZoneFilter,RamFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,CoreFilter
diff --git a/docs/integration-guide.md b/docs/integration-guide.md
index 8c828a60b2..3d7952ff08 100644
--- a/docs/integration-guide.md
+++ b/docs/integration-guide.md
@@ -62,6 +62,8 @@ all containers.  This allows a simple method of ensuring every type of node
     MARIADB_SERVICE_HOST=<IP> - The IP Address where Mariadb is running
     NETWORK_MANAGER=<nova|neutron> - Use Nova or Neutron networking
     NOVA_API_SERVICE_HOST=<IP> - The IP Address where the Nova API Service is hosted
+    METADATA_HOST=<IP> - The IP address of the Nova Metadata service
+    ENABLED_APIS=<ec2,osapi_compute,metadata> - Enabled Nova API services.
     NOVA_DB_NAME=<nova> - The name of the nova entry in the database
     NOVA_DB_PASSWORD=<password> - The password used to access nova
     NOVA_DB_USER=<nova> - The name of the nova DB password
diff --git a/tools/genenv b/tools/genenv
index c13ddf02b9..01bdbe61a3 100755
--- a/tools/genenv
+++ b/tools/genenv
@@ -64,6 +64,8 @@ NOVA_EC2_SERVICE_HOST=$HOST_IP
 NOVA_PUBLIC_INTERFACE=$MY_DEV
 NOVA_FLAT_INTERFACE=eth1
 CONFIG_NETWORK=True
+ENABLED_APIS=ec2,osapi_compute,metadata
+METADATA_HOST=$HOST_IP
 
 # Heat
 HEAT_DB_NAME=heat
@@ -103,6 +105,8 @@ MARIADB_SERVICE_HOST=$HOST_IP
 MARIADB_ROOT_PASSWORD=$MARIADB_ROOT_PASSWORD
 NETWORK_MANAGER=nova
 NOVA_API_SERVICE_HOST=$NOVA_API_SERVICE_HOST
+ENABLED_APIS=$ENABLED_APIS
+METADATA_HOST=$METADATA_HOST
 NOVA_DB_NAME=$NOVA_DB_NAME
 NOVA_DB_PASSWORD=$NOVA_DB_PASSWORD
 NOVA_DB_USER=$NOVA_DB_USER
-- 
GitLab