-
Notifications
You must be signed in to change notification settings - Fork 900
/
Copy pathext_management_system.rb
412 lines (338 loc) · 13.7 KB
/
ext_management_system.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
FactoryBot.define do
factory :ext_management_system,
:class => "ManageIQ::Providers::Vmware::InfraManager" do
# The provider has to be set before the hostname/ipaddress sequences as in some cases these attributes
# might be delegated to the provider. As the attributes are being set based on the order in this file,
# it is important to keep this line at the beginning of the factory.
provider { nil }
sequence(:name) { |n| "ems_#{seq_padded_for_sorting(n)}" }
sequence(:hostname) { |n| "ems-#{seq_padded_for_sorting(n)}" }
sequence(:ipaddress) { |n| ip_from_seq(n) }
zone { FactoryBot.create(:zone) }
storage_profiles { [] }
# authorizations
transient do
authtype { nil }
end
after(:create) do |ems, ev|
Array(ev.authtype).each { |a| ems.authentications << FactoryBot.create(:authentication, :authtype => a) }
end
# Traits
trait :with_clusters do
transient do
cluster_count { 3 }
end
after :create do |ems, evaluator|
create_list :ems_cluster, evaluator.cluster_count, :ext_management_system => ems
end
end
trait :with_storages do
transient do
storage_count { 3 }
end
after :create do |ems, evaluator|
create_list :storage, evaluator.storage_count, :ext_management_system => ems
end
end
trait :with_storages_redhat do
transient do
storage_count { 1 }
end
after :create do |ems, evaluator|
ems.storages = create_list :storage_redhat, evaluator.storage_count, :ext_management_system => ems
end
end
trait :with_authentication do
authtype { "default" }
end
trait :with_unvalidated_authentication do
after(:create) do |x|
x.authentications << FactoryBot.create(:authentication, :status => nil)
end
end
trait :with_invalid_authentication do
after(:create) do |x|
x.authentications << FactoryBot.create(:authentication, :status => "invalid")
end
end
end
# Intermediate classes
# using leaf classes...
factory :ems_infra,
:aliases => ["manageiq/providers/infra_manager"],
:class => "ManageIQ::Providers::Vmware::InfraManager",
:parent => :ext_management_system
factory :ems_physical_infra,
:aliases => ["manageiq/providers/physical_infra_manager"],
:class => "ManageIQ::Providers::Redfish::PhysicalInfraManager",
:parent => :ext_management_system
factory(:ems_cloud,
:aliases => ["manageiq/providers/cloud_manager"],
:class => "ManageIQ::Providers::Amazon::CloudManager",
:parent => :ext_management_system) do
provider_region { "us-east-1" }
end
factory :ems_network,
:aliases => ["manageiq/providers/network_manager"],
:class => "ManageIQ::Providers::Openstack::NetworkManager",
:parent => :ext_management_system do
parent_manager { FactoryBot.create(:ext_management_system) }
end
factory :ems_storage,
:aliases => ["manageiq/providers/storage_manager"],
:class => "ManageIQ::Providers::Openstack::StorageManager::SwiftManager",
:parent => :ext_management_system do
parent_manager { FactoryBot.create(:ext_management_system) }
end
factory :ems_cinder,
:aliases => ["manageiq/providers/storage_manager/cinder_manager"],
:class => "ManageIQ::Providers::Openstack::StorageManager::CinderManager",
:parent => :ext_management_system do
parent_manager { FactoryBot.create(:ext_management_system) }
end
factory :ems_autosde,
:aliases => ["manageiq/providers/storage_manager/autosde_manager"],
:class => "ManageIQ::Providers::Autosde::StorageManager",
:parent => :ext_management_system do
parent_manager { FactoryBot.create(:ext_management_system) }
end
factory :ems_swift,
:aliases => ["manageiq/providers/storage_manager/swift_manager"],
:class => "ManageIQ::Providers::Openstack::StorageManager::SwiftManager",
:parent => :ext_management_system do
parent_manager { FactoryBot.create(:ext_management_system) }
end
factory :ems_container,
:aliases => ["manageiq/providers/container_manager"],
:class => "ManageIQ::Providers::Openshift::ContainerManager",
:parent => :ext_management_system
factory :configuration_manager,
:aliases => ["manageiq/providers/configuration_manager"],
:class => "ManageIQ::Providers::Foreman::ConfigurationManager",
:parent => :ext_management_system do
provider :factory => :provider_foreman
end
# Automation managers
factory :automation_manager,
:aliases => ["manageiq/providers/automation_manager"],
:class => "ManageIQ::Providers::Awx::AutomationManager",
:parent => :ext_management_system
factory :provisioning_manager,
:aliases => ["manageiq/providers/provisioning_manager"],
:class => "ManageIQ::Providers::Foreman::ProvisioningManager",
:parent => :ext_management_system do
provider :factory => :provider_foreman
end
# Leaf classes for ems_infra
factory :ems_vmware,
:aliases => ["manageiq/providers/vmware/infra_manager"],
:class => "ManageIQ::Providers::Vmware::InfraManager",
:parent => :ems_infra
factory :ems_vmware_with_authentication,
:parent => :ems_vmware do
authtype { "default" }
end
factory :ems_redhat,
:aliases => ["manageiq/providers/redhat/infra_manager"],
:class => "ManageIQ::Providers::Redhat::InfraManager",
:parent => :ems_infra
factory :ems_redhat_v3,
:parent => :ems_redhat do
api_version { '3.5' }
end
factory :ems_redhat_v4,
:parent => :ems_redhat do
api_version { '4.0' }
end
factory :ems_redhat_with_authentication,
:parent => :ems_redhat do
authtype { "default" }
end
trait :skip_validate do
to_create { |instance| instance.save(:validate => false) }
end
factory :ems_redhat_with_authentication_with_ca,
:parent => :ems_redhat do
certificate_authority { "cert108" }
authtype { "default" }
end
factory :ems_redhat_with_metrics_authentication,
:parent => :ems_redhat do
after(:create) do |x|
x.authentications << FactoryBot.create(:authentication_redhat_metric)
end
end
factory :ems_ovirt_with_metrics_authentication,
:parent => :ems_ovirt do
after(:create) do |x|
x.authentications << FactoryBot.create(:authentication_redhat_metric)
end
end
factory :ems_ovirt,
:aliases => ["manageiq/providers/ovirt/infra_manager"],
:class => "ManageIQ::Providers::Ovirt::InfraManager",
:parent => :ems_infra
factory :ems_ovirt_with_authentication,
:parent => :ems_ovirt do
authtype { "default" }
end
factory :ems_openstack_infra,
:aliases => ["manageiq/providers/openstack/infra_manager"],
:class => "ManageIQ::Providers::Openstack::InfraManager",
:parent => :ems_infra
factory :ems_openstack_infra_with_stack,
:parent => :ems_openstack_infra do
after :create do |x|
x.orchestration_stacks << FactoryBot.create(:orchestration_stack_openstack_infra)
4.times { x.hosts << FactoryBot.create(:host_openstack_infra) }
end
end
factory :ems_openstack_infra_with_stack_and_compute_nodes,
:parent => :ems_openstack_infra do
after :create do |x|
x.orchestration_stacks << FactoryBot.create(:orchestration_stack_openstack_infra)
x.hosts += [FactoryBot.create(:host_openstack_infra_compute),
FactoryBot.create(:host_openstack_infra_compute_maintenance)]
end
end
factory :ems_openstack_infra_with_authentication,
:parent => :ems_openstack_infra do
authtype { %w[default amqp] }
end
factory :ems_vmware_cloud,
:aliases => ["manageiq/providers/vmware/cloud_manager"],
:class => "ManageIQ::Providers::Vmware::CloudManager",
:parent => :ems_cloud
factory :ems_vmware_cloud_network,
:aliases => ["manageiq/providers/vmware/network_manager"],
:class => "ManageIQ::Providers::Vmware::NetworkManager",
:parent => :ems_cloud do
parent_manager { FactoryBot.create(:ext_management_system) }
end
# Leaf classes for ems_cloud
factory :ems_amazon,
:aliases => ["manageiq/providers/amazon/cloud_manager"],
:class => "ManageIQ::Providers::Amazon::CloudManager",
:parent => :ems_cloud do
provider_region { "us-east-1" }
end
factory :ems_amazon_network,
:aliases => ["manageiq/providers/amazon/network_manager"],
:class => "ManageIQ::Providers::Amazon::NetworkManager",
:parent => :ems_network do
provider_region { "us-east-1" }
end
factory :ems_amazon_with_authentication,
:parent => :ems_amazon do
authtype { "default" }
end
factory :ems_azure,
:aliases => ["manageiq/providers/azure/cloud_manager"],
:class => "ManageIQ::Providers::Azure::CloudManager",
:parent => :ems_cloud do
provider_region { "eastus" }
end
factory :ems_azure_network,
:aliases => ["manageiq/providers/azure/network_manager"],
:class => "ManageIQ::Providers::Azure::NetworkManager",
:parent => :ems_network do
provider_region { "eastus" }
end
factory :ems_azure_with_authentication,
:parent => :ems_azure do
azure_tenant_id { "ABCDEFGHIJABCDEFGHIJ0123456789AB" }
subscription { "0123456789ABCDEFGHIJABCDEFGHIJKL" }
authtype { "default" }
end
factory :ems_openstack,
:aliases => ["manageiq/providers/openstack/cloud_manager"],
:class => "ManageIQ::Providers::Openstack::CloudManager",
:parent => :ext_management_system
factory :ems_openstack_with_authentication,
:parent => :ems_openstack do
authtype { %w[default amqp] }
end
factory :ems_openstack_network,
:aliases => ["manageiq/providers/openstack/network_manager"],
:class => "ManageIQ::Providers::Openstack::NetworkManager",
:parent => :ems_network
factory :ems_nuage_network,
:aliases => ["manageiq/providers/nuage/network_manager"],
:class => "ManageIQ::Providers::Nuage::NetworkManager",
:parent => :ems_network
factory :ems_nsxt_network,
:aliases => ["manageiq/providers/nsxt/network_manager"],
:class => "ManageIQ::Providers::Nsxt::NetworkManager",
:parent => :ems_network
factory :ems_google,
:aliases => ["manageiq/providers/google/cloud_manager"],
:class => "ManageIQ::Providers::Google::CloudManager",
:parent => :ems_cloud
factory :ems_google_with_authentication,
:parent => :ems_google do
after(:create) do |ems|
ems.authentications << FactoryBot.create(:auth_token)
end
end
factory :ems_google_network,
:aliases => ["manageiq/providers/google/network_manager"],
:class => "ManageIQ::Providers::Google::NetworkManager",
:parent => :ems_network
# Leaf classes for ems_container
factory :ems_kubernetes,
:aliases => ["manageiq/providers/kubernetes/container_manager"],
:class => "ManageIQ::Providers::Kubernetes::ContainerManager",
:parent => :ems_container
factory :ems_kubernetes_with_authentication_err,
:parent => :ems_kubernetes do
after :create do |x|
x.authentications << FactoryBot.create(:authentication_status_error)
end
end
factory :ems_openshift,
:aliases => ["manageiq/providers/openshift/container_manager"],
:class => "ManageIQ::Providers::Openshift::ContainerManager",
:parent => :ems_container
# Leaf classes for configuration_manager
factory :configuration_manager_foreman,
:aliases => ["manageiq/providers/foreman/configuration_manager"],
:class => "ManageIQ::Providers::Foreman::ConfigurationManager",
:parent => :configuration_manager do
provider :factory => :provider_foreman
end
trait(:provider) do
after(:build, &:create_provider)
end
trait(:configuration_script) do
after(:create) do |x|
type = (x.type.split("::")[0..2] + ["AutomationManager", "ConfigurationScript"]).join("::")
x.configuration_scripts << FactoryBot.create(:configuration_script, :type => type)
end
end
trait(:configuration_workflow) do
after(:create) do |x|
type = (x.type.split("::")[0..2] + %w[AutomationManager ConfigurationWorkflow]).join("::")
x.configuration_scripts << FactoryBot.create(:configuration_workflow, :type => type)
end
end
factory :embedded_automation_manager,
:aliases => ["manageiq/providers/embedded_automation_manager"],
:class => "ManageIQ::Providers::EmbeddedAutomationManager",
:parent => :automation_manager
# Leaf classes for automation_manager
factory :embedded_automation_manager_ansible,
:aliases => ["manageiq/providers/embedded_ansible/automation_manager"],
:class => "ManageIQ::Providers::EmbeddedAnsible::AutomationManager",
:parent => :embedded_automation_manager do
provider do
raise "DO NOT USE! Use :provider_embedded_ansible and reference the automation_manager from that record"
end
end
# Leaf classes for provisioning_manager
factory :provisioning_manager_foreman,
:aliases => ["manageiq/providers/foreman/provisioning_manager"],
:class => "ManageIQ::Providers::Foreman::ProvisioningManager",
:parent => :provisioning_manager do
provider :factory => :provider_foreman
end
end