opennebula 6.0.0.1 → 6.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/CommandManager.rb +13 -16
- data/lib/DriverExecHelper.rb +12 -22
- data/lib/cloud/CloudClient.rb +1 -1
- data/lib/datacenter.rb +71 -35
- data/lib/distributed_firewall.rb +17 -4
- data/lib/file_helper.rb +4 -0
- data/lib/host.rb +4 -4
- data/lib/models/service.rb +46 -4
- data/lib/network.rb +7 -1
- data/lib/nsx_client.rb +17 -4
- data/lib/nsx_constants.rb +18 -5
- data/lib/nsx_driver.rb +15 -2
- data/lib/nsx_rule.rb +17 -4
- data/lib/nsxt_client.rb +17 -4
- data/lib/nsxv_client.rb +17 -4
- data/lib/opennebula.rb +1 -1
- data/lib/opennebula/flow/service_template.rb +12 -2
- data/lib/opennebula/marketplace.rb +30 -2
- data/lib/opennebula/virtual_machine_ext.rb +35 -17
- data/lib/opennebula/wait_ext.rb +92 -78
- data/lib/scripts_common.rb +1 -10
- data/lib/vcenter_driver.rb +14 -12
- data/lib/vcenter_importer.rb +2 -2
- data/lib/virtual_machine.rb +50 -10
- data/lib/vm_monitor.rb +0 -2
- data/lib/vm_template.rb +6 -3
- data/lib/vmm_importer.rb +8 -0
- metadata +5 -5
data/lib/network.rb
CHANGED
@@ -534,7 +534,13 @@ module VCenterDriver
|
|
534
534
|
params[:one_host] = one_host
|
535
535
|
params[:args] = {}
|
536
536
|
|
537
|
-
selected =
|
537
|
+
selected, _networks_type, _hosts_list, _clusters_list =
|
538
|
+
dc_folder.process_network(
|
539
|
+
params,
|
540
|
+
{},
|
541
|
+
{},
|
542
|
+
{}
|
543
|
+
)
|
538
544
|
|
539
545
|
selected = selected[index]
|
540
546
|
|
data/lib/nsx_client.rb
CHANGED
@@ -29,14 +29,27 @@ module NSXDriver
|
|
29
29
|
unless defined?(GEMS_LOCATION)
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
# rubocop: disable all
|
33
|
+
# %%RUBYGEMS_SETUP_BEGIN%%
|
34
|
+
if File.directory?(GEMS_LOCATION)
|
35
|
+
real_gems_path = File.realpath(GEMS_LOCATION)
|
36
|
+
if !defined?(Gem) || Gem.path != [real_gems_path]
|
37
|
+
$LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
|
38
|
+
|
39
|
+
# Suppress warnings from Rubygems
|
40
|
+
# https://github.com/OpenNebula/one/issues/5379
|
41
|
+
begin
|
42
|
+
verb = $VERBOSE
|
43
|
+
$VERBOSE = nil
|
36
44
|
require 'rubygems'
|
37
45
|
Gem.use_paths(real_gems_path)
|
46
|
+
ensure
|
47
|
+
$VERBOSE = verb
|
38
48
|
end
|
39
49
|
end
|
50
|
+
end
|
51
|
+
# %%RUBYGEMS_SETUP_END%%
|
52
|
+
# rubocop: enable all
|
40
53
|
|
41
54
|
$LOAD_PATH << RUBY_LIB_LOCATION
|
42
55
|
|
data/lib/nsx_constants.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# a copy of the License at #
|
7
7
|
# #
|
8
8
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
-
#
|
9
|
+
# #
|
10
10
|
# Unless required by applicable law or agreed to in writing, software #
|
11
11
|
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
@@ -29,14 +29,27 @@ module NSXDriver
|
|
29
29
|
unless defined?(GEMS_LOCATION)
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
# rubocop: disable all
|
33
|
+
# %%RUBYGEMS_SETUP_BEGIN%%
|
34
|
+
if File.directory?(GEMS_LOCATION)
|
35
|
+
real_gems_path = File.realpath(GEMS_LOCATION)
|
36
|
+
if !defined?(Gem) || Gem.path != [real_gems_path]
|
37
|
+
$LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
|
38
|
+
|
39
|
+
# Suppress warnings from Rubygems
|
40
|
+
# https://github.com/OpenNebula/one/issues/5379
|
41
|
+
begin
|
42
|
+
verb = $VERBOSE
|
43
|
+
$VERBOSE = nil
|
36
44
|
require 'rubygems'
|
37
45
|
Gem.use_paths(real_gems_path)
|
46
|
+
ensure
|
47
|
+
$VERBOSE = verb
|
38
48
|
end
|
39
49
|
end
|
50
|
+
end
|
51
|
+
# %%RUBYGEMS_SETUP_END%%
|
52
|
+
# rubocop: enable all
|
40
53
|
|
41
54
|
$LOAD_PATH << RUBY_LIB_LOCATION
|
42
55
|
|
data/lib/nsx_driver.rb
CHANGED
@@ -36,14 +36,27 @@ end
|
|
36
36
|
|
37
37
|
ENV['LANG'] = 'C'
|
38
38
|
|
39
|
+
# rubocop: disable all
|
40
|
+
# %%RUBYGEMS_SETUP_BEGIN%%
|
39
41
|
if File.directory?(GEMS_LOCATION)
|
40
42
|
real_gems_path = File.realpath(GEMS_LOCATION)
|
41
43
|
if !defined?(Gem) || Gem.path != [real_gems_path]
|
42
44
|
$LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
|
43
|
-
|
44
|
-
|
45
|
+
|
46
|
+
# Suppress warnings from Rubygems
|
47
|
+
# https://github.com/OpenNebula/one/issues/5379
|
48
|
+
begin
|
49
|
+
verb = $VERBOSE
|
50
|
+
$VERBOSE = nil
|
51
|
+
require 'rubygems'
|
52
|
+
Gem.use_paths(real_gems_path)
|
53
|
+
ensure
|
54
|
+
$VERBOSE = verb
|
55
|
+
end
|
45
56
|
end
|
46
57
|
end
|
58
|
+
# %%RUBYGEMS_SETUP_END%%
|
59
|
+
# rubocop: enable all
|
47
60
|
|
48
61
|
$LOAD_PATH << LIB_LOCATION + '/ruby'
|
49
62
|
$LOAD_PATH << LIB_LOCATION + '/ruby/nsx_driver'
|
data/lib/nsx_rule.rb
CHANGED
@@ -33,14 +33,27 @@ module NSXDriver
|
|
33
33
|
unless defined?(GEMS_LOCATION)
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
# rubocop: disable all
|
37
|
+
# %%RUBYGEMS_SETUP_BEGIN%%
|
38
|
+
if File.directory?(GEMS_LOCATION)
|
39
|
+
real_gems_path = File.realpath(GEMS_LOCATION)
|
40
|
+
if !defined?(Gem) || Gem.path != [real_gems_path]
|
41
|
+
$LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
|
42
|
+
|
43
|
+
# Suppress warnings from Rubygems
|
44
|
+
# https://github.com/OpenNebula/one/issues/5379
|
45
|
+
begin
|
46
|
+
verb = $VERBOSE
|
47
|
+
$VERBOSE = nil
|
40
48
|
require 'rubygems'
|
41
49
|
Gem.use_paths(real_gems_path)
|
50
|
+
ensure
|
51
|
+
$VERBOSE = verb
|
42
52
|
end
|
43
53
|
end
|
54
|
+
end
|
55
|
+
# %%RUBYGEMS_SETUP_END%%
|
56
|
+
# rubocop: enable all
|
44
57
|
|
45
58
|
$LOAD_PATH << RUBY_LIB_LOCATION
|
46
59
|
|
data/lib/nsxt_client.rb
CHANGED
@@ -29,14 +29,27 @@ module NSXDriver
|
|
29
29
|
unless defined?(GEMS_LOCATION)
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
# rubocop: disable all
|
33
|
+
# %%RUBYGEMS_SETUP_BEGIN%%
|
34
|
+
if File.directory?(GEMS_LOCATION)
|
35
|
+
real_gems_path = File.realpath(GEMS_LOCATION)
|
36
|
+
if !defined?(Gem) || Gem.path != [real_gems_path]
|
37
|
+
$LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
|
38
|
+
|
39
|
+
# Suppress warnings from Rubygems
|
40
|
+
# https://github.com/OpenNebula/one/issues/5379
|
41
|
+
begin
|
42
|
+
verb = $VERBOSE
|
43
|
+
$VERBOSE = nil
|
36
44
|
require 'rubygems'
|
37
45
|
Gem.use_paths(real_gems_path)
|
46
|
+
ensure
|
47
|
+
$VERBOSE = verb
|
38
48
|
end
|
39
49
|
end
|
50
|
+
end
|
51
|
+
# %%RUBYGEMS_SETUP_END%%
|
52
|
+
# rubocop: enable all
|
40
53
|
|
41
54
|
$LOAD_PATH << RUBY_LIB_LOCATION
|
42
55
|
|
data/lib/nsxv_client.rb
CHANGED
@@ -29,14 +29,27 @@ module NSXDriver
|
|
29
29
|
unless defined?(GEMS_LOCATION)
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
# rubocop: disable all
|
33
|
+
# %%RUBYGEMS_SETUP_BEGIN%%
|
34
|
+
if File.directory?(GEMS_LOCATION)
|
35
|
+
real_gems_path = File.realpath(GEMS_LOCATION)
|
36
|
+
if !defined?(Gem) || Gem.path != [real_gems_path]
|
37
|
+
$LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
|
38
|
+
|
39
|
+
# Suppress warnings from Rubygems
|
40
|
+
# https://github.com/OpenNebula/one/issues/5379
|
41
|
+
begin
|
42
|
+
verb = $VERBOSE
|
43
|
+
$VERBOSE = nil
|
36
44
|
require 'rubygems'
|
37
45
|
Gem.use_paths(real_gems_path)
|
46
|
+
ensure
|
47
|
+
$VERBOSE = verb
|
38
48
|
end
|
39
49
|
end
|
50
|
+
end
|
51
|
+
# %%RUBYGEMS_SETUP_END%%
|
52
|
+
# rubocop: enable all
|
40
53
|
|
41
54
|
$LOAD_PATH << RUBY_LIB_LOCATION
|
42
55
|
|
data/lib/opennebula.rb
CHANGED
@@ -361,8 +361,8 @@ module OpenNebula
|
|
361
361
|
# exceeds the limit
|
362
362
|
new_name = "#{template.name}-#{name}"
|
363
363
|
|
364
|
-
if new_name.size >
|
365
|
-
new_name = "#{template.name[0..(
|
364
|
+
if new_name.size > 119
|
365
|
+
new_name = "#{template.name[0..(119 - name.size)]}-#{name}"
|
366
366
|
end
|
367
367
|
|
368
368
|
rc = template.clone(new_name, recursive)
|
@@ -451,6 +451,16 @@ module OpenNebula
|
|
451
451
|
validate_values(template)
|
452
452
|
end
|
453
453
|
|
454
|
+
def self.validate_role(template)
|
455
|
+
validator = Validator::Validator.new(
|
456
|
+
:default_values => true,
|
457
|
+
:delete_extra_properties => false,
|
458
|
+
:allow_extra_properties => true
|
459
|
+
)
|
460
|
+
|
461
|
+
validator.validate!(template, ROLE_SCHEMA)
|
462
|
+
end
|
463
|
+
|
454
464
|
def instantiate(merge_template)
|
455
465
|
rc = nil
|
456
466
|
|
@@ -29,7 +29,15 @@ module OpenNebula
|
|
29
29
|
:update => "market.update",
|
30
30
|
:chown => "market.chown",
|
31
31
|
:chmod => "market.chmod",
|
32
|
-
:rename => "market.rename"
|
32
|
+
:rename => "market.rename",
|
33
|
+
:enable => "market.enable"
|
34
|
+
}
|
35
|
+
|
36
|
+
MARKETPLACE_STATES=%w{ENABLED DISABLED}
|
37
|
+
|
38
|
+
SHORT_MARKETPLACE_STATES={
|
39
|
+
"ENABLED" => "on",
|
40
|
+
"DISABLED" => "off"
|
33
41
|
}
|
34
42
|
|
35
43
|
# Creates a MarketPlace description with just its identifier
|
@@ -130,13 +138,33 @@ module OpenNebula
|
|
130
138
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
131
139
|
# otherwise
|
132
140
|
def rename(name)
|
133
|
-
|
141
|
+
call(MARKETPLACE_METHODS[:rename], @pe_id, name)
|
142
|
+
end
|
143
|
+
|
144
|
+
# Enables this marketplace
|
145
|
+
def enable
|
146
|
+
call(MARKETPLACE_METHODS[:enable], @pe_id, true)
|
147
|
+
end
|
148
|
+
|
149
|
+
# Enables this marketplace
|
150
|
+
def disable
|
151
|
+
call(MARKETPLACE_METHODS[:enable], @pe_id, false)
|
134
152
|
end
|
135
153
|
|
136
154
|
# ---------------------------------------------------------------------
|
137
155
|
# Helpers to get information
|
138
156
|
# ---------------------------------------------------------------------
|
139
157
|
|
158
|
+
# Returns the state of the Zone (numeric value)
|
159
|
+
def state
|
160
|
+
self['STATE'].to_i
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns the state of the Zone (string value)
|
164
|
+
def state_str
|
165
|
+
MARKETPLACE_STATES[state]
|
166
|
+
end
|
167
|
+
|
140
168
|
# Returns whether or not the marketplace app with id 'id' is part of
|
141
169
|
# this marketplace
|
142
170
|
def contains(id)
|
@@ -267,17 +267,20 @@ module OpenNebula::VirtualMachineExt
|
|
267
267
|
# --------------------------------------------------------------
|
268
268
|
# Check backup consistency
|
269
269
|
# --------------------------------------------------------------
|
270
|
-
|
271
|
-
rc = info
|
272
|
-
raise rc.message if OpenNebula.is_error?(rc)
|
270
|
+
rc = info
|
273
271
|
|
274
|
-
|
272
|
+
raise rc.message if OpenNebula.is_error?(rc)
|
273
|
+
|
274
|
+
binfo.merge!(backup_info) do |key, old_val, new_val|
|
275
|
+
new_val.nil? ? old_val : new_val
|
275
276
|
end
|
276
277
|
|
277
278
|
raise 'No backup information' if binfo.nil?
|
278
279
|
|
279
280
|
raise 'No frequency defined' unless valid?(binfo[:freq])
|
280
281
|
|
282
|
+
raise 'No marketplace defined' unless valid?(binfo[:market])
|
283
|
+
|
281
284
|
return if Time.now.to_i - binfo[:last].to_i < binfo[:freq].to_i
|
282
285
|
|
283
286
|
# --------------------------------------------------------------
|
@@ -319,19 +322,12 @@ module OpenNebula::VirtualMachineExt
|
|
319
322
|
# --------------------------------------------------------------
|
320
323
|
# Cleanup
|
321
324
|
# --------------------------------------------------------------
|
322
|
-
logger
|
323
|
-
|
324
|
-
tmp.delete(true)
|
325
|
-
|
326
|
-
binfo[:apps].each do |id|
|
327
|
-
logger.info "Deleting applicance #{id}" if logger
|
328
|
-
|
329
|
-
papp = OpenNebula::MarketPlaceApp.new_with_id(id, @client)
|
330
|
-
|
331
|
-
papp.delete
|
332
|
-
end if !keep && binfo[:apps]
|
325
|
+
backup_cleanup(keep, logger, binfo, tmp)
|
333
326
|
rescue Error, StandardError => e
|
327
|
+
backup_cleanup(keep, logger, binfo, tmp)
|
328
|
+
|
334
329
|
logger.fatal(e.inspect) if logger
|
330
|
+
|
335
331
|
raise
|
336
332
|
end
|
337
333
|
|
@@ -421,9 +417,9 @@ module OpenNebula::VirtualMachineExt
|
|
421
417
|
|
422
418
|
private
|
423
419
|
|
424
|
-
|
420
|
+
#-------------------------------------------------------------------
|
425
421
|
# Check an attribute is defined and valid
|
426
|
-
|
422
|
+
#-------------------------------------------------------------------
|
427
423
|
def valid?(att)
|
428
424
|
return false if att.nil?
|
429
425
|
|
@@ -454,6 +450,9 @@ module OpenNebula::VirtualMachineExt
|
|
454
450
|
binfo
|
455
451
|
end
|
456
452
|
|
453
|
+
#-------------------------------------------------------------------
|
454
|
+
# Generate backup information string
|
455
|
+
#-------------------------------------------------------------------
|
457
456
|
def backup_attr(binfo, ids)
|
458
457
|
'BACKUP=[' \
|
459
458
|
" MARKETPLACE_APP_IDS = \"#{ids.join(',')}\"," \
|
@@ -462,6 +461,25 @@ module OpenNebula::VirtualMachineExt
|
|
462
461
|
" MARKETPLACE_ID = \"#{binfo[:market]}\" ]"
|
463
462
|
end
|
464
463
|
|
464
|
+
#-------------------------------------------------------------------
|
465
|
+
# Cleanup backup leftovers in case of failure
|
466
|
+
#-------------------------------------------------------------------
|
467
|
+
def backup_cleanup(keep, logger, binfo, template)
|
468
|
+
if template
|
469
|
+
logger.info "Deleting template #{template.id}" if logger
|
470
|
+
|
471
|
+
template.delete(true)
|
472
|
+
end
|
473
|
+
|
474
|
+
binfo[:apps].each do |id|
|
475
|
+
logger.info "Deleting applicance #{id}" if logger
|
476
|
+
|
477
|
+
papp = OpenNebula::MarketPlaceApp.new_with_id(id, @client)
|
478
|
+
|
479
|
+
papp.delete
|
480
|
+
end if !keep && binfo[:apps]
|
481
|
+
end
|
482
|
+
|
465
483
|
end
|
466
484
|
end
|
467
485
|
|
data/lib/opennebula/wait_ext.rb
CHANGED
@@ -14,107 +14,118 @@
|
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
|
-
|
18
17
|
require 'opennebula/host'
|
19
18
|
require 'opennebula/image'
|
20
19
|
require 'opennebula/virtual_machine'
|
21
20
|
|
22
|
-
module OpenNebula
|
23
|
-
def wait_event(ctx, event, timeout)
|
24
|
-
subscriber = ctx.socket(ZMQ::SUB)
|
21
|
+
module OpenNebula
|
25
22
|
|
26
|
-
|
27
|
-
|
28
|
-
content = ''
|
23
|
+
# Module to wait OpenNebula objects events using ZMQ
|
24
|
+
module WaitExtEvent
|
29
25
|
|
30
|
-
|
31
|
-
|
32
|
-
subscriber.connect(@client.one_zmq)
|
26
|
+
def wait_event(ctx, event, timeout)
|
27
|
+
subscriber = ctx.socket(ZMQ::SUB)
|
33
28
|
|
34
|
-
|
35
|
-
|
29
|
+
# Create subscriber
|
30
|
+
key = ''
|
31
|
+
content = ''
|
36
32
|
|
37
|
-
|
33
|
+
subscriber.setsockopt(ZMQ::RCVTIMEO, timeout * 1000)
|
34
|
+
subscriber.setsockopt(ZMQ::SUBSCRIBE, event)
|
35
|
+
subscriber.connect(@client.one_zmq)
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
subscriber.setsockopt(ZMQ::UNSUBSCRIBE, event)
|
42
|
-
subscriber.close
|
43
|
-
end
|
37
|
+
rc = subscriber.recv_string(key)
|
38
|
+
rc = subscriber.recv_string(content) if rc != -1
|
44
39
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
40
|
+
return if ZMQ::Util.errno == ZMQ::EAGAIN || rc == -1
|
41
|
+
|
42
|
+
content
|
43
|
+
ensure
|
44
|
+
subscriber.setsockopt(ZMQ::UNSUBSCRIBE, event)
|
45
|
+
subscriber.close
|
46
|
+
end
|
47
|
+
|
48
|
+
def wait2(sstr1, sstr2, timeout = 60, cycles = -1)
|
49
|
+
wfun = OpenNebula::WaitExt::WAIT[self.class]
|
50
|
+
|
51
|
+
# Start with a timeout of 2 seconds, to wait until the first
|
52
|
+
# info.
|
53
|
+
#
|
54
|
+
# The timeout is increased later, to avoid multiple info calls.
|
55
|
+
c_timeout = 2
|
56
|
+
recvs = 0
|
57
|
+
in_state = false
|
58
|
+
|
59
|
+
# Subscribe with timeout seconds
|
60
|
+
#
|
61
|
+
# Subscribe string:
|
62
|
+
#
|
63
|
+
# EVENT STATE element_name/state_str//self.ID
|
64
|
+
#
|
65
|
+
# - element_name: is the element name to find in the message
|
66
|
+
# - self.ID: returns element ID to find in the message
|
67
|
+
ctx = ZMQ::Context.new(1)
|
68
|
+
|
69
|
+
until in_state || (cycles != -1 && recvs >= cycles)
|
70
|
+
content = wait_event(ctx,
|
71
|
+
wfun[:event].call(self, sstr1, sstr2),
|
72
|
+
c_timeout)
|
73
|
+
|
74
|
+
if content && !content.empty?
|
75
|
+
in_state = wfun[:in_state_e].call(sstr1, sstr2, content)
|
76
|
+
|
77
|
+
break if in_state
|
78
|
+
end
|
76
79
|
|
77
|
-
|
78
|
-
|
80
|
+
c_timeout *= 10
|
81
|
+
c_timeout = timeout if c_timeout > timeout
|
79
82
|
|
80
|
-
|
83
|
+
rco = info
|
81
84
|
|
82
|
-
|
85
|
+
return false if OpenNebula.is_error?(rco)
|
83
86
|
|
84
|
-
|
87
|
+
in_state = wfun[:in_state].call(self, sstr1, sstr2)
|
85
88
|
|
86
|
-
|
89
|
+
recvs += 1
|
90
|
+
end
|
91
|
+
|
92
|
+
in_state
|
87
93
|
end
|
88
94
|
|
89
|
-
in_state
|
90
95
|
end
|
91
96
|
|
92
97
|
end
|
93
98
|
|
94
|
-
module OpenNebula
|
95
|
-
|
96
|
-
|
99
|
+
module OpenNebula
|
100
|
+
|
101
|
+
# Module to wait OpenNebula objects events using polling
|
102
|
+
module WaitExtPolling
|
103
|
+
|
104
|
+
def wait2(sstr1, sstr2, timeout = 60, cycles = -1)
|
105
|
+
wfun = OpenNebula::WaitExt::WAIT[self.class]
|
106
|
+
|
107
|
+
stime = 5
|
108
|
+
recvs = 0
|
109
|
+
cycles = timeout / stime if cycles == -1
|
110
|
+
in_state = false
|
97
111
|
|
98
|
-
|
99
|
-
|
100
|
-
cycles = timeout / stime
|
101
|
-
in_state = false
|
112
|
+
loop do
|
113
|
+
rco = info
|
102
114
|
|
103
|
-
|
104
|
-
rco = info
|
115
|
+
return false if OpenNebula.is_error?(rco)
|
105
116
|
|
106
|
-
|
117
|
+
in_state = wfun[:in_state].call(self, sstr1, sstr2)
|
107
118
|
|
108
|
-
|
119
|
+
recvs += 1
|
109
120
|
|
110
|
-
|
121
|
+
break if in_state || recvs >= cycles
|
111
122
|
|
112
|
-
|
123
|
+
sleep stime
|
124
|
+
end
|
113
125
|
|
114
|
-
|
126
|
+
in_state
|
115
127
|
end
|
116
128
|
|
117
|
-
in_state
|
118
129
|
end
|
119
130
|
|
120
131
|
end
|
@@ -124,6 +135,7 @@ end
|
|
124
135
|
#
|
125
136
|
# rubocop:disable Style/ClassAndModuleChildren
|
126
137
|
module OpenNebula::WaitExt
|
138
|
+
|
127
139
|
# Wait classes and the name published in ZMQ/STATE
|
128
140
|
WAIT = {
|
129
141
|
OpenNebula::Host => {
|
@@ -176,7 +188,7 @@ module OpenNebula::WaitExt
|
|
176
188
|
},
|
177
189
|
|
178
190
|
:in_state => lambda {|o, s1, s2|
|
179
|
-
|
191
|
+
obj_s1 = Integer(o['STATE'])
|
180
192
|
inx_s1 = OpenNebula::VirtualMachine::VM_STATE.index(s1)
|
181
193
|
|
182
194
|
obj_s2 = Integer(o['LCM_STATE'])
|
@@ -203,13 +215,15 @@ module OpenNebula::WaitExt
|
|
203
215
|
wait?(obj)
|
204
216
|
|
205
217
|
class << obj
|
206
|
-
begin
|
207
|
-
require 'ffi-rzmq'
|
208
218
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
219
|
+
begin
|
220
|
+
require 'ffi-rzmq'
|
221
|
+
|
222
|
+
include OpenNebula::WaitExtEvent
|
223
|
+
rescue LoadError
|
224
|
+
include OpenNebula::WaitExtPolling
|
225
|
+
end
|
226
|
+
|
213
227
|
end
|
214
228
|
|
215
229
|
super
|