Module: OpenNebula::WaitExtPolling

Defined in:
lib/opennebula/wait_ext.rb

Overview

Module to wait OpenNebula objects events using polling

Instance Method Summary collapse

Instance Method Details

#wait2(sstr1, sstr2, timeout = 60, cycles = -1)) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# 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