opennebula 5.12.13 → 5.13.80.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +5 -5
  2. data/lib/ActionManager.rb +1 -1
  3. data/lib/CommandManager.rb +1 -1
  4. data/lib/DriverExecHelper.rb +44 -28
  5. data/lib/OpenNebulaDriver.rb +8 -4
  6. data/lib/VirtualMachineDriver.rb +9 -2
  7. data/lib/cloud/CloudClient.rb +3 -3
  8. data/lib/datacenter.rb +1258 -0
  9. data/lib/datastore.rb +1025 -0
  10. data/lib/distributed_firewall.rb +280 -0
  11. data/lib/file_helper.rb +370 -0
  12. data/lib/host.rb +1517 -0
  13. data/lib/logical_port.rb +50 -0
  14. data/lib/logical_switch.rb +77 -0
  15. data/lib/memoize.rb +74 -0
  16. data/lib/models/role.rb +39 -8
  17. data/lib/models/service.rb +92 -31
  18. data/lib/models.rb +5 -5
  19. data/lib/network.rb +635 -0
  20. data/lib/nsx_client.rb +144 -0
  21. data/lib/nsx_component.rb +28 -0
  22. data/lib/nsx_constants.rb +149 -0
  23. data/lib/nsx_driver.rb +78 -0
  24. data/lib/nsx_error.rb +77 -0
  25. data/lib/nsx_rule.rb +193 -0
  26. data/lib/nsxt_client.rb +176 -0
  27. data/lib/nsxt_dfw.rb +196 -0
  28. data/lib/nsxt_logical_port.rb +94 -0
  29. data/lib/nsxt_rule.rb +188 -0
  30. data/lib/nsxt_tz.rb +38 -0
  31. data/lib/nsxv_client.rb +176 -0
  32. data/lib/nsxv_dfw.rb +202 -0
  33. data/lib/nsxv_logical_port.rb +107 -0
  34. data/lib/nsxv_rule.rb +172 -0
  35. data/lib/nsxv_tz.rb +41 -0
  36. data/lib/opaque_network.rb +134 -0
  37. data/lib/opennebula/acl.rb +1 -1
  38. data/lib/opennebula/acl_pool.rb +1 -1
  39. data/lib/opennebula/client.rb +1 -1
  40. data/lib/opennebula/cluster.rb +1 -1
  41. data/lib/opennebula/cluster_pool.rb +1 -1
  42. data/lib/opennebula/datastore.rb +1 -1
  43. data/lib/opennebula/datastore_pool.rb +1 -1
  44. data/lib/opennebula/document.rb +8 -29
  45. data/lib/opennebula/document_json.rb +42 -12
  46. data/lib/opennebula/document_pool.rb +1 -1
  47. data/lib/opennebula/document_pool_json.rb +1 -1
  48. data/lib/opennebula/error.rb +4 -1
  49. data/lib/opennebula/flow/grammar.rb +1195 -0
  50. data/lib/{models → opennebula/flow}/service_pool.rb +26 -2
  51. data/lib/{models → opennebula/flow}/service_template.rb +86 -17
  52. data/lib/opennebula/flow/service_template_ext.rb +84 -0
  53. data/lib/{models → opennebula/flow}/service_template_pool.rb +1 -1
  54. data/lib/opennebula/flow/validator.rb +499 -0
  55. data/lib/opennebula/flow.rb +23 -0
  56. data/lib/opennebula/group.rb +1 -1
  57. data/lib/opennebula/group_pool.rb +1 -1
  58. data/lib/opennebula/hook.rb +5 -12
  59. data/lib/opennebula/hook_log.rb +1 -1
  60. data/lib/opennebula/hook_pool.rb +1 -1
  61. data/lib/opennebula/host.rb +1 -1
  62. data/lib/opennebula/host_pool.rb +1 -1
  63. data/lib/opennebula/image.rb +17 -14
  64. data/lib/opennebula/image_pool.rb +1 -1
  65. data/lib/opennebula/ldap_auth.rb +1 -1
  66. data/lib/opennebula/ldap_auth_spec.rb +1 -1
  67. data/lib/opennebula/lockable_ext.rb +163 -0
  68. data/lib/opennebula/marketplace.rb +1 -1
  69. data/lib/opennebula/marketplace_pool.rb +1 -1
  70. data/lib/opennebula/marketplaceapp.rb +9 -119
  71. data/lib/opennebula/marketplaceapp_ext.rb +522 -0
  72. data/lib/opennebula/marketplaceapp_pool.rb +1 -1
  73. data/lib/opennebula/oneflow_client.rb +4 -3
  74. data/lib/opennebula/pool.rb +4 -3
  75. data/lib/opennebula/pool_element.rb +1 -1
  76. data/lib/opennebula/security_group.rb +1 -1
  77. data/lib/opennebula/security_group_pool.rb +1 -1
  78. data/lib/opennebula/server_cipher_auth.rb +1 -1
  79. data/lib/opennebula/server_x509_auth.rb +1 -1
  80. data/lib/opennebula/ssh_auth.rb +1 -1
  81. data/lib/opennebula/system.rb +1 -1
  82. data/lib/opennebula/template.rb +4 -13
  83. data/lib/opennebula/template_ext.rb +325 -0
  84. data/lib/opennebula/template_pool.rb +1 -1
  85. data/lib/opennebula/user.rb +26 -2
  86. data/lib/opennebula/user_pool.rb +1 -1
  87. data/lib/opennebula/utils.rb +1 -1
  88. data/lib/opennebula/vdc.rb +1 -1
  89. data/lib/opennebula/vdc_pool.rb +1 -1
  90. data/lib/opennebula/virtual_machine.rb +25 -207
  91. data/lib/opennebula/virtual_machine_ext.rb +469 -0
  92. data/lib/opennebula/virtual_machine_pool.rb +1 -5
  93. data/lib/opennebula/virtual_network.rb +4 -10
  94. data/lib/opennebula/virtual_network_pool.rb +1 -1
  95. data/lib/opennebula/virtual_router.rb +4 -12
  96. data/lib/opennebula/virtual_router_pool.rb +1 -1
  97. data/lib/opennebula/vm_group.rb +4 -11
  98. data/lib/opennebula/vm_group_pool.rb +1 -1
  99. data/lib/opennebula/vntemplate.rb +4 -13
  100. data/lib/opennebula/vntemplate_pool.rb +1 -1
  101. data/lib/opennebula/wait_ext.rb +222 -0
  102. data/lib/opennebula/x509_auth.rb +1 -1
  103. data/lib/opennebula/xml_element.rb +1 -1
  104. data/lib/opennebula/xml_pool.rb +1 -1
  105. data/lib/opennebula/xml_utils.rb +1 -1
  106. data/lib/opennebula/zone.rb +1 -1
  107. data/lib/opennebula/zone_pool.rb +1 -1
  108. data/lib/opennebula.rb +5 -2
  109. data/lib/rest_client.rb +201 -0
  110. data/lib/scripts_common.rb +180 -0
  111. data/lib/transport_zone.rb +43 -0
  112. data/lib/vcenter_driver.rb +9 -22
  113. data/lib/vcenter_importer.rb +616 -0
  114. data/lib/vi_client.rb +281 -0
  115. data/lib/vi_helper.rb +312 -0
  116. data/lib/virtual_machine.rb +3477 -0
  117. data/lib/virtual_wire.rb +158 -0
  118. data/lib/vm_device.rb +80 -0
  119. data/lib/vm_disk.rb +202 -0
  120. data/lib/vm_folder.rb +69 -0
  121. data/lib/vm_helper.rb +30 -0
  122. data/lib/vm_monitor.rb +303 -0
  123. data/lib/vm_nic.rb +70 -0
  124. data/lib/vm_template.rb +1961 -0
  125. data/lib/vmm_importer.rb +121 -0
  126. metadata +101 -35
@@ -0,0 +1,1195 @@
1
+ # -------------------------------------------------------------------------- #
2
+ # Autogenerated from a Treetop grammar. Edits may be lost.
3
+
4
+
5
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
6
+ # #
7
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may #
8
+ # not use this file except in compliance with the License. You may obtain #
9
+ # a copy of the License at #
10
+ # #
11
+ # http://www.apache.org/licenses/LICENSE-2.0 #
12
+ # #
13
+ # Unless required by applicable law or agreed to in writing, software #
14
+ # distributed under the License is distributed on an "AS IS" BASIS, #
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
16
+ # See the License for the specific language governing permissions and #
17
+ # limitations under the License. #
18
+ #--------------------------------------------------------------------------- #
19
+
20
+ module ElasticityGrammar
21
+ include Treetop::Runtime
22
+
23
+ def root
24
+ @root ||= :expression
25
+ end
26
+
27
+ module Expression0
28
+ def space1
29
+ elements[0]
30
+ end
31
+
32
+ def exp
33
+ elements[1]
34
+ end
35
+
36
+ def space2
37
+ elements[2]
38
+ end
39
+ end
40
+
41
+ module Expression1
42
+ def result(role, vm_pool)
43
+ return exp.result(role, vm_pool)
44
+ end
45
+ end
46
+
47
+ def _nt_expression
48
+ start_index = index
49
+ if node_cache[:expression].has_key?(index)
50
+ cached = node_cache[:expression][index]
51
+ if cached
52
+ node_cache[:expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
53
+ @index = cached.interval.end
54
+ end
55
+ return cached
56
+ end
57
+
58
+ i0, s0 = index, []
59
+ r1 = _nt_space
60
+ s0 << r1
61
+ if r1
62
+ i2 = index
63
+ r3 = _nt_boolean_exp
64
+ if r3
65
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
66
+ r2 = r3
67
+ else
68
+ r4 = _nt_logic_cond
69
+ if r4
70
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
71
+ r2 = r4
72
+ else
73
+ @index = i2
74
+ r2 = nil
75
+ end
76
+ end
77
+ s0 << r2
78
+ if r2
79
+ r5 = _nt_space
80
+ s0 << r5
81
+ end
82
+ end
83
+ if s0.last
84
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
85
+ r0.extend(Expression0)
86
+ r0.extend(Expression1)
87
+ else
88
+ @index = i0
89
+ r0 = nil
90
+ end
91
+
92
+ node_cache[:expression][start_index] = r0
93
+
94
+ r0
95
+ end
96
+
97
+ module BooleanExp0
98
+ def left
99
+ elements[0]
100
+ end
101
+
102
+ def space1
103
+ elements[1]
104
+ end
105
+
106
+ def op
107
+ elements[2]
108
+ end
109
+
110
+ def space2
111
+ elements[3]
112
+ end
113
+
114
+ def right
115
+ elements[4]
116
+ end
117
+ end
118
+
119
+ module BooleanExp1
120
+ def result(role, vm_pool)
121
+ l_val, l_st = left.result(role, vm_pool)
122
+ r_val, r_st = right.result(role, vm_pool)
123
+
124
+ st = "#{l_st} #{op.text_value} #{r_st}"
125
+ val = l_val && r_val
126
+
127
+ return [val, st]
128
+ end
129
+ end
130
+
131
+ module BooleanExp2
132
+ def left
133
+ elements[0]
134
+ end
135
+
136
+ def space1
137
+ elements[1]
138
+ end
139
+
140
+ def op
141
+ elements[2]
142
+ end
143
+
144
+ def space2
145
+ elements[3]
146
+ end
147
+
148
+ def right
149
+ elements[4]
150
+ end
151
+ end
152
+
153
+ module BooleanExp3
154
+ def result(role, vm_pool)
155
+ l_val, l_st = left.result(role, vm_pool)
156
+ r_val, r_st = right.result(role, vm_pool)
157
+
158
+ st = "#{l_st} #{op.text_value} #{r_st}"
159
+ val = l_val || r_val
160
+
161
+ return [val, st]
162
+ end
163
+ end
164
+
165
+ def _nt_boolean_exp
166
+ start_index = index
167
+ if node_cache[:boolean_exp].has_key?(index)
168
+ cached = node_cache[:boolean_exp][index]
169
+ if cached
170
+ node_cache[:boolean_exp][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
171
+ @index = cached.interval.end
172
+ end
173
+ return cached
174
+ end
175
+
176
+ i0 = index
177
+ i1, s1 = index, []
178
+ r2 = _nt_logic_cond
179
+ s1 << r2
180
+ if r2
181
+ r3 = _nt_space
182
+ s1 << r3
183
+ if r3
184
+ i4 = index
185
+ if (match_len = has_terminal?('&&', false, index))
186
+ r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
187
+ @index += match_len
188
+ else
189
+ terminal_parse_failure('\'&&\'')
190
+ r5 = nil
191
+ end
192
+ if r5
193
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
194
+ r4 = r5
195
+ else
196
+ if (match_len = has_terminal?('&', false, index))
197
+ r6 = true
198
+ @index += match_len
199
+ else
200
+ terminal_parse_failure('\'&\'')
201
+ r6 = nil
202
+ end
203
+ if r6
204
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
205
+ r4 = r6
206
+ else
207
+ @index = i4
208
+ r4 = nil
209
+ end
210
+ end
211
+ s1 << r4
212
+ if r4
213
+ r7 = _nt_space
214
+ s1 << r7
215
+ if r7
216
+ r8 = _nt_expression
217
+ s1 << r8
218
+ end
219
+ end
220
+ end
221
+ end
222
+ if s1.last
223
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
224
+ r1.extend(BooleanExp0)
225
+ r1.extend(BooleanExp1)
226
+ else
227
+ @index = i1
228
+ r1 = nil
229
+ end
230
+ if r1
231
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
232
+ r0 = r1
233
+ else
234
+ i9, s9 = index, []
235
+ r10 = _nt_logic_cond
236
+ s9 << r10
237
+ if r10
238
+ r11 = _nt_space
239
+ s9 << r11
240
+ if r11
241
+ i12 = index
242
+ if (match_len = has_terminal?('||', false, index))
243
+ r13 = instantiate_node(SyntaxNode,input, index...(index + match_len))
244
+ @index += match_len
245
+ else
246
+ terminal_parse_failure('\'||\'')
247
+ r13 = nil
248
+ end
249
+ if r13
250
+ r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
251
+ r12 = r13
252
+ else
253
+ if (match_len = has_terminal?('|', false, index))
254
+ r14 = true
255
+ @index += match_len
256
+ else
257
+ terminal_parse_failure('\'|\'')
258
+ r14 = nil
259
+ end
260
+ if r14
261
+ r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
262
+ r12 = r14
263
+ else
264
+ @index = i12
265
+ r12 = nil
266
+ end
267
+ end
268
+ s9 << r12
269
+ if r12
270
+ r15 = _nt_space
271
+ s9 << r15
272
+ if r15
273
+ r16 = _nt_expression
274
+ s9 << r16
275
+ end
276
+ end
277
+ end
278
+ end
279
+ if s9.last
280
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
281
+ r9.extend(BooleanExp2)
282
+ r9.extend(BooleanExp3)
283
+ else
284
+ @index = i9
285
+ r9 = nil
286
+ end
287
+ if r9
288
+ r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
289
+ r0 = r9
290
+ else
291
+ @index = i0
292
+ r0 = nil
293
+ end
294
+ end
295
+
296
+ node_cache[:boolean_exp][start_index] = r0
297
+
298
+ r0
299
+ end
300
+
301
+ module LogicCond0
302
+ def left
303
+ elements[0]
304
+ end
305
+
306
+ def space1
307
+ elements[1]
308
+ end
309
+
310
+ def comp_op
311
+ elements[2]
312
+ end
313
+
314
+ def space2
315
+ elements[3]
316
+ end
317
+
318
+ def right
319
+ elements[4]
320
+ end
321
+ end
322
+
323
+ module LogicCond1
324
+ def result(role, vm_pool)
325
+ l_val, l_st = left.result(role, vm_pool)
326
+ r_val, r_st = right.result(role, vm_pool)
327
+
328
+ st = "#{l_st} #{comp_op.text_value} #{r_st}"
329
+
330
+ if l_val.nil? || r_val.nil?
331
+ # An attribute was not found, we return false instead
332
+ # of assuming a value of 0
333
+
334
+ val = false
335
+ else
336
+ val = comp_op.apply(l_val, r_val)
337
+ end
338
+
339
+ return [val, st]
340
+ end
341
+ end
342
+
343
+ module LogicCond2
344
+ def space
345
+ elements[1]
346
+ end
347
+
348
+ def expression
349
+ elements[2]
350
+ end
351
+ end
352
+
353
+ module LogicCond3
354
+ def result(role, vm_pool)
355
+ e_val, e_st = expression.result(role, vm_pool)
356
+
357
+ val = !e_val
358
+ st = "!#{e_st}"
359
+
360
+ return [val, st]
361
+ end
362
+ end
363
+
364
+ module LogicCond4
365
+ def space1
366
+ elements[1]
367
+ end
368
+
369
+ def expression
370
+ elements[2]
371
+ end
372
+
373
+ def space2
374
+ elements[3]
375
+ end
376
+
377
+ end
378
+
379
+ module LogicCond5
380
+ def result(role, vm_pool)
381
+ e_val, e_st = expression.result(role, vm_pool)
382
+
383
+ st = "(#{e_st})"
384
+
385
+ return [e_val, st]
386
+ end
387
+ end
388
+
389
+ def _nt_logic_cond
390
+ start_index = index
391
+ if node_cache[:logic_cond].has_key?(index)
392
+ cached = node_cache[:logic_cond][index]
393
+ if cached
394
+ node_cache[:logic_cond][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
395
+ @index = cached.interval.end
396
+ end
397
+ return cached
398
+ end
399
+
400
+ i0 = index
401
+ i1, s1 = index, []
402
+ r2 = _nt_operand
403
+ s1 << r2
404
+ if r2
405
+ r3 = _nt_space
406
+ s1 << r3
407
+ if r3
408
+ r4 = _nt_comp_op
409
+ s1 << r4
410
+ if r4
411
+ r5 = _nt_space
412
+ s1 << r5
413
+ if r5
414
+ r6 = _nt_operand
415
+ s1 << r6
416
+ end
417
+ end
418
+ end
419
+ end
420
+ if s1.last
421
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
422
+ r1.extend(LogicCond0)
423
+ r1.extend(LogicCond1)
424
+ else
425
+ @index = i1
426
+ r1 = nil
427
+ end
428
+ if r1
429
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
430
+ r0 = r1
431
+ else
432
+ i7, s7 = index, []
433
+ if (match_len = has_terminal?('!', false, index))
434
+ r8 = true
435
+ @index += match_len
436
+ else
437
+ terminal_parse_failure('\'!\'')
438
+ r8 = nil
439
+ end
440
+ s7 << r8
441
+ if r8
442
+ r9 = _nt_space
443
+ s7 << r9
444
+ if r9
445
+ r10 = _nt_expression
446
+ s7 << r10
447
+ end
448
+ end
449
+ if s7.last
450
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
451
+ r7.extend(LogicCond2)
452
+ r7.extend(LogicCond3)
453
+ else
454
+ @index = i7
455
+ r7 = nil
456
+ end
457
+ if r7
458
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
459
+ r0 = r7
460
+ else
461
+ i11, s11 = index, []
462
+ if (match_len = has_terminal?('(', false, index))
463
+ r12 = true
464
+ @index += match_len
465
+ else
466
+ terminal_parse_failure('\'(\'')
467
+ r12 = nil
468
+ end
469
+ s11 << r12
470
+ if r12
471
+ r13 = _nt_space
472
+ s11 << r13
473
+ if r13
474
+ r14 = _nt_expression
475
+ s11 << r14
476
+ if r14
477
+ r15 = _nt_space
478
+ s11 << r15
479
+ if r15
480
+ if (match_len = has_terminal?(')', false, index))
481
+ r16 = true
482
+ @index += match_len
483
+ else
484
+ terminal_parse_failure('\')\'')
485
+ r16 = nil
486
+ end
487
+ s11 << r16
488
+ end
489
+ end
490
+ end
491
+ end
492
+ if s11.last
493
+ r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
494
+ r11.extend(LogicCond4)
495
+ r11.extend(LogicCond5)
496
+ else
497
+ @index = i11
498
+ r11 = nil
499
+ end
500
+ if r11
501
+ r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
502
+ r0 = r11
503
+ else
504
+ @index = i0
505
+ r0 = nil
506
+ end
507
+ end
508
+ end
509
+
510
+ node_cache[:logic_cond][start_index] = r0
511
+
512
+ r0
513
+ end
514
+
515
+ module CompOp0
516
+ def apply(a,b)
517
+ a == b
518
+ end
519
+ end
520
+
521
+ module CompOp1
522
+ def apply(a,b)
523
+ a != b
524
+ end
525
+ end
526
+
527
+ module CompOp2
528
+ def apply(a,b)
529
+ a >= b
530
+ end
531
+ end
532
+
533
+ module CompOp3
534
+ def apply(a,b)
535
+ a > b
536
+ end
537
+ end
538
+
539
+ module CompOp4
540
+ def apply(a,b)
541
+ a <= b
542
+ end
543
+ end
544
+
545
+ module CompOp5
546
+ def apply(a,b)
547
+ a < b
548
+ end
549
+ end
550
+
551
+ def _nt_comp_op
552
+ start_index = index
553
+ if node_cache[:comp_op].has_key?(index)
554
+ cached = node_cache[:comp_op][index]
555
+ if cached
556
+ node_cache[:comp_op][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
557
+ @index = cached.interval.end
558
+ end
559
+ return cached
560
+ end
561
+
562
+ i0 = index
563
+ i1 = index
564
+ if (match_len = has_terminal?('==', false, index))
565
+ r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
566
+ @index += match_len
567
+ else
568
+ terminal_parse_failure('\'==\'')
569
+ r2 = nil
570
+ end
571
+ if r2
572
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
573
+ r1 = r2
574
+ r1.extend(CompOp0)
575
+ else
576
+ if (match_len = has_terminal?('=', false, index))
577
+ r3 = true
578
+ @index += match_len
579
+ else
580
+ terminal_parse_failure('\'=\'')
581
+ r3 = nil
582
+ end
583
+ if r3
584
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
585
+ r1 = r3
586
+ r1.extend(CompOp0)
587
+ else
588
+ @index = i1
589
+ r1 = nil
590
+ end
591
+ end
592
+ if r1
593
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
594
+ r0 = r1
595
+ else
596
+ i4 = index
597
+ if (match_len = has_terminal?('!=', false, index))
598
+ r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
599
+ @index += match_len
600
+ else
601
+ terminal_parse_failure('\'!=\'')
602
+ r5 = nil
603
+ end
604
+ if r5
605
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
606
+ r4 = r5
607
+ r4.extend(CompOp1)
608
+ else
609
+ if (match_len = has_terminal?('<>', false, index))
610
+ r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
611
+ @index += match_len
612
+ else
613
+ terminal_parse_failure('\'<>\'')
614
+ r6 = nil
615
+ end
616
+ if r6
617
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
618
+ r4 = r6
619
+ r4.extend(CompOp1)
620
+ else
621
+ @index = i4
622
+ r4 = nil
623
+ end
624
+ end
625
+ if r4
626
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
627
+ r0 = r4
628
+ else
629
+ if (match_len = has_terminal?('>=', false, index))
630
+ r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
631
+ r7.extend(CompOp2)
632
+ @index += match_len
633
+ else
634
+ terminal_parse_failure('\'>=\'')
635
+ r7 = nil
636
+ end
637
+ if r7
638
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
639
+ r0 = r7
640
+ else
641
+ if (match_len = has_terminal?('>', false, index))
642
+ r8 = instantiate_node(SyntaxNode,input, index...(index + match_len))
643
+ r8.extend(CompOp3)
644
+ @index += match_len
645
+ else
646
+ terminal_parse_failure('\'>\'')
647
+ r8 = nil
648
+ end
649
+ if r8
650
+ r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
651
+ r0 = r8
652
+ else
653
+ if (match_len = has_terminal?('<=', false, index))
654
+ r9 = instantiate_node(SyntaxNode,input, index...(index + match_len))
655
+ r9.extend(CompOp4)
656
+ @index += match_len
657
+ else
658
+ terminal_parse_failure('\'<=\'')
659
+ r9 = nil
660
+ end
661
+ if r9
662
+ r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
663
+ r0 = r9
664
+ else
665
+ if (match_len = has_terminal?('<', false, index))
666
+ r10 = instantiate_node(SyntaxNode,input, index...(index + match_len))
667
+ r10.extend(CompOp5)
668
+ @index += match_len
669
+ else
670
+ terminal_parse_failure('\'<\'')
671
+ r10 = nil
672
+ end
673
+ if r10
674
+ r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
675
+ r0 = r10
676
+ else
677
+ @index = i0
678
+ r0 = nil
679
+ end
680
+ end
681
+ end
682
+ end
683
+ end
684
+ end
685
+
686
+ node_cache[:comp_op][start_index] = r0
687
+
688
+ r0
689
+ end
690
+
691
+ module Operand0
692
+ def result
693
+ number.result(role)
694
+ end
695
+ end
696
+
697
+ module Operand1
698
+ def result
699
+ variable.result(role)
700
+ end
701
+ end
702
+
703
+ def _nt_operand
704
+ start_index = index
705
+ if node_cache[:operand].has_key?(index)
706
+ cached = node_cache[:operand][index]
707
+ if cached
708
+ node_cache[:operand][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
709
+ @index = cached.interval.end
710
+ end
711
+ return cached
712
+ end
713
+
714
+ i0 = index
715
+ r1 = _nt_number
716
+ if r1
717
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
718
+ r0 = r1
719
+ else
720
+ r2 = _nt_variable
721
+ if r2
722
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
723
+ r0 = r2
724
+ else
725
+ @index = i0
726
+ r0 = nil
727
+ end
728
+ end
729
+
730
+ node_cache[:operand][start_index] = r0
731
+
732
+ r0
733
+ end
734
+
735
+ module Number0
736
+ end
737
+
738
+ module Number1
739
+ def result(role, _vm_pool = nil)
740
+ val = text_value.to_f
741
+ st = val.to_s
742
+
743
+ return [val, st]
744
+ end
745
+ end
746
+
747
+ module Number2
748
+ end
749
+
750
+ module Number3
751
+ def result(role, _vm_pool = nil)
752
+ val = text_value.to_i
753
+ st = val.to_s
754
+
755
+ return [val, st]
756
+ end
757
+ end
758
+
759
+ def _nt_number
760
+ start_index = index
761
+ if node_cache[:number].has_key?(index)
762
+ cached = node_cache[:number][index]
763
+ if cached
764
+ node_cache[:number][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
765
+ @index = cached.interval.end
766
+ end
767
+ return cached
768
+ end
769
+
770
+ i0 = index
771
+ i1, s1 = index, []
772
+ if (match_len = has_terminal?('-', false, index))
773
+ r3 = true
774
+ @index += match_len
775
+ else
776
+ terminal_parse_failure('\'-\'')
777
+ r3 = nil
778
+ end
779
+ if r3
780
+ r2 = r3
781
+ else
782
+ r2 = instantiate_node(SyntaxNode,input, index...index)
783
+ end
784
+ s1 << r2
785
+ if r2
786
+ s4, i4 = [], index
787
+ loop do
788
+ if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index)
789
+ r5 = true
790
+ @index += 1
791
+ else
792
+ terminal_parse_failure('[0-9]')
793
+ r5 = nil
794
+ end
795
+ if r5
796
+ s4 << r5
797
+ else
798
+ break
799
+ end
800
+ end
801
+ if s4.empty?
802
+ @index = i4
803
+ r4 = nil
804
+ else
805
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
806
+ end
807
+ s1 << r4
808
+ if r4
809
+ if (match_len = has_terminal?('.', false, index))
810
+ r6 = true
811
+ @index += match_len
812
+ else
813
+ terminal_parse_failure('\'.\'')
814
+ r6 = nil
815
+ end
816
+ s1 << r6
817
+ if r6
818
+ s7, i7 = [], index
819
+ loop do
820
+ if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index)
821
+ r8 = true
822
+ @index += 1
823
+ else
824
+ terminal_parse_failure('[0-9]')
825
+ r8 = nil
826
+ end
827
+ if r8
828
+ s7 << r8
829
+ else
830
+ break
831
+ end
832
+ end
833
+ if s7.empty?
834
+ @index = i7
835
+ r7 = nil
836
+ else
837
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
838
+ end
839
+ s1 << r7
840
+ end
841
+ end
842
+ end
843
+ if s1.last
844
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
845
+ r1.extend(Number0)
846
+ r1.extend(Number1)
847
+ else
848
+ @index = i1
849
+ r1 = nil
850
+ end
851
+ if r1
852
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
853
+ r0 = r1
854
+ else
855
+ i9, s9 = index, []
856
+ if (match_len = has_terminal?('-', false, index))
857
+ r11 = true
858
+ @index += match_len
859
+ else
860
+ terminal_parse_failure('\'-\'')
861
+ r11 = nil
862
+ end
863
+ if r11
864
+ r10 = r11
865
+ else
866
+ r10 = instantiate_node(SyntaxNode,input, index...index)
867
+ end
868
+ s9 << r10
869
+ if r10
870
+ s12, i12 = [], index
871
+ loop do
872
+ if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index)
873
+ r13 = true
874
+ @index += 1
875
+ else
876
+ terminal_parse_failure('[0-9]')
877
+ r13 = nil
878
+ end
879
+ if r13
880
+ s12 << r13
881
+ else
882
+ break
883
+ end
884
+ end
885
+ if s12.empty?
886
+ @index = i12
887
+ r12 = nil
888
+ else
889
+ r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
890
+ end
891
+ s9 << r12
892
+ end
893
+ if s9.last
894
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
895
+ r9.extend(Number2)
896
+ r9.extend(Number3)
897
+ else
898
+ @index = i9
899
+ r9 = nil
900
+ end
901
+ if r9
902
+ r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
903
+ r0 = r9
904
+ else
905
+ @index = i0
906
+ r0 = nil
907
+ end
908
+ end
909
+
910
+ node_cache[:number][start_index] = r0
911
+
912
+ r0
913
+ end
914
+
915
+ module Variable0
916
+ end
917
+
918
+ module Variable1
919
+ end
920
+
921
+ module Variable2
922
+ end
923
+
924
+ module Variable3
925
+
926
+ def result(role, vm_pool)
927
+ nodes = role.info_nodes(vm_pool)
928
+ total = 0
929
+ n_nodes = 0
930
+ att = text_value.upcase
931
+
932
+ nodes.each { |node|
933
+ if node && node['vm_info']
934
+
935
+ vm_state = node['vm_info']['VM']['STATE']
936
+ lcm_state = node['vm_info']['VM']['LCM_STATE']
937
+
938
+ # Use values from VMs in RUNNING only
939
+
940
+ if vm_state != '3' || lcm_state != '3'
941
+ next
942
+ end
943
+
944
+ value = nil
945
+ if node['vm_info']['VM']['USER_TEMPLATE'][att]
946
+ value = node['vm_info']['VM']['USER_TEMPLATE'][att]
947
+ elsif node['vm_info']['VM']['MONITORING'][att]
948
+ value = node['vm_info']['VM']['MONITORING'][att]
949
+ elsif node['vm_info']['VM']['TEMPLATE'][att]
950
+ value = node['vm_info']['VM']['TEMPLATE'][att]
951
+ elsif node['vm_info']['VM'][att]
952
+ value = node['vm_info']['VM'][att]
953
+ end
954
+
955
+ if value && value.respond_to?(:to_f)
956
+ total += value.to_f
957
+ n_nodes += 1
958
+ end
959
+ end
960
+ }
961
+
962
+ # The attribute wasn't found for any of the nodes
963
+ if n_nodes == 0
964
+ val = nil
965
+ st = "#{att}[--]"
966
+ else
967
+ val = ((total / n_nodes)*100).round/100.0
968
+ st = "#{att}[#{val.to_s}]"
969
+ end
970
+
971
+ return [val, st]
972
+ end
973
+ end
974
+
975
+ def _nt_variable
976
+ start_index = index
977
+ if node_cache[:variable].has_key?(index)
978
+ cached = node_cache[:variable][index]
979
+ if cached
980
+ node_cache[:variable][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
981
+ @index = cached.interval.end
982
+ end
983
+ return cached
984
+ end
985
+
986
+ i0 = index
987
+ i1, s1 = index, []
988
+ if (match_len = has_terminal?('"', false, index))
989
+ r2 = true
990
+ @index += match_len
991
+ else
992
+ terminal_parse_failure('\'"\'')
993
+ r2 = nil
994
+ end
995
+ s1 << r2
996
+ if r2
997
+ if has_terminal?(@regexps[gr = '\A[a-zA-Z]'] ||= Regexp.new(gr), :regexp, index)
998
+ r3 = true
999
+ @index += 1
1000
+ else
1001
+ terminal_parse_failure('[a-zA-Z]')
1002
+ r3 = nil
1003
+ end
1004
+ s1 << r3
1005
+ if r3
1006
+ s4, i4 = [], index
1007
+ loop do
1008
+ if has_terminal?(@regexps[gr = '\A[0-9a-zA-Z_]'] ||= Regexp.new(gr), :regexp, index)
1009
+ r5 = true
1010
+ @index += 1
1011
+ else
1012
+ terminal_parse_failure('[0-9a-zA-Z_]')
1013
+ r5 = nil
1014
+ end
1015
+ if r5
1016
+ s4 << r5
1017
+ else
1018
+ break
1019
+ end
1020
+ end
1021
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
1022
+ s1 << r4
1023
+ if r4
1024
+ if (match_len = has_terminal?('"', false, index))
1025
+ r6 = true
1026
+ @index += match_len
1027
+ else
1028
+ terminal_parse_failure('\'"\'')
1029
+ r6 = nil
1030
+ end
1031
+ s1 << r6
1032
+ end
1033
+ end
1034
+ end
1035
+ if s1.last
1036
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1037
+ r1.extend(Variable0)
1038
+ else
1039
+ @index = i1
1040
+ r1 = nil
1041
+ end
1042
+ if r1
1043
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1044
+ r0 = r1
1045
+ r0.extend(Variable3)
1046
+ else
1047
+ i7, s7 = index, []
1048
+ if (match_len = has_terminal?('\'', false, index))
1049
+ r8 = true
1050
+ @index += match_len
1051
+ else
1052
+ terminal_parse_failure('\'\\\'\'')
1053
+ r8 = nil
1054
+ end
1055
+ s7 << r8
1056
+ if r8
1057
+ if has_terminal?(@regexps[gr = '\A[a-zA-Z]'] ||= Regexp.new(gr), :regexp, index)
1058
+ r9 = true
1059
+ @index += 1
1060
+ else
1061
+ terminal_parse_failure('[a-zA-Z]')
1062
+ r9 = nil
1063
+ end
1064
+ s7 << r9
1065
+ if r9
1066
+ s10, i10 = [], index
1067
+ loop do
1068
+ if has_terminal?(@regexps[gr = '\A[0-9a-zA-Z_]'] ||= Regexp.new(gr), :regexp, index)
1069
+ r11 = true
1070
+ @index += 1
1071
+ else
1072
+ terminal_parse_failure('[0-9a-zA-Z_]')
1073
+ r11 = nil
1074
+ end
1075
+ if r11
1076
+ s10 << r11
1077
+ else
1078
+ break
1079
+ end
1080
+ end
1081
+ r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
1082
+ s7 << r10
1083
+ if r10
1084
+ if (match_len = has_terminal?('\'', false, index))
1085
+ r12 = true
1086
+ @index += match_len
1087
+ else
1088
+ terminal_parse_failure('\'\\\'\'')
1089
+ r12 = nil
1090
+ end
1091
+ s7 << r12
1092
+ end
1093
+ end
1094
+ end
1095
+ if s7.last
1096
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
1097
+ r7.extend(Variable1)
1098
+ else
1099
+ @index = i7
1100
+ r7 = nil
1101
+ end
1102
+ if r7
1103
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
1104
+ r0 = r7
1105
+ r0.extend(Variable3)
1106
+ else
1107
+ i13, s13 = index, []
1108
+ if has_terminal?(@regexps[gr = '\A[a-zA-Z]'] ||= Regexp.new(gr), :regexp, index)
1109
+ r14 = true
1110
+ @index += 1
1111
+ else
1112
+ terminal_parse_failure('[a-zA-Z]')
1113
+ r14 = nil
1114
+ end
1115
+ s13 << r14
1116
+ if r14
1117
+ s15, i15 = [], index
1118
+ loop do
1119
+ if has_terminal?(@regexps[gr = '\A[0-9a-zA-Z_]'] ||= Regexp.new(gr), :regexp, index)
1120
+ r16 = true
1121
+ @index += 1
1122
+ else
1123
+ terminal_parse_failure('[0-9a-zA-Z_]')
1124
+ r16 = nil
1125
+ end
1126
+ if r16
1127
+ s15 << r16
1128
+ else
1129
+ break
1130
+ end
1131
+ end
1132
+ r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
1133
+ s13 << r15
1134
+ end
1135
+ if s13.last
1136
+ r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
1137
+ r13.extend(Variable2)
1138
+ else
1139
+ @index = i13
1140
+ r13 = nil
1141
+ end
1142
+ if r13
1143
+ r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
1144
+ r0 = r13
1145
+ r0.extend(Variable3)
1146
+ else
1147
+ @index = i0
1148
+ r0 = nil
1149
+ end
1150
+ end
1151
+ end
1152
+
1153
+ node_cache[:variable][start_index] = r0
1154
+
1155
+ r0
1156
+ end
1157
+
1158
+ def _nt_space
1159
+ start_index = index
1160
+ if node_cache[:space].has_key?(index)
1161
+ cached = node_cache[:space][index]
1162
+ if cached
1163
+ node_cache[:space][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1164
+ @index = cached.interval.end
1165
+ end
1166
+ return cached
1167
+ end
1168
+
1169
+ s0, i0 = [], index
1170
+ loop do
1171
+ if (match_len = has_terminal?(' ', false, index))
1172
+ r1 = true
1173
+ @index += match_len
1174
+ else
1175
+ terminal_parse_failure('\' \'')
1176
+ r1 = nil
1177
+ end
1178
+ if r1
1179
+ s0 << r1
1180
+ else
1181
+ break
1182
+ end
1183
+ end
1184
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1185
+
1186
+ node_cache[:space][start_index] = r0
1187
+
1188
+ r0
1189
+ end
1190
+
1191
+ end
1192
+
1193
+ class ElasticityGrammarParser < Treetop::Runtime::CompiledParser
1194
+ include ElasticityGrammar
1195
+ end