Sha256: f9023f032db6488a9b6c927127ba83e69ee635a87edbd50c22dafd82e169ef1f

Contents?: true

Size: 976 Bytes

Versions: 1

Compression:

Stored size: 976 Bytes

Contents

require 'test-unit-ext'
require 'test/unit'
gem 'openstack-compute', OPENSTACK_COMPUTE_VERSION
require 'openstack/compute'

module Torpedo
module Compute
module Helper

  def self.get_connection
    debug = false
    if ENV['DEBUG'] and ENV['DEBUG'] == 'true' then
        debug = true
    end
    OpenStack::Compute::Connection.new(:username => USERNAME, :api_key => API_KEY, :auth_url => API_URL, :is_debug => debug)
  end

  def self.get_image_ref(conn)

    image_ref = ENV['IMAGE_REF']
    image_name = ENV['IMAGE_NAME']

    if image_name and not image_name.empty? then
      images = conn.images.each do |image|
        if image[:name] == image_name then
          image_ref = image[:id]
        end
      end
    elsif image_ref.nil? or image_ref.empty? then
      #take the last image if IMAGE_REF and or IMAGE_NAME aren't set
      images = conn.images.sort{|x,y| x[:id] <=> y[:id]}
      image_ref = images.last[:id].to_s
    end

    image_ref

  end

end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
torpedo-1.0.0 lib/torpedo/compute/helper.rb