From 7db6a70e712889a664019dbc61f18d33ff0de97b Mon Sep 17 00:00:00 2001 From: Xian Chaobo Date: Fri, 13 Nov 2015 10:37:12 +0800 Subject: [PATCH] Add a global var to maintain swarm version Currently Swarm version in magnum are appear in multiple files. It's not easy for us to maintain. This patch add a global var to store swarm image and its version. so that we can update swarm image more easy. Change-Id: I3063ff4350f8e2f3c96b0bc3700ed509edad206b Closes-Bug: #1515567 --- .../swarm/fragments/write-swarm-agent-service.yaml | 4 ++-- .../swarm/fragments/write-swarm-master-service.sh | 4 ++-- magnum/templates/swarm/swarm.yaml | 7 +++++++ magnum/templates/swarm/swarmnode.yaml | 6 ++++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/magnum/templates/swarm/fragments/write-swarm-agent-service.yaml b/magnum/templates/swarm/fragments/write-swarm-agent-service.yaml index 63300cd395..b5ffb5023c 100644 --- a/magnum/templates/swarm/fragments/write-swarm-agent-service.yaml +++ b/magnum/templates/swarm/fragments/write-swarm-agent-service.yaml @@ -15,8 +15,8 @@ write_files: TimeoutStartSec=0 ExecStartPre=-/usr/bin/docker kill swarm-agent ExecStartPre=-/usr/bin/docker rm swarm-agent - ExecStartPre=-/usr/bin/docker pull swarm:1.0.0 - ExecStart=/usr/bin/docker run -e http_proxy=$HTTP_PROXY -e https_proxy=$HTTPS_PROXY -e no_proxy=$NO_PROXY --name swarm-agent swarm:1.0.0 join --addr $NODE_IP:2375 etcd://$SWARM_MASTER_IP:2379/v2/keys/swarm/ + ExecStartPre=-/usr/bin/docker pull swarm:$SWARM_VERSION + ExecStart=/usr/bin/docker run -e http_proxy=$HTTP_PROXY -e https_proxy=$HTTPS_PROXY -e no_proxy=$NO_PROXY --name swarm-agent swarm:$SWARM_VERSION join --addr $NODE_IP:2375 etcd://$SWARM_MASTER_IP:2379/v2/keys/swarm/ ExecStop=/usr/bin/docker stop swarm-agent ExecStartPost=/usr/bin/curl -sf -X PUT -H 'Content-Type: application/json' \ --data-binary '{"Status": "SUCCESS", "Reason": "Setup complete", "Data": "OK", "UniqueId": "00000"}' \ diff --git a/magnum/templates/swarm/fragments/write-swarm-master-service.sh b/magnum/templates/swarm/fragments/write-swarm-master-service.sh index 2423ad2a02..f1693270e9 100644 --- a/magnum/templates/swarm/fragments/write-swarm-master-service.sh +++ b/magnum/templates/swarm/fragments/write-swarm-master-service.sh @@ -11,14 +11,14 @@ OnFailure=swarm-manager-failure.service TimeoutStartSec=0 ExecStartPre=-/usr/bin/docker kill swarm-manager ExecStartPre=-/usr/bin/docker rm swarm-manager -ExecStartPre=-/usr/bin/docker pull swarm:1.0.0 +ExecStartPre=-/usr/bin/docker pull swarm:$SWARM_VERSION ExecStart=/usr/bin/docker run --name swarm-manager \\ -v /etc/docker:/etc/docker \\ -p 2376:2375 \\ -e http_proxy=$HTTP_PROXY \\ -e https_proxy=$HTTPS_PROXY \\ -e no_proxy=$NO_PROXY \\ - swarm:1.0.0 \\ + swarm:$SWARM_VERSION \\ manage -H tcp://0.0.0.0:2375 \\ END_SERVICE_TOP diff --git a/magnum/templates/swarm/swarm.yaml b/magnum/templates/swarm/swarm.yaml index b408d84f9a..6b05eac2c1 100644 --- a/magnum/templates/swarm/swarm.yaml +++ b/magnum/templates/swarm/swarm.yaml @@ -116,6 +116,11 @@ parameters: constraints: - allowed_values: ["true", "false"] + swarm_version: + type: string + description: version of swarm used for swarm cluster + default: 1.0.0 + resources: cloud_init_wait_handle: @@ -330,6 +335,7 @@ resources: "$HTTP_PROXY": {get_param: http_proxy} "$HTTPS_PROXY": {get_param: https_proxy} "$NO_PROXY": {get_param: no_proxy} + "$SWARM_VERSION": {get_param: swarm_version} write_swarm_master_service: type: "OS::Heat::SoftwareConfig" @@ -346,6 +352,7 @@ resources: "$HTTPS_PROXY": {get_param: https_proxy} "$NO_PROXY": {get_param: no_proxy} "$TLS_DISABLED": {get_param: tls_disabled} + "$SWARM_VERSION": {get_param: swarm_version} enable_services: type: "OS::Heat::SoftwareConfig" diff --git a/magnum/templates/swarm/swarmnode.yaml b/magnum/templates/swarm/swarmnode.yaml index bd8885e6d1..d2a97f4add 100644 --- a/magnum/templates/swarm/swarmnode.yaml +++ b/magnum/templates/swarm/swarmnode.yaml @@ -84,6 +84,11 @@ parameters: type: boolean description: whether or not to disable TLS + swarm_version: + type: string + description: version of swarm used for swarm cluster + default: 1.0.0 + resources: node_cloud_init_wait_handle: @@ -218,6 +223,7 @@ resources: "$HTTP_PROXY": {get_param: http_proxy} "$HTTPS_PROXY": {get_param: https_proxy} "$NO_PROXY": {get_param: no_proxy} + "$SWARM_VERSION": {get_param: swarm_version} enable_services: type: "OS::Heat::SoftwareConfig"