1
|
|
|
# Licensed to the StackStorm, Inc ('StackStorm') under one or more |
2
|
|
|
# contributor license agreements. See the NOTICE file distributed with |
3
|
|
|
# this work for additional information regarding copyright ownership. |
4
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0 |
5
|
|
|
# (the "License"); you may not use this file except in compliance with |
6
|
|
|
# the License. You may obtain a copy of the License at |
7
|
|
|
# |
8
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
9
|
|
|
# |
10
|
|
|
# Unless required by applicable law or agreed to in writing, software |
11
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
12
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13
|
|
|
# See the License for the specific language governing permissions and |
14
|
|
|
|
15
|
|
|
from st2tests.base import BaseActionAliasTestCase |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
class NcmConfigDownloadActionAliasTestCase(BaseActionAliasTestCase): |
19
|
|
|
action_alias_name = 'ncm_config_download' |
20
|
|
|
|
21
|
|
|
def test_ncm_config_download_alias(self): |
22
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
23
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
24
|
|
|
|
25
|
|
|
command = "orion ncm config-download orion router1" |
26
|
|
|
expected_parameters = { |
27
|
|
|
'platform': 'orion', |
28
|
|
|
'node': 'router1' |
29
|
|
|
} |
30
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
31
|
|
|
command=command, |
32
|
|
|
parameters=expected_parameters) |
33
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
34
|
|
|
format_strings=format_strings, |
35
|
|
|
command=command) |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
class NodeStatusActionAliasTestCase(BaseActionAliasTestCase): |
39
|
|
|
action_alias_name = 'node_status' |
40
|
|
|
|
41
|
|
|
def test_node_status_alias(self): |
42
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
43
|
|
|
|
44
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
45
|
|
|
command = "orion node status orion router1" |
46
|
|
|
expected_parameters = { |
47
|
|
|
'platform': 'orion', |
48
|
|
|
'node': 'router1' |
49
|
|
|
} |
50
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
51
|
|
|
command=command, |
52
|
|
|
parameters=expected_parameters) |
53
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
54
|
|
|
format_strings=format_strings, |
55
|
|
|
command=command) |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
class NodeCreateActionAliasTestCase(BaseActionAliasTestCase): |
59
|
|
|
action_alias_name = 'node_create' |
60
|
|
|
|
61
|
|
|
def test_node_create_alias(self): |
62
|
|
|
format_strings = self.action_alias_db.get_format_strings() |
63
|
|
|
|
64
|
|
|
# First Format 'orion node create' |
65
|
|
|
format_string = self.action_alias_db.formats[0]['representation'][0] |
66
|
|
|
command = "orion node create router1 ip 192.168.0.1 snmp read platform orion" |
67
|
|
|
expected_parameters = { |
68
|
|
|
'ip_address': "192.168.0.1", |
69
|
|
|
'node': 'router1', |
70
|
|
|
'platform': 'orion', |
71
|
|
|
'poller': 'primary', |
72
|
|
|
'std_community': 'read' |
73
|
|
|
} |
74
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
75
|
|
|
command=command, |
76
|
|
|
parameters=expected_parameters) |
77
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
78
|
|
|
format_strings=format_strings, |
79
|
|
|
command=command) |
80
|
|
|
|
81
|
|
|
command = "orion node create router1 ip 192.168.0.1 platform orion poller1" |
82
|
|
|
expected_parameters = { |
83
|
|
|
'ip_address': "192.168.0.1", |
84
|
|
|
'node': 'router1', |
85
|
|
|
'platform': 'orion', |
86
|
|
|
'poller': 'poller1', |
87
|
|
|
'std_community': None |
88
|
|
|
} |
89
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
90
|
|
|
command=command, |
91
|
|
|
parameters=expected_parameters) |
92
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
93
|
|
|
format_strings=format_strings, |
94
|
|
|
command=command) |
95
|
|
|
|
96
|
|
|
command = "orion node create router1 ip 192.168.0.1 snmp read" |
97
|
|
|
expected_parameters = { |
98
|
|
|
'ip_address': "192.168.0.1", |
99
|
|
|
'node': 'router1', |
100
|
|
|
'platform': None, |
101
|
|
|
'poller': 'primary', |
102
|
|
|
'std_community': 'read' |
103
|
|
|
} |
104
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
105
|
|
|
command=command, |
106
|
|
|
parameters=expected_parameters) |
107
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
108
|
|
|
format_strings=format_strings, |
109
|
|
|
command=command) |
110
|
|
|
|
111
|
|
|
command = "orion node create router1 ip 192.168.0.1" |
112
|
|
|
expected_parameters = { |
113
|
|
|
'ip_address': "192.168.0.1", |
114
|
|
|
'node': 'router1', |
115
|
|
|
'platform': None, |
116
|
|
|
'poller': 'primary', |
117
|
|
|
'std_community': None |
118
|
|
|
} |
119
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
120
|
|
|
command=command, |
121
|
|
|
parameters=expected_parameters) |
122
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
123
|
|
|
format_strings=format_strings, |
124
|
|
|
command=command) |
125
|
|
|
|
126
|
|
|
# Second format 'create orion node' |
127
|
|
|
format_string = self.action_alias_db.formats[1]['representation'][0] |
128
|
|
|
|
129
|
|
|
command = "create orion node router1 at 192.168.0.1 with read on orion poller1" |
130
|
|
|
expected_parameters = { |
131
|
|
|
'ip_address': "192.168.0.1", |
132
|
|
|
'node': 'router1', |
133
|
|
|
'platform': 'orion', |
134
|
|
|
'poller': 'poller1', |
135
|
|
|
'std_community': 'read' |
136
|
|
|
} |
137
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
138
|
|
|
command=command, |
139
|
|
|
parameters=expected_parameters) |
140
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
141
|
|
|
format_strings=format_strings, |
142
|
|
|
command=command) |
143
|
|
|
|
144
|
|
|
command = "create orion node router1 at 192.168.0.1 with read" |
145
|
|
|
expected_parameters = { |
146
|
|
|
'ip_address': "192.168.0.1", |
147
|
|
|
'node': 'router1', |
148
|
|
|
'platform': None, |
149
|
|
|
'poller': 'primary', |
150
|
|
|
'std_community': 'read' |
151
|
|
|
} |
152
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
153
|
|
|
command=command, |
154
|
|
|
parameters=expected_parameters) |
155
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
156
|
|
|
format_strings=format_strings, |
157
|
|
|
command=command) |
158
|
|
|
|
159
|
|
|
command = "create orion node router1 at 192.168.0.1 on orion" |
160
|
|
|
expected_parameters = { |
161
|
|
|
'ip_address': "192.168.0.1", |
162
|
|
|
'node': 'router1', |
163
|
|
|
'platform': 'orion', |
164
|
|
|
'poller': 'primary', |
165
|
|
|
'std_community': None |
166
|
|
|
} |
167
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
168
|
|
|
command=command, |
169
|
|
|
parameters=expected_parameters) |
170
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
171
|
|
|
format_strings=format_strings, |
172
|
|
|
command=command) |
173
|
|
|
|
174
|
|
|
command = "create orion node router1 at 192.168.0.1" |
175
|
|
|
expected_parameters = { |
176
|
|
|
'ip_address': "192.168.0.1", |
177
|
|
|
'node': 'router1', |
178
|
|
|
'platform': None, |
179
|
|
|
'poller': 'primary', |
180
|
|
|
'std_community': None |
181
|
|
|
} |
182
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
183
|
|
|
command=command, |
184
|
|
|
parameters=expected_parameters) |
185
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
186
|
|
|
format_strings=format_strings, |
187
|
|
|
command=command) |
188
|
|
|
|