Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
denisa-dan committed Feb 28, 2017
1 parent aa4e3dc commit d175c1f
Show file tree
Hide file tree
Showing 7 changed files with 434 additions and 0 deletions.
24 changes: 24 additions & 0 deletions content/io/cloudslang/samples/yoda/contains.sl
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 content/io/cloudslang/samples/yoda/generate_random_quote.sl
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
47 changes: 47 additions & 0 deletions content/io/cloudslang/samples/yoda/print_image.sl
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
61 changes: 61 additions & 0 deletions content/io/cloudslang/samples/yoda/quote_check.sl
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
18 changes: 18 additions & 0 deletions content/io/cloudslang/samples/yoda/samples.prop.sl
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'
Loading

0 comments on commit d175c1f

Please sign in to comment.