module OpenNebula::WaitExtPolling

Module to wait OpenNebula objects events using polling

Public Instance Methods

wait2(sstr1, sstr2, timeout = 60, cycles = -1) click to toggle source
# File lib/opennebula/wait_ext.rb, line 104
def wait2(sstr1, sstr2, timeout = 60, cycles = -1)
    wfun = OpenNebula::WaitExt::WAIT[self.class]

    stime    = 5
    recvs    = 0
    cycles   = timeout / stime if cycles == -1
    in_state = false

    loop do
        rco = info

        return false if OpenNebula.is_error?(rco)

        in_state = wfun[:in_state].call(self, sstr1, sstr2)

        recvs += 1

        break if in_state || recvs >= cycles

        sleep stime
    end

    in_state
end