Sha256: 498d2c667ffefcf35b29d1a4c439e79c9dffbc4a25fe30d50a5213288574e2ca

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 KB

Contents

module NexusSW
  module LXD
    class Driver
      module Mixins
        module Helpers
          module WaitMixin
            def check_for_ip(driver, container_name)
              cc = driver.container(container_name)
              state = driver.container_state(container_name)
              cc[:expanded_devices].each do |nic, data|
                next unless data[:type] == 'nic'
                state[:network][nic][:addresses].each do |address|
                  return address[:address] if address[:family] == 'inet' && address[:address] && !address[:address].empty?
                end
              end
              nil
            end

            def wait_for(container_name, what, timeout = 60)
              Timeout.timeout timeout do
                loop do
                  retval = nil
                  case what
                  when :ip
                    retval = check_for_ip(self, container_name)
                  else
                    raise 'unrecognized option'
                  end
                  return retval if retval
                  sleep 0.5
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
lxd-common-0.9.5 lib/nexussw/lxd/driver/mixins/helpers/wait.rb
lxd-common-0.9.4 lib/nexussw/lxd/driver/mixins/helpers/wait.rb
lxd-common-0.9.3 lib/nexussw/lxd/driver/mixins/helpers/wait.rb
lxd-common-0.9.2 lib/nexussw/lxd/driver/mixins/helpers/wait.rb
lxd-common-0.9.1 lib/nexussw/lxd/driver/mixins/helpers/wait.rb
lxd-common-0.9.0 lib/nexussw/lxd/driver/mixins/helpers/wait.rb
lxd-common-0.8.1 lib/nexussw/lxd/driver/mixins/helpers/wait.rb
lxd-common-0.8.0 lib/nexussw/lxd/driver/mixins/helpers/wait.rb
lxd-common-0.7.0 lib/nexussw/lxd/driver/mixins/helpers/wait.rb
lxd-common-0.6.0 lib/nexussw/lxd/driver/mixins/helpers/wait.rb
lxd-common-0.5.0 lib/nexussw/lxd/driver/mixins/helpers/wait.rb