class Fog::OpenStack::Image::V1::Images
Public Instance Methods
all(options = {})
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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-' headers = service.get_image_by_id(id).headers.select { |h, _| h.start_with?(marker) } # partioning on the longer prefix, leaving X-Image-Meta # headers in the second returned hash. custom_properties, params = headers.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
Also aliased as: get
find_by_size_max(size)
click to toggle source
# 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)
click to toggle source
# File lib/fog/openstack/image/v1/models/images.rb, line 69 def find_by_size_min(size) find_attribute(__method__, size) end
method_missing(method_sym, *arguments, &block)
click to toggle source
Calls superclass method
# 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
private()
click to toggle source
# 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()
click to toggle source
# 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 = {})
click to toggle source
# File lib/fog/openstack/image/v1/models/images.rb, line 15 def summary(options = {}) load_response(service.list_public_images(options), 'images') end
Private Instance Methods
convert_to_type(v)
click to toggle source
# File lib/fog/openstack/image/v1/models/images.rb, line 84 def convert_to_type(v) case v when /^\d+$/ v.to_i when 'True' true when 'False' false when /^\d\d\d\d\-\d\d\-\d\dT/ ::Time.parse(v) else v end end
remove_prefix_and_convert_type(hash, prefix)
click to toggle source
# File lib/fog/openstack/image/v1/models/images.rb, line 99 def remove_prefix_and_convert_type(hash, prefix) Hash[hash.map { |k, v| [k.gsub(prefix, '').downcase, convert_to_type(v)] }] end