1
|
|
|
""" |
2
|
|
|
Copyright 2016 Brocade Communications Systems, Inc. |
3
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); |
4
|
|
|
you may not use this file except in compliance with the License. |
5
|
|
|
You may obtain a copy of the License at |
6
|
|
|
http://www.apache.org/licenses/LICENSE-2.0 |
7
|
|
|
Unless required by applicable law or agreed to in writing, software |
8
|
|
|
distributed under the License is distributed on an "AS IS" BASIS, |
9
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
10
|
|
|
See the License for the specific language governing permissions and |
11
|
|
|
limitations under the License. |
12
|
|
|
""" |
13
|
|
|
|
14
|
|
|
from st2actions.runners.pythonrunner import Action |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
class ExcelAction(Action): |
18
|
|
|
def __init__(self, config): |
19
|
|
|
super(ExcelAction, self).__init__(config) |
20
|
|
|
self._excel_file = self.config['excel_file'] |
21
|
|
|
self._key_column = self.config['key_column'] |
22
|
|
|
self._var_name_row = self.config['variable_name_row'] |
23
|
|
|
self._lock_retries = self.config['lock_file_retries'] |
24
|
|
|
self._lock_delay = self.config['lock_file_delay'] |
25
|
|
|
|
26
|
|
|
def replace_defaults(self, excel_file, key_column, var_name_row): |
27
|
|
|
''' Replace defaults if provided ''' |
28
|
|
|
if excel_file: |
29
|
|
|
self._excel_file = excel_file |
30
|
|
|
if key_column: |
31
|
|
|
self._key_column = key_column |
32
|
|
|
if var_name_row: |
33
|
|
|
self._var_name_row = var_name_row |
34
|
|
|
|
35
|
|
|
# Verify excel_file is specified either as config option or action parameter |
36
|
|
|
if not self._excel_file: |
37
|
|
|
raise ValueError('"excel_file" needs to be specified either as config option or ' |
38
|
|
|
'as action parameter') |
39
|
|
|
|