all(options = {})
click to toggle source
def all(options = {})
load_response(service.list_public_images_detailed(options), 'images')
end
destroy(id)
click to toggle source
def destroy(id)
image = find_by_id(id)
image.destroy
end
details(options = {}, deprecated_query = nil)
click to toggle source
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
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
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) }
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::Image::OpenStack::NotFound
nil
end
find_by_size_max(size)
click to toggle source
def find_by_size_max(size)
find_attribute(__method__, size)
end
find_by_size_min(size)
click to toggle source
def find_by_size_min(size)
find_attribute(__method__, size)
end
method_missing(method_sym, *arguments, &block)
click to toggle source
Calls superclass method
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
def private
images = load(service.list_public_images_detailed.body['images'])
images.delete_if(&:is_public)
end
public()
click to toggle source
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
def summary(options = {})
load_response(service.list_public_images(options), 'images')
end