-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
denisa-dan
committed
Feb 28, 2017
1 parent
aa4e3dc
commit d175c1f
Showing
7 changed files
with
434 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# (c) Copyright 2017 Hewlett-Packard Enterprise 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 | ||
# | ||
######################################################################################################################## | ||
#!! | ||
#! @description: Check the state of a System Property file | ||
#! | ||
#! @result CONTAINS: System Property is set at default value. | ||
#! @result DOES_NOT_CONTAIN: System Property is not set at default value. | ||
#!!# | ||
######################################################################################################################## | ||
|
||
namespace: io.cloudslang.samples.yoda | ||
|
||
decision: | ||
name: contains | ||
|
||
results: | ||
- CONTAINS: ${get_sp('io.cloudslang.samples.properties.default_quote', 'false') == 'true'} | ||
- DOES_NOT_CONTAIN |
58 changes: 58 additions & 0 deletions
58
content/io/cloudslang/samples/yoda/generate_random_quote.sl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# (c) Copyright 2017 Hewlett-Packard Enterprise 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 | ||
######################################################################################################################## | ||
#!! | ||
#! @description: Based on a random number generator display a quote from Yoda | ||
#! | ||
#! @input file_path: The path for the file that contains the quotes | ||
#! | ||
#! @result SUCCESS: Flow completed successfully. | ||
#! @result FAILURE: Failure occurred during execution. | ||
#!!# | ||
######################################################################################################################## | ||
|
||
namespace: io.cloudslang.samples.yoda | ||
|
||
imports: | ||
math: io.cloudslang.base.math | ||
base: io.cloudslang.base.print | ||
fs: io.cloudslang.base.filesystem | ||
|
||
flow: | ||
name: generate_random_quote | ||
|
||
inputs: | ||
- file_path | ||
|
||
workflow: | ||
- read_quotes: | ||
do: | ||
fs.read_from_file: | ||
- file_path: ${file_path} | ||
publish: | ||
- read_text | ||
navigate: | ||
- SUCCESS: generate_random_number | ||
- FAILURE: FAILURE | ||
|
||
- generate_random_number: | ||
do: | ||
math.random_number_generator: | ||
- min: '0' | ||
- max: ${str(len(read_text.strip().split(';')) - 2)} | ||
publish: | ||
- random_number | ||
navigate: | ||
- SUCCESS: print_quote | ||
- FAILURE: FAILURE | ||
|
||
- print_quote: | ||
do: | ||
base.print_text: | ||
- text: ${str(read_text.split(';')[int(random_number)])} | ||
navigate: | ||
- SUCCESS: SUCCESS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# (c) Copyright 2017 Hewlett-Packard Enterprise 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 | ||
# | ||
######################################################################################################################## | ||
#!! | ||
#! @description: Read an image from a file and print it. | ||
#! | ||
#! @input file_path: The path of the image | ||
#! | ||
#! @result SUCCESS: Flow completed successfully. | ||
#! @result FAILURE: Failure occurred during execution. | ||
#!!# | ||
######################################################################################################################## | ||
|
||
namespace: io.cloudslang.samples.yoda | ||
|
||
imports: | ||
base: io.cloudslang.base.print | ||
fs: io.cloudslang.base.filesystem | ||
|
||
flow: | ||
name: print_image | ||
|
||
inputs: | ||
- file_path | ||
|
||
workflow: | ||
- read_start: | ||
do: | ||
fs.read_from_file: | ||
- file_path: ${file_path} | ||
publish: | ||
- read_text | ||
navigate: | ||
- SUCCESS: print_start | ||
- FAILURE: FAILURE | ||
|
||
- print_start: | ||
do: | ||
base.print_text: | ||
- text: ${read_text} | ||
navigate: | ||
- SUCCESS: SUCCESS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# (c) Copyright 2017 Hewlett-Packard Enterprise 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 | ||
# | ||
#########################################################################################################################!! | ||
#! @description: Based on a System Property file | ||
#! If it is set on true it displays the default quote, otherwise generates a random quote. | ||
#! | ||
#! @input default_quote : quote with a default value | ||
#! @input file_path: The path for the file that contains the quotes | ||
#! | ||
#! @result SUCCESS: Flow completed successfully. | ||
#! @result FAILURE: Failure occurred during execution. | ||
#!! | ||
######################################################################################################################## | ||
|
||
namespace: io.cloudslang.samples.yoda | ||
|
||
imports: | ||
base: io.cloudslang.base.print | ||
fs: io.cloudslang.base.filesystem | ||
math: io.cloudslang.base.math | ||
quoteGenerator: io.cloudslang.samples.yoda | ||
|
||
flow: | ||
name: quote_check | ||
|
||
inputs: | ||
- default_quote: | ||
default: "Do or do not, there is no try!" | ||
private: true | ||
- file_path | ||
|
||
workflow: | ||
- print_quote: | ||
do: | ||
quoteGenerator.contains: [] | ||
navigate: | ||
- CONTAINS: print_default_quote | ||
- DOES_NOT_CONTAIN: print_random_quote | ||
|
||
- print_random_quote: | ||
do: | ||
quoteGenerator.generate_random_quote: | ||
- file_path | ||
navigate: | ||
- SUCCESS: SUCCESS | ||
- FAILURE: FAILURE | ||
|
||
- print_default_quote: | ||
do: | ||
base.print_text: | ||
- text: ${default_quote} | ||
navigate: | ||
- SUCCESS: SUCCESS | ||
results: | ||
- SUCCESS | ||
- FAILURE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# (c) Copyright 2017 Hewlett-Packard Enterprise 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 | ||
# | ||
######################################################################################################################## | ||
# System property file for samples.yoda operations. | ||
# | ||
# io.cloudslang.samples.properties.default_quote: value of default quote | ||
# | ||
######################################################################################################################## | ||
|
||
namespace: io.cloudslang.samples.properties | ||
|
||
properties: | ||
- default_quote: 'true' |
Oops, something went wrong.