opennebula 6.3.80.pre → 6.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ActionManager.rb +1 -1
  3. data/lib/CommandManager.rb +1 -1
  4. data/lib/DriverExecHelper.rb +1 -1
  5. data/lib/OpenNebulaDriver.rb +1 -1
  6. data/lib/VirtualMachineDriver.rb +1 -1
  7. data/lib/cloud/CloudClient.rb +3 -3
  8. data/lib/datacenter.rb +1 -1
  9. data/lib/datastore.rb +1 -1
  10. data/lib/distributed_firewall.rb +1 -1
  11. data/lib/file_helper.rb +1 -1
  12. data/lib/host.rb +1 -1
  13. data/lib/logical_port.rb +1 -1
  14. data/lib/logical_switch.rb +1 -1
  15. data/lib/memoize.rb +1 -1
  16. data/lib/models/role.rb +74 -3
  17. data/lib/models/service.rb +122 -56
  18. data/lib/models.rb +1 -1
  19. data/lib/network.rb +1 -1
  20. data/lib/nsx_client.rb +1 -1
  21. data/lib/nsx_component.rb +1 -1
  22. data/lib/nsx_constants.rb +1 -1
  23. data/lib/nsx_driver.rb +1 -1
  24. data/lib/nsx_error.rb +1 -1
  25. data/lib/nsx_rule.rb +1 -1
  26. data/lib/nsxt_client.rb +1 -1
  27. data/lib/nsxt_dfw.rb +1 -1
  28. data/lib/nsxt_logical_port.rb +1 -1
  29. data/lib/nsxt_rule.rb +1 -1
  30. data/lib/nsxt_tz.rb +1 -1
  31. data/lib/nsxv_client.rb +1 -1
  32. data/lib/nsxv_dfw.rb +1 -1
  33. data/lib/nsxv_logical_port.rb +1 -1
  34. data/lib/nsxv_rule.rb +1 -1
  35. data/lib/nsxv_tz.rb +1 -1
  36. data/lib/opaque_network.rb +1 -1
  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 +1 -1
  45. data/lib/opennebula/document_json.rb +1 -1
  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 +1 -1
  49. data/lib/opennebula/flow/grammar.rb +1 -1
  50. data/lib/opennebula/flow/service_pool.rb +1 -1
  51. data/lib/opennebula/flow/service_template.rb +9 -4
  52. data/lib/opennebula/flow/service_template_ext.rb +1 -1
  53. data/lib/opennebula/flow/service_template_pool.rb +1 -1
  54. data/lib/opennebula/flow/validator.rb +1 -1
  55. data/lib/opennebula/flow.rb +1 -1
  56. data/lib/opennebula/group.rb +1 -1
  57. data/lib/opennebula/group_pool.rb +1 -1
  58. data/lib/opennebula/hook.rb +1 -1
  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 +1 -1
  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 +1 -1
  68. data/lib/opennebula/marketplace.rb +1 -1
  69. data/lib/opennebula/marketplace_pool.rb +1 -1
  70. data/lib/opennebula/marketplaceapp.rb +1 -1
  71. data/lib/opennebula/marketplaceapp_ext.rb +41 -14
  72. data/lib/opennebula/marketplaceapp_pool.rb +1 -1
  73. data/lib/opennebula/oneflow_client.rb +37 -25
  74. data/lib/opennebula/pool.rb +1 -1
  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 +1 -1
  83. data/lib/opennebula/template_ext.rb +1 -1
  84. data/lib/opennebula/template_pool.rb +1 -1
  85. data/lib/opennebula/user.rb +1 -1
  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 +5 -1
  91. data/lib/opennebula/virtual_machine_ext.rb +1 -1
  92. data/lib/opennebula/virtual_machine_pool.rb +1 -1
  93. data/lib/opennebula/virtual_network.rb +39 -2
  94. data/lib/opennebula/virtual_network_pool.rb +1 -1
  95. data/lib/opennebula/virtual_router.rb +1 -1
  96. data/lib/opennebula/virtual_router_pool.rb +1 -1
  97. data/lib/opennebula/vm_group.rb +1 -1
  98. data/lib/opennebula/vm_group_pool.rb +1 -1
  99. data/lib/opennebula/vntemplate.rb +1 -1
  100. data/lib/opennebula/vntemplate_pool.rb +1 -1
  101. data/lib/opennebula/wait_ext.rb +23 -1
  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 +2 -2
  109. data/lib/rest_client.rb +1 -1
  110. data/lib/scripts_common.rb +1 -1
  111. data/lib/transport_zone.rb +1 -1
  112. data/lib/vcenter_driver.rb +1 -1
  113. data/lib/vcenter_importer.rb +1 -12
  114. data/lib/vi_client.rb +1 -1
  115. data/lib/vi_helper.rb +1 -1
  116. data/lib/virtual_machine.rb +5 -2
  117. data/lib/virtual_wire.rb +1 -1
  118. data/lib/vm_disk.rb +1 -1
  119. data/lib/vm_folder.rb +1 -1
  120. data/lib/vm_helper.rb +1 -1
  121. data/lib/vm_monitor.rb +1 -1
  122. data/lib/vm_nic.rb +1 -1
  123. data/lib/vm_template.rb +32 -22
  124. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cbf5d10fd120f0a5f41abc59d743f38b1080002271e2ecbb131463a0e145cfba
4
- data.tar.gz: e3de025f53033170cea9ca52871dd4c0c2ef417d8ca0637b861fe9f495b9d011
3
+ metadata.gz: ae702b1caa32e4a526435ad37d29bb6cb7c4a246aa0b13d1355def1129ef6d9c
4
+ data.tar.gz: c162738a79f54ed6d5b19c1e286ba0bf56485205d5dc692af888b735955e585b
5
5
  SHA512:
6
- metadata.gz: d02e4f443085e4e797b09252a9583c7b59255335abcc51a3a50b0f4f82d2007ab17f7fc13df49bfc7214dd92ba68bc07f4282c019807a3237af1cb0675bf07b1
7
- data.tar.gz: 86fede32beb5965879433a8808237d17765da216125ef7b312649f6b6707a337fe3783c7cde67aa90cc9feef413c73d69817ff5cb7cee0dec42b3a91f3b5abb9
6
+ metadata.gz: 36ee51231d555025c271c2b67c71461c0d20760fc775e9598c02ad4f28bb281fa54a99c83e3c2ecee85f393702931871768e7e908d7667faf78dd01ca9d396a9
7
+ data.tar.gz: c44fdbd373155a95f6b6cad8c2b34d276b8f7149e52fb177e956844a7b68144c2573e262bccba4c1de378524355c24f41628cd534f04f8a1337c947115203c03
data/lib/ActionManager.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- */
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may */
4
4
  # not use this file except in compliance with the License. You may obtain */
5
5
  # a copy of the License at */
@@ -1,5 +1,5 @@
1
1
  # --------------------------------------------------------------------------
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems
2
+ # Copyright 2002-2022, 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,6 +1,6 @@
1
1
  # rubocop:disable Naming/FileName
2
2
  # -------------------------------------------------------------------------- #
3
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
4
4
  # #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
6
6
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
@@ -51,7 +51,7 @@ end
51
51
  module CloudClient
52
52
 
53
53
  # OpenNebula version
54
- VERSION = '6.3.80'
54
+ VERSION = '6.4.0'
55
55
 
56
56
  # #########################################################################
57
57
  # Default location for the authentication file
@@ -229,7 +229,7 @@ module CloudCLI
229
229
  def version_text
230
230
  version=<<EOT
231
231
  OpenNebula #{CloudClient::VERSION}
232
- Copyright 2002-2021, OpenNebula Project, OpenNebula Systems
232
+ Copyright 2002-2022, OpenNebula Project, OpenNebula Systems
233
233
 
234
234
  Licensed under the Apache License, Version 2.0 (the "License"); you may
235
235
  not use this file except in compliance with the License. You may obtain
data/lib/datacenter.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/datastore.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/file_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/host.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/logical_port.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/memoize.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/models/role.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
@@ -65,7 +65,8 @@ module OpenNebula
65
65
  'FAILED_DEPLOYING' => 7,
66
66
  'SCALING' => 8,
67
67
  'FAILED_SCALING' => 9,
68
- 'COOLDOWN' => 10
68
+ 'COOLDOWN' => 10,
69
+ 'HOLD' => 11
69
70
  }
70
71
 
71
72
  STATE_STR = %w[
@@ -80,6 +81,7 @@ module OpenNebula
80
81
  SCALING
81
82
  FAILED_SCALING
82
83
  COOLDOWN
84
+ HOLD
83
85
  ]
84
86
 
85
87
  RECOVER_DEPLOY_STATES = %w[
@@ -147,6 +149,7 @@ module OpenNebula
147
149
 
148
150
  @body['cooldown'] = @@default_cooldown if @body['cooldown'].nil?
149
151
  @body['nodes'] ||= []
152
+ @body['on_hold'] = false if @body['on_hold'].nil?
150
153
  end
151
154
 
152
155
  def name
@@ -195,12 +198,25 @@ module OpenNebula
195
198
  true
196
199
  end
197
200
 
201
+ def can_release?
202
+ state == STATE['HOLD']
203
+ end
204
+
198
205
  # Returns the role parents
199
206
  # @return [Array] the role parents
200
207
  def parents
201
208
  @body['parents'] || []
202
209
  end
203
210
 
211
+ def any_parent_on_hold?
212
+ parents.each do |parent|
213
+ next unless @service.roles[parent]
214
+
215
+ return true if @service.roles[parent].on_hold?
216
+ end
217
+ false
218
+ end
219
+
204
220
  # Returns the role cardinality
205
221
  # @return [Integer] the role cardinality
206
222
  def cardinality
@@ -357,6 +373,23 @@ module OpenNebula
357
373
  @body.delete('scale_way')
358
374
  end
359
375
 
376
+ # Returns the on_hold role option
377
+ # @return [true, false] true if the on_hold option is enabled
378
+ def on_hold?
379
+ @body['on_hold']
380
+ end
381
+
382
+ # Returns the on_hold service option
383
+ # @return [true, false] true if the on_hold option is enabled
384
+ def service_on_hold?
385
+ @service.on_hold?
386
+ end
387
+
388
+ # Set the on_hold vm option to true
389
+ def hold(hold)
390
+ @body['on_hold'] = hold
391
+ end
392
+
360
393
  # Retrieves the VM information for each Node in this Role. If a Node
361
394
  # is to be disposed and it is found in DONE, it will be cleaned
362
395
  #
@@ -436,7 +469,7 @@ module OpenNebula
436
469
  "template #{template_id}, with name #{vm_name}",
437
470
  @service.id
438
471
 
439
- vm_id = template.instantiate(vm_name, false, extra_template)
472
+ vm_id = template.instantiate(vm_name, on_hold?, extra_template)
440
473
 
441
474
  deployed_nodes << vm_id
442
475
 
@@ -546,6 +579,44 @@ module OpenNebula
546
579
  [true, nil]
547
580
  end
548
581
 
582
+ # Release all the nodes in this role
583
+ # @return [Array, Bool] true if all the VMs
584
+ # were released, false otherwise and Array with VMs released
585
+ def release
586
+ release_nodes = []
587
+ success = true
588
+
589
+ # Release all vms in the role
590
+ nodes.each do |node|
591
+ vm_id = node['deploy_id']
592
+
593
+ Log.debug(LOG_COMP,
594
+ "Role #{name}: Releasing VM #{vm_id}",
595
+ @service.id)
596
+
597
+ vm = OpenNebula::VirtualMachine.new_with_id(vm_id,
598
+ @service.client)
599
+ rc = vm.release
600
+
601
+ if OpenNebula.is_error?(rc)
602
+ msg = "Role #{name}: Release failed for VM #{vm_id}, " \
603
+ "#{rc.message}"
604
+
605
+ Log.error(LOG_COMP, msg, @service.id)
606
+ @service.log_error(msg)
607
+ success = false
608
+ else
609
+ Log.debug(LOG_COMP,
610
+ "Role #{name}: Release success for VM #{vm_id}",
611
+ @service.id)
612
+
613
+ release_nodes << vm_id
614
+ end
615
+ end
616
+
617
+ [release_nodes, success]
618
+ end
619
+
549
620
  # Schedule the given action on all the VMs that belong to the Role
550
621
  # @param [String] action one of the available SCHEDULE_ACTIONS
551
622
  # @param [Integer] period
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
@@ -24,17 +24,22 @@ module OpenNebula
24
24
  DOCUMENT_TYPE = 100
25
25
 
26
26
  STATE = {
27
- 'PENDING' => 0,
28
- 'DEPLOYING' => 1,
29
- 'RUNNING' => 2,
30
- 'UNDEPLOYING' => 3,
31
- 'WARNING' => 4,
32
- 'DONE' => 5,
33
- 'FAILED_UNDEPLOYING' => 6,
34
- 'FAILED_DEPLOYING' => 7,
35
- 'SCALING' => 8,
36
- 'FAILED_SCALING' => 9,
37
- 'COOLDOWN' => 10
27
+ 'PENDING' => 0,
28
+ 'DEPLOYING' => 1,
29
+ 'RUNNING' => 2,
30
+ 'UNDEPLOYING' => 3,
31
+ 'WARNING' => 4,
32
+ 'DONE' => 5,
33
+ 'FAILED_UNDEPLOYING' => 6,
34
+ 'FAILED_DEPLOYING' => 7,
35
+ 'SCALING' => 8,
36
+ 'FAILED_SCALING' => 9,
37
+ 'COOLDOWN' => 10,
38
+ 'DEPLOYING_NETS' => 11,
39
+ 'UNDEPLOYING_NETS' => 12,
40
+ 'FAILED_DEPLOYING_NETS' => 13,
41
+ 'FAILED_UNDEPLOYING_NETS' => 14,
42
+ 'HOLD' => 15
38
43
  }
39
44
 
40
45
  STATE_STR = %w[
@@ -49,6 +54,11 @@ module OpenNebula
49
54
  SCALING
50
55
  FAILED_SCALING
51
56
  COOLDOWN
57
+ DEPLOYING_NETS
58
+ UNDEPLOYING_NETS
59
+ FAILED_DEPLOYING_NETS
60
+ FAILED_UNDEPLOYING_NETS
61
+ HOLD
52
62
  ]
53
63
 
54
64
  TRANSIENT_STATES = %w[
@@ -56,12 +66,16 @@ module OpenNebula
56
66
  UNDEPLOYING
57
67
  SCALING
58
68
  COOLDOWN
69
+ DEPLOYING_NETS
70
+ UNDEPLOYING_NETS
59
71
  ]
60
72
 
61
73
  FAILED_STATES = %w[
62
74
  FAILED_DEPLOYING
63
75
  FAILED_UNDEPLOYING
64
76
  FAILED_SCALING
77
+ FAILED_DEPLOYING_NETS
78
+ FAILED_UNDEPLOYING_NETS
65
79
  ]
66
80
 
67
81
  RECOVER_DEPLOY_STATES = %w[
@@ -73,6 +87,7 @@ module OpenNebula
73
87
  RECOVER_UNDEPLOY_STATES = %w[
74
88
  FAILED_UNDEPLOYING
75
89
  UNDEPLOYING
90
+ FAILED_UNDEPLOYING_NETS
76
91
  ]
77
92
 
78
93
  RECOVER_SCALE_STATES = %w[
@@ -80,6 +95,13 @@ module OpenNebula
80
95
  SCALING
81
96
  ]
82
97
 
98
+ RECOVER_DEPLOY_NETS_STATES = %w[DEPLOYING_NETS FAILED_DEPLOYING_NETS]
99
+
100
+ RECOVER_UNDEPLOY_NETS_STATES = %w[
101
+ UNDEPLOYING_NETS
102
+ FAILED_UNDEPLOYING_NETS
103
+ ]
104
+
83
105
  # List of attributes that can't be changed in update operation
84
106
  #
85
107
  # custom_attrs: it only has sense when deploying, not in running
@@ -168,6 +190,14 @@ module OpenNebula
168
190
  RECOVER_SCALE_STATES.include? STATE_STR[state]
169
191
  end
170
192
 
193
+ def can_recover_deploy_nets?
194
+ RECOVER_DEPLOY_NETS_STATES.include?(STATE_STR[state])
195
+ end
196
+
197
+ def can_recover_undeploy_nets?
198
+ RECOVER_UNDEPLOY_NETS_STATES.include?(STATE_STR[state])
199
+ end
200
+
171
201
  # Return true if the service is running
172
202
  # @return true if the service is runnning, false otherwise
173
203
  def running?
@@ -188,6 +218,16 @@ module OpenNebula
188
218
  self['GID'].to_i
189
219
  end
190
220
 
221
+ # Returns the on_hold service option
222
+ # @return [true, false] true if the on_hold option is enabled
223
+ def on_hold?
224
+ @body['on_hold']
225
+ end
226
+
227
+ def hold?
228
+ state_str == 'HOLD'
229
+ end
230
+
191
231
  # Replaces this object's client with a new one
192
232
  # @param [OpenNebula::Client] owner_client the new client
193
233
  def replace_client(owner_client)
@@ -237,6 +277,36 @@ module OpenNebula
237
277
  true
238
278
  end
239
279
 
280
+ # Returns true if all the nodes are in hold state
281
+ # @return [true, false] true if all the nodes are in hold state
282
+ def all_roles_hold?
283
+ @roles.each do |_name, role|
284
+ if role.state != Role::STATE['HOLD']
285
+ return false
286
+ end
287
+ end
288
+
289
+ true
290
+ end
291
+
292
+ # Returns virtual networks IDs
293
+ # @return [Array] Array of integers containing the IDs
294
+ def networks(deploy)
295
+ ret = []
296
+
297
+ return ret unless @body['networks_values']
298
+
299
+ @body['networks_values'].each do |vnet|
300
+ vnet.each do |_, net|
301
+ next if net.keys.first == 'id' && !deploy
302
+
303
+ ret << net['id'].to_i
304
+ end
305
+ end
306
+
307
+ ret
308
+ end
309
+
240
310
  # Create a new service based on the template provided
241
311
  # @param [String] template_json
242
312
  # @return [nil, OpenNebula::Error] nil in case of success, Error
@@ -570,17 +640,22 @@ module OpenNebula
570
640
 
571
641
  return if body['networks_values'].nil?
572
642
 
573
- body['networks_values'].each do |net|
574
- rc = create_vnet(net) if net[net.keys[0]].key?('template_id')
575
-
576
- if OpenNebula.is_error?(rc)
577
- return rc
578
- end
643
+ body['networks_values'].each do |vnet|
644
+ vnet.each do |name, net|
645
+ key = net.keys.first
646
+
647
+ case key
648
+ when 'id'
649
+ next
650
+ when 'template_id'
651
+ rc = create_vnet(name, net)
652
+ when 'reserve_from'
653
+ rc = reserve(name, net)
654
+ end
579
655
 
580
- rc = reserve(net) if net[net.keys[0]].key?('reserve_from')
656
+ return rc if OpenNebula.is_error?(rc)
581
657
 
582
- if OpenNebula.is_error?(rc)
583
- return rc
658
+ net['id'] = rc
584
659
  end
585
660
  end if deploy
586
661
 
@@ -593,22 +668,25 @@ module OpenNebula
593
668
  end
594
669
 
595
670
  def delete_networks
596
- vnets = @body['networks_values']
671
+ vnets = @body['networks_values']
597
672
  vnets_failed = []
598
673
 
599
674
  return if vnets.nil?
600
675
 
601
676
  vnets.each do |vnet|
602
- next unless vnet[vnet.keys[0]].key?('template_id') ||
603
- vnet[vnet.keys[0]].key?('reserve_from')
677
+ vnet.each do |_, net|
678
+ key = net.keys.first
679
+
680
+ next unless %w[template_id reserve_from].include?(key)
604
681
 
605
- vnet_id = vnet[vnet.keys[0]]['id'].to_i
682
+ rc = OpenNebula::VirtualNetwork.new_with_id(
683
+ net['id'],
684
+ @client
685
+ ).delete
606
686
 
607
- rc = OpenNebula::VirtualNetwork
608
- .new_with_id(vnet_id, @client).delete
687
+ next unless OpenNebula.is_error?(rc)
609
688
 
610
- if OpenNebula.is_error?(rc)
611
- vnets_failed << vnet_id
689
+ vnets_failed << net['id']
612
690
  end
613
691
  end
614
692
 
@@ -677,44 +755,32 @@ module OpenNebula
677
755
  @body['log'] = @body['log'].last(MAX_LOG)
678
756
  end
679
757
 
680
- def create_vnet(net)
758
+ def create_vnet(name, net)
681
759
  extra = ''
760
+ extra = net['extra'] if net.key? 'extra'
682
761
 
683
- extra = net[net.keys[0]]['extra'] if net[net.keys[0]].key? 'extra'
684
-
685
- vntmpl_id = OpenNebula::VNTemplate
686
- .new_with_id(net[net.keys[0]]['template_id']
687
- .to_i, @client).instantiate(get_vnet_name(net), extra)
688
-
689
- # TODO, check which error should be returned
690
- return vntmpl_id if OpenNebula.is_error?(vntmpl_id)
691
-
692
- net[net.keys[0]]['id'] = vntmpl_id
693
-
694
- true
762
+ OpenNebula::VNTemplate.new_with_id(
763
+ net['template_id'].to_i,
764
+ @client
765
+ ).instantiate(get_vnet_name(name), extra)
695
766
  end
696
767
 
697
- def reserve(net)
698
- get_vnet_name(net)
699
- extra = net[net.keys[0]]['extra'] if net[net.keys[0]].key? 'extra'
768
+ def reserve(name, net)
769
+ extra = ''
770
+ extra = net['extra'] if net.key? 'extra'
700
771
 
701
772
  return false if !extra || extra.empty?
702
773
 
703
- extra.concat("\nNAME=\"#{get_vnet_name(net)}\"\n")
704
-
705
- reserve_id = OpenNebula::VirtualNetwork
706
- .new_with_id(net[net.keys[0]]['reserve_from']
707
- .to_i, @client).reserve_with_extra(extra)
708
-
709
- return reserve_id if OpenNebula.is_error?(reserve_id)
774
+ extra.concat("\nNAME=\"#{get_vnet_name(name)}\"\n")
710
775
 
711
- net[net.keys[0]]['id'] = reserve_id
712
-
713
- true
776
+ OpenNebula::VirtualNetwork.new_with_id(
777
+ net['reserve_from'].to_i,
778
+ @client
779
+ ).reserve_with_extra(extra)
714
780
  end
715
781
 
716
782
  def get_vnet_name(net)
717
- "#{net.keys[0]}-#{id}"
783
+ "#{net}-#{id}"
718
784
  end
719
785
 
720
786
  def resolve_attributes(template)
data/lib/models.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/network.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/nsx_client.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/nsx_component.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/nsx_constants.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/nsx_driver.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # ---------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/nsx_error.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/nsx_rule.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/nsxt_client.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #
data/lib/nsxt_dfw.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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-2021, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, 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 #