Sha256: 5a1ad53dd8a13f6b13603d09b1494b5ec8d78c22026cc697bb9f928fb141bbdd

Contents?: true

Size: 894 Bytes

Versions: 7

Compression:

Stored size: 894 Bytes

Contents

# OpenStack Image Management
class ComputeImages
  def initialize(compute)
    @compute = compute
  end
  
  def all_images
    @compute.images
  end

  def list_images
    images = all_images
    image_list = []

    # Get image names into array
    images.each do |i|
      next unless i.status == 'ACTIVE'
      image_list.push(i.name)
    end

    image_list
  end

  def get_image_by_name(image_name)
    images = all_images

    # Get image based on input image_name.
    image = 'nil'
    images.each do |i|
      next unless i.name == image_name
      next unless i.status == 'ACTIVE'
      image = i
    end

    image
  end

  def get_image_by_id(image_id)
    images = all_images

    # Get image based on input image_id.
    image = 'nil'
    images.each do |i|
      next unless i.id == image_id
      next unless i.status == 'ACTIVE'
      image = i
    end

    image
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
danarchy_sys-0.2.17 lib/danarchy_sys/openstack/compute/images.rb
danarchy_sys-0.2.16 lib/danarchy_sys/openstack/compute/images.rb
danarchy_sys-0.2.15 lib/danarchy_sys/openstack/compute/images.rb
danarchy_sys-0.2.14 lib/danarchy_sys/openstack/compute/images.rb
danarchy_sys-0.2.12 lib/danarchy_sys/openstack/compute/images.rb
danarchy_sys-0.2.11 lib/danarchy_sys/openstack/compute/images.rb
danarchy_sys-0.2.10 lib/danarchy_sys/openstack/compute/images.rb