Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add start_swarm_manager use case #221

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
95 changes: 95 additions & 0 deletions content/io/cloudslang/docker/swarm/start_swarm_manager.sl
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions test/io/cloudslang/docker/swarm/start_swarm_manager.inputs.yaml
Original file line number Diff line number Diff line change
@@ -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]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can't you run swarm on travis/circleci?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, we need Docker hosts for it - maybe we can use multiple dind containers

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's one possibility...
but swarm_manager can not run on a single host?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bonczidai ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

working on a local test first, then will try to align it with travis / circleci

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
125 changes: 125 additions & 0 deletions test/io/cloudslang/docker/swarm/test_start_swarm_manager.sl
Original file line number Diff line number Diff line change
@@ -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