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
|
|
|
'std_community': 'read' |
72
|
|
|
} |
73
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
74
|
|
|
command=command, |
75
|
|
|
parameters=expected_parameters) |
76
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
77
|
|
|
format_strings=format_strings, |
78
|
|
|
command=command) |
79
|
|
|
|
80
|
|
|
command = "orion node create router1 ip 192.168.0.1 platform orion" |
81
|
|
|
expected_parameters = { |
82
|
|
|
'ip_address': "192.168.0.1", |
83
|
|
|
'node': 'router1', |
84
|
|
|
'platform': 'orion', |
85
|
|
|
'std_community': None |
86
|
|
|
} |
87
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
88
|
|
|
command=command, |
89
|
|
|
parameters=expected_parameters) |
90
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
91
|
|
|
format_strings=format_strings, |
92
|
|
|
command=command) |
93
|
|
|
|
94
|
|
|
command = "orion node create router1 ip 192.168.0.1 snmp read" |
95
|
|
|
expected_parameters = { |
96
|
|
|
'ip_address': "192.168.0.1", |
97
|
|
|
'node': 'router1', |
98
|
|
|
'platform': None, |
99
|
|
|
'std_community': 'read' |
100
|
|
|
} |
101
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
102
|
|
|
command=command, |
103
|
|
|
parameters=expected_parameters) |
104
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
105
|
|
|
format_strings=format_strings, |
106
|
|
|
command=command) |
107
|
|
|
|
108
|
|
|
command = "orion node create router1 ip 192.168.0.1" |
109
|
|
|
expected_parameters = { |
110
|
|
|
'ip_address': "192.168.0.1", |
111
|
|
|
'node': 'router1', |
112
|
|
|
'platform': None, |
113
|
|
|
'std_community': None |
114
|
|
|
} |
115
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
116
|
|
|
command=command, |
117
|
|
|
parameters=expected_parameters) |
118
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
119
|
|
|
format_strings=format_strings, |
120
|
|
|
command=command) |
121
|
|
|
|
122
|
|
|
# Second format 'create orion node' |
123
|
|
|
format_string = self.action_alias_db.formats[1]['representation'][0] |
124
|
|
|
|
125
|
|
|
command = "create orion node router1 at 192.168.0.1 with read on poller1" |
126
|
|
|
expected_parameters = { |
127
|
|
|
'ip_address': "192.168.0.1", |
128
|
|
|
'node': 'router1', |
129
|
|
|
'platform': 'poller1', |
130
|
|
|
'std_community': 'read' |
131
|
|
|
} |
132
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
133
|
|
|
command=command, |
134
|
|
|
parameters=expected_parameters) |
135
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
136
|
|
|
format_strings=format_strings, |
137
|
|
|
command=command) |
138
|
|
|
|
139
|
|
|
command = "create orion node router1 at 192.168.0.1 with read" |
140
|
|
|
expected_parameters = { |
141
|
|
|
'ip_address': "192.168.0.1", |
142
|
|
|
'node': 'router1', |
143
|
|
|
'platform': None, |
144
|
|
|
'std_community': 'read' |
145
|
|
|
} |
146
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
147
|
|
|
command=command, |
148
|
|
|
parameters=expected_parameters) |
149
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
150
|
|
|
format_strings=format_strings, |
151
|
|
|
command=command) |
152
|
|
|
|
153
|
|
|
command = "create orion node router1 at 192.168.0.1 on poller1" |
154
|
|
|
expected_parameters = { |
155
|
|
|
'ip_address': "192.168.0.1", |
156
|
|
|
'node': 'router1', |
157
|
|
|
'platform': 'poller1', |
158
|
|
|
'std_community': None |
159
|
|
|
} |
160
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
161
|
|
|
command=command, |
162
|
|
|
parameters=expected_parameters) |
163
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
164
|
|
|
format_strings=format_strings, |
165
|
|
|
command=command) |
166
|
|
|
|
167
|
|
|
command = "create orion node router1 at 192.168.0.1" |
168
|
|
|
expected_parameters = { |
169
|
|
|
'ip_address': "192.168.0.1", |
170
|
|
|
'node': 'router1', |
171
|
|
|
'platform': None, |
172
|
|
|
'std_community': None |
173
|
|
|
} |
174
|
|
|
self.assertExtractedParametersMatch(format_string=format_string, |
175
|
|
|
command=command, |
176
|
|
|
parameters=expected_parameters) |
177
|
|
|
self.assertCommandMatchesExactlyOneFormatString( |
178
|
|
|
format_strings=format_strings, |
179
|
|
|
command=command) |
180
|
|
|
|