Skip to content

Commit d175c1f

Browse files
author
denisa-dan
committed
initial commit
1 parent aa4e3dc commit d175c1f

File tree

7 files changed

+434
-0
lines changed

7 files changed

+434
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P.
2+
# All rights reserved. This program and the accompanying materials
3+
# are made available under the terms of the Apache License v2.0 which accompany this distribution.
4+
#
5+
# The Apache License is available at
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
########################################################################################################################
9+
#!!
10+
#! @description: Check the state of a System Property file
11+
#!
12+
#! @result CONTAINS: System Property is set at default value.
13+
#! @result DOES_NOT_CONTAIN: System Property is not set at default value.
14+
#!!#
15+
########################################################################################################################
16+
17+
namespace: io.cloudslang.samples.yoda
18+
19+
decision:
20+
name: contains
21+
22+
results:
23+
- CONTAINS: ${get_sp('io.cloudslang.samples.properties.default_quote', 'false') == 'true'}
24+
- DOES_NOT_CONTAIN
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P.
2+
# All rights reserved. This program and the accompanying materials
3+
# are made available under the terms of the Apache License v2.0 which accompany this distribution.
4+
#
5+
# The Apache License is available at
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
########################################################################################################################
8+
#!!
9+
#! @description: Based on a random number generator display a quote from Yoda
10+
#!
11+
#! @input file_path: The path for the file that contains the quotes
12+
#!
13+
#! @result SUCCESS: Flow completed successfully.
14+
#! @result FAILURE: Failure occurred during execution.
15+
#!!#
16+
########################################################################################################################
17+
18+
namespace: io.cloudslang.samples.yoda
19+
20+
imports:
21+
math: io.cloudslang.base.math
22+
base: io.cloudslang.base.print
23+
fs: io.cloudslang.base.filesystem
24+
25+
flow:
26+
name: generate_random_quote
27+
28+
inputs:
29+
- file_path
30+
31+
workflow:
32+
- read_quotes:
33+
do:
34+
fs.read_from_file:
35+
- file_path: ${file_path}
36+
publish:
37+
- read_text
38+
navigate:
39+
- SUCCESS: generate_random_number
40+
- FAILURE: FAILURE
41+
42+
- generate_random_number:
43+
do:
44+
math.random_number_generator:
45+
- min: '0'
46+
- max: ${str(len(read_text.strip().split(';')) - 2)}
47+
publish:
48+
- random_number
49+
navigate:
50+
- SUCCESS: print_quote
51+
- FAILURE: FAILURE
52+
53+
- print_quote:
54+
do:
55+
base.print_text:
56+
- text: ${str(read_text.split(';')[int(random_number)])}
57+
navigate:
58+
- SUCCESS: SUCCESS
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P.
2+
# All rights reserved. This program and the accompanying materials
3+
# are made available under the terms of the Apache License v2.0 which accompany this distribution.
4+
#
5+
# The Apache License is available at
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
########################################################################################################################
9+
#!!
10+
#! @description: Read an image from a file and print it.
11+
#!
12+
#! @input file_path: The path of the image
13+
#!
14+
#! @result SUCCESS: Flow completed successfully.
15+
#! @result FAILURE: Failure occurred during execution.
16+
#!!#
17+
########################################################################################################################
18+
19+
namespace: io.cloudslang.samples.yoda
20+
21+
imports:
22+
base: io.cloudslang.base.print
23+
fs: io.cloudslang.base.filesystem
24+
25+
flow:
26+
name: print_image
27+
28+
inputs:
29+
- file_path
30+
31+
workflow:
32+
- read_start:
33+
do:
34+
fs.read_from_file:
35+
- file_path: ${file_path}
36+
publish:
37+
- read_text
38+
navigate:
39+
- SUCCESS: print_start
40+
- FAILURE: FAILURE
41+
42+
- print_start:
43+
do:
44+
base.print_text:
45+
- text: ${read_text}
46+
navigate:
47+
- SUCCESS: SUCCESS
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P.
2+
# All rights reserved. This program and the accompanying materials
3+
# are made available under the terms of the Apache License v2.0 which accompany this distribution.
4+
#
5+
# The Apache License is available at
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
#########################################################################################################################!!
9+
#! @description: Based on a System Property file
10+
#! If it is set on true it displays the default quote, otherwise generates a random quote.
11+
#!
12+
#! @input default_quote : quote with a default value
13+
#! @input file_path: The path for the file that contains the quotes
14+
#!
15+
#! @result SUCCESS: Flow completed successfully.
16+
#! @result FAILURE: Failure occurred during execution.
17+
#!!
18+
########################################################################################################################
19+
20+
namespace: io.cloudslang.samples.yoda
21+
22+
imports:
23+
base: io.cloudslang.base.print
24+
fs: io.cloudslang.base.filesystem
25+
math: io.cloudslang.base.math
26+
quoteGenerator: io.cloudslang.samples.yoda
27+
28+
flow:
29+
name: quote_check
30+
31+
inputs:
32+
- default_quote:
33+
default: "Do or do not, there is no try!"
34+
private: true
35+
- file_path
36+
37+
workflow:
38+
- print_quote:
39+
do:
40+
quoteGenerator.contains: []
41+
navigate:
42+
- CONTAINS: print_default_quote
43+
- DOES_NOT_CONTAIN: print_random_quote
44+
45+
- print_random_quote:
46+
do:
47+
quoteGenerator.generate_random_quote:
48+
- file_path
49+
navigate:
50+
- SUCCESS: SUCCESS
51+
- FAILURE: FAILURE
52+
53+
- print_default_quote:
54+
do:
55+
base.print_text:
56+
- text: ${default_quote}
57+
navigate:
58+
- SUCCESS: SUCCESS
59+
results:
60+
- SUCCESS
61+
- FAILURE
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P.
2+
# All rights reserved. This program and the accompanying materials
3+
# are made available under the terms of the Apache License v2.0 which accompany this distribution.
4+
#
5+
# The Apache License is available at
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
########################################################################################################################
9+
# System property file for samples.yoda operations.
10+
#
11+
# io.cloudslang.samples.properties.default_quote: value of default quote
12+
#
13+
########################################################################################################################
14+
15+
namespace: io.cloudslang.samples.properties
16+
17+
properties:
18+
- default_quote: 'true'

0 commit comments

Comments
 (0)