Use deployment name rather than id for compose project

Latest docker-compose only recreates containers whose
configurationhas changed since they were created[1].
This patch  uses sd 'name' rather than 'id' for the
project name that helps in recreating containers with
the same name after an update. Also changes
docker-compose version to 1.4.0.

[1] https://github.com/docker/compose/releases/tag/1.4.0

Change-Id: Ia9b8621c8785b55551a0660fed0148b15ab4f20c
This commit is contained in:
Rabi Mishra 2015-08-18 10:29:49 +05:30 committed by Thomas Herve
parent 31ce16226e
commit 4d789c4b75
5 changed files with 8 additions and 8 deletions

View File

@ -12,6 +12,6 @@ elif [ -f /etc/redhat-release ]; then
systemctl enable docker.service
fi
pip install -U dpath docker-compose
pip install -U dpath docker-compose==1.4.0
install -D -g root -o root -m 0755 ${SCRIPTDIR}/hook-docker-compose.py /var/lib/heat-config/hooks/docker-compose

View File

@ -62,7 +62,7 @@ def main(argv=sys.argv):
input_values = dict((i['name'], i['value']) for i in c['inputs'])
proj = os.path.join(WORKING_DIR, c.get('id'))
proj = os.path.join(WORKING_DIR, c.get('name'))
prepare_dir(proj)
stdout, stderr = {}, {}

View File

@ -64,7 +64,7 @@ def main(argv=sys.argv):
def cleanup_stale_projects(configs):
def deployments(configs):
for c in configs:
yield c['id']
yield c['name']
def compose_projects(compose_dir):
for proj in os.listdir(compose_dir):
@ -104,7 +104,7 @@ def write_compose_config(c):
yaml_config = yaml.safe_dump(compose_conf, default_flow_style=False)
else:
yaml_config = compose_conf
proj_dir = os.path.join(DOCKER_COMPOSE_DIR, c['id'])
proj_dir = os.path.join(DOCKER_COMPOSE_DIR, c['name'])
prepare_dir(proj_dir)
fn = os.path.join(proj_dir, 'docker-compose.yml')
with os.fdopen(os.open(fn, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f:

View File

@ -27,7 +27,7 @@ class HeatConfigDockerComposeORCTest(common.RunScriptTest):
data = [
{
"id": "abcdef001",
"name": "abcdef001",
"group": "docker-compose",
"inputs": {},
"config": {
@ -46,7 +46,7 @@ class HeatConfigDockerComposeORCTest(common.RunScriptTest):
}
},
{
"id": "abcdef002",
"name": "abcdef002",
"group": "docker-compose",
"inputs": {},
"config": {

View File

@ -21,7 +21,7 @@ from tests.software_config import common
class HookDockerComposeTest(common.RunScriptTest):
data = {
"id": "abcdef001",
"name": "abcdef001",
"group": "docker-compose",
"inputs": [
{
@ -50,7 +50,7 @@ class HookDockerComposeTest(common.RunScriptTest):
}
data_without_input = {
"id": "abcdef001",
"name": "abcdef001",
"group": "docker-compose",
"inputs": [],
"config": {