module OpenNebula::WaitExt
Module to decorate Wait classes with the following methods:
- Wait
rubocop:disable Style/ClassAndModuleChildren
Constants
- WAIT
-
Wait classes and the name published in ZMQ/STATE
Public Class Methods
Source
# File lib/opennebula/wait_ext.rb, line 236 def self.extend_object(obj) wait?(obj) class << obj begin require 'ffi-rzmq' include OpenNebula::WaitExtEvent rescue LoadError include OpenNebula::WaitExtPolling end end super end
Calls superclass method
Source
# File lib/opennebula/wait_ext.rb, line 269 def self.wait?(obj) # Get obj class to find parents in wait class # rubocop:disable Style/TernaryParentheses (obj.is_a? Class) ? o_class = obj : o_class = obj.class # rubocop:enable Style/TernaryParentheses found = false i_class = o_class while i_class if WAIT.keys.include?(i_class) found = true break end i_class = i_class.superclass end return if found raise StandardError, "Cannot extend #{o_class} with WaitExt" end
Check if object has the method wait or not
@param obj [Object or Class] Object
to check class
Public Instance Methods
Source
# File lib/opennebula/wait_ext.rb, line 262 def wait(state_str, timeout = 60, cycles = -1) wait2(state_str, '', timeout, cycles) end
Wait until the element reaches some specific state It waits until the state can be found in ZMQ event message
@param state_str [String] State name to wait @param timeout [Integer] Number of seconds to timeout event recv @param cycles [Integer] Number of recv cycles. After each one
object status is checked in OpenNebula. Use -1 (default) to wait forever.