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,499 @@
1
+ # -------------------------------------------------------------------------- #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
+ # #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
+ # not use this file except in compliance with the License. You may obtain #
6
+ # 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
+ # limitations under the License. #
15
+ #--------------------------------------------------------------------------- #
16
+
17
+ require 'uri'
18
+
19
+ class Hash
20
+ # Returns a new hash containing the contents of other_hash and the
21
+ # contents of self. If the value for entries with duplicate keys
22
+ # is a Hash, it will be merged recursively, otherwise it will be that
23
+ # of other_hash.
24
+ #
25
+ # @param [Hash] other_hash
26
+ #
27
+ # @return [Hash] Containing the merged values
28
+ #
29
+ # @example Merging two hashes
30
+ # h1 = {:a => 3, {:b => 3, :c => 7}}
31
+ # h2 = {:a => 22, c => 4, {:b => 5}}
32
+ #
33
+ # h1.deep_merge(h2) #=> {:a => 22, c => 4, {:b => 5, :c => 7}}
34
+ def deep_merge(other_hash)
35
+ target = dup
36
+
37
+ other_hash.each do |hash_key, hash_value|
38
+ if hash_value.is_a?(Hash) and self[hash_key].is_a?(Hash)
39
+ target[hash_key] = self[hash_key].deep_merge(hash_value)
40
+ elsif hash_value.is_a?(Array) and self[hash_key].is_a?(Array)
41
+ hash_value.each_with_index { |elem, i|
42
+ if self[hash_key][i].is_a?(Hash) and elem.is_a?(Hash)
43
+ target[hash_key][i] = self[hash_key][i].deep_merge(elem)
44
+ else
45
+ target[hash_key] = hash_value
46
+ end
47
+ }
48
+ else
49
+ target[hash_key] = hash_value
50
+ end
51
+ end
52
+
53
+ target
54
+ end
55
+ end
56
+
57
+ module Validator
58
+
59
+ class ParseException < StandardError; end
60
+ class SchemaException < StandardError; end
61
+
62
+ class Validator
63
+
64
+ # @param [Hash] opts the options to validate a body
65
+ # @option opts [Boolean] :default_values Set default values if the schema
66
+ # specifies it (if true)
67
+ # @option opts [Boolean] :delete_extra_properties If the body contains properties
68
+ # not specified in the schema delete them from the body (if true)
69
+ # or raise an exception (if false)
70
+ # @option opts [Boolean] :allow_extra_properties Allow properties
71
+ # not specified in the schema
72
+ def initialize(opts={})
73
+ @opts = {
74
+ :default_values => true,
75
+ :delete_extra_properties => false,
76
+ :allow_extra_properties => false
77
+ }.merge(opts)
78
+ end
79
+
80
+ # Recursively validate and modify a JSON body based on a schema.
81
+ #
82
+ # @see http://tools.ietf.org/html/draft-zyp-json-schema-03
83
+ #
84
+ # @param [Hash, Array, String, nil] body JSON represented as Ruby objects
85
+ # @param [Hash] schema that will be used to validate
86
+ # @param [String] key of the body that will be validated in this step
87
+ #
88
+ # @return [Hash, Array, String, nil] The modified body
89
+ #
90
+ # @raise [SchemaException] If the schema is not correctly defined
91
+ # @raise [ParseException] if the body does not meet the schema definition
92
+ #
93
+ # @example Validate a User
94
+ # schema = {
95
+ # :type => :object,
96
+ # :properties => {
97
+ # 'username' => {
98
+ # :type => :string
99
+ # }
100
+ # }
101
+ # }
102
+ #
103
+ # hash = {
104
+ # 'username' => 'pepe'
105
+ # }
106
+ #
107
+ # Validator.validate!(hash, schema)
108
+ # #=> {'username' => 'pepe'}
109
+ #
110
+ # @note The parameter body will be modified
111
+ # @note Schema options supported
112
+ # :extends
113
+ # :type => [:object, :array, :string, :null]
114
+ #
115
+ def validate!(body, schema, key="")
116
+ if schema[:extends]
117
+ base_schema = schema.delete(:extends)
118
+ schema = base_schema.deep_merge(schema)
119
+ end
120
+
121
+ case schema[:type]
122
+ when :object then validate_object(body, schema, key)
123
+ when :array then validate_array(body, schema, key)
124
+ when :string then validate_string(body, schema, key)
125
+ when :integer then validate_integer(body, schema, key)
126
+ when :null then validate_null(body, schema, key)
127
+ when :boolean then validate_boolean(body, schema, key)
128
+ else raise SchemaException, "type #{schema[:type]} is not a valid type"
129
+ end
130
+ end
131
+
132
+ private
133
+
134
+ # Validate an object type
135
+ #
136
+ # @param [Hash] body to be validated
137
+ # @param [Hash] schema_object of the objectto validate the body
138
+ # @param [String] key of the body that will be validated in this step
139
+ #
140
+ # @return [Hash] The modified body
141
+ #
142
+ # @raise [ParseException] if the body does not meet the schema definition
143
+ #
144
+ # @example Validate with default values
145
+ # schema_body = {
146
+ # :type => :object,
147
+ # :properties => {
148
+ # 'username' => {
149
+ # :type => :string,
150
+ # :default => 'def'
151
+ # }
152
+ # }
153
+ #
154
+ # body = {}
155
+ #
156
+ # Validator.validate_object(body, schema_body)
157
+ # #=> {'username' => 'def'}
158
+ #
159
+ # @note The parameter body will be modified
160
+ # @note Schema options supported
161
+ # :properties
162
+ # :required
163
+ # :default
164
+ #
165
+ def validate_object(body, schema_object, key)
166
+ unless body.is_a?(Hash)
167
+ raise ParseException, "KEY: #{key} must be a Hash; SCHEMA:"
168
+ end
169
+
170
+ new_body = body.dup
171
+
172
+ schema_object[:properties].each{ |schema_key, schema_value|
173
+ body_value = new_body.delete(schema_key)
174
+
175
+ if body_value
176
+ body[schema_key] = validate!(body_value, schema_value,
177
+ schema_key)
178
+ else
179
+ if schema_value[:required]
180
+ raise ParseException, "KEY: '#{schema_key}' is required;"
181
+ end
182
+
183
+ if @opts[:default_values] && schema_value[:default]
184
+ body[schema_key] = schema_value[:default]
185
+ end
186
+ end
187
+ }
188
+
189
+ # raise error if body.keys is not empty
190
+ unless new_body.keys.empty?
191
+ if @opts[:delete_extra_properties]
192
+ new_body.keys.each{ |key|
193
+ body.delete(key)
194
+ }
195
+ else
196
+ if @opts[:allow_extra_properties]
197
+ return body
198
+ else
199
+ raise ParseException, "KEY: #{new_body.keys.join(', ')} not"\
200
+ " allowed;"
201
+ end
202
+ end
203
+ end
204
+
205
+ body
206
+ end
207
+
208
+ # Validate an array type
209
+ #
210
+ # @param [Array] body to be validated
211
+ # @param [Hash] schema_array of the object to validate the body
212
+ # @param [String] schema_key of the body that will be validated in this step
213
+ #
214
+ # @return [Hash] The modified body
215
+ #
216
+ # @raise [ParseException] if the body does not meet the schema definition
217
+ #
218
+ # @example Validate array
219
+ # schema = {
220
+ # :type => :array,
221
+ # :items => {
222
+ # :type => :string
223
+ # }
224
+ # }
225
+ #
226
+ # body = ['pepe', 'luis', 'juan']
227
+ #
228
+ # Validator.validate_array(body, schema)
229
+ # #=> 'username' => ['pepe', 'luis', 'juan']
230
+ #
231
+ # @note The parameter body will be modified
232
+ # @note Schema options supported
233
+ # :items
234
+ #
235
+ def validate_array(body, schema_array, schema_key)
236
+ if body.instance_of?(Array)
237
+ body.collect { |body_item|
238
+ validate!(body_item, schema_array[:items], schema_key)
239
+ }
240
+ else
241
+ raise ParseException, "KEY: '#{schema_key}' must be an Array;"
242
+ end
243
+ end
244
+
245
+ # Validate an integer type
246
+ #
247
+ # @param [Array] body to be validated
248
+ # @param [Hash] schema_array of the object to validate the body
249
+ # @param [String] schema_key of the body that will be validated in this step
250
+ #
251
+ # @return [Hash] The modified body
252
+ #
253
+ # @raise [ParseException] if the body does not meet the schema definition
254
+ #
255
+ # @example Validate array
256
+ # schema = {
257
+ # :type => :integer
258
+ # }
259
+ #
260
+ # body = 5
261
+ #
262
+ # Validator.validate_integer(body, schema)
263
+ # #=> 5
264
+ #
265
+ #
266
+ def validate_integer(body, schema_array, schema_key)
267
+ value = Integer(body)
268
+
269
+ if schema_array[:maximum]
270
+ excl = schema_array[:exclusiveMaximum]
271
+ max = schema_array[:maximum]
272
+ if !(excl ? value < max : value <= max)
273
+ raise ParseException, "KEY: '#{schema_key}' must be "\
274
+ "lower than #{excl ? '' : 'or equal to'} #{max};"
275
+ end
276
+ end
277
+
278
+ if schema_array[:minimum]
279
+ excl = schema_array[:exclusiveMinimum]
280
+ min = schema_array[:minimum]
281
+ if !(excl ? value > min : value >= min)
282
+ raise ParseException, "KEY: '#{schema_key}' must be "\
283
+ "greater than #{excl ? '' : 'or equal to'} #{min};"
284
+ end
285
+ end
286
+
287
+ value
288
+ rescue ArgumentError
289
+ raise ParseException, "KEY: '#{schema_key}' must be an Integer;"
290
+ end
291
+
292
+ # Validate an null type
293
+ #
294
+ # @param [nil] body to be validated
295
+ # @param [Hash] schema_null of the object to validate the body
296
+ # @param [String] schema_key of the body that will be validated in this step
297
+ #
298
+ # @return [nil]
299
+ #
300
+ # @raise [ParseException] if the body is not nil
301
+ #
302
+ # @example Validate array
303
+ # schema = {
304
+ # :type => :null
305
+ # }
306
+ #
307
+ # body = nil
308
+ #
309
+ # Validator.validate_null(body, schema)
310
+ # #=> nil
311
+ #
312
+ #
313
+ def validate_null(body, schema_null, schema_key)
314
+ if body != nil
315
+ raise ParseException, "KEY: '#{schema_key}' is not allowed;"
316
+ end
317
+ end
318
+
319
+ # Validate an boolean type
320
+ #
321
+ # @param [Object] body to be validated
322
+ # @param [Hash] schema_boolean of the object to validate the body
323
+ # @param [String] schema_key of the body that will be validated in this step
324
+ #
325
+ # @return [nil]
326
+ #
327
+ # @raise [ParseException] if the body is not a boolean
328
+ #
329
+ # @example Validate array
330
+ # schema = {
331
+ # :type => :boolean
332
+ # }
333
+ #
334
+ # body = true
335
+ #
336
+ # Validator.validate_boolean(body, schema)
337
+ # #=> nil
338
+ #
339
+ #
340
+ def validate_boolean(body, schema_boolean, schema_key)
341
+ if body != true && body != false
342
+ raise ParseException, "KEY: '#{schema_key}' is not allowed;"
343
+ end
344
+
345
+ body
346
+ end
347
+
348
+ # Validate an string type
349
+ #
350
+ # @param [String] body to be validated
351
+ # @param [Hash] schema_string of the object to validate the body
352
+ # @param [String] schema_key of the body that will be validated in this step
353
+ #
354
+ # @return [String] The modified body
355
+ #
356
+ # @raise [ParseException] if the body does not meet the schema definition
357
+ #
358
+ # @example Validate array
359
+ # schema = {
360
+ # :type => :string
361
+ # }
362
+ #
363
+ # body = "pepe"
364
+ #
365
+ # Validator.validate_string(body, schema)
366
+ # #=> "pepe"
367
+ #
368
+ # @note The parameter body will be modified
369
+ # @note Schema options supported
370
+ # :format
371
+ # :enum
372
+ # :regex
373
+ #
374
+ def validate_string(body, schema_string, schema_key)
375
+ if body.instance_of?(String)
376
+ if schema_string[:format]
377
+ check_format(body, schema_string, schema_key)
378
+ elsif schema_string[:enum]
379
+ check_enum(body, schema_string, schema_key)
380
+ elsif schema_string[:regex]
381
+ check_regex(body, schema_string, schema_key)
382
+ else
383
+ body
384
+ end
385
+ else
386
+ raise ParseException, "KEY: '#{schema_key}' must be a String;"
387
+ end
388
+ end
389
+
390
+ # Validate an string format
391
+ #
392
+ # @param [String] body_value to be validated
393
+ # @param [Hash] schema_string of the object to validate the body
394
+ # @param [String] schema_key of the body that will be validated in this step
395
+ #
396
+ # @return [String] The modified body
397
+ #
398
+ # @raise [ParseException] if the body does not meet the schema definition
399
+ #
400
+ # @example Validate array
401
+ # schema = {
402
+ # :type => :string,
403
+ # :format => :url
404
+ # }
405
+ #
406
+ # body = "http://localhost:4567"
407
+ #
408
+ # Validator.check_format(body, schema)
409
+ # #=> "http://localhost:4567"
410
+ #
411
+ # @note The parameter body will be modified
412
+ # @note Schema options supported
413
+ # :url
414
+ #
415
+ def check_format(body_value, schema_string, schema_key)
416
+ case schema_string[:format]
417
+ when :uri
418
+ begin
419
+ require 'uri'
420
+ uri = URI.parse(body_value)
421
+ rescue
422
+ raise ParseException, "KEY: '#{schema_key}' must be a valid URL;"
423
+ end
424
+
425
+ body_value
426
+ end
427
+
428
+ body_value
429
+ end
430
+
431
+ # Validate an string enum
432
+ #
433
+ # @param [String] body_value to be validated
434
+ # @param [Hash] schema_string of the object to validate the body
435
+ # @param [String] schema_key of the body that will be validated in this step
436
+ #
437
+ # @return [String] The modified body
438
+ #
439
+ # @raise [ParseException] if the body does not meet the schema definition
440
+ #
441
+ # @example Validate array
442
+ # schema = {
443
+ # :type => :string,
444
+ # :enum => ['juan', 'luis']
445
+ # }
446
+ #
447
+ # body = "juan"
448
+ #
449
+ # Validator.check_enum(body, schema)
450
+ # #=> "juan"
451
+ #
452
+ # @note The parameter body will be modified
453
+ # @note Schema options supported
454
+ # :enum
455
+ #
456
+ def check_enum(body_value, schema_string, schema_key)
457
+ if schema_string[:enum].include?(body_value)
458
+ body_value
459
+ else
460
+ raise ParseException, "KEY: '#{schema_key}' must be one of"\
461
+ " #{schema_string[:enum].join(', ')};"
462
+ end
463
+ end
464
+
465
+ # Validate an string regex
466
+ #
467
+ # @param [String] body_value to be validated
468
+ # @param [Hash] schema_string of the object to validate the body
469
+ # @param [String] schema_key of the body that will be validated in this step
470
+ #
471
+ # @return [String] The modified body
472
+ #
473
+ # @raise [ParseException] if the body does not meet the schema definition
474
+ #
475
+ # @example Validate array
476
+ # schema = {
477
+ # :type => :string,
478
+ # :regex => /^\w+$/
479
+ # }
480
+ #
481
+ # body = "juan"
482
+ #
483
+ # Validator.check_regex(body, schema)
484
+ # #=> "juan"
485
+ #
486
+ # @note The parameter body will be modified
487
+ # @note Schema options supported
488
+ # :enum
489
+ #
490
+ def check_regex(body_value, schema_string, schema_key)
491
+ if schema_string[:regex] =~ body_value
492
+ body_value
493
+ else
494
+ raise ParseException, "KEY: '#{schema_key}' must match regexp #{schema_string[:regex].inspect};"
495
+ end
496
+ end
497
+ end
498
+
499
+ end
@@ -0,0 +1,23 @@
1
+ # -------------------------------------------------------------------------- #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
+ # #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
+ # not use this file except in compliance with the License. You may obtain #
6
+ # 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
+ # limitations under the License. #
15
+ #--------------------------------------------------------------------------- #
16
+
17
+ require 'treetop'
18
+ require 'treetop/version'
19
+ require 'opennebula/flow/grammar'
20
+ require 'opennebula/flow/service_pool'
21
+ require 'opennebula/flow/service_template_pool'
22
+ require 'opennebula/flow/service_template'
23
+ require 'opennebula/flow/validator'
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -14,6 +14,7 @@
14
14
  # limitations under the License. #
15
15
  #--------------------------------------------------------------------------- #
16
16
 
17
+ require 'opennebula/lockable_ext'
17
18
  require 'opennebula/pool_element'
18
19
 
19
20
  module OpenNebula
@@ -54,13 +55,15 @@ module OpenNebula
54
55
 
55
56
  # Class constructor
56
57
  def initialize(xml, client)
58
+ LockableExt.make_lockable(self, HOOK_METHODS)
59
+
57
60
  super(xml, client)
58
61
 
59
62
  @client = client
60
63
  end
61
64
 
62
65
  #######################################################################
63
- # XML-RPC Methods for the Template Object
66
+ # XML-RPC Methods for the Hook Object
64
67
  #######################################################################
65
68
 
66
69
  # Retrieves the information of the given Hook.
@@ -146,16 +149,6 @@ module OpenNebula
146
149
  self['UID'].to_i
147
150
  end
148
151
 
149
- # Lock a Hook
150
- def lock(level)
151
- call(HOOK_METHODS[:lock], @pe_id, level)
152
- end
153
-
154
- # Unlock a Hook
155
- def unlock
156
- call(HOOK_METHODS[:unlock], @pe_id)
157
- end
158
-
159
152
  end
160
153
 
161
154
  end
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -14,8 +14,9 @@
14
14
  # limitations under the License. #
15
15
  #--------------------------------------------------------------------------- #
16
16
 
17
-
17
+ require 'opennebula/lockable_ext'
18
18
  require 'opennebula/pool_element'
19
+
19
20
  require 'fileutils'
20
21
 
21
22
  module OpenNebula
@@ -92,9 +93,9 @@ module OpenNebula
92
93
 
93
94
  # Class constructor
94
95
  def initialize(xml, client)
95
- super(xml,client)
96
+ LockableExt.make_lockable(self, IMAGE_METHODS)
96
97
 
97
- @client = client
98
+ super(xml,client)
98
99
  end
99
100
 
100
101
  #######################################################################
@@ -102,8 +103,8 @@ module OpenNebula
102
103
  #######################################################################
103
104
 
104
105
  # Retrieves the information of the given Image.
105
- def info()
106
- super(IMAGE_METHODS[:info], 'IMAGE')
106
+ def info(decrypt = false)
107
+ super(IMAGE_METHODS[:info], 'IMAGE', decrypt)
107
108
  end
108
109
 
109
110
  alias_method :info!, :info
@@ -298,14 +299,6 @@ module OpenNebula
298
299
  self['GID'].to_i
299
300
  end
300
301
 
301
- def lock(level)
302
- return call(IMAGE_METHODS[:lock], @pe_id, level)
303
- end
304
-
305
- def unlock()
306
- return call(IMAGE_METHODS[:unlock], @pe_id)
307
- end
308
-
309
302
  def public?
310
303
  if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1"
311
304
  true
@@ -314,6 +307,16 @@ module OpenNebula
314
307
  end
315
308
  end
316
309
 
310
+ def wait_state(state, timeout=120)
311
+ extend OpenNebula::WaitExt
312
+
313
+ rc = wait(state, timeout)
314
+
315
+ return Error.new("Timeout expired for state #{state}.") unless rc
316
+
317
+ true
318
+ end
319
+
317
320
  private
318
321
 
319
322
  def set_enabled(enabled)