Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tested environment
- ```
- root@5a6e72caaa0d:~# dpkg -l | grep st2
- ii st2 3.0dev-38 amd64 StackStorm Event-driven automation
- ii st2chatops 3.0dev-1 amd64 St2Chatops - StackStorm ChatOps.
- ii st2mistral 3.0dev-4 amd64 st2 Mistral workflow service.
- ii st2web 3.0dev-9 amd64 St2Web - StackStorm Web UI.
- ```
- # Notes
- - core.local doesn't accept unicode at action level while core.remote seems to run without any problem
- ```
- root@5a6e72caaa0d:/# st2 run core.local cmd="echo あ"
- .
- id: 5be19c5be78e2f06259cfc2c
- status: failed
- parameters:
- cmd: "echo あ"
- result:
- error: '''ascii'' codec can''t encode character u''あ'' in position 39: ordinal not in range(128)'
- traceback: " File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2actions/container/base.py", line 127, in _do_run
- (status, result, context) = runner.run(action_params)
- File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/local_runner/local_shell_command_runner.py", line 49, in run
- return self._run(action=action)
- File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/local_runner/base.py", line 175, in _run
- read_stderr_buffer=stderr)
- File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/util/green/shell.py", line 109, in run_command
- env=env, cwd=cwd, shell=shell, preexec_fn=preexec_func)
- File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/eventlet/green/subprocess.py", line 58, in __init__
- subprocess_orig.Popen.__init__(self, args, 0, *argss, **kwds)
- File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
- errread, errwrite)
- File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
- raise child_exception
- "
- ```
- ```
- root@5a6e72caaa0d:/# st2 run core.remote cmd="echo あ" hosts=192.168.33.10 username=vagrant password=vagrant
- .
- id: 5be19c8de78e2f06259cfc2f
- status: succeeded
- parameters:
- cmd: "echo あ"
- hosts: 192.168.33.10
- password: '********'
- username: vagrant
- result:
- 192.168.33.10:
- failed: false
- return_code: 0
- stderr: ''
- stdout: "あ"
- succeeded: true
- ```
- # Test 0: Success
- - Unicode character in workflow yaml
- ```
- version: 1.0
- tasks:
- task1:
- action: core.remote
- input:
- hosts: 192.168.33.10
- username: vagrant
- password: vagrant
- cwd: /vagrant
- cmd: echo あ
- ```
- ```
- root@5a6e72caaa0d:/# st2 run demo.orquesta-unicode
- .
- id: 5be1ab57e78e2f08ae2ed9e6
- action.ref: demo.orquesta-unicode
- parameters: None
- status: succeeded
- start_timestamp: Tue, 06 Nov 2018 14:55:19 UTC
- end_timestamp: Tue, 06 Nov 2018 14:55:21 UTC
- result:
- output: null
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- | id | status | task | action | start_timestamp |
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- | 5be1ab58e78e2f06c4cba105 | succeeded (1s elapsed) | task1 | core.remote | Tue, 06 Nov 2018 14:55:20 UTC |
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- root@5a6e72caaa0d:/# st2 execution get 5be1ab58e78e2f06c4cba105
- id: 5be1ab58e78e2f06c4cba105
- status: succeeded (1s elapsed)
- parameters:
- cmd: "echo あ"
- cwd: /vagrant
- hosts: 192.168.33.10
- password: '********'
- username: vagrant
- result:
- 192.168.33.10:
- failed: false
- return_code: 0
- stderr: ''
- stdout: "あ"
- succeeded: true
- ```
- # Test 1: Success
- - Unicode character in variable
- ```
- version: 1.0
- vars:
- - diff: あ
- tasks:
- task1:
- action: core.remote
- input:
- hosts: 192.168.33.10
- username: vagrant
- password: vagrant
- cwd: /vagrant
- cmd: echo {{ ctx('diff') }}
- ```
- ```
- root@5a6e72caaa0d:/# st2 run demo.orquesta-unicode
- .
- id: 5be1abb6e78e2f08ae2ed9e9
- action.ref: demo.orquesta-unicode
- parameters: None
- status: succeeded
- start_timestamp: Tue, 06 Nov 2018 14:56:54 UTC
- end_timestamp: Tue, 06 Nov 2018 14:56:56 UTC
- result:
- output: null
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- | id | status | task | action | start_timestamp |
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- | 5be1abb7e78e2f06c4cba108 | succeeded (0s elapsed) | task1 | core.remote | Tue, 06 Nov 2018 14:56:55 UTC |
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- root@5a6e72caaa0d:/# st2 execution get 5be1abb7e78e2f06c4cba108
- id: 5be1abb7e78e2f06c4cba108
- status: succeeded (0s elapsed)
- parameters:
- cmd: "echo あ"
- cwd: /vagrant
- hosts: 192.168.33.10
- password: '********'
- username: vagrant
- result:
- 192.168.33.10:
- failed: false
- return_code: 0
- stderr: ''
- stdout: "あ"
- succeeded: true
- ```
- # Test 2: Success
- - Passing unicode character as an input to workflow
- ```
- version: 1.0
- input:
- - diff
- tasks:
- task1:
- action: core.remote
- input:
- hosts: 192.168.33.10
- username: vagrant
- password: vagrant
- cwd: /vagrant
- cmd: echo {{ ctx().diff }}
- ```
- ```
- root@5a6e72caaa0d:/# st2 run demo.orquesta-unicode diff=塩
- .
- id: 5be1ac0fe78e2f08ae2ed9ef
- action.ref: demo.orquesta-unicode
- parameters:
- diff: "塩"
- status: succeeded
- start_timestamp: Tue, 06 Nov 2018 14:58:23 UTC
- end_timestamp: Tue, 06 Nov 2018 14:58:24 UTC
- result:
- output: null
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- | id | status | task | action | start_timestamp |
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- | 5be1ac0fe78e2f06c4cba10b | succeeded (1s elapsed) | task1 | core.remote | Tue, 06 Nov 2018 14:58:23 UTC |
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- root@5a6e72caaa0d:/# st2 execution get 5be1ac0fe78e2f06c4cba10b
- id: 5be1ac0fe78e2f06c4cba10b
- status: succeeded (1s elapsed)
- parameters:
- cmd: "echo 塩"
- cwd: /vagrant
- hosts: 192.168.33.10
- password: '********'
- username: vagrant
- result:
- 192.168.33.10:
- failed: false
- return_code: 0
- stderr: ''
- stdout: "塩"
- succeeded: true
- ```
- # Test 3: Success
- - Return output containing unicode character
- ```
- version: 1.0
- output:
- - diff: "{{ ctx().diff }}"
- tasks:
- task1:
- action: core.remote
- input:
- hosts: 192.168.33.10
- username: vagrant
- password: vagrant
- cwd: /vagrant
- cmd: echo あ
- next:
- - when: "{{ succeeded() }}"
- publish: diff={{ result() | jsonpath_query('*.stdout') | first }}
- ```
- ```
- root@5a6e72caaa0d:/# st2 run demo.orquesta-unicode
- ..
- id: 5be1ac51e78e2f08ae2ed9f5
- action.ref: demo.orquesta-unicode
- parameters: None
- status: succeeded
- start_timestamp: Tue, 06 Nov 2018 14:59:29 UTC
- end_timestamp: Tue, 06 Nov 2018 14:59:32 UTC
- result:
- output:
- diff: "あ"
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- | id | status | task | action | start_timestamp |
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- | 5be1ac52e78e2f06c4cba10e | succeeded (1s elapsed) | task1 | core.remote | Tue, 06 Nov 2018 14:59:30 UTC |
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- ```
- # Test4: Success
- - Chain output that contains unicode character as an input to next action
- ```
- version: 1.0
- tasks:
- task1:
- action: core.remote
- input:
- hosts: 192.168.33.10
- username: vagrant
- password: vagrant
- cwd: /vagrant
- cmd: echo 塩
- next:
- - when: "{{ succeeded() }}"
- publish: diff={{ result() | jsonpath_query('*.stdout') | first }}
- do: task2
- task2:
- action: core.remote
- input:
- hosts: 192.168.33.10
- username: vagrant
- password: vagrant
- cwd: /vagrant
- cmd: echo {{ ctx().diff }}
- ```
- ```
- root@5a6e72caaa0d:/# st2 run demo.orquesta-unicode
- ..
- id: 5be1ac87e78e2f08ae2ed9f8
- action.ref: demo.orquesta-unicode
- parameters: None
- status: succeeded
- start_timestamp: Tue, 06 Nov 2018 15:00:23 UTC
- end_timestamp: Tue, 06 Nov 2018 15:00:26 UTC
- result:
- output: null
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- | id | status | task | action | start_timestamp |
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- | 5be1ac88e78e2f06c4cba111 | succeeded (1s elapsed) | task1 | core.remote | Tue, 06 Nov 2018 15:00:24 UTC |
- | 5be1ac89e78e2f06c4cba114 | succeeded (1s elapsed) | task2 | core.remote | Tue, 06 Nov 2018 15:00:25 UTC |
- +--------------------------+------------------------+-------+-------------+-------------------------------+
- root@5a6e72caaa0d:/# st2 execution get 5be1ac89e78e2f06c4cba114
- id: 5be1ac89e78e2f06c4cba114
- status: succeeded (1s elapsed)
- parameters:
- cmd: "echo 塩"
- cwd: /vagrant
- hosts: 192.168.33.10
- password: '********'
- username: vagrant
- result:
- 192.168.33.10:
- failed: false
- return_code: 0
- stderr: ''
- stdout: "塩"
- succeeded: true
- ```
- # Test 5: OK
- - More practical example
- ```
- version: 1.0
- output:
- - slack_result: "{{ ctx('slack_result') }}"
- tasks:
- task1:
- action: core.remote
- input:
- hosts: 192.168.33.10
- username: vagrant
- password: vagrant
- cwd: /vagrant
- cmd: diff -u text1 text2 || true
- next:
- - when: "{{ succeeded() }}"
- publish: diff={{ result() | jsonpath_query('*.stdout') | first }}
- do: task2
- task2:
- action: slack.files.upload
- input:
- channels: sandbox
- content: |
- 塩 塩 塩
- {{ ctx('diff') }}
- next:
- - when: "{{ succeeded() }}"
- publish:
- - slack_result:
- channel: "{{ result().result.file.channels | first }}"
- timestamp: "{{ result().result.file.timestamp }}"
- ```
Add Comment
Please, Sign In to add comment