Class: ComputeImages

Inherits:
Object
  • Object
show all
Defined in:
lib/danarchy_sys/openstack/compute/images.rb

Overview

OpenStack Image Management

Instance Method Summary collapse

Constructor Details

#initialize(compute, images) ⇒ ComputeImages

Returns a new instance of ComputeImages.



4
5
6
7
# File 'lib/danarchy_sys/openstack/compute/images.rb', line 4

def initialize(compute, images)
  @compute = compute
  @images = images
end

Instance Method Details

#all_images(*filter) ⇒ Object



9
10
11
12
# File 'lib/danarchy_sys/openstack/compute/images.rb', line 9

def all_images(*filter)
  filter = filter.shift || {'status' => ['ACTIVE']}
  @images = @compute.images(filters: filter)
end

#get_image_by_id(image_id) ⇒ Object



22
23
24
25
26
# File 'lib/danarchy_sys/openstack/compute/images.rb', line 22

def get_image_by_id(image_id)
  @images.collect do |i|
    i if i.id == image_id
  end.compact!.first
end

#get_image_by_name(image_name) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/danarchy_sys/openstack/compute/images.rb', line 14

def get_image_by_name(image_name)
  @images.collect do |i|
    next unless i.status == 'ACTIVE'
    next unless i.name == image_name
    i
  end.compact!.first
end