StackStorm-Exchange / stackstorm-excel

excel actions to read and write variables to an excel file
https://exchange.stackstorm.org/
Apache License 2.0
9 stars 8 forks source link

fails to perform basic functions with st2 v2.3.0 #3

Closed ghost closed 7 years ago

ghost commented 7 years ago

With st2 2.3.0, pack fails to perform basic functions - sample Excel workbook attached. rbridge_info.xlsx

# st2 run excel.get_sheets excel_file=/tmp/rbridge_info.xlsx
.
id: 595cfe1406ac8d62ae7f0bde
status: failed
parameters:
  excel_file: /tmp/rbridge_info.xlsx
result:
  exit_code: 1
  result: None
  stderr: "Traceback (most recent call last):
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py", line 259, in <module>
    obj.run()
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py", line 154, in run
    action = self._get_action_instance()
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py", line 229, in _get_action_instance
    action_service=action_service)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/runners/utils.py", line 81, in get_action_class_instance
    action_instance = action_cls(**kwargs)
  File "/opt/stackstorm/packs/excel/actions/lib/excel_action.py", line 20, in __init__
    self._excel_file = self.config['excel_file']
KeyError: 'excel_file'
"
  stdout: ''

Initial triage from @LindsayHill was:

looks like maybe pack config needs to be updated

LindsayHill commented 7 years ago

@leecowdrey

looks like maybe pack config needs to be updated Did you try loading the config with st2ctl reload --register-configs?

humblearner commented 7 years ago

@leecowdrey: You have to create config for the excel pack


vagrant@u16:~$ st2 pack config excel
lock_file_retries (integer) [3]:
key_column (integer) [1]:
variable_name_row (integer) [1]:
excel_file:
lock_file_delay (integer) [1]:
---
Do you want to preview the config in an editor before saving? [y]: y
---
Do you want me to save it? [y]: y
+----------+------------------------------+
| Property | Value                        |
+----------+------------------------------+
| id       | 595d177fde59a45a92bbb07d     |
| pack     | excel                        |
| values   | {                            |
|          |     "lock_file_retries": 3,  |
|          |     "excel_file": null,      |
|          |     "variable_name_row": 1,  |
|          |     "key_column": 1,         |
|          |     "lock_file_delay": 1     |
|          | }                            |
+----------+------------------------------+
vagrant@u16:~$ st2 run excel.get_sheets excel_file="/vagrant/shared/rbridge_info.xlsx"
.
id: 595d1782de59a45a92bbb07f
status: succeeded
parameters:
  excel_file: /vagrant/shared/rbridge_info.xlsx
result:
  exit_code: 0
  result:
  - Tabelle1
  - Tabelle2
  - Tabelle3
  stderr: ''
  stdout: ''

------------------------------
Without excel_config param:
------------------------------

vagrant@u16:~$ st2 run excel.get_sheets
.
id: 595d1790de59a45a92bbb082
status: failed
parameters: None
result:
  exit_code: 1
  result: None
  stderr: "Traceback (most recent call last):
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py", line 259, in <module>
    obj.run()
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py", line 155, in run
    output = action.run(**self._parameters)
  File "/opt/stackstorm/packs/excel/actions/get_sheets.py", line 20, in run
    self.replace_defaults(excel_file, None, None)
  File "/opt/stackstorm/packs/excel/actions/lib/excel_action.py", line 37, in replace_defaults
    raise ValueError('"excel_file" needs to be specified either as config option or '
ValueError: "excel_file" needs to be specified either as config option or as action parameter
"
  stdout: ''```
ghost commented 7 years ago

Thanks progress, though not complete...

root@bwc-vnf:/opt/stackstorm/packs/excel# more config.schema.yaml
---
  excel_file:
    description: "Path and filename to excel file"
    type: "string"
    secret: false
    required: false
  key_column:
    description: "Column in the spreadsheet that contains the key field"
    type: "integer"
    secret: false
    required: true
    default: 1
  variable_name_row:
    description: "Row in the spreadsheet that contains the variables names"
    type: "integer"
    secret: false
    required: true
    default: 1
  lock_file_retries:
    description: "Number of times to retry to open a the excel file for edits"
    type: "integer"
    secret: false
    required: true
    default: 3
  lock_file_delay:
    description: "Delay in seconds between attempts to read a file that was previously locked"
    type: "integer"
    secret: false
    required: true
    default: 1
root@bwc-vnf:/opt/stackstorm/packs/excel# st2 pack config excel
lock_file_retries (integer) [3]:
key_column (integer) [1]:
variable_name_row (integer) [1]:
excel_file:
lock_file_delay (integer) [1]:
---
Do you want to preview the config in an editor before saving? [y]: n
---
Do you want me to save it? [y]: y
+----------+------------------------------+
| Property | Value                        |
+----------+------------------------------+
| id       | 595d3ade06ac8d62ae7f0be0     |
| pack     | excel                        |
| values   | {                            |
|          |     "lock_file_retries": 3,  |
|          |     "excel_file": null,      |
|          |     "variable_name_row": 1,  |
|          |     "key_column": 1,         |
|          |     "lock_file_delay": 1     |
|          | }                            |
+----------+------------------------------+

Re-running the action, apparently it can not find the specified file:

root@bwc-vnf:/opt/stackstorm/packs/excel# ls -lt /tmp/rbridge_info.xlsx
-rw-rw-rw- 1 lee st2packs 11890 Jul  5 11:27 /tmp/rbridge_info.xlsx

root@bwc-vnf:/opt/stackstorm/packs/excel# st2 run excel.get_sheets excel_file=/tmp/rbridge_info.xlsx
.
id: 595d3b6f06ac8d62ae7f0be8
status: failed
parameters:
  excel_file: /tmp/rbridge_info.xlsx
result:
  exit_code: 1
  result: None
  stderr: "Traceback (most recent call last):
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py", line 259, in <module>
    obj.run()
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py", line 155, in run
    output = action.run(**self._parameters)
  File "/opt/stackstorm/packs/excel/actions/get_sheets.py", line 22, in run
    excel = excel_reader.ExcelReader(self._excel_file)
  File "/opt/stackstorm/packs/excel/actions/lib/excel_reader.py", line 39, in __init__
    raise ValueError('File "%s" doesn\'t exist' % (self._filename))
ValueError: File "/tmp/rbridge_info.xlsx" doesn't exist"
  stdout: ''

Something is not adding up... have restarted st2 via st2ctl restart but results are the same.

Will delete the pack and re-install, re-run config pack etc:

root@bwc-vnf:/opt/stackstorm/packs# st2 pack remove excel

        [ succeeded ] unregister packs
        [ succeeded ] delete packs

+-------------+------------------------------------------------------------+
| Property    | Value                                                      |
+-------------+------------------------------------------------------------+
| name        | excel                                                      |
| description | excel actions to read and write variables to an excel file |
| version     | 0.2.0                                                      |
| author      | Tim Braly                                                  |
+-------------+------------------------------------------------------------+
root@bwc-vnf:/opt/stackstorm/packs# st2 pack list
+--------------------+--------------------+-------------------------------------------+---------+------------------+
| ref                | name               | description                               | version | author           |
+--------------------+--------------------+-------------------------------------------+---------+------------------+
| chatops            | chatops            | ChatOps integration pack                  | 0.3.0   | Kirill Enykeev   |
| core               | core               | st2 content pack containing basic         | 0.3.1   | st2-dev          |
|                    |                    | actions.                                  |         |                  |
| dcfabric           | dcfabric           | Brocade Workflow Composer Datacenter      | 1.1.0   | Brocade          |
|                    |                    | Fabric Pack                               |         |                  |
| default            | default            | Pack where all the resources which are    | 0.1.0   | st2-dev          |
|                    |                    | created using the API and don't have a    |         |                  |
|                    |                    | pack specified get saved.                 |         |                  |
| linux              | linux              | Generic linux actions                     | 0.1.0   | st2-dev          |
| network_essentials | Network Essentials | Brocade Workflow Composer Network         | 1.2.0   | Brocade          |
|                    |                    | Essentials Pack                           |         |                  |
| network_inventory  | network_inventory  | Brocade workflow composer Network         | 1.1.0   | Brocade          |
|                    |                    | Inventory pack                            |         |                  |
| packs              | packs              | core st2 content pack containing pack     | 0.2.0   | st2-dev          |
|                    |                    | management functionality.                 |         |                  |
| st2                | st2                | StackStorm pack management                | 0.3.0   | StackStorm, Inc. |
+--------------------+--------------------+-------------------------------------------+---------+------------------+

Re-installed & re-configured:

root@bwc-vnf:/opt/stackstorm/packs# st2 pack install excel

        [ succeeded ] download pack
        [ succeeded ] make a prerun
        [ succeeded ] install pack dependencies
        [ succeeded ] register pack

+-------------+------------------------------------------------------------+
| Property    | Value                                                      |
+-------------+------------------------------------------------------------+
| name        | excel                                                      |
| description | excel actions to read and write variables to an excel file |
| version     | 0.2.0                                                      |
| author      | Tim Braly                                                  |
+-------------+------------------------------------------------------------+
root@bwc-vnf:/opt/stackstorm/packs# st2 pack config excel
lock_file_retries (integer) [3]:
key_column (integer) [1]:
variable_name_row (integer) [1]:
excel_file:
lock_file_delay (integer) [1]:
---
Do you want to preview the config in an editor before saving? [y]: y
---
Do you want me to save it? [y]: y
+----------+------------------------------+
| Property | Value                        |
+----------+------------------------------+
| id       | 595d3dae06ac8d0895922219     |
| pack     | excel                        |
| values   | {                            |
|          |     "lock_file_retries": 3,  |
|          |     "excel_file": null,      |
|          |     "variable_name_row": 1,  |
|          |     "key_column": 1,         |
|          |     "lock_file_delay": 1     |
|          | }                            |
+----------+------------------------------+
root@bwc-vnf:/opt/stackstorm/packs# st2 run excel.get_sheets excel_file="/tmp/rbridge_info.xlsx"
.
id: 595d3de006ac8d089592221b
status: failed
parameters:
  excel_file: /tmp/rbridge_info.xlsx
result:
  exit_code: 1
  result: None
  stderr: "Traceback (most recent call last):
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py", line 259, in <module>
    obj.run()
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py", line 155, in run
    output = action.run(**self._parameters)
  File "/opt/stackstorm/packs/excel/actions/get_sheets.py", line 22, in run
    excel = excel_reader.ExcelReader(self._excel_file)
  File "/opt/stackstorm/packs/excel/actions/lib/excel_reader.py", line 39, in __init__
    raise ValueError('File "%s" doesn\'t exist' % (self._filename))
ValueError: File "/tmp/rbridge_info.xlsx" doesn't exist
"
  stdout: ''
root@bwc-vnf:/opt/stackstorm/packs# ls -lt /tmp/rbridge_info.xlsx
-rw-rw-rw- 1 lee st2packs 11890 Jul  5 11:27 /tmp/rbridge_info.xlsx
root@bwc-vnf:/opt/stackstorm/packs#

Any more suggestions?

LindsayHill commented 7 years ago

@leecowdrey use a path other than /tmp. If you're using a recent RHEL/Ubuntu distro, it will be using privateTmp

ghost commented 7 years ago

Now behaving correctly - and now also more reasons to hate systemd

root@bwc-vnf:/opt/stackstorm/packs/default/actions# st2 run excel.get_sheets excel_file=/opt/stackstorm/packs/default/rbridge_info.xlsx
.
id: 595dff9006ac8d0895922279
status: succeeded
parameters:
  excel_file: /opt/stackstorm/packs/default/rbridge_info.xlsx
result:
  exit_code: 0
  result:
  - Tabelle1
  - Tabelle2
  - Tabelle3
  stderr: ''
  stdout: ''