Class: Fog::OpenStack::Image::V1::Images
- Inherits:
-
Collection
- Object
- Collection
- Collection
- Fog::OpenStack::Image::V1::Images
show all
- Defined in:
- lib/fog/openstack/image/v1/models/images.rb
Instance Attribute Summary
Attributes inherited from Collection
#response
Instance Method Summary
collapse
Methods inherited from Collection
#load_response
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
61
62
63
64
65
66
67
|
# File 'lib/fog/openstack/image/v1/models/images.rb', line 61
def method_missing(method_sym, *arguments, &block)
if method_sym.to_s =~ /^find_by_(.*)$/
load(service.list_public_images_detailed($1, arguments.first).body['images'])
else
super
end
end
|
Instance Method Details
#all(options = {}) ⇒ Object
11
12
13
|
# File 'lib/fog/openstack/image/v1/models/images.rb', line 11
def all(options = {})
load_response(service.list_public_images_detailed(options), 'images')
end
|
#destroy(id) ⇒ Object
56
57
58
59
|
# File 'lib/fog/openstack/image/v1/models/images.rb', line 56
def destroy(id)
image = find_by_id(id)
image.destroy
end
|
#details(options = {}, deprecated_query = nil) ⇒ Object
19
20
21
22
23
|
# File 'lib/fog/openstack/image/v1/models/images.rb', line 19
def details(options = {}, deprecated_query = nil)
Fog::Logger.deprecation("Calling OpenStack[:glance].images.details will be removed, "\
" call .images.all for detailed list.")
load_response(service.list_public_images_detailed(options, deprecated_query), 'images')
end
|
#find_attribute(attribute, value) ⇒ Object
77
78
79
80
|
# File 'lib/fog/openstack/image/v1/models/images.rb', line 77
def find_attribute(attribute, value)
attribute = attribute.to_s.gsub("find_by_", "")
load(service.list_public_images_detailed(attribute, value).body['images'])
end
|
#find_by_id(id) ⇒ Object
Also known as:
get
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/fog/openstack/image/v1/models/images.rb', line 25
def find_by_id(id)
marker = 'X-Image-Meta-'
property_marker = 'X-Image-Meta-Property-'
= service.get_image_by_id(id)..select { |h, _| h.start_with?(marker) }
custom_properties, params = .partition do |k, _|
k.start_with?(property_marker)
end.map { |p| Hash[p] }
params = remove_prefix_and_convert_type(params, marker)
custom_properties = remove_prefix_and_convert_type(custom_properties, property_marker)
params['properties'] = custom_properties
new(params)
rescue Fog::OpenStack::Image::NotFound
nil
end
|
#find_by_size_max(size) ⇒ Object
73
74
75
|
# File 'lib/fog/openstack/image/v1/models/images.rb', line 73
def find_by_size_max(size)
find_attribute(__method__, size)
end
|
#find_by_size_min(size) ⇒ Object
69
70
71
|
# File 'lib/fog/openstack/image/v1/models/images.rb', line 69
def find_by_size_min(size)
find_attribute(__method__, size)
end
|
#private ⇒ Object
51
52
53
54
|
# File 'lib/fog/openstack/image/v1/models/images.rb', line 51
def private
images = load(service.list_public_images_detailed.body['images'])
images.delete_if(&:is_public)
end
|
#public ⇒ Object
46
47
48
49
|
# File 'lib/fog/openstack/image/v1/models/images.rb', line 46
def public
images = load(service.list_public_images_detailed.body['images'])
images.delete_if { |image| image.is_public == false }
end
|
#summary(options = {}) ⇒ Object
15
16
17
|
# File 'lib/fog/openstack/image/v1/models/images.rb', line 15
def summary(options = {})
load_response(service.list_public_images(options), 'images')
end
|