File 06_Pass_launch_metadata_as_enviroment_variables.patch of Package openstack-nova-docker
commit 3e7ab5cf01468beb90e927ca86f5aba31e6962a1
Author: Eric Windisch <eric@windisch.us>
Date: Fri Nov 21 13:45:32 2014 -0500
Pass launch metadata as enviroment variables
The launch metadata is provided with 'nova boot' and
serves effectively to pass varibles into an instance. This
runtime key-value pairing seems to map cleanly to environment
variables as used by Docker. Use of environment variables
is highly desired amongst nova-docker users and this seems to
be the cleanest solution to deliver this feature.
Co-Authored-By: Davanum Srinivas <dims@linux.vnet.ibm.com>
Change-Id: I0292bf065191c6a188e39a7d2f2c0a5057ec67f5
diff --git a/novadocker/virt/docker/driver.py b/novadocker/virt/docker/driver.py
index a49fae4..4a467d4 100644
--- a/novadocker/virt/docker/driver.py
+++ b/novadocker/virt/docker/driver.py
@@ -39,6 +39,7 @@ from nova.image import glance
from nova.openstack.common import fileutils
from nova.openstack.common import log
from nova import utils
+from nova import utils as nova_utils
from nova.virt import driver
from nova.virt import firewall
from nova.virt import images
@@ -426,6 +427,9 @@ class DockerDriver(driver.ComputeDriver)
image_meta.get('properties', {}).get('os_command_line')):
args['command'] = image_meta['properties'].get('os_command_line')
+ if 'metadata' in instance:
+ args['environment'] = nova_utils.instance_meta(instance)
+
container_id = self._create_container(instance, image_name, args)
if not container_id:
raise exception.InstanceDeployFailure(