forked from ciao-project/ciao
-
Notifications
You must be signed in to change notification settings - Fork 0
/
payloads.go
579 lines (504 loc) · 16.3 KB
/
payloads.go
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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
//
// Copyright (c) 2016 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package testutil
import "github.com/01org/ciao/payloads"
// AgentIP is a test agent IP address
const AgentIP = "10.2.3.4"
//TenantSubnet is a test tenant subnet
const TenantSubnet = "10.2.0.0/16"
// SubnetKey is a test tenant subnet key
const SubnetKey = "8"
// InstancePublicIP is a test instance public IP
const InstancePublicIP = "10.1.2.3"
// InstancePrivateIP is a test instance private IP
const InstancePrivateIP = "192.168.1.2"
// VNICMAC is a test instance VNIC MAC address
const VNICMAC = "aa:bb:cc:01:02:03"
// VNICUUID is a test instance VNIC UUID
const VNICUUID = "7f49d00d-1995-4156-8c79-5f5ab24ce138"
// TenantUUID is a test tenant UUID
const TenantUUID = "2491851d-dce9-48d6-b83a-a717417072ce"
// CNCIUUID is a test CNCI instance UUID
const CNCIUUID = "7e84c2d6-5a84-4f9b-98e3-38980f722d1b"
// CNCIIP is a test CNCI instance IP address
const CNCIIP = "10.1.2.3"
// CNCIMAC is a test CNCI instance MAC address
const CNCIMAC = "CA:FE:C0:00:01:02"
// SchedulerAddr is a test scheduler address
const SchedulerAddr = "192.168.42.5"
// KeystoneURL is a test Keystone identity server url
const KeystoneURL = "http://keystone.example.com"
// GlanceURL is a test Glance image server url
const GlanceURL = "http://glance.example.com"
// ComputeNet is a test compute network
const ComputeNet = "192.168.1.110"
// MgmtNet is a test management network
const MgmtNet = "192.168.1.111"
// ManagementID is a test identifier for a Ceph ID
const ManagementID = "ciao"
// StorageURI is a test storage URI
const StorageURI = "/etc/ciao/ciao.json"
// IdentityUser is a test user for the test identity server
const IdentityUser = "controller"
// IdentityPassword is a test password for the test identity server
const IdentityPassword = "ciao"
// VolumePort is a test port for the compute service
const VolumePort = "446"
// ComputePort is a test port for the compute service
const ComputePort = "443"
// HTTPSKey is a path to a key for the compute service
const HTTPSKey = "/etc/pki/ciao/compute_key.pem"
// HTTPSCACert is a path to the CA cert used to sign the HTTPSKey
const HTTPSCACert = "/etc/pki/ciao/compute_ca.pem"
// DockerImage is a docker image name for use in start/restart tests
const DockerImage = "docker/latest"
// ImageUUID is a disk image UUID for use in start/restart tests
const ImageUUID = "59460b8a-5f53-4e3e-b5ce-b71fed8c7e64"
// InstanceUUID is an instance UUID for use in start/stop/restart/delete tests
const InstanceUUID = "3390740c-dce9-48d6-b83a-a717417072ce"
// CNCIInstanceUUID is a CNCI instance UUID for use in start/stop/restart/delete tests
const CNCIInstanceUUID = "c6beb8b5-0bfc-43fd-9638-7dd788179fd8"
// NetAgentUUID is a network node UUID for coordinated tests
const NetAgentUUID = "6be56328-92e2-4ecd-b426-8fe529c04e0c"
// AgentUUID is a node UUID for coordinated stop/restart/delete tests
const AgentUUID = "4cb19522-1e18-439a-883a-f9b2a3a95f5e"
// VolumeUUID is a node UUID for storage tests
const VolumeUUID = "67d86208-b46c-4465-9018-e14187d4010"
//////////////////////////////////////////////////////////////////////////////
// StartYaml is a sample workload START ssntp.Command payload for test usage
const StartYaml = `start:
tenant_uuid: ` + TenantUUID + `
instance_uuid: ` + InstanceUUID + `
image_uuid: ` + ImageUUID + `
docker_image: ` + DockerImage + `
fw_type: efi
persistence: host
vm_type: qemu
requested_resources:
- type: vcpus
value: 2
mandatory: true
- type: mem_mb
value: 4096
mandatory: true
- type: disk_mb
value: 10000
mandatory: true
estimated_resources:
- type: vcpus
value: 1
- type: mem_mb
value: 128
- type: disk_mb
value: 4096
networking:
vnic_mac: ""
vnic_uuid: ""
concentrator_uuid: ""
concentrator_ip: ""
subnet: ""
subnet_key: ""
subnet_uuid: ""
private_ip: ""
public_ip: false
`
// CNCIStartYaml is a sample CNCI workload START ssntp.Command payload for test cases
const CNCIStartYaml = `start:
instance_uuid: ` + CNCIInstanceUUID + `
image_uuid: ` + ImageUUID + `
fw_type: efi
persistence: host
vm_type: qemu
requested_resources:
- type: vcpus
value: 4
mandatory: true
- type: mem_mb
value: 4096
mandatory: true
- type: network_node
value: 1
mandatory: true
networking:
vnic_mac: ` + VNICMAC + `
vnic_uuid: ` + VNICUUID + `
concentrator_uuid: ` + CNCIUUID + `
concentrator_ip: ` + CNCIIP + `
subnet: ` + TenantSubnet + `
subnet_key: ` + SubnetKey + `
subnet_uuid: ""
private_ip: ""
public_ip: false
`
// PartialStartYaml is a sample minimal workload START ssntp.Command payload for test cases
const PartialStartYaml = `start:
instance_uuid: ` + InstanceUUID + `
image_uuid: ` + ImageUUID + `
docker_image: ` + DockerImage + `
fw_type: efi
persistence: host
vm_type: qemu
requested_resources:
- type: vcpus
value: 2
mandatory: true
`
// StartFailureYaml is a sample workload StartFailure ssntp.Error payload for test cases
const StartFailureYaml = `instance_uuid: ` + InstanceUUID + `
reason: full_cloud
`
// RestartYaml is a sample workload RESTART ssntp.Command payload for test cases
const RestartYaml = `restart:
tenant_uuid: ` + TenantUUID + `
instance_uuid: ` + InstanceUUID + `
image_uuid: ` + ImageUUID + `
workload_agent_uuid: ` + AgentUUID + `
fw_type: efi
persistence: host
requested_resources:
- type: vcpus
value: 2
mandatory: true
- type: mem_mb
value: 4096
mandatory: true
- type: disk_mb
value: 10000
mandatory: true
estimated_resources:
- type: vcpus
value: 1
- type: mem_mb
value: 128
- type: disk_mb
value: 4096
networking:
vnic_mac: ""
vnic_uuid: ""
concentrator_uuid: ""
concentrator_ip: ""
subnet: ""
subnet_key: ""
subnet_uuid: ""
private_ip: ""
public_ip: false
`
// PartialRestartYaml is a sample minimal workload RESTART ssntp.Command payload for test cases
const PartialRestartYaml = `restart:
instance_uuid: ` + InstanceUUID + `
workload_agent_uuid: ` + AgentUUID + `
fw_type: efi
persistence: host
requested_resources:
- type: vcpus
value: 2
mandatory: true
`
// RestartFailureYaml is a sample workload RestartFailure ssntp.Error payload for test cases
const RestartFailureYaml = `instance_uuid: ` + InstanceUUID + `
reason: already_running
`
// StopYaml is a sample workload STOP ssntp.Command payload for test cases
const StopYaml = `stop:
instance_uuid: ` + InstanceUUID + `
workload_agent_uuid: ` + AgentUUID + `
`
// StopFailureYaml is a sample workload StopFailure ssntp.Error payload for test cases
const StopFailureYaml = `instance_uuid: ` + InstanceUUID + `
reason: already_stopped
`
// DeleteYaml is a sample workload DELETE ssntp.Command payload for test cases
const DeleteYaml = `delete:
instance_uuid: ` + InstanceUUID + `
workload_agent_uuid: ` + AgentUUID + `
`
// EvacuateYaml is a sample node EVACUATE ssntp.Command payload for test cases
const EvacuateYaml = `evacuate:
workload_agent_uuid: ` + AgentUUID + `
`
// CNCIAddedYaml is a sample ConcentratorInstanceAdded ssntp.Event payload for test cases
const CNCIAddedYaml = `concentrator_instance_added:
instance_uuid: ` + CNCIUUID + `
tenant_uuid: ` + TenantUUID + `
concentrator_ip: ` + CNCIIP + `
concentrator_mac: ` + CNCIMAC + `
`
// AssignIPYaml is a sample AssignPublicIP ssntp.Command payload for test cases
const AssignIPYaml = `assign_public_ip:
concentrator_uuid: ` + CNCIUUID + `
tenant_uuid: ` + TenantUUID + `
instance_uuid: ` + InstanceUUID + `
public_ip: ` + InstancePublicIP + `
private_ip: ` + InstancePrivateIP + `
vnic_mac: ` + VNICMAC + `
`
// ReleaseIPYaml is a sample ReleasePublicIP ssntp.Command payload for test cases
const ReleaseIPYaml = `release_public_ip:
concentrator_uuid: ` + CNCIUUID + `
tenant_uuid: ` + TenantUUID + `
instance_uuid: ` + InstanceUUID + `
public_ip: ` + InstancePublicIP + `
private_ip: ` + InstancePrivateIP + `
vnic_mac: ` + VNICMAC + `
`
// AssignedIPYaml is a sample PublicIPAssigned ssntp.Event payload for test cases
const AssignedIPYaml = `public_ip_assigned:
concentrator_uuid: ` + CNCIUUID + `
instance_uuid: ` + InstanceUUID + `
public_ip: ` + InstancePublicIP + `
private_ip: ` + InstancePrivateIP + `
`
// TenantAddedYaml is a sample TenantAdded ssntp.Event payload for test cases
const TenantAddedYaml = `tenant_added:
agent_uuid: ` + AgentUUID + `
agent_ip: ` + AgentIP + `
tenant_uuid: ` + TenantUUID + `
tenant_subnet: ` + TenantSubnet + `
concentrator_uuid: ` + CNCIUUID + `
concentrator_ip: ` + CNCIIP + `
subnet_key: ` + SubnetKey + `
`
// TenantRemovedYaml is a sample TenantRemove ssntp.Event payload for test cases
const TenantRemovedYaml = `tenant_removed:
agent_uuid: ` + AgentUUID + `
agent_ip: ` + AgentIP + `
tenant_uuid: ` + TenantUUID + `
tenant_subnet: ` + TenantSubnet + `
concentrator_uuid: ` + CNCIUUID + `
concentrator_ip: ` + CNCIIP + `
subnet_key: ` + SubnetKey + `
`
// CNCIInstanceData is a sample CNCIInstanceConfig payload for test cases
const CNCIInstanceData = `scheduler_addr: 192.168.42.5
`
// ConfigureYaml is a sample CONFIGURE ssntp.Command payload for test cases
const ConfigureYaml = `configure:
scheduler:
storage_uri: ` + StorageURI + `
storage:
ceph_id: ` + ManagementID + `
controller:
volume_port: ` + VolumePort + `
compute_port: ` + ComputePort + `
compute_ca: ` + HTTPSCACert + `
compute_cert: ` + HTTPSKey + `
identity_user: ` + IdentityUser + `
identity_password: ` + IdentityPassword + `
launcher:
compute_net:
- ` + ComputeNet + `
mgmt_net:
- ` + MgmtNet + `
disk_limit: false
mem_limit: false
image_service:
type: glance
url: ` + GlanceURL + `
identity_service:
type: keystone
url: ` + KeystoneURL + `
`
// DeleteFailureYaml is a sample workload DeleteFailure ssntp.Error payload for test cases
const DeleteFailureYaml = `instance_uuid: ` + InstanceUUID + `
reason: no_instance
`
// InsDelYaml is a sample workload InstanceDeleted ssntp.Event payload for test cases
const InsDelYaml = `instance_deleted:
instance_uuid: ` + InstanceUUID + `
`
// NodeConnectedYaml is a sample node NodeConnected ssntp.Event payload for test cases
const NodeConnectedYaml = `node_connected:
node_uuid: ` + AgentUUID + `
node_type: ` + payloads.NetworkNode + `
`
// ReadyPayload is a helper to craft a mostly fixed ssntp.READY status
// payload, with parameters to specify the source node uuid and memory metrics
func ReadyPayload(uuid string, memTotal int, memAvail int) payloads.Ready {
p := payloads.Ready{
NodeUUID: uuid,
MemTotalMB: memTotal,
MemAvailableMB: memAvail,
DiskTotalMB: 500000,
DiskAvailableMB: 256000,
Load: 0,
CpusOnline: 4,
}
return p
}
// ReadyYaml is a sample node READY ssntp.Status payload for test cases
const ReadyYaml = `node_uuid: ` + AgentUUID + `
mem_total_mb: 3896
mem_available_mb: 3896
disk_total_mb: 500000
disk_available_mb: 256000
load: 0
cpus_online: 4
`
// PartialReadyYaml is a sample minimal node READY ssntp.Status payload for test cases
const PartialReadyYaml = `node_uuid: ` + AgentUUID + `
load: 1
`
// InstanceStat001 is a sample payloads.InstanceStat
var InstanceStat001 = payloads.InstanceStat{
InstanceUUID: "fe2970fa-7b36-460b-8b79-9eb4745e62f2",
State: payloads.Running,
MemoryUsageMB: 40,
DiskUsageMB: 2,
CPUUsage: 90,
SSHIP: "",
SSHPort: 0,
}
// InstanceStat002 is a sample payloads.InstanceStat
var InstanceStat002 = payloads.InstanceStat{
InstanceUUID: "cbda5bd8-33bd-4d39-9f52-ace8c9f0b99c",
State: payloads.Running,
MemoryUsageMB: 50,
DiskUsageMB: 10,
CPUUsage: 0,
SSHIP: "172.168.2.2",
SSHPort: 8768,
}
// InstanceStat003 is a sample payloads.InstanceStat
var InstanceStat003 = payloads.InstanceStat{
InstanceUUID: "1f5b2fe6-4493-4561-904a-8f4e956218d9",
State: payloads.Exited,
MemoryUsageMB: -1,
DiskUsageMB: 2,
CPUUsage: -1,
Volumes: []string{VolumeUUID},
}
// NetworkStat001 is a sample payloads.NetworkStat
var NetworkStat001 = payloads.NetworkStat{
NodeIP: "192.168.1.1",
NodeMAC: "02:00:15:03:6f:49",
}
// NetworkStat002 is a sample payloads.NetworkStat
var NetworkStat002 = payloads.NetworkStat{
NodeIP: "10.168.1.1",
NodeMAC: "02:00:8c:ba:f9:45",
}
// StatsPayload is a factory function for a node STATS ssntp.Command payload for test cases
// The StatsPayload() factory function returns a payloads.Stat object.
// If passed uuid==AgentUUID, instances==[InstanceStat001,InstanceStat002,InstanceStat003]
// and networks==[NetworkStat001,NetworkStat002], then StatsPayload() will
// return a payloads.Stat matching the StatsYaml string.
func StatsPayload(uuid string, name string, instances []payloads.InstanceStat, networks []payloads.NetworkStat) payloads.Stat {
p := payloads.Stat{
NodeUUID: uuid,
Status: "READY",
MemTotalMB: 3896,
MemAvailableMB: 3896,
DiskTotalMB: 500000,
DiskAvailableMB: 256000,
Load: 0,
CpusOnline: 4,
NodeHostName: name,
Instances: instances,
Networks: networks,
}
return p
}
// StatsYaml is a sample node STATS ssntp.Command payload for test cases
const StatsYaml = `node_uuid: ` + AgentUUID + `
status: READY
mem_total_mb: 3896
mem_available_mb: 3896
disk_total_mb: 500000
disk_available_mb: 256000
load: 0
cpus_online: 4
hostname: test
networks:
- ip: 192.168.1.1
mac: 02:00:15:03:6f:49
- ip: 10.168.1.1
mac: 02:00:8c:ba:f9:45
instances:
- instance_uuid: fe2970fa-7b36-460b-8b79-9eb4745e62f2
state: active
ssh_ip: ""
ssh_port: 0
memory_usage_mb: 40
disk_usage_mb: 2
cpu_usage: 90
volumes: []
- instance_uuid: cbda5bd8-33bd-4d39-9f52-ace8c9f0b99c
state: active
ssh_ip: 172.168.2.2
ssh_port: 8768
memory_usage_mb: 50
disk_usage_mb: 10
cpu_usage: 0
volumes: []
- instance_uuid: 1f5b2fe6-4493-4561-904a-8f4e956218d9
state: exited
ssh_ip: ""
ssh_port: 0
memory_usage_mb: -1
disk_usage_mb: 2
cpu_usage: -1
volumes:
- 67d86208-b46c-4465-9018-e14187d4010
`
// NodeOnlyStatsYaml is a sample minimal node STATS ssntp.Command payload for test cases
// with no per-instance statistics
const NodeOnlyStatsYaml = `node_uuid: ` + AgentUUID + `
mem_total_mb: 3896
mem_available_mb: 3896
disk_total_mb: 500000
disk_available_mb: 256000
load: 0
cpus_online: 4
hostname: test
networks:
- ip: 192.168.1.1
mac: 02:00:15:03:6f:49
`
// PartialStatsYaml is a sample minimal node STATS ssntp.Command payload for test cases
// with limited node statistics and no per-instance statistics
const PartialStatsYaml = `node_uuid: ` + AgentUUID + `
load: 1
`
// AttachVolumeYaml is a sample yaml payload for the ssntp Attach Volume command.
const AttachVolumeYaml = `attach_volume:
instance_uuid: ` + InstanceUUID + `
volume_uuid: ` + VolumeUUID + `
workload_agent_uuid: ` + AgentUUID + `
`
// BadAttachVolumeYaml is a corrupt yaml payload for the ssntp Attach Volume command.
const BadAttachVolumeYaml = `attach_volume:
volume_uuid: ` + VolumeUUID + `
`
// DetachVolumeYaml is a sample yaml payload for the ssntp Detach Volume command.
const DetachVolumeYaml = `detach_volume:
instance_uuid: ` + InstanceUUID + `
volume_uuid: ` + VolumeUUID + `
workload_agent_uuid: ` + AgentUUID + `
`
// BadDetachVolumeYaml is a corrupt yaml payload for the ssntp Detach Volume command.
const BadDetachVolumeYaml = `detach_volume:
instance_uuid: ` + InstanceUUID + `
`
// AttachVolumeFailureYaml is a sample AttachVolumeFailure ssntp.Error payload for test cases
const AttachVolumeFailureYaml = `instance_uuid: ` + InstanceUUID + `
volume_uuid: ` + VolumeUUID + `
reason: attach_failure
`
// DetachVolumeFailureYaml is a sample DetachVolumeFailure ssntp.Error payload for test cases
const DetachVolumeFailureYaml = `instance_uuid: ` + InstanceUUID + `
volume_uuid: ` + VolumeUUID + `
reason: detach_failure
`