From 185e929a3998a4a82726db8519c3a757363c2f16 Mon Sep 17 00:00:00 2001 From: Bonczidai Levente Date: Wed, 1 Jul 2015 13:56:58 +0300 Subject: [PATCH] add start_swarm_manager use case Signed-off-by: Bonczidai Levente --- .../docker/containers/get_all_containers.sl | 7 +- .../docker/swarm/start_swarm_manager.sl | 95 +++++++++++++ .../swarm/start_swarm_manager.inputs.yaml | 19 +++ .../docker/swarm/test_start_swarm_manager.sl | 125 ++++++++++++++++++ 4 files changed, 240 insertions(+), 6 deletions(-) create mode 100644 content/io/cloudslang/docker/swarm/start_swarm_manager.sl create mode 100644 test/io/cloudslang/docker/swarm/start_swarm_manager.inputs.yaml create mode 100644 test/io/cloudslang/docker/swarm/test_start_swarm_manager.sl diff --git a/content/io/cloudslang/docker/containers/get_all_containers.sl b/content/io/cloudslang/docker/containers/get_all_containers.sl index 9c8c73542d..e63dd5ac90 100644 --- a/content/io/cloudslang/docker/containers/get_all_containers.sl +++ b/content/io/cloudslang/docker/containers/get_all_containers.sl @@ -89,12 +89,7 @@ flow: - agentForwarding: required: false publish: - - container_list: returnResult.replace("\n"," ").replace("CONTAINER","") - - returnCode - navigate: - SUCCESS: SUCCESS - FAILURE: FAILURE - FAIL_VALIDATE_SSH: FAILURE + - container_list: returnResult.replace("\n"," ").strip() outputs: - container_list diff --git a/content/io/cloudslang/docker/swarm/start_swarm_manager.sl b/content/io/cloudslang/docker/swarm/start_swarm_manager.sl new file mode 100644 index 0000000000..bdf9eb1c5b --- /dev/null +++ b/content/io/cloudslang/docker/swarm/start_swarm_manager.sl @@ -0,0 +1,95 @@ +# (c) Copyright 2014 Hewlett-Packard Development Company, L.P. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License v2.0 which accompany this distribution. +# +# The Apache License is available at +# http://www.apache.org/licenses/LICENSE-2.0 +# +######################################################################################################## +# Starts the Swarm manager. +# +# Inputs: +# - swarm_port - port of the host used by the Swarm manager +# - cluster_id - ID of the Swarm cluster +# - swarm_image - optional - Docker image the Swarm agent container is created from - Default: swarm (latest) +# - host - Docker machine host +# - port - optional - SSH port +# - username - Docker machine username +# - password - optional - Docker machine password +# - private_key_file - optional - path to private key file +# - character_set - optional - character encoding used for input stream encoding from target machine - Valid: SJIS, EUC-JP, UTF-8 +# - pty - optional - whether to use PTY - Valid: true, false +# - timeout - optional - time in milliseconds to wait for the command to complete +# - close_session - optional - if false SSH session will be cached for future calls during the life of the flow, +# - if true the SSH session used will be closed; +# - Valid: true, false +# - agent_forwarding - optional - whether to forward the user authentication agent +# Outputs: +# - manager_container_ID - ID of the created manager container +######################################################################################################## + +namespace: io.cloudslang.docker.swarm + +imports: + containers: io.cloudslang.docker.containers + +flow: + name: start_swarm_manager + inputs: + - swarm_port + - cluster_id + - swarm_image: + default: "'swarm'" + - host + - port: + required: false + - username + - password: + required: false + - private_key_file: + required: false + - character_set: + required: false + - pty: + required: false + - timeout: + required: false + - close_session: + required: false + - agent_forwarding: + required: false + + workflow: + - run_manager_container: + do: + containers.run_container: + - container_params: > + '-p ' + swarm_port + ':2375' + - container_command: > + 'manage token://' + cluster_id + - image_name: swarm_image + - host + - port: + required: false + - username + - password: + required: false + - private_key_file: + required: false + - characterSet: + default: character_set + required: false + - pty: + required: false + - timeout: + required: false + - closeSession: + default: close_session + required: false + - agentForwarding: + default: agent_forwarding + required: false + publish: + - manager_container_ID: container_ID + outputs: + - manager_container_ID diff --git a/test/io/cloudslang/docker/swarm/start_swarm_manager.inputs.yaml b/test/io/cloudslang/docker/swarm/start_swarm_manager.inputs.yaml new file mode 100644 index 0000000000..0047427142 --- /dev/null +++ b/test/io/cloudslang/docker/swarm/start_swarm_manager.inputs.yaml @@ -0,0 +1,19 @@ +# (c) Copyright 2014 Hewlett-Packard Development Company, L.P. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License v2.0 which accompany this distribution. +# +# The Apache License is available at +# http://www.apache.org/licenses/LICENSE-2.0 +# +######################################################################################################## +test_start_swarm_manager_success: + testSuites: [swarm_local] + description: Tests SUCCESS case - this test needs to be run on the local machine by activating the test suite and supplying the inputs + testFlowPath: io.cloudslang.docker.swarm.test_start_swarm_manager + inputs: + - swarm_port: "2375" + - cluster_id: 3572e1a3ad805fca3f80949af011fad2 + - host: 111.111.111.111 + - username: core + - private_key_file: c:/.../id_rsa + result: SUCCESS diff --git a/test/io/cloudslang/docker/swarm/test_start_swarm_manager.sl b/test/io/cloudslang/docker/swarm/test_start_swarm_manager.sl new file mode 100644 index 0000000000..25ed3ca85c --- /dev/null +++ b/test/io/cloudslang/docker/swarm/test_start_swarm_manager.sl @@ -0,0 +1,125 @@ +# (c) Copyright 2014 Hewlett-Packard Development Company, L.P. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License v2.0 which accompany this distribution. +# +# The Apache License is available at +# http://www.apache.org/licenses/LICENSE-2.0 +# +#################################################### + +namespace: io.cloudslang.docker.swarm + +imports: + maintenance: io.cloudslang.docker.maintenance + swarm: io.cloudslang.docker.swarm + containers: io.cloudslang.docker.containers + strings: io.cloudslang.base.strings + +flow: + name: test_start_swarm_manager + inputs: + - swarm_port + - cluster_id + - host + - port: + required: false + - username + - password: + required: false + - private_key_file: + required: false + - timeout: + required: false + + workflow: + - pre_clear_machine: + do: + maintenance.clear_docker_host: + - docker_host: host + - docker_username: username + - docker_password: + default: password + required: false + - private_key_file: + required: false + - timeout: + required: false + - port: + required: false + navigate: + SUCCESS: start_swarm_manager + FAILURE: PRE_CLEAR_MACHINE_PROBLEM + + - start_swarm_manager: + do: + swarm.start_swarm_manager: + - swarm_port + - cluster_id + - host + - port: + required: false + - username + - password: + required: false + - private_key_file: + required: false + - timeout: + required: false + publish: + - expected_container_id: manager_container_ID + navigate: + SUCCESS: get_running_container_ids + FAILURE: FAILURE + + - get_running_container_ids: + do: + containers.get_all_containers: + - host + - port: + required: false + - username + - password: + required: false + - private_key_file: + required: false + - timeout: + required: false + publish: + - actual_container_id: container_list + navigate: + SUCCESS: verify_container_is_running + FAILURE: GET_RUNNING_CONTAINER_IDS_PROBLEM + + - verify_container_is_running: + do: + strings.string_occurrence_counter: + - string_in_which_to_search: expected_container_id + - string_to_find: actual_container_id + navigate: + SUCCESS: post_clear_machine + FAILURE: VERIFY_CONTAINER_IS_RUNNING_PROBLEM + + - post_clear_machine: + do: + maintenance.clear_docker_host: + - docker_host: host + - docker_username: username + - docker_password: + default: password + required: false + - private_key_file: + required: false + - timeout: + required: false + - port: + required: false + navigate: + SUCCESS: SUCCESS + FAILURE: POST_CLEAR_MACHINE_PROBLEM + results: + - SUCCESS + - FAILURE + - PRE_CLEAR_MACHINE_PROBLEM + - GET_RUNNING_CONTAINER_IDS_PROBLEM + - VERIFY_CONTAINER_IS_RUNNING_PROBLEM + - POST_CLEAR_MACHINE_PROBLEM