opennebula 5.12.9 → 6.0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ActionManager.rb +1 -1
- data/lib/CommandManager.rb +1 -1
- data/lib/DriverExecHelper.rb +44 -28
- data/lib/OpenNebulaDriver.rb +8 -4
- data/lib/VirtualMachineDriver.rb +9 -2
- data/lib/cloud/CloudClient.rb +3 -3
- data/lib/datacenter.rb +1257 -0
- data/lib/datastore.rb +1025 -0
- data/lib/distributed_firewall.rb +280 -0
- data/lib/file_helper.rb +370 -0
- data/lib/host.rb +1517 -0
- data/lib/logical_port.rb +50 -0
- data/lib/logical_switch.rb +77 -0
- data/lib/memoize.rb +74 -0
- data/lib/models.rb +32 -0
- data/lib/models/role.rb +1126 -0
- data/lib/models/service.rb +709 -0
- data/lib/network.rb +699 -0
- data/lib/nsx_client.rb +144 -0
- data/lib/nsx_component.rb +28 -0
- data/lib/nsx_constants.rb +149 -0
- data/lib/nsx_driver.rb +78 -0
- data/lib/nsx_error.rb +77 -0
- data/lib/nsx_rule.rb +193 -0
- data/lib/nsxt_client.rb +176 -0
- data/lib/nsxt_dfw.rb +196 -0
- data/lib/nsxt_logical_port.rb +94 -0
- data/lib/nsxt_rule.rb +188 -0
- data/lib/nsxt_tz.rb +38 -0
- data/lib/nsxv_client.rb +176 -0
- data/lib/nsxv_dfw.rb +202 -0
- data/lib/nsxv_logical_port.rb +107 -0
- data/lib/nsxv_rule.rb +172 -0
- data/lib/nsxv_tz.rb +41 -0
- data/lib/opaque_network.rb +134 -0
- data/lib/opennebula.rb +5 -2
- data/lib/opennebula/acl.rb +1 -1
- data/lib/opennebula/acl_pool.rb +1 -1
- data/lib/opennebula/client.rb +10 -2
- data/lib/opennebula/cluster.rb +1 -1
- data/lib/opennebula/cluster_pool.rb +1 -1
- data/lib/opennebula/datastore.rb +1 -1
- data/lib/opennebula/datastore_pool.rb +1 -1
- data/lib/opennebula/document.rb +8 -29
- data/lib/opennebula/document_json.rb +42 -12
- data/lib/opennebula/document_pool.rb +1 -1
- data/lib/opennebula/document_pool_json.rb +1 -1
- data/lib/opennebula/error.rb +4 -1
- data/lib/opennebula/flow.rb +23 -0
- data/lib/opennebula/flow/grammar.rb +1195 -0
- data/lib/opennebula/flow/service_pool.rb +190 -0
- data/lib/opennebula/flow/service_template.rb +608 -0
- data/lib/opennebula/flow/service_template_ext.rb +84 -0
- data/lib/opennebula/flow/service_template_pool.rb +32 -0
- data/lib/opennebula/flow/validator.rb +499 -0
- data/lib/opennebula/group.rb +1 -1
- data/lib/opennebula/group_pool.rb +1 -1
- data/lib/opennebula/hook.rb +5 -12
- data/lib/opennebula/hook_log.rb +1 -1
- data/lib/opennebula/hook_pool.rb +1 -1
- data/lib/opennebula/host.rb +1 -1
- data/lib/opennebula/host_pool.rb +1 -1
- data/lib/opennebula/image.rb +19 -14
- data/lib/opennebula/image_pool.rb +1 -1
- data/lib/opennebula/ldap_auth.rb +1 -1
- data/lib/opennebula/ldap_auth_spec.rb +1 -1
- data/lib/opennebula/lockable_ext.rb +163 -0
- data/lib/opennebula/marketplace.rb +1 -1
- data/lib/opennebula/marketplace_pool.rb +1 -1
- data/lib/opennebula/marketplaceapp.rb +9 -119
- data/lib/opennebula/marketplaceapp_ext.rb +586 -0
- data/lib/opennebula/marketplaceapp_pool.rb +1 -1
- data/lib/opennebula/oneflow_client.rb +4 -3
- data/lib/opennebula/pool.rb +6 -3
- data/lib/opennebula/pool_element.rb +1 -1
- data/lib/opennebula/security_group.rb +1 -1
- data/lib/opennebula/security_group_pool.rb +1 -1
- data/lib/opennebula/server_cipher_auth.rb +1 -1
- data/lib/opennebula/server_x509_auth.rb +1 -1
- data/lib/opennebula/ssh_auth.rb +1 -1
- data/lib/opennebula/system.rb +1 -1
- data/lib/opennebula/template.rb +4 -13
- data/lib/opennebula/template_ext.rb +342 -0
- data/lib/opennebula/template_pool.rb +1 -1
- data/lib/opennebula/user.rb +26 -2
- data/lib/opennebula/user_pool.rb +1 -1
- data/lib/opennebula/utils.rb +1 -1
- data/lib/opennebula/vdc.rb +1 -1
- data/lib/opennebula/vdc_pool.rb +1 -1
- data/lib/opennebula/virtual_machine.rb +26 -206
- data/lib/opennebula/virtual_machine_ext.rb +469 -0
- data/lib/opennebula/virtual_machine_pool.rb +1 -1
- data/lib/opennebula/virtual_network.rb +4 -10
- data/lib/opennebula/virtual_network_pool.rb +1 -1
- data/lib/opennebula/virtual_router.rb +4 -12
- data/lib/opennebula/virtual_router_pool.rb +1 -1
- data/lib/opennebula/vm_group.rb +4 -11
- data/lib/opennebula/vm_group_pool.rb +1 -1
- data/lib/opennebula/vntemplate.rb +4 -13
- data/lib/opennebula/vntemplate_pool.rb +1 -1
- data/lib/opennebula/wait_ext.rb +257 -0
- data/lib/opennebula/x509_auth.rb +1 -1
- data/lib/opennebula/xml_element.rb +1 -1
- data/lib/opennebula/xml_pool.rb +1 -1
- data/lib/opennebula/xml_utils.rb +1 -1
- data/lib/opennebula/zone.rb +1 -1
- data/lib/opennebula/zone_pool.rb +1 -1
- data/lib/rest_client.rb +201 -0
- data/lib/scripts_common.rb +183 -0
- data/lib/transport_zone.rb +43 -0
- data/lib/vcenter_driver.rb +13 -12
- data/lib/vcenter_importer.rb +616 -0
- data/lib/vi_client.rb +281 -0
- data/lib/vi_helper.rb +313 -0
- data/lib/virtual_machine.rb +3477 -0
- data/lib/virtual_wire.rb +158 -0
- data/lib/vm_device.rb +80 -0
- data/lib/vm_disk.rb +202 -0
- data/lib/vm_folder.rb +69 -0
- data/lib/vm_helper.rb +30 -0
- data/lib/vm_monitor.rb +303 -0
- data/lib/vm_nic.rb +70 -0
- data/lib/vm_template.rb +1963 -0
- data/lib/vmm_importer.rb +121 -0
- metadata +140 -27
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
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-
|
|
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,7 +14,7 @@
|
|
|
14
14
|
# limitations under the License. #
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
require 'opennebula/lockable_ext'
|
|
18
18
|
require 'opennebula/pool_element'
|
|
19
19
|
require 'ipaddr'
|
|
20
20
|
|
|
@@ -62,6 +62,8 @@ module OpenNebula
|
|
|
62
62
|
|
|
63
63
|
# Class constructor
|
|
64
64
|
def initialize(xml, client)
|
|
65
|
+
LockableExt.make_lockable(self, VN_METHODS)
|
|
66
|
+
|
|
65
67
|
super(xml,client)
|
|
66
68
|
end
|
|
67
69
|
|
|
@@ -338,14 +340,6 @@ module OpenNebula
|
|
|
338
340
|
return array
|
|
339
341
|
end
|
|
340
342
|
|
|
341
|
-
def lock(level)
|
|
342
|
-
return call(VN_METHODS[:lock], @pe_id, level)
|
|
343
|
-
end
|
|
344
|
-
|
|
345
|
-
def unlock()
|
|
346
|
-
return call(VN_METHODS[:unlock], @pe_id)
|
|
347
|
-
end
|
|
348
|
-
|
|
349
343
|
private
|
|
350
344
|
def set_publish(published)
|
|
351
345
|
group_u = published ? 1 : 0
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
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-
|
|
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,7 +14,7 @@
|
|
|
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
20
|
module OpenNebula
|
|
@@ -57,6 +57,8 @@ module OpenNebula
|
|
|
57
57
|
|
|
58
58
|
# Class constructor
|
|
59
59
|
def initialize(xml, client)
|
|
60
|
+
LockableExt.make_lockable(self, VIRTUAL_ROUTER_METHODS)
|
|
61
|
+
|
|
60
62
|
super(xml,client)
|
|
61
63
|
|
|
62
64
|
@client = client
|
|
@@ -177,16 +179,6 @@ module OpenNebula
|
|
|
177
179
|
return call(VIRTUAL_ROUTER_METHODS[:detachnic], @pe_id, nic_id)
|
|
178
180
|
end
|
|
179
181
|
|
|
180
|
-
# Lock a VRouter
|
|
181
|
-
def lock(level)
|
|
182
|
-
return call(VIRTUAL_ROUTER_METHODS[:lock], @pe_id, level)
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
# Unlock a VRouter
|
|
186
|
-
def unlock()
|
|
187
|
-
return call(VIRTUAL_ROUTER_METHODS[:unlock], @pe_id)
|
|
188
|
-
end
|
|
189
|
-
|
|
190
182
|
#######################################################################
|
|
191
183
|
# Helpers to get VirtualRouter information
|
|
192
184
|
#######################################################################
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
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 #
|
data/lib/opennebula/vm_group.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
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
|
|
@@ -48,6 +49,8 @@ module OpenNebula
|
|
|
48
49
|
|
|
49
50
|
# Class constructor
|
|
50
51
|
def initialize(xml, client)
|
|
52
|
+
LockableExt.make_lockable(self, VMGROUP_METHODS)
|
|
53
|
+
|
|
51
54
|
super(xml,client)
|
|
52
55
|
|
|
53
56
|
@client = client
|
|
@@ -131,16 +134,6 @@ module OpenNebula
|
|
|
131
134
|
return call(VMGROUP_METHODS[:rename], @pe_id, name)
|
|
132
135
|
end
|
|
133
136
|
|
|
134
|
-
# Lock a VMGroup
|
|
135
|
-
def lock(level)
|
|
136
|
-
return call(VMGROUP_METHODS[:lock], @pe_id, level)
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
# Unlock a VMGroup
|
|
140
|
-
def unlock()
|
|
141
|
-
return call(VMGROUP_METHODS[:unlock], @pe_id)
|
|
142
|
-
end
|
|
143
|
-
|
|
144
137
|
#######################################################################
|
|
145
138
|
# Helpers to get VMGroup information
|
|
146
139
|
#######################################################################
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
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-
|
|
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,7 +14,7 @@
|
|
|
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
20
|
module OpenNebula
|
|
@@ -23,7 +23,6 @@ module OpenNebula
|
|
|
23
23
|
# Constants and Class Methods
|
|
24
24
|
#######################################################################
|
|
25
25
|
|
|
26
|
-
|
|
27
26
|
TEMPLATE_METHODS = {
|
|
28
27
|
:allocate => "vntemplate.allocate",
|
|
29
28
|
:instantiate => "vntemplate.instantiate",
|
|
@@ -57,6 +56,8 @@ module OpenNebula
|
|
|
57
56
|
|
|
58
57
|
# Class constructor
|
|
59
58
|
def initialize(xml, client)
|
|
59
|
+
LockableExt.make_lockable(self, TEMPLATE_METHODS)
|
|
60
|
+
|
|
60
61
|
super(xml,client)
|
|
61
62
|
|
|
62
63
|
@client = client
|
|
@@ -231,16 +232,6 @@ module OpenNebula
|
|
|
231
232
|
self['UID'].to_i
|
|
232
233
|
end
|
|
233
234
|
|
|
234
|
-
# Lock a VNTemplate
|
|
235
|
-
def lock(level)
|
|
236
|
-
return call(TEMPLATE_METHODS[:lock], @pe_id, level)
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
# Unlock a VNTemplate
|
|
240
|
-
def unlock()
|
|
241
|
-
return call(TEMPLATE_METHODS[:unlock], @pe_id)
|
|
242
|
-
end
|
|
243
|
-
|
|
244
235
|
def public?
|
|
245
236
|
if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1"
|
|
246
237
|
true
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
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 #
|
|
@@ -0,0 +1,257 @@
|
|
|
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
|
+
|
|
18
|
+
require 'opennebula/host'
|
|
19
|
+
require 'opennebula/image'
|
|
20
|
+
require 'opennebula/virtual_machine'
|
|
21
|
+
|
|
22
|
+
module OpenNebula::WaitExtEvent
|
|
23
|
+
def wait_event(ctx, event, timeout)
|
|
24
|
+
subscriber = ctx.socket(ZMQ::SUB)
|
|
25
|
+
|
|
26
|
+
# Create subscriber
|
|
27
|
+
key = ''
|
|
28
|
+
content = ''
|
|
29
|
+
|
|
30
|
+
subscriber.setsockopt(ZMQ::RCVTIMEO, timeout * 1000)
|
|
31
|
+
subscriber.setsockopt(ZMQ::SUBSCRIBE, event)
|
|
32
|
+
subscriber.connect(@client.one_zmq)
|
|
33
|
+
|
|
34
|
+
rc = subscriber.recv_string(key)
|
|
35
|
+
rc = subscriber.recv_string(content) if rc != -1
|
|
36
|
+
|
|
37
|
+
return if ZMQ::Util.errno == ZMQ::EAGAIN || rc == -1
|
|
38
|
+
|
|
39
|
+
content
|
|
40
|
+
ensure
|
|
41
|
+
subscriber.setsockopt(ZMQ::UNSUBSCRIBE, event)
|
|
42
|
+
subscriber.close
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def wait2(sstr1, sstr2, timeout = 60, cycles = -1)
|
|
46
|
+
wfun = OpenNebula::WaitExt::WAIT[self.class]
|
|
47
|
+
|
|
48
|
+
# Start with a timeout of 2 seconds, to wait until the first
|
|
49
|
+
# info.
|
|
50
|
+
#
|
|
51
|
+
# The timeout is increased later, to avoid multiple info calls.
|
|
52
|
+
c_timeout = 2
|
|
53
|
+
recvs = 0
|
|
54
|
+
in_state = false
|
|
55
|
+
|
|
56
|
+
# Subscribe with timeout seconds
|
|
57
|
+
#
|
|
58
|
+
# Subscribe string:
|
|
59
|
+
#
|
|
60
|
+
# EVENT STATE element_name/state_str//self.ID
|
|
61
|
+
#
|
|
62
|
+
# - element_name: is the element name to find in the message
|
|
63
|
+
# - self.ID: returns element ID to find in the message
|
|
64
|
+
ctx = ZMQ::Context.new(1)
|
|
65
|
+
|
|
66
|
+
until in_state || (cycles != -1 && recvs >= cycles)
|
|
67
|
+
content = wait_event(ctx,
|
|
68
|
+
wfun[:event].call(self, sstr1, sstr2),
|
|
69
|
+
c_timeout)
|
|
70
|
+
|
|
71
|
+
if content && !content.empty?
|
|
72
|
+
in_state = wfun[:in_state_e].call(sstr1, sstr2, content)
|
|
73
|
+
|
|
74
|
+
break if in_state
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
c_timeout *= 10
|
|
78
|
+
c_timeout = timeout if c_timeout > timeout
|
|
79
|
+
|
|
80
|
+
rco = info
|
|
81
|
+
|
|
82
|
+
return false if OpenNebula.is_error?(rco)
|
|
83
|
+
|
|
84
|
+
in_state = wfun[:in_state].call(self, sstr1, sstr2)
|
|
85
|
+
|
|
86
|
+
recvs += 1
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
in_state
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
module OpenNebula::WaitExtPolling
|
|
95
|
+
def wait2(sstr1, sstr2, timeout = 60, cycles = -1)
|
|
96
|
+
wfun = OpenNebula::WaitExt::WAIT[self.class]
|
|
97
|
+
|
|
98
|
+
stime = 5
|
|
99
|
+
recvs = 0
|
|
100
|
+
cycles = timeout / stime
|
|
101
|
+
in_state = false
|
|
102
|
+
|
|
103
|
+
loop do
|
|
104
|
+
rco = info
|
|
105
|
+
|
|
106
|
+
return false if OpenNebula.is_error?(rco)
|
|
107
|
+
|
|
108
|
+
in_state = wfun[:in_state].call(self, sstr1, sstr2)
|
|
109
|
+
|
|
110
|
+
recvs += 1
|
|
111
|
+
|
|
112
|
+
break if in_state || recvs >= cycles
|
|
113
|
+
|
|
114
|
+
sleep stime
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
in_state
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Module to decorate Wait classes with the following methods:
|
|
123
|
+
# - Wait
|
|
124
|
+
#
|
|
125
|
+
# rubocop:disable Style/ClassAndModuleChildren
|
|
126
|
+
module OpenNebula::WaitExt
|
|
127
|
+
# Wait classes and the name published in ZMQ/STATE
|
|
128
|
+
WAIT = {
|
|
129
|
+
OpenNebula::Host => {
|
|
130
|
+
:event => lambda {|o, s1, _s2|
|
|
131
|
+
"EVENT STATE HOST/#{s1}//#{o['ID']}"
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
:in_state => lambda {|o, s1, _s2|
|
|
135
|
+
obj_s = Integer(o['STATE'])
|
|
136
|
+
inx_s = OpenNebula::Host::HOST_STATES.index(s1)
|
|
137
|
+
|
|
138
|
+
obj_s == inx_s
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
:in_state_e => lambda {|s1, _s2, content|
|
|
142
|
+
xml = Nokogiri::XML(Base64.decode64(content))
|
|
143
|
+
|
|
144
|
+
obj_s = Integer(xml.xpath('//HOST/STATE').text)
|
|
145
|
+
inx_s = OpenNebula::Host::HOST_STATES.index(s1)
|
|
146
|
+
|
|
147
|
+
obj_s == inx_s
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
OpenNebula::Image => {
|
|
152
|
+
:event => lambda {|o, s1, _s2|
|
|
153
|
+
"EVENT STATE IMAGE/#{s1}//#{o['ID']}"
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
:in_state => lambda {|o, s1, _s2|
|
|
157
|
+
obj_s = Integer(o['STATE'])
|
|
158
|
+
inx_s = OpenNebula::Image::IMAGE_STATES.index(s1)
|
|
159
|
+
|
|
160
|
+
obj_s == inx_s
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
:in_state_e => lambda {|s1, _s2, content|
|
|
164
|
+
xml = Nokogiri::XML(Base64.decode64(content))
|
|
165
|
+
|
|
166
|
+
obj_s = Integer(xml.xpath('//IMAGE/STATE').text)
|
|
167
|
+
inx_s = OpenNebula::Image::IMAGE_STATES.index(s1)
|
|
168
|
+
|
|
169
|
+
obj_s == inx_s
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
OpenNebula::VirtualMachine => {
|
|
174
|
+
:event => lambda {|o, s1, s2|
|
|
175
|
+
"EVENT STATE VM/#{s1}/#{s2}/#{o['ID']}"
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
:in_state => lambda {|o, s1, s2|
|
|
179
|
+
obj_s1 = Integer(o['STATE'])
|
|
180
|
+
inx_s1 = OpenNebula::VirtualMachine::VM_STATE.index(s1)
|
|
181
|
+
|
|
182
|
+
obj_s2 = Integer(o['LCM_STATE'])
|
|
183
|
+
inx_s2 = OpenNebula::VirtualMachine::LCM_STATE.index(s2)
|
|
184
|
+
|
|
185
|
+
obj_s1 == inx_s1 && obj_s2 == inx_s2
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
:in_state_e => lambda {|s1, s2, content|
|
|
189
|
+
xml = Nokogiri::XML(Base64.decode64(content))
|
|
190
|
+
|
|
191
|
+
obj_s1 = Integer(xml.xpath('//VM/STATE').text)
|
|
192
|
+
inx_s1 = OpenNebula::VirtualMachine::VM_STATE.index(s1)
|
|
193
|
+
|
|
194
|
+
obj_s2 = Integer(xml.xpath('//VM/LCM_STATE').text)
|
|
195
|
+
inx_s2 = OpenNebula::VirtualMachine::LCM_STATE.index(s2)
|
|
196
|
+
|
|
197
|
+
obj_s1 == inx_s1 && obj_s2 == inx_s2
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
def self.extend_object(obj)
|
|
203
|
+
wait?(obj)
|
|
204
|
+
|
|
205
|
+
class << obj
|
|
206
|
+
begin
|
|
207
|
+
require 'ffi-rzmq'
|
|
208
|
+
|
|
209
|
+
include OpenNebula::WaitExtEvent
|
|
210
|
+
rescue LoadError
|
|
211
|
+
include OpenNebula::WaitExtPolling
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
super
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Wait until the element reaches some specific state
|
|
219
|
+
# It waits until the state can be found in ZMQ event message
|
|
220
|
+
#
|
|
221
|
+
# @param state_str [String] State name to wait
|
|
222
|
+
# @param timeout [Integer] Number of seconds to timeout event recv
|
|
223
|
+
# @param cycles [Integer] Number of recv cycles. After each one
|
|
224
|
+
# object status is checked in OpenNebula.
|
|
225
|
+
# Use -1 (default) to wait forever.
|
|
226
|
+
def wait(state_str, timeout = 60, cycles = -1)
|
|
227
|
+
wait2(state_str, '', timeout, cycles)
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# Check if object has the method wait or not
|
|
231
|
+
#
|
|
232
|
+
# @param obj [Object or Class] Object to check class
|
|
233
|
+
def self.wait?(obj)
|
|
234
|
+
# Get obj class to find parents in wait class
|
|
235
|
+
# rubocop:disable Style/TernaryParentheses
|
|
236
|
+
(obj.is_a? Class) ? o_class = obj : o_class = obj.class
|
|
237
|
+
# rubocop:enable Style/TernaryParentheses
|
|
238
|
+
|
|
239
|
+
found = false
|
|
240
|
+
i_class = o_class
|
|
241
|
+
|
|
242
|
+
while i_class
|
|
243
|
+
if WAIT.keys.include?(i_class)
|
|
244
|
+
found = true
|
|
245
|
+
break
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
i_class = i_class.superclass
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
return if found
|
|
252
|
+
|
|
253
|
+
raise StandardError, "Cannot extend #{o_class} with WaitExt"
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
end
|
|
257
|
+
# rubocop:enable Style/ClassAndModuleChildren
|