[openstack] Glance v2 API

This commit is contained in:
Darren Hague 2015-09-11 14:57:31 +01:00
parent 906971a514
commit 2eb6073e1a
71 changed files with 12373 additions and 725 deletions

View File

@ -2,6 +2,8 @@ require 'fog/openstack/compute'
require 'fog/openstack/identity_v2'
require 'fog/openstack/identity_v3'
require 'fog/openstack/image'
require 'fog/openstack/image_v1'
require 'fog/openstack/image_v2'
require 'fog/openstack/metering'
require 'fog/openstack/network'
require 'fog/openstack/orchestration'

View File

@ -572,6 +572,33 @@ module Fog
version
end
def self.get_supported_version_path(supported_versions, uri, auth_token, connection_options = {})
connection = Fog::Core::Connection.new("#{uri.scheme}://#{uri.host}:#{uri.port}", false, connection_options)
response = connection.request({
:expects => [200, 204, 300],
:headers => {'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Auth-Token' => auth_token},
:method => 'GET'
})
body = Fog::JSON.decode(response.body)
path = nil
unless body['versions'].empty?
supported_version = body['versions'].find do |x|
x["id"].match(supported_versions) &&
(x["status"] == "CURRENT" || x["status"] == "SUPPORTED")
end
path = URI.parse(supported_version['links'].first['href']).path if supported_version
end
if path.nil?
raise Fog::OpenStack::Errors::ServiceUnavailable.new(
"OpenStack service only supports API versions #{supported_versions.inspect}")
end
path.chomp '/'
end
# CGI.escape, but without special treatment on spaces
def self.escape(str, extra_exclude_chars = '')
str.gsub(/([^a-zA-Z0-9_.-#{extra_exclude_chars}]+)/) do

View File

@ -7,20 +7,21 @@ module Fog
# Fog::Identity::OpenStack.new() will return a Fog::Identity::OpenStack::V2 or a Fog::Identity::OpenStack::V3,
# depending on whether the auth URL is for an OpenStack Identity V2 or V3 API endpoint
def self.new(args = {})
@openstack_auth_uri = URI.parse(args[:openstack_auth_url]) if args[:openstack_auth_url]
if self.inspect == 'Fog::Identity::OpenStack'
if args[:openstack_auth_url]
@openstack_auth_uri = URI.parse(args[:openstack_auth_url])
if @openstack_auth_uri.path =~ /\/v3/
service = Fog::Identity::OpenStack::V3.new(args)
end
end
service ||= Fog::Identity::OpenStack::V2.new(args)
service = (is_v3? args) ? Fog::Identity::OpenStack::V3.new(args) : Fog::Identity::OpenStack::V2.new(args)
else
service = Fog::Service.new(args)
end
service
end
private
def self.is_v3?(args)
@openstack_auth_uri && @openstack_auth_uri.path =~ /\/v3/
end
module Common
attr_reader :unscoped_token

View File

@ -3,154 +3,59 @@ require 'fog/openstack/core'
module Fog
module Image
class OpenStack < Fog::Service
SUPPORTED_VERSIONS = /v1(\.(0|1))*/
requires :openstack_auth_url
recognizes :openstack_auth_token, :openstack_management_url,
:persistent, :openstack_service_type, :openstack_service_name,
:openstack_tenant, :openstack_tenant_id,
:openstack_api_key, :openstack_username, :openstack_identity_endpoint,
:current_user, :current_tenant, :openstack_region,
:openstack_endpoint_type,
:openstack_project_name, :openstack_project_id,
:openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
:openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id
model_path 'fog/openstack/models/image'
model :image
collection :images
request_path 'fog/openstack/requests/image'
request :list_public_images
request :list_public_images_detailed
request :get_image
request :create_image
request :update_image
request :get_image_members
request :update_image_members
request :get_shared_images
request :add_member_to_image
request :remove_member_from_image
request :delete_image
request :get_image_by_id
request :set_tenant
class Mock
def self.data
@data ||= Hash.new do |hash, key|
hash[key] = {
:images => {}
}
end
end
def self.reset
@data = nil
end
def initialize(options={})
@openstack_username = options[:openstack_username]
@openstack_tenant = options[:openstack_tenant]
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
@auth_token = Fog::Mock.random_base64(64)
@auth_token_expiration = (Time.now.utc + 86400).iso8601
management_url = URI.parse(options[:openstack_auth_url])
management_url.port = 9292
management_url.path = '/v1'
@openstack_management_url = management_url.to_s
@data ||= { :users => {} }
unless @data[:users].find {|u| u['name'] == options[:openstack_username]}
id = Fog::Mock.random_numbers(6).to_s
@data[:users][id] = {
'id' => id,
'name' => options[:openstack_username],
'email' => "#{options[:openstack_username]}@mock.com",
'tenantId' => Fog::Mock.random_numbers(6).to_s,
'enabled' => true
}
end
end
def data
self.class.data[@openstack_username]
end
def reset_data
self.class.data.delete(@openstack_username)
end
def credentials
{ :provider => 'openstack',
:openstack_auth_url => @openstack_auth_uri.to_s,
:openstack_auth_token => @auth_token,
:openstack_region => @openstack_region,
:openstack_management_url => @openstack_management_url }
# Fog::Image::OpenStack.new() will return a Fog::Image::OpenStack::V2 or a Fog::Image::OpenStack::V3,
# choosing the latest available
def self.new(args = {})
@openstack_auth_uri = URI.parse(args[:openstack_auth_url]) if args[:openstack_auth_url]
if self.inspect == 'Fog::Image::OpenStack'
service = Fog::Image::OpenStack::V2.new(args) unless args.empty?
service ||= Fog::Image::OpenStack::V1.new(args)
else
service = Fog::Service.new(args)
end
service
end
class Real
module Common
attr_reader :unscoped_token
include Fog::OpenStack::Core
def initialize(options={})
initialize_identity options
@openstack_service_type = options[:openstack_service_type] || ['image']
@openstack_service_name = options[:openstack_service_name]
@openstack_endpoint_type = options[:openstack_endpoint_type] || 'adminURL'
@connection_options = options[:connection_options] || {}
authenticate
unless @path.match(SUPPORTED_VERSIONS)
@path = "/" + Fog::OpenStack.get_supported_version(SUPPORTED_VERSIONS,
@openstack_management_uri,
@auth_token,
@connection_options)
end
@persistent = options[:persistent] || false
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def request(params)
retried = false
begin
response = @connection.request(params.merge({
:headers => {
std_headers = {
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Auth-Token' => @auth_token
}.merge!(params[:headers] || {}),
:path => "#{@path}/#{params[:path]}"#,
}
param_headers = params.fetch(:headers,{})
response = @connection.request(params.merge({
:headers => std_headers.merge(param_headers),
:path => "#{@path}/#{params[:path]}"
}))
rescue Excon::Errors::Unauthorized => error
if error.response.body != 'Bad username or password' # token expiration
@openstack_must_reauthenticate = true
authenticate
retry
else # bad credentials
raise error
end
raise if retried
retried = true
@openstack_must_reauthenticate = true
authenticate
retry
rescue Excon::Errors::HTTPStatusError => error
raise case error
when Excon::Errors::NotFound
Fog::Compute::OpenStack::NotFound.slurp(error)
else
error
end
when Excon::Errors::NotFound
Fog::Image::OpenStack::NotFound.slurp(error)
else
error
end
end
unless response.body.empty?
response.body = Fog::JSON.decode(response.body)
response.body = Fog::JSON.decode(response.body) unless params[:raw_body]
end
response
end
private
end
end
end

View File

@ -0,0 +1,142 @@
require 'fog/openstack/core'
require 'fog/openstack/image'
module Fog
module Image
class OpenStack
class V1 < Fog::Service
SUPPORTED_VERSIONS = /v1(\.(0|1))*/
requires :openstack_auth_url
recognizes :openstack_auth_token, :openstack_management_url,
:persistent, :openstack_service_type, :openstack_service_name,
:openstack_tenant, :openstack_tenant_id,
:openstack_api_key, :openstack_username, :openstack_identity_endpoint,
:current_user, :current_tenant, :openstack_region,
:openstack_endpoint_type,
:openstack_project_name, :openstack_project_id,
:openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
:openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id
model_path 'fog/openstack/models/image_v1'
model :image
collection :images
request_path 'fog/openstack/requests/image_v1'
request :list_public_images
request :list_public_images_detailed
request :get_image
request :create_image
request :update_image
request :get_image_members
request :update_image_members
request :get_shared_images
request :add_member_to_image
request :remove_member_from_image
request :delete_image
request :get_image_by_id
request :set_tenant
class Mock
def self.data
@data ||= Hash.new do |hash, key|
hash[key] = {
:images => {}
}
end
end
def self.reset
@data = nil
end
def initialize(options={})
@openstack_username = options[:openstack_username]
@openstack_tenant = options[:openstack_tenant]
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
@auth_token = Fog::Mock.random_base64(64)
@auth_token_expiration = (Time.now.utc + 86400).iso8601
management_url = URI.parse(options[:openstack_auth_url])
management_url.port = 9292
management_url.path = '/v1'
@openstack_management_url = management_url.to_s
@data ||= { :users => {} }
unless @data[:users].find {|u| u['name'] == options[:openstack_username]}
id = Fog::Mock.random_numbers(6).to_s
@data[:users][id] = {
'id' => id,
'name' => options[:openstack_username],
'email' => "#{options[:openstack_username]}@mock.com",
'tenantId' => Fog::Mock.random_numbers(6).to_s,
'enabled' => true
}
end
end
def data
self.class.data[@openstack_username]
end
def reset_data
self.class.data.delete(@openstack_username)
end
def credentials
{ :provider => 'openstack',
:openstack_auth_url => @openstack_auth_uri.to_s,
:openstack_auth_token => @auth_token,
:openstack_region => @openstack_region,
:openstack_management_url => @openstack_management_url }
end
end
class Real
include Fog::OpenStack::Core
include Fog::Image::OpenStack::Common
def initialize(options={})
initialize_identity options
@openstack_service_type = options[:openstack_service_type] || ['image']
@openstack_service_name = options[:openstack_service_name]
@openstack_endpoint_type = options[:openstack_endpoint_type] || 'adminURL'
@connection_options = options[:connection_options] || {}
authenticate
process_path @openstack_management_uri
unless @path.match(SUPPORTED_VERSIONS)
@path = Fog::OpenStack.get_supported_version_path(SUPPORTED_VERSIONS,
@openstack_management_uri,
@auth_token,
@connection_options)
end
@persistent = options[:persistent] || false
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def process_path uri
unless @path.match(SUPPORTED_VERSIONS)
@path = "/" + Fog::OpenStack.get_supported_version(SUPPORTED_VERSIONS,
uri,
@auth_token,
@connection_options)
end
@path
end
private
end
end
end
end
end

View File

@ -0,0 +1,137 @@
require 'fog/openstack/core'
require 'fog/openstack/image'
module Fog
module Image
class OpenStack
class V2 < Fog::Service
SUPPORTED_VERSIONS = /v2(\.(0|1|2|3))*/
requires :openstack_auth_url
recognizes :openstack_auth_token, :openstack_management_url,
:persistent, :openstack_service_type, :openstack_service_name,
:openstack_tenant, :openstack_tenant_id,
:openstack_api_key, :openstack_username, :openstack_identity_endpoint,
:current_user, :current_tenant, :openstack_region,
:openstack_endpoint_type,
:openstack_project_name, :openstack_project_id,
:openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
:openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id
model_path 'fog/openstack/models/image_v2'
model :image
collection :images
request_path 'fog/openstack/requests/image_v2'
request :list_images
request :get_image
request :create_image
request :update_image
request :upload_image
request :download_image
request :reactivate_image
request :deactivate_image
request :add_tag_to_image
request :remove_tag_from_image
request :get_image_members
request :get_member_details
request :update_image_member
request :get_shared_images
request :add_member_to_image
request :remove_member_from_image
request :delete_image
request :get_image_by_id
request :set_tenant
class Mock
def self.data
@data ||= Hash.new do |hash, key|
hash[key] = {
:images => {}
}
end
end
def self.reset
@data = nil
end
def initialize(options={})
@openstack_username = options[:openstack_username]
@openstack_tenant = options[:openstack_tenant]
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
@auth_token = Fog::Mock.random_base64(64)
@auth_token_expiration = (Time.now.utc + 86400).iso8601
management_url = URI.parse(options[:openstack_auth_url])
management_url.port = 9292
management_url.path = '/v2'
@openstack_management_url = management_url.to_s
@data ||= { :users => {} }
unless @data[:users].find {|u| u['name'] == options[:openstack_username]}
id = Fog::Mock.random_numbers(6).to_s
@data[:users][id] = {
'id' => id,
'name' => options[:openstack_username],
'email' => "#{options[:openstack_username]}@mock.com",
'tenantId' => Fog::Mock.random_numbers(6).to_s,
'enabled' => true
}
end
end
def data
self.class.data[@openstack_username]
end
def reset_data
self.class.data.delete(@openstack_username)
end
def credentials
{ :provider => 'openstack',
:openstack_auth_url => @openstack_auth_uri.to_s,
:openstack_auth_token => @auth_token,
:openstack_region => @openstack_region,
:openstack_management_url => @openstack_management_url }
end
end
class Real
include Fog::OpenStack::Core
include Fog::Image::OpenStack::Common
def initialize(options={})
initialize_identity options
@openstack_service_type = options[:openstack_service_type] || ['image']
@openstack_service_name = options[:openstack_service_name]
@openstack_endpoint_type = options[:openstack_endpoint_type] || 'adminURL'
@connection_options = options[:connection_options] || {}
authenticate
unless @path.match(SUPPORTED_VERSIONS)
@path = Fog::OpenStack.get_supported_version_path(SUPPORTED_VERSIONS,
@openstack_management_uri,
@auth_token,
@connection_options)
end
@persistent = options[:persistent] || false
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
private
end
end
end
end
end

View File

@ -1,76 +0,0 @@
require 'fog/openstack/models/model'
module Fog
module Image
class OpenStack
class Image < Fog::OpenStack::Model
identity :id
attribute :name
attribute :size
attribute :disk_format
attribute :container_format
attribute :id
attribute :checksum
#detailed
attribute :min_disk
attribute :created_at
attribute :deleted_at
attribute :updated_at
attribute :deleted
attribute :protected
attribute :is_public
attribute :status
attribute :min_ram
attribute :owner
attribute :properties
attribute :location
attribute :copy_from
def create
requires :name
merge_attributes(service.create_image(self.attributes).body['image'])
self
end
def update
requires :name
merge_attributes(service.update_image(self.attributes).body['image'])
self
end
def destroy
requires :id
service.delete_image(self.id)
true
end
def add_member(member_id)
requires :id
service.add_member_to_image(self.id, member_id)
end
def remove_member(member_id)
requires :id
service.remove_member_from_image(self.id, member_id)
end
def update_members(members)
requires :id
service.update_image_members(self.id, members)
end
def members
requires :id
service.get_image_members(self.id).body['members']
end
def metadata
requires :id
service.get_image(self.id).headers
end
end
end
end
end

View File

@ -1,67 +0,0 @@
require 'fog/openstack/models/collection'
require 'fog/openstack/models/image/image'
module Fog
module Image
class OpenStack
class Images < Fog::OpenStack::Collection
model Fog::Image::OpenStack::Image
def all(options = {})
load_response(service.list_public_images_detailed(options), 'images')
end
def summary(options = {})
load_response(service.list_public_images(options), 'images')
end
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
def find_by_id(id)
all.find {|image| image.id == id}
end
alias_method :get, :find_by_id
def public
images = load(service.list_public_images_detailed.body['images'])
images.delete_if{|image| image.is_public == false}
end
def private
images = load(service.list_public_images_detailed.body['images'])
images.delete_if{|image| image.is_public}
end
def destroy(id)
image = self.find_by_id(id)
image.destroy
end
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
def find_by_size_min(size)
find_attribute(__method__, size)
end
def find_by_size_max(size)
find_attribute(__method__, size)
end
def find_attribute(attribute,value)
attribute = attribute.to_s.gsub("find_by_", "")
load(service.list_public_images_detailed(attribute , value).body['images'])
end
end
end
end
end

View File

@ -0,0 +1,78 @@
require 'fog/openstack/models/model'
module Fog
module Image
class OpenStack
class V1
class Image < Fog::OpenStack::Model
identity :id
attribute :name
attribute :size
attribute :disk_format
attribute :container_format
attribute :id
attribute :checksum
#detailed
attribute :min_disk
attribute :created_at
attribute :deleted_at
attribute :updated_at
attribute :deleted
attribute :protected
attribute :is_public
attribute :status
attribute :min_ram
attribute :owner
attribute :properties
attribute :location
attribute :copy_from
def create
requires :name
merge_attributes(service.create_image(self.attributes).body['image'])
self
end
def update
requires :name
merge_attributes(service.update_image(self.attributes).body['image'])
self
end
def destroy
requires :id
service.delete_image(self.id)
true
end
def add_member(member_id)
requires :id
service.add_member_to_image(self.id, member_id)
end
def remove_member(member_id)
requires :id
service.remove_member_from_image(self.id, member_id)
end
def update_members(members)
requires :id
service.update_image_members(self.id, members)
end
def members
requires :id
service.get_image_members(self.id).body['members']
end
def metadata
requires :id
service.get_image(self.id).headers
end
end
end
end
end
end

View File

@ -0,0 +1,70 @@
require 'fog/openstack/models/collection'
require 'fog/openstack/models/image_v1/image'
module Fog
module Image
class OpenStack
class V1
class Images < Fog::OpenStack::Collection
model Fog::Image::OpenStack::V1::Image
def all(options = {})
load_response(service.list_public_images_detailed(options), 'images')
end
def summary(options = {})
load_response(service.list_public_images(options), 'images')
end
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
def find_by_id(id)
all.find {|image| image.id == id}
end
alias_method :get, :find_by_id
def public
images = load(service.list_public_images_detailed.body['images'])
images.delete_if{|image| image.is_public == false}
end
def private
images = load(service.list_public_images_detailed.body['images'])
images.delete_if{|image| image.is_public}
end
def destroy(id)
image = self.find_by_id(id)
image.destroy
end
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
def find_by_size_min(size)
find_attribute(__method__, size)
end
def find_by_size_max(size)
find_attribute(__method__, size)
end
def find_attribute(attribute,value)
attribute = attribute.to_s.gsub("find_by_", "")
load(service.list_public_images_detailed(attribute , value).body['images'])
end
end
end
end
end
end

View File

@ -0,0 +1,149 @@
require 'fog/openstack/models/model'
module Fog
module Image
class OpenStack
class V2
class Image < Fog::OpenStack::Model
identity :id
attribute :name
attribute :visibility # public or private
attribute :tags
attribute :self
attribute :size
attribute :disk_format
attribute :container_format
attribute :id
attribute :checksum
attribute :self
attribute :file
#detailed
attribute :min_disk
attribute :created_at
attribute :updated_at
attribute :protected
attribute :status # "queued","saving","active","killed","deleted","pending_delete"
attribute :min_ram
attribute :owner
attribute :properties
attribute :metadata
attribute :location
# from snapshot support
attribute :network_allocated
attribute :base_image_ref
attribute :image_type
attribute :instance_uuid
attribute :user_id
def create
requires :name
merge_attributes(service.create_image(self.attributes).body)
self
end
# This overrides the behaviour of Fog::OpenStack::Model::save() which tries to be clever and
# assumes save=update if an ID is present - but Image V2 allows ID to specified on creation
def identity
nil
end
# Hash of attributes to update is passed in. Setting value to nil will delete that attribute.
# Here we convert that hash into a form suitable for Glance's usage of JSON Patch (RFC6902)
def update(attr = {})
requires :id
json_patch = []
attr.each do |key, value|
op = (@attributes.keys.include? key) ? 'replace' : 'add'
op = 'remove' if value.nil?
json_patch << {:op => op, :path => "/#{key}", :value => value }
end
merge_attributes(
service.update_image(self.id, json_patch).body)
self
end
def destroy
requires :id
service.delete_image(self.id)
true
end
def upload_data(io_obj)
requires :id
if io_obj.is_a? Hash
service.upload_image(self.id, nil, io_obj)
else
service.upload_image(self.id, io_obj)
end
end
def download_data(params={})
requires :id
service.download_image(self.id, content_range=params[:content_range], params)
end
def reactivate
requires :id
service.reactivate_image(self.id)
end
def deactivate
requires :id
service.deactivate_image(self.id)
end
def add_member(member_id)
requires :id
service.add_member_to_image(self.id, member_id)
end
def remove_member(member_id)
requires :id
service.remove_member_from_image(self.id, member_id)
end
def update_member(member)
requires :id
service.update_image_member(self.id, member)
end
def members
requires :id
service.get_image_members(self.id).body['members']
end
def member(member_id)
requires :id
service.get_member_details(self.id, member_id)
end
def add_tags(tags)
requires :id
tags.each {|tag| add_tag tag}
end
def add_tag(tag)
requires :id
service.add_tag_to_image(self.id, tag)
end
def remove_tags(tags)
requires :id
tags.each {|tag| remove_tag tag}
end
def remove_tag(tag)
requires :id
service.remove_tag_from_image(self.id, tag)
end
end
end
end
end
end

View File

@ -0,0 +1,67 @@
require 'fog/openstack/models/collection'
require 'fog/openstack/models/image_v2/image'
module Fog
module Image
class OpenStack
class V2
class Images < Fog::OpenStack::Collection
model Fog::Image::OpenStack::V2::Image
def all(options = {})
load_response(service.list_images(options), 'images')
end
def summary(options = {})
load_response(service.list_images(options), 'images')
end
def find_by_id(id)
image_hash = service.get_image_by_id(id).body
Fog::Image::OpenStack::V2::Image.new(
image_hash.merge(:service => service))
end
alias_method :get, :find_by_id
def public
images = load(service.list_images.body['images'])
images.delete_if { |image| image.is_public == false }
end
def private
images = load(service.list_images.body['images'])
images.delete_if { |image| image.is_public }
end
def destroy(id)
image = self.find_by_id(id)
image.destroy
end
def method_missing(method_sym, *arguments, &block)
if method_sym.to_s =~ /^find_by_(.*)$/
load(service.list_images_detailed($1, arguments.first).body['images'])
else
super
end
end
def find_by_size_min(size)
find_attribute(__method__, size)
end
def find_by_size_max(size)
find_attribute(__method__, size)
end
def find_attribute(attribute, value)
attribute = attribute.to_s.gsub("find_by_", "")
load(service.list_images_detailed(attribute, value).body['images'])
end
end
end
end
end
end

View File

@ -1,76 +0,0 @@
module Fog
module Image
class OpenStack
class Real
def create_image(attributes)
data = {
'Content-Type' =>'application/octet-stream',
'x-image-meta-name' => attributes[:name],
'x-image-meta-disk-format' => attributes[:disk_format],
'x-image-meta-container-format' => attributes[:container_format],
'x-image-meta-size' => attributes[:size],
'x-image-meta-is-public' => attributes[:is_public],
'x-image-meta-min-ram' => attributes[:min_ram],
'x-image-meta-min-disk' => attributes[:min_disk],
'x-image-meta-checksum' => attributes[:checksum],
'x-image-meta-owner' => attributes[:owner],
'x-glance-api-copy-from' => attributes[:copy_from]
}.reject {|k,v| v.nil? }
body = String.new
if attributes[:location]
body = File.open(attributes[:location], "rb")
# Make sure the image file size is always present
data['x-image-meta-size'] = File.size(body)
end
unless attributes[:properties].nil?
attributes[:properties].each do |key,value|
data["x-image-meta-property-#{key}"] = value
end
end
request(
:headers => data,
:body => body,
:expects => 201,
:method => 'POST',
:path => "images"
)
ensure
body.close if body.respond_to?(:close)
end
end
class Mock
def create_image(attributes)
response = Excon::Response.new
response.status = 201
image_id = Fog::Mock.random_hex(32)
image = self.data[:images][image_id] = {
'name' => attributes[:name],
'size' => attributes[:size] || Fog::Mock.random_numbers(8).to_i,
'min_disk' => attributes[:min_disk] || 0,
'disk_format' => attributes[:disk_format] || 'raw',
'created_at' => Time.now.strftime('%FT%T.%6N'),
'container_format' => attributes[:container_format] || 'bare',
'deleted_at' => nil,
'updated_at' => Time.now.strftime('%FT%T.%6N'),
'checksum' => attributes[:checksum] || Fog::Mock.random_hex(32),
'id' => image_id,
'deleted' => false,
'protected' => false,
'is_public' => attributes[:is_public].to_s == 'true',
'status' => 'queued',
'min_ram' => attributes[:min_ram] || 0,
'owner' => attributes[:owner],
'properties' => attributes[:properties] || {}
}
response.body = { 'image'=> image }
response
end
end
end
end
end

View File

@ -1,23 +0,0 @@
module Fog
module Image
class OpenStack
class Real
def delete_image(image_id)
request(
:expects => 200,
:method => 'DELETE',
:path => "images/#{image_id}"
)
end
end
class Mock
def delete_image(image_id)
response = Excon::Response.new
response.status = 200
response
end
end
end
end
end

View File

@ -1,45 +0,0 @@
module Fog
module Image
class OpenStack
class Real
def get_image(image_id)
request(
:expects => [200, 204],
:method => 'HEAD',
:path => "images/#{image_id}"
)
end
end # class Real
class Mock
def get_image(image_id)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.headers= {"X-Image-Meta-Is_public"=>"True",
"X-Image-Meta-Min_disk"=>"0",
"X-Image-Meta-Property-Ramdisk_id"=>"b45aa128-cd36-4ad9-a026-1a1c2bfd8fdc",
"X-Image-Meta-Disk_format"=>"ami",
"X-Image-Meta-Created_at"=>"2012-02-21T07:32:26",
"X-Image-Meta-Container_format"=>"ami",
"Etag"=>"2f81976cae15c16ef0010c51e3a6c163",
"Location"=>"http://192.168.27.100:9292/v1/images/0e09fbd6-43c5-448a-83e9-0d3d05f9747e",
"X-Image-Meta-Protected"=>"False",
"Date"=>"Fri, 24 Feb 2012 02:14:25 GMT",
"X-Image-Meta-Name"=>"cirros-0.3.0-x86_64-blank",
"X-Image-Meta-Min_ram"=>"0", "Content-Type"=>"text/html; charset=UTF-8",
"X-Image-Meta-Updated_at"=>"2012-02-21T07:32:29",
"X-Image-Meta-Property-Kernel_id"=>"cd28951e-e1c2-4bc5-95d3-f0495abbcdc5",
"X-Image-Meta-Size"=>"25165824",
"X-Image-Meta-Checksum"=>"2f81976cae15c16ef0010c51e3a6c163",
"X-Image-Meta-Deleted"=>"False",
"Content-Length"=>"0",
"X-Image-Meta-Owner"=>"ff528b20431645ebb5fa4b0a71ca002f",
"X-Image-Meta-Status"=>"active",
"X-Image-Meta-Id"=>"0e09fbd6-43c5-448a-83e9-0d3d05f9747e"}
response.body = ""
response
end # def list_tenants
end # class Mock
end # class OpenStack
end # module Identity
end # module Fog

View File

@ -1,32 +0,0 @@
module Fog
module Image
class OpenStack
class Real
def get_image_by_id(image_id)
request(
:expects => [200, 204],
:method => 'GET',
:path => "images/#{image_id}"
)
end
end # class Real
class Mock
def get_image_by_id(image_id)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.body = {
"images"=>[{
"name"=>"mock-image-name",
"size"=>25165824,
"disk_format"=>"ami",
"container_format"=>"ami",
"id"=>"0e09fbd6-43c5-448a-83e9-0d3d05f9747e",
"checksum"=>"2f81976cae15c16ef0010c51e3a6c163"}]
}
response
end # def list_tenants
end # class Mock
end # class OpenStack
end # module Identity
end # module Fog

View File

@ -1,29 +0,0 @@
module Fog
module Image
class OpenStack
class Real
def get_image_members(image_id)
request(
:expects => [200, 204],
:method => 'GET',
:path => "images/#{image_id}/members"
)
end
end # class Real
class Mock
def get_image_members(image_id)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.body = {
"members"=>[
{"member_id"=>"ff528b20431645ebb5fa4b0a71ca002f",
"can_share"=>false}
]
}
response
end # def list_tenants
end # class Mock
end # class OpenStack
end # module Identity
end # module Fog

View File

@ -1,29 +0,0 @@
module Fog
module Image
class OpenStack
class Real
def get_shared_images(tenant_id)
request(
:expects => [200, 204],
:method => 'GET',
:path => "shared-images/#{tenant_id}"
)
end
end # class Real
class Mock
def get_shared_images(tenant_id)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.body = {
"shared_images"=>[
{"image_id"=>"ff528b20431645ebb5fa4b0a71ca002f",
"can_share"=>false}
]
}
response
end # def list_tenants
end # class Mock
end # class OpenStack
end # module Identity
end # module Fog

View File

@ -1,33 +0,0 @@
module Fog
module Image
class OpenStack
class Real
def list_public_images(options = {})
request(
:expects => [200, 204],
:method => 'GET',
:path => 'images',
:query => options
)
end
end # class Real
class Mock
def list_public_images(options = {})
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.body = {
"images"=>[{
"name" => Fog::Mock.random_letters(10),
"size" => Fog::Mock.random_numbers(8).to_i,
"disk_format" => "iso",
"container_format" => "bare",
"id" => Fog::Mock.random_hex(36),
"checksum" => Fog::Mock.random_hex(32)}]
}
response
end # def list_tenants
end # class Mock
end # class OpenStack
end # module Identity
end # module Fog

View File

@ -1,35 +0,0 @@
module Fog
module Image
class OpenStack
class Real
def list_public_images_detailed(options = {}, query_deprecated = nil)
if options.is_a?(Hash)
query = options
elsif options
Fog::Logger.deprecation("Calling OpenStack[:glance].list_public_images_detailed(attribute, query) format"\
" is deprecated, call .list_public_images_detailed(attribute => query) instead")
query = { options => query_deprecated }
else
query = {}
end
request(
:expects => [200, 204],
:method => 'GET',
:path => 'images/detail',
:query => query
)
end
end # class Real
class Mock
def list_public_images_detailed(options = {}, query_deprecated = nil)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.body = {'images' => self.data[:images].values}
response
end # def list_public_images_detailed
end # class Mock
end # class OpenStack
end # module Image
end # module Fog

View File

@ -1,23 +0,0 @@
module Fog
module Image
class OpenStack
class Real
def remove_member_from_image(image_id, member_id)
request(
:expects => [200, 204],
:method => 'DELETE',
:path => "images/#{image_id}/members/#{member_id}"
)
end
end # class Real
class Mock
def remove_member_from_image(image_id, member_id)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response
end # def list_tenants
end # class Mock
end # class OpenStack
end # module Identity
end # module Fog

View File

@ -1,19 +0,0 @@
module Fog
module Image
class OpenStack
class Real
def set_tenant(tenant)
@openstack_must_reauthenticate = true
@openstack_tenant = tenant.to_s
authenticate
end
end
class Mock
def set_tenant(tenant)
true
end
end
end # class OpenStack
end # module Compute
end # module Fog

View File

@ -1,64 +0,0 @@
module Fog
module Image
class OpenStack
class Real
def update_image(attributes)
data = {
'x-image-meta-name' => attributes[:name],
'x-image-meta-disk-format' => attributes[:disk_format],
'x-image-meta-container-format' => attributes[:container_format],
'x-image-meta-size' => attributes[:size],
'x-image-meta-is-public' => attributes[:is_public],
'x-image-meta-min-ram' => attributes[:min_ram],
'x-image-meta-min-disk' => attributes[:min_disk],
'x-image-meta-checksum' => attributes[:checksum],
'x-image-meta-owner' => attributes[:owner]
}.reject {|k,v| v.nil? }
unless attributes[:properties].nil?
attributes[:properties].each do |key,value|
data["x-image-meta-property-#{key}"] = value
end
end
request(
:headers => data,
:expects => 200,
:method => 'PUT',
:path => "images/#{attributes[:id]}"
)
end
end
class Mock
def update_image(attributes)
response = Excon::Response.new
response.status = 200
image = self.images.last
response.body = {
'image'=> {
'name' => attributes[:name] || image.name,
'size' => image.size,
'min_disk' => (attributes[:min_disk] || image.min_disk).to_i,
'disk_format' => attributes[:disk_format] || image.disk_format,
'created_at' => image.created_at,
'container_format' => attributes[:container_format] || image.container_format,
'deleted_at' => nil,
'updated_at' => Time.now.to_s,
'checksum' => image.checksum,
'id' => attributes[:id],
'deleted' => false,
'protected' => false,
'is_public' => attributes[:is_public] || image.is_public,
'status' => image.status,
'min_ram' => (attributes[:min_ram] || image.min_ram).to_i,
'owner' => attributes[:owner] || image.owner,
'properties' => attributes[:properties] || image.properties
}
}
response
end
end
end
end
end

View File

@ -1,37 +0,0 @@
module Fog
module Image
class OpenStack
class Real
def update_image_members(image_id, members)
# Sample members
# [
# {'member_id' => 'tenant1', 'can_share' => true },
# {'member_id' => 'tenant2', 'can_share' => false }
# ]
data = { 'memberships' => members }
request(
:body => Fog::JSON.encode(data),
:expects => [204],
:method => 'PUT',
:path => "images/#{image_id}/members"
)
end
end # class Real
class Mock
def update_image_members(image_id, members)
response = Excon::Response.new
response.status = 204
response.body = {
'members' => [
{ 'member_id'=>'ff528b20431645ebb5fa4b0a71ca002f', 'can_share' => false },
{ 'member_id'=>'ff528b20431645ebb5fa4b0a71ca002f', 'can_share' => true }
]
}
response
end
end # class Mock
end # class OpenStack
end # module Identity
end # module Fog

View File

@ -1,6 +1,7 @@
module Fog
module Image
class OpenStack
class V1
class Real
def add_member_to_image(image_id, tenant_id)
request(
@ -18,6 +19,7 @@ module Fog
response
end # def list_tenants
end # class Mock
end # class V1
end # class OpenStack
end # module Identity
end # module Fog

View File

@ -0,0 +1,78 @@
module Fog
module Image
class OpenStack
class V1
class Real
def create_image(attributes)
data = {
'Content-Type' => 'application/octet-stream',
'x-image-meta-name' => attributes[:name],
'x-image-meta-disk-format' => attributes[:disk_format],
'x-image-meta-container-format' => attributes[:container_format],
'x-image-meta-size' => attributes[:size],
'x-image-meta-is-public' => attributes[:is_public],
'x-image-meta-min-ram' => attributes[:min_ram],
'x-image-meta-min-disk' => attributes[:min_disk],
'x-image-meta-checksum' => attributes[:checksum],
'x-image-meta-owner' => attributes[:owner],
'x-glance-api-copy-from' => attributes[:copy_from]
}.reject { |k, v| v.nil? }
body = String.new
if attributes[:location]
body = File.open(attributes[:location], "rb")
# Make sure the image file size is always present
data['x-image-meta-size'] = File.size(body)
end
unless attributes[:properties].nil?
attributes[:properties].each do |key, value|
data["x-image-meta-property-#{key}"] = value
end
end
request(
:headers => data,
:body => body,
:expects => 201,
:method => 'POST',
:path => "images"
)
ensure
body.close if body.respond_to?(:close)
end
end
class Mock
def create_image(attributes)
response = Excon::Response.new
response.status = 201
image_id = Fog::Mock.random_hex(32)
image = self.data[:images][image_id] = {
'name' => attributes[:name],
'size' => attributes[:size] || Fog::Mock.random_numbers(8).to_i,
'min_disk' => attributes[:min_disk] || 0,
'disk_format' => attributes[:disk_format] || 'raw',
'created_at' => Time.now.strftime('%FT%T.%6N'),
'container_format' => attributes[:container_format] || 'bare',
'deleted_at' => nil,
'updated_at' => Time.now.strftime('%FT%T.%6N'),
'checksum' => attributes[:checksum] || Fog::Mock.random_hex(32),
'id' => image_id,
'deleted' => false,
'protected' => false,
'is_public' => attributes[:is_public].to_s == 'true',
'status' => 'queued',
'min_ram' => attributes[:min_ram] || 0,
'owner' => attributes[:owner],
'properties' => attributes[:properties] || {}
}
response.body = {'image' => image}
response
end
end
end
end
end
end

View File

@ -0,0 +1,25 @@
module Fog
module Image
class OpenStack
class V1
class Real
def delete_image(image_id)
request(
:expects => 200,
:method => 'DELETE',
:path => "images/#{image_id}"
)
end
end
class Mock
def delete_image(image_id)
response = Excon::Response.new
response.status = 200
response
end
end
end
end
end
end

View File

@ -0,0 +1,47 @@
module Fog
module Image
class OpenStack
class V1
class Real
def get_image(image_id)
request(
:expects => [200, 204],
:method => 'HEAD',
:path => "images/#{image_id}"
)
end
end # class Real
class Mock
def get_image(image_id)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.headers= {"X-Image-Meta-Is_public" => "True",
"X-Image-Meta-Min_disk" => "0",
"X-Image-Meta-Property-Ramdisk_id" => "b45aa128-cd36-4ad9-a026-1a1c2bfd8fdc",
"X-Image-Meta-Disk_format" => "ami",
"X-Image-Meta-Created_at" => "2012-02-21T07:32:26",
"X-Image-Meta-Container_format" => "ami",
"Etag" => "2f81976cae15c16ef0010c51e3a6c163",
"Location" => "http://192.168.27.100:9292/v1/images/0e09fbd6-43c5-448a-83e9-0d3d05f9747e",
"X-Image-Meta-Protected" => "False",
"Date" => "Fri, 24 Feb 2012 02:14:25 GMT",
"X-Image-Meta-Name" => "cirros-0.3.0-x86_64-blank",
"X-Image-Meta-Min_ram" => "0", "Content-Type" => "text/html; charset=UTF-8",
"X-Image-Meta-Updated_at" => "2012-02-21T07:32:29",
"X-Image-Meta-Property-Kernel_id" => "cd28951e-e1c2-4bc5-95d3-f0495abbcdc5",
"X-Image-Meta-Size" => "25165824",
"X-Image-Meta-Checksum" => "2f81976cae15c16ef0010c51e3a6c163",
"X-Image-Meta-Deleted" => "False",
"Content-Length" => "0",
"X-Image-Meta-Owner" => "ff528b20431645ebb5fa4b0a71ca002f",
"X-Image-Meta-Status" => "active",
"X-Image-Meta-Id" => "0e09fbd6-43c5-448a-83e9-0d3d05f9747e"}
response.body = ""
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,34 @@
module Fog
module Image
class OpenStack
class V1
class Real
def get_image_by_id(image_id)
request(
:expects => [200, 204],
:method => 'GET',
:path => "images/#{image_id}"
)
end
end # class Real
class Mock
def get_image_by_id(image_id)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.body = {
"images" => [{
"name" => "mock-image-name",
"size" => 25165824,
"disk_format" => "ami",
"container_format" => "ami",
"id" => "0e09fbd6-43c5-448a-83e9-0d3d05f9747e",
"checksum" => "2f81976cae15c16ef0010c51e3a6c163"}]
}
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,31 @@
module Fog
module Image
class OpenStack
class V1
class Real
def get_image_members(image_id)
request(
:expects => [200, 204],
:method => 'GET',
:path => "images/#{image_id}/members"
)
end
end # class Real
class Mock
def get_image_members(image_id)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.body = {
"members" => [
{"member_id" => "ff528b20431645ebb5fa4b0a71ca002f",
"can_share" => false}
]
}
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,31 @@
module Fog
module Image
class OpenStack
class V1
class Real
def get_shared_images(tenant_id)
request(
:expects => [200, 204],
:method => 'GET',
:path => "shared-images/#{tenant_id}"
)
end
end # class Real
class Mock
def get_shared_images(tenant_id)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.body = {
"shared_images" => [
{"image_id" => "ff528b20431645ebb5fa4b0a71ca002f",
"can_share" => false}
]
}
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,35 @@
module Fog
module Image
class OpenStack
class V1
class Real
def list_public_images(options = {})
request(
:expects => [200, 204],
:method => 'GET',
:path => 'images',
:query => options
)
end
end # class Real
class Mock
def list_public_images(options = {})
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.body = {
"images" => [{
"name" => Fog::Mock.random_letters(10),
"size" => Fog::Mock.random_numbers(8).to_i,
"disk_format" => "iso",
"container_format" => "bare",
"id" => Fog::Mock.random_hex(36),
"checksum" => Fog::Mock.random_hex(32)}]
}
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,37 @@
module Fog
module Image
class OpenStack
class V1
class Real
def list_public_images_detailed(options = {}, query_deprecated = nil)
if options.is_a?(Hash)
query = options
elsif options
Fog::Logger.deprecation("Calling OpenStack[:glance].list_public_images_detailed(attribute, query) format"\
" is deprecated, call .list_public_images_detailed(attribute => query) instead")
query = {options => query_deprecated}
else
query = {}
end
request(
:expects => [200, 204],
:method => 'GET',
:path => 'images/detail',
:query => query
)
end
end # class Real
class Mock
def list_public_images_detailed(options = {}, query_deprecated = nil)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.body = {'images' => self.data[:images].values}
response
end # def list_public_images_detailed
end # class Mock
end # class OpenStack
end
end # module Image
end # module Fog

View File

@ -0,0 +1,25 @@
module Fog
module Image
class OpenStack
class V1
class Real
def remove_member_from_image(image_id, member_id)
request(
:expects => [200, 204],
:method => 'DELETE',
:path => "images/#{image_id}/members/#{member_id}"
)
end
end # class Real
class Mock
def remove_member_from_image(image_id, member_id)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,21 @@
module Fog
module Image
class OpenStack
class V1
class Real
def set_tenant(tenant)
@openstack_must_reauthenticate = true
@openstack_tenant = tenant.to_s
authenticate
end
end
class Mock
def set_tenant(tenant)
true
end
end
end # class OpenStack
end
end # module Image
end # module Fog

View File

@ -0,0 +1,66 @@
module Fog
module Image
class OpenStack
class V1
class Real
def update_image(attributes)
data = {
'x-image-meta-name' => attributes[:name],
'x-image-meta-disk-format' => attributes[:disk_format],
'x-image-meta-container-format' => attributes[:container_format],
'x-image-meta-size' => attributes[:size],
'x-image-meta-is-public' => attributes[:is_public],
'x-image-meta-min-ram' => attributes[:min_ram],
'x-image-meta-min-disk' => attributes[:min_disk],
'x-image-meta-checksum' => attributes[:checksum],
'x-image-meta-owner' => attributes[:owner]
}.reject { |k, v| v.nil? }
unless attributes[:properties].nil?
attributes[:properties].each do |key, value|
data["x-image-meta-property-#{key}"] = value
end
end
request(
:headers => data,
:expects => 200,
:method => 'PUT',
:path => "images/#{attributes[:id]}"
)
end
end
class Mock
def update_image(attributes)
response = Excon::Response.new
response.status = 200
image = self.images.last
response.body = {
'image' => {
'name' => attributes[:name] || image.name,
'size' => image.size,
'min_disk' => (attributes[:min_disk] || image.min_disk).to_i,
'disk_format' => attributes[:disk_format] || image.disk_format,
'created_at' => image.created_at,
'container_format' => attributes[:container_format] || image.container_format,
'deleted_at' => nil,
'updated_at' => Time.now.to_s,
'checksum' => image.checksum,
'id' => attributes[:id],
'deleted' => false,
'protected' => false,
'is_public' => attributes[:is_public] || image.is_public,
'status' => image.status,
'min_ram' => (attributes[:min_ram] || image.min_ram).to_i,
'owner' => attributes[:owner] || image.owner,
'properties' => attributes[:properties] || image.properties
}
}
response
end
end
end
end
end
end

View File

@ -0,0 +1,39 @@
module Fog
module Image
class OpenStack
class V1
class Real
def update_image_members(image_id, members)
# Sample members
# [
# {'member_id' => 'tenant1', 'can_share' => true },
# {'member_id' => 'tenant2', 'can_share' => false }
# ]
data = {'memberships' => members}
request(
:body => Fog::JSON.encode(data),
:expects => [204],
:method => 'PUT',
:path => "images/#{image_id}/members"
)
end
end # class Real
class Mock
def update_image_members(image_id, members)
response = Excon::Response.new
response.status = 204
response.body = {
'members' => [
{'member_id' => 'ff528b20431645ebb5fa4b0a71ca002f', 'can_share' => false},
{'member_id' => 'ff528b20431645ebb5fa4b0a71ca002f', 'can_share' => true}
]
}
response
end
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,26 @@
module Fog
module Image
class OpenStack
class V2
class Real
def add_member_to_image(image_id, tenant_id)
request(
:expects => [200],
:method => 'POST',
:path => "images/#{image_id}/members",
:body => Fog::JSON.encode({:member => tenant_id})
)
end
end # class Real
class Mock
def add_member_to_image(image_id, tenant_id)
response = Excon::Response.new
response.status = 200
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,25 @@
module Fog
module Image
class OpenStack
class V2
class Real
def add_tag_to_image(image_id, tag)
request(
:expects => [204],
:method => 'PUT',
:path => "images/#{image_id}/tags/#{tag}"
)
end
end # class Real
class Mock
def add_tag_to_image(image_id, tag)
response = Excon::Response.new
response.status = 204
response
end # def add_tag_to_image
end # class Mock
end # class OpenStack
end
end # module Image
end # module Fog

View File

@ -0,0 +1,54 @@
module Fog
module Image
class OpenStack
class V2
class Real
def create_image(image)
location = image.delete :location
headers = {}
headers["Location"] = location if location
request(
:headers => headers,
:expects => [201],
:method => 'POST',
:path => "images",
:body => Fog::JSON.encode(image)
)
end
end
class Mock
def create_image(attributes)
response = Excon::Response.new
response.status = 201
image_id = Fog::Mock.random_hex(32)
image = self.data[:images][image_id] = {
'tags' => attributes[:tags] || [],
'name' => attributes[:name],
'size' => nil,
'min_disk' => attributes[:min_disk] || 0,
'disk_format' => attributes[:disk_format] || 'raw',
'created_at' => Time.now.strftime('%FT%T.%6N'),
'container_format' => attributes[:container_format] || 'bare',
'deleted_at' => nil,
'updated_at' => Time.now.strftime('%FT%T.%6N'),
'checksum' => nil,
'id' => image_id,
'visibility' => attributes[:visibility] || 'public',
'status' => 'queued',
'min_ram' => attributes[:min_ram] || 0,
'owner' => attributes[:owner] || Fog::Mock.random_hex(32)
}
response.body = image
response
end
end
end
end
end
end

View File

@ -0,0 +1,25 @@
module Fog
module Image
class OpenStack
class V2
class Real
def deactivate_image(image_id)
request(
:expects => 204,
:method => 'POST',
:path => "images/#{image_id}/actions/deactivate"
)
end
end
class Mock
def deactivate_image(image_id)
response = Excon::Response.new
response.status = 204
response
end
end
end
end
end
end

View File

@ -0,0 +1,25 @@
module Fog
module Image
class OpenStack
class V2
class Real
def delete_image(image_id)
request(
:expects => 204,
:method => 'DELETE',
:path => "images/#{image_id}"
)
end
end
class Mock
def delete_image(image_id)
response = Excon::Response.new
response.status = 204
response
end
end
end
end
end
end

View File

@ -0,0 +1,29 @@
module Fog
module Image
class OpenStack
class V2
class Real
def download_image(image_id, content_range=nil, params) # TODO: implement content range handling
request_hash = {
:expects => [200, 204],
:method => 'GET',
:raw_body => true,
:path => "images/#{image_id}/file",
}
request_hash[:response_block] = params[:response_block] if params[:response_block]
request(request_hash).body
end
end # class Real
class Mock
def download_image(image_id, content_range=nil)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.body = ""
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,47 @@
module Fog
module Image
class OpenStack
class V2
class Real
def get_image(image_id)
request(
:expects => [200, 204],
:method => 'HEAD',
:path => "images/#{image_id}"
)
end
end # class Real
class Mock
def get_image(image_id)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.headers= {"X-Image-Meta-Is_public" => "True",
"X-Image-Meta-Min_disk" => "0",
"X-Image-Meta-Property-Ramdisk_id" => "b45aa128-cd36-4ad9-a026-1a1c2bfd8fdc",
"X-Image-Meta-Disk_format" => "ami",
"X-Image-Meta-Created_at" => "2012-02-21T07:32:26",
"X-Image-Meta-Container_format" => "ami",
"Etag" => "2f81976cae15c16ef0010c51e3a6c163",
"Location" => "http://192.168.27.100:9292/v1/images/0e09fbd6-43c5-448a-83e9-0d3d05f9747e",
"X-Image-Meta-Protected" => "False",
"Date" => "Fri, 24 Feb 2012 02:14:25 GMT",
"X-Image-Meta-Name" => "cirros-0.3.0-x86_64-blank",
"X-Image-Meta-Min_ram" => "0", "Content-Type" => "text/html; charset=UTF-8",
"X-Image-Meta-Updated_at" => "2012-02-21T07:32:29",
"X-Image-Meta-Property-Kernel_id" => "cd28951e-e1c2-4bc5-95d3-f0495abbcdc5",
"X-Image-Meta-Size" => "25165824",
"X-Image-Meta-Checksum" => "2f81976cae15c16ef0010c51e3a6c163",
"X-Image-Meta-Deleted" => "False",
"Content-Length" => "0",
"X-Image-Meta-Owner" => "ff528b20431645ebb5fa4b0a71ca002f",
"X-Image-Meta-Status" => "active",
"X-Image-Meta-Id" => "0e09fbd6-43c5-448a-83e9-0d3d05f9747e"}
response.body = ""
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,34 @@
module Fog
module Image
class OpenStack
class V2
class Real
def get_image_by_id(image_id)
request(
:expects => [200],
:method => 'GET',
:path => "images/#{image_id}"
)
end
end # class Real
class Mock
def get_image_by_id(image_id)
response = Excon::Response.new
response.status = [200][rand(1)]
response.body = {
"images" => [{
"name" => "mock-image-name",
"size" => 25165824,
"disk_format" => "ami",
"container_format" => "ami",
"id" => "0e09fbd6-43c5-448a-83e9-0d3d05f9747e",
"checksum" => "2f81976cae15c16ef0010c51e3a6c163"}]
}
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,31 @@
module Fog
module Image
class OpenStack
class V2
class Real
def get_image_members(image_id)
request(
:expects => [200, 204],
:method => 'GET',
:path => "images/#{image_id}/members"
)
end
end # class Real
class Mock
def get_image_members(image_id)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.body = {
"members" => [
{"member_id" => "ff528b20431645ebb5fa4b0a71ca002f",
"can_share" => false}
]
}
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,33 @@
module Fog
module Image
class OpenStack
class V2
class Real
def get_member_details(image_id, member_id)
request(
:expects => [200],
:method => 'GET',
:path => "images/#{image_id}/members/#{member_id}"
).body
end
end # class Real
class Mock
def get_member_details(image_id, member_id)
response = Excon::Response.new
response.status = 200
response.body = {
:status=> "pending",
:created_at=> "2013-11-26T07:21:21Z",
:updated_at=> "2013-11-26T07:21:21Z",
:image_id=> "0ae74cc5-5147-4239-9ce2-b0c580f7067e",
:member_id=> "8989447062e04a818baf9e073fd04fa7",
:schema=> "/v2/schemas/member"
}
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,31 @@
module Fog
module Image
class OpenStack
class V2
class Real
def get_shared_images(tenant_id)
request(
:expects => [200, 204],
:method => 'GET',
:path => "shared-images/#{tenant_id}"
)
end
end # class Real
class Mock
def get_shared_images(tenant_id)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.body = {
"shared_images" => [
{"image_id" => "ff528b20431645ebb5fa4b0a71ca002f",
"can_share" => false}
]
}
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,35 @@
module Fog
module Image
class OpenStack
class V2
class Real
def list_images(options = {})
request(
:expects => [200],
:method => 'GET',
:path => 'images',
:query => options
)
end
end # class Real
class Mock
def list_images(options = {})
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response.body = {
"images" => [{
"name" => Fog::Mock.random_letters(10),
"size" => Fog::Mock.random_numbers(8).to_i,
"disk_format" => "iso",
"container_format" => "bare",
"id" => Fog::Mock.random_hex(36),
"checksum" => Fog::Mock.random_hex(32)}]
}
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,25 @@
module Fog
module Image
class OpenStack
class V2
class Real
def reactivate_image(image_id)
request(
:expects => 204,
:method => 'POST',
:path => "images/#{image_id}/actions/reactivate"
)
end
end
class Mock
def reactivate_image(image_id)
response = Excon::Response.new
response.status = 204
response
end
end
end
end
end
end

View File

@ -0,0 +1,25 @@
module Fog
module Image
class OpenStack
class V2
class Real
def remove_member_from_image(image_id, member_id)
request(
:expects => [200, 204],
:method => 'DELETE',
:path => "images/#{image_id}/members/#{member_id}"
)
end
end # class Real
class Mock
def remove_member_from_image(image_id, member_id)
response = Excon::Response.new
response.status = [200, 204][rand(1)]
response
end # def list_tenants
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,25 @@
module Fog
module Image
class OpenStack
class V2
class Real
def remove_tag_from_image(image_id, tag)
request(
:expects => [204],
:method => 'DELETE',
:path => "images/#{image_id}/tags/#{tag}"
)
end
end # class Real
class Mock
def remove_tag_from_image(image_id, tag)
response = Excon::Response.new
response.status = 204
response
end # def remove_tag_from_image
end # class Mock
end # class OpenStack
end
end # module Image
end # module Fog

View File

@ -0,0 +1,21 @@
module Fog
module Image
class OpenStack
class V2
class Real
def set_tenant(tenant)
@openstack_must_reauthenticate = true
@openstack_tenant = tenant.to_s
authenticate
end
end
class Mock
def set_tenant(tenant)
true
end
end
end # class OpenStack
end
end # module Compute
end # module Fog

View File

@ -0,0 +1,49 @@
module Fog
module Image
class OpenStack
class V2
class Real
def update_image(id, json_patch)
request(
:headers => {'Content-Type' => 'application/openstack-images-v2.1-json-patch'},
:expects => [200],
:method => 'PATCH',
:path => "images/#{id}",
:body => Fog::JSON.encode(json_patch)
)
end
end
class Mock
def update_image(attributes)
response = Excon::Response.new
response.status = 200
image = self.images.last
response.body = {
'image' => {
'name' => attributes[:name] || image.name,
'size' => image.size,
'min_disk' => (attributes[:min_disk] || image.min_disk).to_i,
'disk_format' => attributes[:disk_format] || image.disk_format,
'created_at' => image.created_at,
'container_format' => attributes[:container_format] || image.container_format,
'deleted_at' => nil,
'updated_at' => Time.now.to_s,
'checksum' => image.checksum,
'id' => attributes[:id],
'deleted' => false,
'protected' => false,
'is_public' => attributes[:is_public] || image.is_public,
'status' => image.status,
'min_ram' => (attributes[:min_ram] || image.min_ram).to_i,
'owner' => attributes[:owner] || image.owner,
'properties' => attributes[:properties] || image.properties
}
}
response
end
end
end
end
end
end

View File

@ -0,0 +1,34 @@
module Fog
module Image
class OpenStack
class V2
class Real
def update_image_member(image_id, member)
request( # 'status' is the only property we can update
:body => Fog::JSON.encode(member.select {|key, value| key=='status'}),
:expects => [200],
:method => 'PUT',
:path => "images/#{image_id}/members/#{member['member_id']}"
)
end
end # class Real
class Mock
def update_image_members(image_id, member)
response = Excon::Response.new
response.status = 204
response.body = {
:status=> "accepted",
:created_at=> "2013-11-26T07:21:21Z",
:updated_at=> "2013-11-26T07:21:21Z",
:image_id=> image_id,
:member_id=> member['member_id'],
:schema=> "/v2/schemas/member"
}
response
end
end # class Mock
end # class OpenStack
end
end # module Identity
end # module Fog

View File

@ -0,0 +1,30 @@
module Fog
module Image
class OpenStack
class V2
class Real
def upload_image(image_id, body, params={})
request_hash = {
:headers => {'Content-Type' => 'application/octet-stream'},
:expects => 204,
:method => 'PUT',
:path => "images/#{image_id}/file"
}
request_hash[:request_block] = params[:request_block] if params[:request_block]
request_hash[:body] = body if body
request(request_hash).body
ensure
body.close if body.respond_to?(:close)
end
end
class Mock
def upload_image(image_id, body)
response = Excon::Response.new
response.status = 204
end
end
end
end
end
end

View File

@ -0,0 +1,144 @@
---
http_interactions:
- request:
method: post
uri: http://devstack.openstack.stack:5000/v3/auth/tokens
body:
encoding: UTF-8
string: ! '{"auth":{"identity":{"methods":["password"],"password":{"user":{"password":"password","domain":{"name":"Default"},"name":"admin"}}},"scope":{"project":{"name":"admin","domain":{"name":"Default"}}}}}'
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
response:
status:
code: 201
message: ''
headers:
Date:
- Mon, 21 Sep 2015 17:49:16 GMT
Server:
- Apache/2.4.7 (Ubuntu)
X-Subject-Token:
- 7016a3d2ce5348ae951b1e3d8edaa55d
Vary:
- X-Auth-Token
X-Openstack-Request-Id:
- req-c5120fdf-de29-4188-9e0c-c5cea44fb961
Content-Length:
- '5874'
Content-Type:
- application/json
body:
encoding: US-ASCII
string: ! '{"token": {"methods": ["password"], "roles": [{"id": "6ead57f8ae124996af8b0beb72ff1007",
"name": "admin"}], "expires_at": "2015-09-21T18:49:16.715164Z", "project":
{"domain": {"id": "default", "name": "Default"}, "id": "123ac695d4db400a9001b91bb3b8aa46",
"name": "admin"}, "catalog": [{"endpoints": [{"region_id": "RegionOne", "url":
"http://devstack.openstack.stack:9292", "region": "RegionOne", "interface": "public",
"id": "6e82c8912d3f49a09df51035681d564c"}, {"region_id": "RegionOne", "url":
"http://devstack.openstack.stack:9292", "region": "RegionOne", "interface": "admin",
"id": "7e44d321ae80457abc3728fa1e6feb32"}, {"region_id": "RegionOne", "url":
"http://devstack.openstack.stack:9292", "region": "RegionOne", "interface": "internal",
"id": "c9a090a4597040849c03bc13588167f6"}], "type": "image", "id": "0d56500210a24c38a3702b6825e24164",
"name": "glance"}, {"endpoints": [{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8776/v2/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "internal", "id": "261aaf6239bb49a4a1cfa87c19859138"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8776/v2/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "admin", "id": "437d282e0bb94622aaacc4d194c069a9"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8776/v2/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "public", "id": "5e78bf7bae7c4ff5b9720b2c2e4da743"}],
"type": "volumev2", "id": "2b92e79c45254516932c633229cd0e8b", "name": "cinderv2"},
{"endpoints": [{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8773/",
"region": "RegionOne", "interface": "admin", "id": "1ce26a6fffd0424bac135b9c68055b6e"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8773/", "region":
"RegionOne", "interface": "public", "id": "98db699b9ffa4dffb027d78163aad8cc"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8773/", "region":
"RegionOne", "interface": "internal", "id": "ece52860cf1e4eb6a8fed05c47a30147"}],
"type": "ec2", "id": "3364a7b95c664bf89a7a8db081576364", "name": "ec2"}, {"endpoints":
[{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8776/v1/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "admin", "id": "4442fbd064844a7bbe6a792507d4b8e3"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8776/v1/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "internal", "id": "4b4178fd2e3d4f329600cc4ceaaa7e3a"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8776/v1/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "public", "id": "90977723dba04ea9a2a184c99565ccff"}],
"type": "volume", "id": "511b94ce0482484ea09028091dd5e9a5", "name": "cinder"},
{"endpoints": [{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8774/v2/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "internal", "id": "81c51855280345e9a6c322ca986d4e4b"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8774/v2/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "admin", "id": "a0310a37cf6144a6a967cbae9a7959ba"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8774/v2/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "public", "id": "f6d38c03b9c04a9e924aaa288ce014b8"}],
"type": "compute", "id": "5b7028751ed045d79467c7845ecb8c58", "name": "nova"},
{"endpoints": [{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8774/v2.1/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "internal", "id": "2f17e155b0aa47838394e6c4f6fe30e0"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8774/v2.1/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "public", "id": "9d2555fd27dd44e5acfb5e56127d974b"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8774/v2.1/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "admin", "id": "e8bdd9403fbb4efa8d77bfd4f6a5e34a"}],
"type": "computev21", "id": "97e665cbada043718180c5a6316df76a", "name": "novav21"},
{"endpoints": [{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:35357/v3",
"region": "RegionOne", "interface": "admin", "id": "185eda94de9340e58245062f75d7f80e"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "internal", "id": "9abd6797844d455f875af9537325cba4"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "public", "id": "d3b31f24e4ea40699f731e29e625c187"}],
"type": "identity", "id": "b577d8f7c7074d04a1165fcca638b600", "name": "keystone_v3x"},
{"endpoints": [{"region_id": "europe", "url": "http://devstack.openstack.stack:35357/v3",
"region": "europe", "interface": "admin", "id": "32bb2c6aea944ea6b4956eb24142d2e2"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "public", "id": "480ea71dc8cf4c959df1c6304be87056"},
{"region_id": "europe", "url": "http://devstack.openstack.stack:5000/v3", "region":
"europe", "interface": "public", "id": "600638643d22494fad4f30e3b22ae124"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "internal", "id": "8a254651925e4a3e9505c863a00c017e"},
{"region_id": "europe", "url": "http://devstack.openstack.stack:5000/v3", "region":
"europe", "interface": "internal", "id": "b93da6aaba654d8cb451ff8378d7d2a5"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:35357/v3", "region":
"RegionOne", "interface": "admin", "id": "d5f8e0da0f3345529a5fb324d735d4a3"}],
"type": "identity_v3", "id": "cd9002bbadfe495d81b5ee4c50768009", "name": "keystone_v3"}],
"extras": {}, "user": {"domain": {"id": "default", "name": "Default"}, "id":
"aa9f25defa6d4cafb48466df83106065", "name": "admin"}, "audit_ids": ["4kw_GZ0MSiuQ46d2BLs_wQ"],
"issued_at": "2015-09-21T17:49:16.715201Z"}}'
http_version:
recorded_at: Mon, 21 Sep 2015 17:49:16 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- 7016a3d2ce5348ae951b1e3d8edaa55d
response:
status:
code: 300
message: ''
headers:
Content-Type:
- application/json; charset=UTF-8
Content-Length:
- '666'
Date:
- Mon, 21 Sep 2015 17:49:16 GMT
body:
encoding: US-ASCII
string: ! '{"versions": [{"status": "CURRENT", "id": "v2.3", "links": [{"href":
"http://devstack.openstack.stack:9292/v2/", "rel": "self"}]}, {"status": "SUPPORTED",
"id": "v2.2", "links": [{"href": "http://devstack.openstack.stack:9292/v2/", "rel":
"self"}]}, {"status": "SUPPORTED", "id": "v2.1", "links": [{"href": "http://devstack.openstack.stack:9292/v2/",
"rel": "self"}]}, {"status": "SUPPORTED", "id": "v2.0", "links": [{"href":
"http://devstack.openstack.stack:9292/v2/", "rel": "self"}]}, {"status": "SUPPORTED",
"id": "v1.1", "links": [{"href": "http://devstack.openstack.stack:9292/v1/", "rel":
"self"}]}, {"status": "SUPPORTED", "id": "v1.0", "links": [{"href": "http://devstack.openstack.stack:9292/v1/",
"rel": "self"}]}]}'
http_version:
recorded_at: Mon, 21 Sep 2015 17:49:16 GMT
recorded_with: VCR 2.9.3

View File

@ -0,0 +1,54 @@
---
http_interactions:
- request:
method: get
uri: http://devstack.openstack.stack:9292/v1.1/images/detail
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- 7016a3d2ce5348ae951b1e3d8edaa55d
response:
status:
code: 200
message: ''
headers:
Content-Type:
- application/json; charset=UTF-8
Content-Length:
- '1621'
X-Openstack-Request-Id:
- req-req-6b19389b-d481-47bf-84e7-bf91e231cf6d
Date:
- Mon, 21 Sep 2015 17:49:17 GMT
body:
encoding: US-ASCII
string: ! '{"images": [{"status": "active", "deleted_at": null, "name": "cirros-0.3.2-x86_64-uec",
"deleted": false, "container_format": "ami", "created_at": "2015-05-07T09:35:58.000000",
"disk_format": "ami", "updated_at": "2015-05-07T09:35:58.000000", "min_disk":
0, "protected": false, "id": "d33e934a-55f3-4599-bf4e-d7557c251370", "min_ram":
0, "checksum": "4eada48c2843d2a262c814ddc92ecf2c", "owner": "123ac695d4db400a9001b91bb3b8aa46",
"is_public": true, "virtual_size": null, "properties": {"kernel_id": "a19e0492-ed63-471f-a017-4afcc4c0bf31",
"ramdisk_id": "56f1b09a-f38c-470d-90bb-0d41800d5a6f"}, "size": 25165824},
{"status": "active", "deleted_at": null, "name": "cirros-0.3.2-x86_64-uec-ramdisk",
"deleted": false, "container_format": "ari", "created_at": "2015-05-07T09:35:57.000000",
"disk_format": "ari", "updated_at": "2015-05-07T09:35:57.000000", "min_disk":
0, "protected": false, "id": "56f1b09a-f38c-470d-90bb-0d41800d5a6f", "min_ram":
0, "checksum": "68085af2609d03e51c7662395b5b6e4b", "owner": "123ac695d4db400a9001b91bb3b8aa46",
"is_public": true, "virtual_size": null, "properties": {}, "size": 3723817},
{"status": "active", "deleted_at": null, "name": "cirros-0.3.2-x86_64-uec-kernel",
"deleted": false, "container_format": "aki", "created_at": "2015-05-07T09:35:55.000000",
"disk_format": "aki", "updated_at": "2015-05-07T09:35:55.000000", "min_disk":
0, "protected": false, "id": "a19e0492-ed63-471f-a017-4afcc4c0bf31", "min_ram":
0, "checksum": "836c69cbcd1dc4f225daedbab6edc7c7", "owner": "123ac695d4db400a9001b91bb3b8aa46",
"is_public": true, "virtual_size": null, "properties": {}, "size": 4969360}]}'
http_version:
recorded_at: Mon, 21 Sep 2015 17:49:17 GMT
recorded_with: VCR 2.9.3

View File

@ -0,0 +1,24 @@
require 'fog/openstack/image_v1'
if RUBY_VERSION =~ /1.8/
require File.expand_path('../shared_context', __FILE__)
else
require_relative './shared_context'
end
RSpec.describe Fog::Image::OpenStack do
include_context 'OpenStack specs with VCR'
before :all do
setup_vcr_and_service(
:vcr_directory => 'spec/fog/openstack/image_v1',
:service_class => Fog::Image::OpenStack::V1
)
end
it 'lists available images' do
VCR.use_cassette('list_images') do
@images = @service.images.all
end
end
end

View File

@ -0,0 +1,144 @@
---
http_interactions:
- request:
method: post
uri: http://devstack.openstack.stack:5000/v3/auth/tokens
body:
encoding: UTF-8
string: ! '{"auth":{"identity":{"methods":["password"],"password":{"user":{"password":"password","domain":{"name":"Default"},"name":"admin"}}},"scope":{"project":{"name":"admin","domain":{"name":"Default"}}}}}'
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
response:
status:
code: 201
message: ''
headers:
Date:
- Thu, 10 Sep 2015 11:32:44 GMT
Server:
- Apache/2.4.7 (Ubuntu)
X-Subject-Token:
- d5a7b6bfe2734b0dbff31717ed6b72aa
Vary:
- X-Auth-Token
X-Openstack-Request-Id:
- req-4caa6a71-5771-410c-a70b-d189d1fa8c7e
Content-Length:
- '5874'
Content-Type:
- application/json
body:
encoding: US-ASCII
string: ! '{"token": {"methods": ["password"], "roles": [{"id": "6ead57f8ae124996af8b0beb72ff1007",
"name": "admin"}], "expires_at": "2015-09-10T12:32:44.238650Z", "project":
{"domain": {"id": "default", "name": "Default"}, "id": "123ac695d4db400a9001b91bb3b8aa46",
"name": "admin"}, "catalog": [{"endpoints": [{"region_id": "RegionOne", "url":
"http://devstack.openstack.stack:9292", "region": "RegionOne", "interface": "public",
"id": "6e82c8912d3f49a09df51035681d564c"}, {"region_id": "RegionOne", "url":
"http://devstack.openstack.stack:9292", "region": "RegionOne", "interface": "admin",
"id": "7e44d321ae80457abc3728fa1e6feb32"}, {"region_id": "RegionOne", "url":
"http://devstack.openstack.stack:9292", "region": "RegionOne", "interface": "internal",
"id": "c9a090a4597040849c03bc13588167f6"}], "type": "image", "id": "0d56500210a24c38a3702b6825e24164",
"name": "glance"}, {"endpoints": [{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8776/v2/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "internal", "id": "261aaf6239bb49a4a1cfa87c19859138"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8776/v2/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "admin", "id": "437d282e0bb94622aaacc4d194c069a9"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8776/v2/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "public", "id": "5e78bf7bae7c4ff5b9720b2c2e4da743"}],
"type": "volumev2", "id": "2b92e79c45254516932c633229cd0e8b", "name": "cinderv2"},
{"endpoints": [{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8773/",
"region": "RegionOne", "interface": "admin", "id": "1ce26a6fffd0424bac135b9c68055b6e"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8773/", "region":
"RegionOne", "interface": "public", "id": "98db699b9ffa4dffb027d78163aad8cc"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8773/", "region":
"RegionOne", "interface": "internal", "id": "ece52860cf1e4eb6a8fed05c47a30147"}],
"type": "ec2", "id": "3364a7b95c664bf89a7a8db081576364", "name": "ec2"}, {"endpoints":
[{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8776/v1/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "admin", "id": "4442fbd064844a7bbe6a792507d4b8e3"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8776/v1/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "internal", "id": "4b4178fd2e3d4f329600cc4ceaaa7e3a"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8776/v1/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "public", "id": "90977723dba04ea9a2a184c99565ccff"}],
"type": "volume", "id": "511b94ce0482484ea09028091dd5e9a5", "name": "cinder"},
{"endpoints": [{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8774/v2/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "internal", "id": "81c51855280345e9a6c322ca986d4e4b"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8774/v2/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "admin", "id": "a0310a37cf6144a6a967cbae9a7959ba"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8774/v2/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "public", "id": "f6d38c03b9c04a9e924aaa288ce014b8"}],
"type": "compute", "id": "5b7028751ed045d79467c7845ecb8c58", "name": "nova"},
{"endpoints": [{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8774/v2.1/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "internal", "id": "2f17e155b0aa47838394e6c4f6fe30e0"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8774/v2.1/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "public", "id": "9d2555fd27dd44e5acfb5e56127d974b"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8774/v2.1/123ac695d4db400a9001b91bb3b8aa46",
"region": "RegionOne", "interface": "admin", "id": "e8bdd9403fbb4efa8d77bfd4f6a5e34a"}],
"type": "computev21", "id": "97e665cbada043718180c5a6316df76a", "name": "novav21"},
{"endpoints": [{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:35357/v3",
"region": "RegionOne", "interface": "admin", "id": "185eda94de9340e58245062f75d7f80e"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "internal", "id": "9abd6797844d455f875af9537325cba4"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "public", "id": "d3b31f24e4ea40699f731e29e625c187"}],
"type": "identity", "id": "b577d8f7c7074d04a1165fcca638b600", "name": "keystone_v3x"},
{"endpoints": [{"region_id": "europe", "url": "http://devstack.openstack.stack:35357/v3",
"region": "europe", "interface": "admin", "id": "32bb2c6aea944ea6b4956eb24142d2e2"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "public", "id": "480ea71dc8cf4c959df1c6304be87056"},
{"region_id": "europe", "url": "http://devstack.openstack.stack:5000/v3", "region":
"europe", "interface": "public", "id": "600638643d22494fad4f30e3b22ae124"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "internal", "id": "8a254651925e4a3e9505c863a00c017e"},
{"region_id": "europe", "url": "http://devstack.openstack.stack:5000/v3", "region":
"europe", "interface": "internal", "id": "b93da6aaba654d8cb451ff8378d7d2a5"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:35357/v3", "region":
"RegionOne", "interface": "admin", "id": "d5f8e0da0f3345529a5fb324d735d4a3"}],
"type": "identity_v3", "id": "cd9002bbadfe495d81b5ee4c50768009", "name": "keystone_v3"}],
"extras": {}, "user": {"domain": {"id": "default", "name": "Default"}, "id":
"aa9f25defa6d4cafb48466df83106065", "name": "admin"}, "audit_ids": ["2Xdv6_TVSV-ZctAYHjLvBQ"],
"issued_at": "2015-09-10T11:32:44.238693Z"}}'
http_version:
recorded_at: Thu, 10 Sep 2015 11:32:33 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d5a7b6bfe2734b0dbff31717ed6b72aa
response:
status:
code: 300
message: ''
headers:
Content-Type:
- application/json; charset=UTF-8
Content-Length:
- '666'
Date:
- Thu, 10 Sep 2015 11:32:44 GMT
body:
encoding: US-ASCII
string: ! '{"versions": [{"status": "CURRENT", "id": "v2.3", "links": [{"href":
"http://devstack.openstack.stack:9292/v2/", "rel": "self"}]}, {"status": "SUPPORTED",
"id": "v2.2", "links": [{"href": "http://devstack.openstack.stack:9292/v2/", "rel":
"self"}]}, {"status": "SUPPORTED", "id": "v2.1", "links": [{"href": "http://devstack.openstack.stack:9292/v2/",
"rel": "self"}]}, {"status": "SUPPORTED", "id": "v2.0", "links": [{"href":
"http://devstack.openstack.stack:9292/v2/", "rel": "self"}]}, {"status": "SUPPORTED",
"id": "v1.1", "links": [{"href": "http://devstack.openstack.stack:9292/v1/", "rel":
"self"}]}, {"status": "SUPPORTED", "id": "v1.0", "links": [{"href": "http://devstack.openstack.stack:9292/v1/",
"rel": "self"}]}]}'
http_version:
recorded_at: Thu, 10 Sep 2015 11:32:33 GMT
recorded_with: VCR 2.9.3

View File

@ -0,0 +1,190 @@
{
"additionalProperties": {
"type": "string"
},
"name": "image",
"links": [{
"href": "{self}",
"rel": "self"
},
{
"href": "{file}",
"rel": "enclosure"
},
{
"href": "{schema}",
"rel": "describedby"
}],
"properties": {
"status": {
"enum": ["queued",
"saving",
"active",
"killed",
"deleted",
"pending_delete"],
"type": "string",
"description": "Status of the image (READ-ONLY)"
},
"tags": {
"items": {
"type": "string",
"maxLength": 255
},
"type": "array",
"description": "List of strings related to the image"
},
"kernel_id": {
"pattern": "^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$",
"type": "string",
"description": "ID of image stored in Glance that should be used as the kernel when booting an AMI-style image.",
"is_base": false
},
"container_format": {
"enum": [null,
"ami",
"ari",
"aki",
"bare",
"ovf",
"ova"],
"type": ["null",
"string"],
"description": "Format of the container"
},
"min_ram": {
"type": "integer",
"description": "Amount of ram (in MB) required to boot image."
},
"ramdisk_id": {
"pattern": "^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$",
"type": "string",
"description": "ID of image stored in Glance that should be used as the ramdisk when booting an AMI-style image.",
"is_base": false
},
"locations": {
"items": {
"required": ["url",
"metadata"],
"type": "object",
"properties": {
"url": {
"type": "string",
"maxLength": 255
},
"metadata": {
"type": "object"
}
}
},
"type": "array",
"description": "A set of URLs to access the image file kept in external store"
},
"visibility": {
"enum": ["public",
"private"],
"type": "string",
"description": "Scope of image accessibility"
},
"updated_at": {
"type": "string",
"description": "Date and time of the last image modification (READ-ONLY)"
},
"owner": {
"type": ["null",
"string"],
"description": "Owner of the image",
"maxLength": 255
},
"file": {
"type": "string",
"description": "(READ-ONLY)"
},
"min_disk": {
"type": "integer",
"description": "Amount of disk space (in GB) required to boot image."
},
"virtual_size": {
"type": ["null",
"integer"],
"description": "Virtual size of image in bytes (READ-ONLY)"
},
"id": {
"pattern": "^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$",
"type": "string",
"description": "An identifier for the image"
},
"size": {
"type": ["null",
"integer"],
"description": "Size of image file in bytes (READ-ONLY)"
},
"instance_uuid": {
"type": "string",
"description": "ID of instance used to create this image.",
"is_base": false
},
"os_distro": {
"type": "string",
"description": "Common name of operating system distribution as specified in http://docs.openstack.org/trunk/openstack-compute/admin/content/adding-images.html",
"is_base": false
},
"name": {
"type": ["null",
"string"],
"description": "Descriptive name for the image",
"maxLength": 255
},
"checksum": {
"type": ["null",
"string"],
"description": "md5 hash of image contents. (READ-ONLY)",
"maxLength": 32
},
"created_at": {
"type": "string",
"description": "Date and time of image registration (READ-ONLY)"
},
"disk_format": {
"enum": [null,
"ami",
"ari",
"aki",
"vhd",
"vmdk",
"raw",
"qcow2",
"vdi",
"iso"],
"type": ["null",
"string"],
"description": "Format of the disk"
},
"os_version": {
"type": "string",
"description": "Operating system version as specified by the distributor",
"is_base": false
},
"protected": {
"type": "boolean",
"description": "If true, image will not be deletable."
},
"architecture": {
"type": "string",
"description": "Operating system architecture as specified in http://docs.openstack.org/trunk/openstack-compute/admin/content/adding-images.html",
"is_base": false
},
"direct_url": {
"type": "string",
"description": "URL to access the image file kept in external store (READ-ONLY)"
},
"self": {
"type": "string",
"description": "(READ-ONLY)"
},
"schema": {
"type": "string",
"description": "(READ-ONLY)"
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,291 @@
---
http_interactions:
- request:
method: post
uri: http://devstack.openstack.stack:9292/v2/images
body:
encoding: UTF-8
string: ! '{"name":"foobar_id","id":"11111111-2222-3333-aaaa-bbbbbbccccdf"}'
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d5a7b6bfe2734b0dbff31717ed6b72aa
response:
status:
code: 201
message: ''
headers:
Content-Length:
- '549'
Content-Type:
- application/json; charset=UTF-8
Location:
- http://devstack.openstack.stack:9292/v2/images/11111111-2222-3333-aaaa-bbbbbbccccdf
X-Openstack-Request-Id:
- req-req-49e694c2-5bb6-4800-930f-ec0b3ea6261c
Date:
- Thu, 10 Sep 2015 11:32:44 GMT
body:
encoding: US-ASCII
string: ! '{"status": "queued", "name": "foobar_id", "tags": [], "container_format":
null, "created_at": "2015-09-10T11:32:44Z", "size": null, "disk_format": null,
"updated_at": "2015-09-10T11:32:44Z", "visibility": "private", "self": "/v2/images/11111111-2222-3333-aaaa-bbbbbbccccdf",
"min_disk": 0, "protected": false, "id": "11111111-2222-3333-aaaa-bbbbbbccccdf",
"file": "/v2/images/11111111-2222-3333-aaaa-bbbbbbccccdf/file", "checksum":
null, "owner": "123ac695d4db400a9001b91bb3b8aa46", "virtual_size": null, "min_ram":
0, "schema": "/v2/schemas/image"}'
http_version:
recorded_at: Thu, 10 Sep 2015 11:32:33 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images?name=foobar_id
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d5a7b6bfe2734b0dbff31717ed6b72aa
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '633'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-bdfc5188-daa4-4833-8490-82503a53325f
Date:
- Thu, 10 Sep 2015 11:32:45 GMT
body:
encoding: US-ASCII
string: ! '{"images": [{"status": "queued", "name": "foobar_id", "tags": [],
"container_format": null, "created_at": "2015-09-10T11:32:44Z", "size": null,
"disk_format": null, "updated_at": "2015-09-10T11:32:44Z", "visibility": "private",
"self": "/v2/images/11111111-2222-3333-aaaa-bbbbbbccccdf", "min_disk": 0,
"protected": false, "id": "11111111-2222-3333-aaaa-bbbbbbccccdf", "file":
"/v2/images/11111111-2222-3333-aaaa-bbbbbbccccdf/file", "checksum": null,
"owner": "123ac695d4db400a9001b91bb3b8aa46", "virtual_size": null, "min_ram":
0, "schema": "/v2/schemas/image"}], "schema": "/v2/schemas/images", "first":
"/v2/images?name=foobar_id"}'
http_version:
recorded_at: Thu, 10 Sep 2015 11:32:33 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/11111111-2222-3333-aaaa-bbbbbbccccdf
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d5a7b6bfe2734b0dbff31717ed6b72aa
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '549'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-8f5d9407-c0e1-40d7-8639-1eb362a6502d
Date:
- Thu, 10 Sep 2015 11:32:45 GMT
body:
encoding: US-ASCII
string: ! '{"status": "queued", "name": "foobar_id", "tags": [], "container_format":
null, "created_at": "2015-09-10T11:32:44Z", "size": null, "disk_format": null,
"updated_at": "2015-09-10T11:32:44Z", "visibility": "private", "self": "/v2/images/11111111-2222-3333-aaaa-bbbbbbccccdf",
"min_disk": 0, "protected": false, "id": "11111111-2222-3333-aaaa-bbbbbbccccdf",
"file": "/v2/images/11111111-2222-3333-aaaa-bbbbbbccccdf/file", "checksum":
null, "owner": "123ac695d4db400a9001b91bb3b8aa46", "virtual_size": null, "min_ram":
0, "schema": "/v2/schemas/image"}'
http_version:
recorded_at: Thu, 10 Sep 2015 11:32:33 GMT
- request:
method: delete
uri: http://devstack.openstack.stack:9292/v2/images/11111111-2222-3333-aaaa-bbbbbbccccdf
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d5a7b6bfe2734b0dbff31717ed6b72aa
response:
status:
code: 204
message: ''
headers:
Content-Type:
- text/html; charset=UTF-8
Content-Length:
- '0'
X-Openstack-Request-Id:
- req-req-25192aa9-049d-41f9-b8a0-6a536f65588f
Date:
- Thu, 10 Sep 2015 11:32:45 GMT
body:
encoding: US-ASCII
string: ''
http_version:
recorded_at: Thu, 10 Sep 2015 11:32:33 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/11111111-2222-3333-aaaa-bbbbbbccccdf
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d5a7b6bfe2734b0dbff31717ed6b72aa
response:
status:
code: 404
message: ''
headers:
Content-Length:
- '79'
Content-Type:
- text/plain; charset=UTF-8
X-Openstack-Request-Id:
- req-req-a61362fd-2ebb-4893-9273-4c6cbdd3399a
Date:
- Thu, 10 Sep 2015 11:32:45 GMT
body:
encoding: US-ASCII
string: ! "404 Not Found\n\nNo image found with ID 11111111-2222-3333-aaaa-bbbbbbccccdf\n\n
\ "
http_version:
recorded_at: Thu, 10 Sep 2015 11:32:34 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images?name=foobar_id
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d5a7b6bfe2734b0dbff31717ed6b72aa
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '84'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-0733b406-d607-4bc0-8004-0ae90db5d972
Date:
- Thu, 10 Sep 2015 11:32:45 GMT
body:
encoding: US-ASCII
string: ! '{"images": [], "schema": "/v2/schemas/images", "first": "/v2/images?name=foobar_id"}'
http_version:
recorded_at: Thu, 10 Sep 2015 11:32:34 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/11111111-2222-3333-aaaa-bbbbbbccccdf
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d5a7b6bfe2734b0dbff31717ed6b72aa
response:
status:
code: 404
message: ''
headers:
Content-Length:
- '79'
Content-Type:
- text/plain; charset=UTF-8
X-Openstack-Request-Id:
- req-req-15646532-d738-49d4-99ff-440ae731f9bb
Date:
- Thu, 10 Sep 2015 11:32:45 GMT
body:
encoding: US-ASCII
string: ! "404 Not Found\n\nNo image found with ID 11111111-2222-3333-aaaa-bbbbbbccccdf\n\n
\ "
http_version:
recorded_at: Thu, 10 Sep 2015 11:32:34 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images?name=foobar_id
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d5a7b6bfe2734b0dbff31717ed6b72aa
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '84'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-23e6d724-f92c-4920-aa89-9d2d545d7c80
Date:
- Thu, 10 Sep 2015 11:32:45 GMT
body:
encoding: US-ASCII
string: ! '{"images": [], "schema": "/v2/schemas/images", "first": "/v2/images?name=foobar_id"}'
http_version:
recorded_at: Thu, 10 Sep 2015 11:32:34 GMT
recorded_with: VCR 2.9.3

View File

@ -0,0 +1,437 @@
---
http_interactions:
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '1987'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-0e399ccb-f5a8-47cc-b017-7e4058daccc2
Date:
- Thu, 10 Sep 2015 15:17:01 GMT
body:
encoding: US-ASCII
string: ! '{"images": [{"status": "active", "name": "cirros-0.3.2-x86_64-uec",
"tags": [], "kernel_id": "a19e0492-ed63-471f-a017-4afcc4c0bf31", "container_format":
"ami", "created_at": "2015-05-07T09:35:58Z", "ramdisk_id": "56f1b09a-f38c-470d-90bb-0d41800d5a6f",
"disk_format": "ami", "updated_at": "2015-05-07T09:35:58Z", "visibility":
"public", "self": "/v2/images/d33e934a-55f3-4599-bf4e-d7557c251370", "min_disk":
0, "protected": false, "id": "d33e934a-55f3-4599-bf4e-d7557c251370", "size":
25165824, "file": "/v2/images/d33e934a-55f3-4599-bf4e-d7557c251370/file",
"checksum": "4eada48c2843d2a262c814ddc92ecf2c", "owner": "123ac695d4db400a9001b91bb3b8aa46",
"virtual_size": null, "min_ram": 0, "schema": "/v2/schemas/image"}, {"status":
"active", "name": "cirros-0.3.2-x86_64-uec-ramdisk", "tags": [], "container_format":
"ari", "created_at": "2015-05-07T09:35:57Z", "size": 3723817, "disk_format":
"ari", "updated_at": "2015-05-07T09:35:57Z", "visibility": "public", "self":
"/v2/images/56f1b09a-f38c-470d-90bb-0d41800d5a6f", "min_disk": 0, "protected":
false, "id": "56f1b09a-f38c-470d-90bb-0d41800d5a6f", "file": "/v2/images/56f1b09a-f38c-470d-90bb-0d41800d5a6f/file",
"checksum": "68085af2609d03e51c7662395b5b6e4b", "owner": "123ac695d4db400a9001b91bb3b8aa46",
"virtual_size": null, "min_ram": 0, "schema": "/v2/schemas/image"}, {"status":
"active", "name": "cirros-0.3.2-x86_64-uec-kernel", "tags": [], "container_format":
"aki", "created_at": "2015-05-07T09:35:55Z", "size": 4969360, "disk_format":
"aki", "updated_at": "2015-05-07T09:35:55Z", "visibility": "public", "self":
"/v2/images/a19e0492-ed63-471f-a017-4afcc4c0bf31", "min_disk": 0, "protected":
false, "id": "a19e0492-ed63-471f-a017-4afcc4c0bf31", "file": "/v2/images/a19e0492-ed63-471f-a017-4afcc4c0bf31/file",
"checksum": "836c69cbcd1dc4f225daedbab6edc7c7", "owner": "123ac695d4db400a9001b91bb3b8aa46",
"virtual_size": null, "min_ram": 0, "schema": "/v2/schemas/image"}], "schema":
"/v2/schemas/images", "first": "/v2/images"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:39 GMT
- request:
method: post
uri: http://devstack.openstack.stack:9292/v2/images
body:
encoding: UTF-8
string: ! '{"name":"foobar"}'
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 201
message: ''
headers:
Content-Length:
- '546'
Content-Type:
- application/json; charset=UTF-8
Location:
- http://devstack.openstack.stack:9292/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5
X-Openstack-Request-Id:
- req-req-e36a81e0-37c4-487a-834a-a946202bc051
Date:
- Thu, 10 Sep 2015 15:17:01 GMT
body:
encoding: US-ASCII
string: ! '{"status": "queued", "name": "foobar", "tags": [], "container_format":
null, "created_at": "2015-09-10T15:17:01Z", "size": null, "disk_format": null,
"updated_at": "2015-09-10T15:17:01Z", "visibility": "private", "self": "/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5",
"min_disk": 0, "protected": false, "id": "bae4352d-db13-4e95-9143-1685f9ea7fd5",
"file": "/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5/file", "checksum":
null, "owner": "123ac695d4db400a9001b91bb3b8aa46", "virtual_size": null, "min_ram":
0, "schema": "/v2/schemas/image"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:39 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images?name=foobar
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '627'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-1e9b9fc5-6858-470a-96ed-32270467b89d
Date:
- Thu, 10 Sep 2015 15:17:01 GMT
body:
encoding: US-ASCII
string: ! '{"images": [{"status": "queued", "name": "foobar", "tags": [], "container_format":
null, "created_at": "2015-09-10T15:17:01Z", "size": null, "disk_format": null,
"updated_at": "2015-09-10T15:17:01Z", "visibility": "private", "self": "/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5",
"min_disk": 0, "protected": false, "id": "bae4352d-db13-4e95-9143-1685f9ea7fd5",
"file": "/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5/file", "checksum":
null, "owner": "123ac695d4db400a9001b91bb3b8aa46", "virtual_size": null, "min_ram":
0, "schema": "/v2/schemas/image"}], "schema": "/v2/schemas/images", "first":
"/v2/images?name=foobar"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:39 GMT
- request:
method: patch
uri: http://devstack.openstack.stack:9292/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5
body:
encoding: UTF-8
string: ! '[{"op":"replace","path":"/name","value":"baz"}]'
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/openstack-images-v2.1-json-patch
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '543'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-14373219-0fe9-4405-b195-e126bcdc358c
Date:
- Thu, 10 Sep 2015 15:17:01 GMT
body:
encoding: US-ASCII
string: ! '{"status": "queued", "name": "baz", "tags": [], "container_format":
null, "created_at": "2015-09-10T15:17:01Z", "size": null, "disk_format": null,
"updated_at": "2015-09-10T15:17:01Z", "visibility": "private", "self": "/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5",
"min_disk": 0, "protected": false, "id": "bae4352d-db13-4e95-9143-1685f9ea7fd5",
"file": "/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5/file", "checksum":
null, "owner": "123ac695d4db400a9001b91bb3b8aa46", "virtual_size": null, "min_ram":
0, "schema": "/v2/schemas/image"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:39 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '543'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-ae8ec1ae-b5c5-4073-81ac-b0e9037c33db
Date:
- Thu, 10 Sep 2015 15:17:01 GMT
body:
encoding: US-ASCII
string: ! '{"status": "queued", "name": "baz", "tags": [], "container_format":
null, "created_at": "2015-09-10T15:17:01Z", "size": null, "disk_format": null,
"updated_at": "2015-09-10T15:17:01Z", "visibility": "private", "self": "/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5",
"min_disk": 0, "protected": false, "id": "bae4352d-db13-4e95-9143-1685f9ea7fd5",
"file": "/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5/file", "checksum":
null, "owner": "123ac695d4db400a9001b91bb3b8aa46", "virtual_size": null, "min_ram":
0, "schema": "/v2/schemas/image"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:40 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images?name=baz
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '621'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-f280e84a-2b32-4616-ba8d-0481c85f1c53
Date:
- Thu, 10 Sep 2015 15:17:01 GMT
body:
encoding: US-ASCII
string: ! '{"images": [{"status": "queued", "name": "baz", "tags": [], "container_format":
null, "created_at": "2015-09-10T15:17:01Z", "size": null, "disk_format": null,
"updated_at": "2015-09-10T15:17:01Z", "visibility": "private", "self": "/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5",
"min_disk": 0, "protected": false, "id": "bae4352d-db13-4e95-9143-1685f9ea7fd5",
"file": "/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5/file", "checksum":
null, "owner": "123ac695d4db400a9001b91bb3b8aa46", "virtual_size": null, "min_ram":
0, "schema": "/v2/schemas/image"}], "schema": "/v2/schemas/images", "first":
"/v2/images?name=baz"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:40 GMT
- request:
method: delete
uri: http://devstack.openstack.stack:9292/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 204
message: ''
headers:
Content-Type:
- text/html; charset=UTF-8
Content-Length:
- '0'
X-Openstack-Request-Id:
- req-req-de47330f-f096-43ce-860e-3ef344bd7da6
Date:
- Thu, 10 Sep 2015 15:17:01 GMT
body:
encoding: US-ASCII
string: ''
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:40 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '1987'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-90e5831c-8569-4416-8997-61e8a0be7ec3
Date:
- Thu, 10 Sep 2015 15:17:01 GMT
body:
encoding: US-ASCII
string: ! '{"images": [{"status": "active", "name": "cirros-0.3.2-x86_64-uec",
"tags": [], "kernel_id": "a19e0492-ed63-471f-a017-4afcc4c0bf31", "container_format":
"ami", "created_at": "2015-05-07T09:35:58Z", "ramdisk_id": "56f1b09a-f38c-470d-90bb-0d41800d5a6f",
"disk_format": "ami", "updated_at": "2015-05-07T09:35:58Z", "visibility":
"public", "self": "/v2/images/d33e934a-55f3-4599-bf4e-d7557c251370", "min_disk":
0, "protected": false, "id": "d33e934a-55f3-4599-bf4e-d7557c251370", "size":
25165824, "file": "/v2/images/d33e934a-55f3-4599-bf4e-d7557c251370/file",
"checksum": "4eada48c2843d2a262c814ddc92ecf2c", "owner": "123ac695d4db400a9001b91bb3b8aa46",
"virtual_size": null, "min_ram": 0, "schema": "/v2/schemas/image"}, {"status":
"active", "name": "cirros-0.3.2-x86_64-uec-ramdisk", "tags": [], "container_format":
"ari", "created_at": "2015-05-07T09:35:57Z", "size": 3723817, "disk_format":
"ari", "updated_at": "2015-05-07T09:35:57Z", "visibility": "public", "self":
"/v2/images/56f1b09a-f38c-470d-90bb-0d41800d5a6f", "min_disk": 0, "protected":
false, "id": "56f1b09a-f38c-470d-90bb-0d41800d5a6f", "file": "/v2/images/56f1b09a-f38c-470d-90bb-0d41800d5a6f/file",
"checksum": "68085af2609d03e51c7662395b5b6e4b", "owner": "123ac695d4db400a9001b91bb3b8aa46",
"virtual_size": null, "min_ram": 0, "schema": "/v2/schemas/image"}, {"status":
"active", "name": "cirros-0.3.2-x86_64-uec-kernel", "tags": [], "container_format":
"aki", "created_at": "2015-05-07T09:35:55Z", "size": 4969360, "disk_format":
"aki", "updated_at": "2015-05-07T09:35:55Z", "visibility": "public", "self":
"/v2/images/a19e0492-ed63-471f-a017-4afcc4c0bf31", "min_disk": 0, "protected":
false, "id": "a19e0492-ed63-471f-a017-4afcc4c0bf31", "file": "/v2/images/a19e0492-ed63-471f-a017-4afcc4c0bf31/file",
"checksum": "836c69cbcd1dc4f225daedbab6edc7c7", "owner": "123ac695d4db400a9001b91bb3b8aa46",
"virtual_size": null, "min_ram": 0, "schema": "/v2/schemas/image"}], "schema":
"/v2/schemas/images", "first": "/v2/images"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:40 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/bae4352d-db13-4e95-9143-1685f9ea7fd5
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 404
message: ''
headers:
Content-Length:
- '79'
Content-Type:
- text/plain; charset=UTF-8
X-Openstack-Request-Id:
- req-req-9133aec2-d901-434a-bbd6-64505195ca9c
Date:
- Thu, 10 Sep 2015 15:17:01 GMT
body:
encoding: US-ASCII
string: ! "404 Not Found\n\nNo image found with ID bae4352d-db13-4e95-9143-1685f9ea7fd5\n\n
\ "
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:40 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '1987'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-de5f2b7d-80e7-4d6f-900b-3e870039d09d
Date:
- Thu, 10 Sep 2015 15:17:01 GMT
body:
encoding: US-ASCII
string: ! '{"images": [{"status": "active", "name": "cirros-0.3.2-x86_64-uec",
"tags": [], "kernel_id": "a19e0492-ed63-471f-a017-4afcc4c0bf31", "container_format":
"ami", "created_at": "2015-05-07T09:35:58Z", "ramdisk_id": "56f1b09a-f38c-470d-90bb-0d41800d5a6f",
"disk_format": "ami", "updated_at": "2015-05-07T09:35:58Z", "visibility":
"public", "self": "/v2/images/d33e934a-55f3-4599-bf4e-d7557c251370", "min_disk":
0, "protected": false, "id": "d33e934a-55f3-4599-bf4e-d7557c251370", "size":
25165824, "file": "/v2/images/d33e934a-55f3-4599-bf4e-d7557c251370/file",
"checksum": "4eada48c2843d2a262c814ddc92ecf2c", "owner": "123ac695d4db400a9001b91bb3b8aa46",
"virtual_size": null, "min_ram": 0, "schema": "/v2/schemas/image"}, {"status":
"active", "name": "cirros-0.3.2-x86_64-uec-ramdisk", "tags": [], "container_format":
"ari", "created_at": "2015-05-07T09:35:57Z", "size": 3723817, "disk_format":
"ari", "updated_at": "2015-05-07T09:35:57Z", "visibility": "public", "self":
"/v2/images/56f1b09a-f38c-470d-90bb-0d41800d5a6f", "min_disk": 0, "protected":
false, "id": "56f1b09a-f38c-470d-90bb-0d41800d5a6f", "file": "/v2/images/56f1b09a-f38c-470d-90bb-0d41800d5a6f/file",
"checksum": "68085af2609d03e51c7662395b5b6e4b", "owner": "123ac695d4db400a9001b91bb3b8aa46",
"virtual_size": null, "min_ram": 0, "schema": "/v2/schemas/image"}, {"status":
"active", "name": "cirros-0.3.2-x86_64-uec-kernel", "tags": [], "container_format":
"aki", "created_at": "2015-05-07T09:35:55Z", "size": 4969360, "disk_format":
"aki", "updated_at": "2015-05-07T09:35:55Z", "visibility": "public", "self":
"/v2/images/a19e0492-ed63-471f-a017-4afcc4c0bf31", "min_disk": 0, "protected":
false, "id": "a19e0492-ed63-471f-a017-4afcc4c0bf31", "file": "/v2/images/a19e0492-ed63-471f-a017-4afcc4c0bf31/file",
"checksum": "836c69cbcd1dc4f225daedbab6edc7c7", "owner": "123ac695d4db400a9001b91bb3b8aa46",
"virtual_size": null, "min_ram": 0, "schema": "/v2/schemas/image"}], "schema":
"/v2/schemas/images", "first": "/v2/images"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:40 GMT
recorded_with: VCR 2.9.3

View File

@ -0,0 +1,451 @@
---
http_interactions:
- request:
method: post
uri: http://devstack.openstack.stack:9292/v2/images
body:
encoding: UTF-8
string: ! '{"name":"foobar4"}'
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 201
message: ''
headers:
Content-Length:
- '547'
Content-Type:
- application/json; charset=UTF-8
Location:
- http://devstack.openstack.stack:9292/v2/images/fc8ecc3c-c3d1-45d3-a006-baf5f5591020
X-Openstack-Request-Id:
- req-req-41d45efa-72f7-4798-9860-cda0dd160ceb
Date:
- Thu, 10 Sep 2015 15:17:02 GMT
body:
encoding: US-ASCII
string: ! '{"status": "queued", "name": "foobar4", "tags": [], "container_format":
null, "created_at": "2015-09-10T15:17:02Z", "size": null, "disk_format": null,
"updated_at": "2015-09-10T15:17:02Z", "visibility": "private", "self": "/v2/images/fc8ecc3c-c3d1-45d3-a006-baf5f5591020",
"min_disk": 0, "protected": false, "id": "fc8ecc3c-c3d1-45d3-a006-baf5f5591020",
"file": "/v2/images/fc8ecc3c-c3d1-45d3-a006-baf5f5591020/file", "checksum":
null, "owner": "123ac695d4db400a9001b91bb3b8aa46", "virtual_size": null, "min_ram":
0, "schema": "/v2/schemas/image"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:41 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/fc8ecc3c-c3d1-45d3-a006-baf5f5591020/members
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '48'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-8e20c9b9-0f22-4203-85d4-dcdd7e6dc6f3
Date:
- Thu, 10 Sep 2015 15:17:02 GMT
body:
encoding: US-ASCII
string: ! '{"members": [], "schema": "/v2/schemas/members"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:41 GMT
- request:
method: post
uri: http://devstack.openstack.stack:9292/v2/images/fc8ecc3c-c3d1-45d3-a006-baf5f5591020/members
body:
encoding: UTF-8
string: ! '{"member":"tenant1"}'
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '205'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-89683138-d364-4e5d-b5e2-c881acd8c26f
Date:
- Thu, 10 Sep 2015 15:17:03 GMT
body:
encoding: US-ASCII
string: ! '{"status": "pending", "created_at": "2015-09-10T15:17:03Z", "updated_at":
"2015-09-10T15:17:03Z", "image_id": "fc8ecc3c-c3d1-45d3-a006-baf5f5591020",
"member_id": "tenant1", "schema": "/v2/schemas/member"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:41 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/fc8ecc3c-c3d1-45d3-a006-baf5f5591020/members
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '253'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-7067500c-f27d-44ea-b4d3-85cf1020a926
Date:
- Thu, 10 Sep 2015 15:17:03 GMT
body:
encoding: US-ASCII
string: ! '{"members": [{"status": "pending", "created_at": "2015-09-10T15:17:03Z",
"updated_at": "2015-09-10T15:17:03Z", "image_id": "fc8ecc3c-c3d1-45d3-a006-baf5f5591020",
"member_id": "tenant1", "schema": "/v2/schemas/member"}], "schema": "/v2/schemas/members"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:41 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/fc8ecc3c-c3d1-45d3-a006-baf5f5591020/members/tenant1
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '205'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-971cdbea-3880-44c2-a548-d0b01d485b30
Date:
- Thu, 10 Sep 2015 15:17:03 GMT
body:
encoding: US-ASCII
string: ! '{"status": "pending", "created_at": "2015-09-10T15:17:03Z", "updated_at":
"2015-09-10T15:17:03Z", "image_id": "fc8ecc3c-c3d1-45d3-a006-baf5f5591020",
"member_id": "tenant1", "schema": "/v2/schemas/member"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:41 GMT
- request:
method: put
uri: http://devstack.openstack.stack:9292/v2/images/fc8ecc3c-c3d1-45d3-a006-baf5f5591020/members/tenant1
body:
encoding: UTF-8
string: ! '{"status":"accepted"}'
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '206'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-dfd8b884-e2cd-470b-8b9f-9bdffbf70a25
Date:
- Thu, 10 Sep 2015 15:17:03 GMT
body:
encoding: US-ASCII
string: ! '{"status": "accepted", "created_at": "2015-09-10T15:17:03Z", "updated_at":
"2015-09-10T15:17:03Z", "image_id": "fc8ecc3c-c3d1-45d3-a006-baf5f5591020",
"member_id": "tenant1", "schema": "/v2/schemas/member"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:41 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/fc8ecc3c-c3d1-45d3-a006-baf5f5591020/members/tenant1
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '206'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-bedabea9-a63b-44f8-aa79-80a553b028f6
Date:
- Thu, 10 Sep 2015 15:17:03 GMT
body:
encoding: US-ASCII
string: ! '{"status": "accepted", "created_at": "2015-09-10T15:17:03Z", "updated_at":
"2015-09-10T15:17:03Z", "image_id": "fc8ecc3c-c3d1-45d3-a006-baf5f5591020",
"member_id": "tenant1", "schema": "/v2/schemas/member"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:41 GMT
- request:
method: delete
uri: http://devstack.openstack.stack:9292/v2/images/fc8ecc3c-c3d1-45d3-a006-baf5f5591020/members/tenant1
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 204
message: ''
headers:
Content-Type:
- text/html; charset=UTF-8
Content-Length:
- '0'
X-Openstack-Request-Id:
- req-req-f804d4d7-a8cb-4f04-939b-39a487347ce1
Date:
- Thu, 10 Sep 2015 15:17:03 GMT
body:
encoding: US-ASCII
string: ''
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:41 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/fc8ecc3c-c3d1-45d3-a006-baf5f5591020/members
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '48'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-4538087a-54c6-4aec-8bac-2e6943266178
Date:
- Thu, 10 Sep 2015 15:17:03 GMT
body:
encoding: US-ASCII
string: ! '{"members": [], "schema": "/v2/schemas/members"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:41 GMT
- request:
method: delete
uri: http://devstack.openstack.stack:9292/v2/images/fc8ecc3c-c3d1-45d3-a006-baf5f5591020
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 204
message: ''
headers:
Content-Type:
- text/html; charset=UTF-8
Content-Length:
- '0'
X-Openstack-Request-Id:
- req-req-696cf118-77d7-4338-ad8b-ffba43a0fa5b
Date:
- Thu, 10 Sep 2015 15:17:03 GMT
body:
encoding: US-ASCII
string: ''
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:42 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images?name=foobar4
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '82'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-4d0180ca-5142-49f8-8950-4b359c07c643
Date:
- Thu, 10 Sep 2015 15:17:03 GMT
body:
encoding: US-ASCII
string: ! '{"images": [], "schema": "/v2/schemas/images", "first": "/v2/images?name=foobar4"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:42 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/fc8ecc3c-c3d1-45d3-a006-baf5f5591020
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 404
message: ''
headers:
Content-Length:
- '79'
Content-Type:
- text/plain; charset=UTF-8
X-Openstack-Request-Id:
- req-req-2922371f-c446-42e9-b81a-fe88b9f83457
Date:
- Thu, 10 Sep 2015 15:17:03 GMT
body:
encoding: US-ASCII
string: ! "404 Not Found\n\nNo image found with ID fc8ecc3c-c3d1-45d3-a006-baf5f5591020\n\n
\ "
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:42 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images?name=foobar4
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- d1c47d0051d24b23a65222e7d4b5ba59
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '82'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-ec7eeb9f-2d21-4ad8-8eb4-918e933b957f
Date:
- Thu, 10 Sep 2015 15:17:03 GMT
body:
encoding: US-ASCII
string: ! '{"images": [], "schema": "/v2/schemas/images", "first": "/v2/images?name=foobar4"}'
http_version:
recorded_at: Thu, 10 Sep 2015 15:16:42 GMT
recorded_with: VCR 2.9.3

View File

@ -0,0 +1,532 @@
---
http_interactions:
- request:
method: post
uri: http://devstack.openstack.stack:9292/v2/images
body:
encoding: UTF-8
string: ! '{"name":"foobar3","container_format":"ovf","disk_format":"vmdk"}'
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 201
message: ''
headers:
Content-Length:
- '550'
Content-Type:
- application/json; charset=UTF-8
Location:
- http://devstack.openstack.stack:9292/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3
X-Openstack-Request-Id:
- req-req-0cf5460a-f062-477d-a259-6a1997de9ea1
Date:
- Fri, 11 Sep 2015 11:04:07 GMT
body:
encoding: US-ASCII
string: ! '{"status": "queued", "name": "foobar3", "tags": [], "container_format":
"ovf", "created_at": "2015-09-11T11:04:07Z", "size": null, "disk_format":
"vmdk", "updated_at": "2015-09-11T11:04:07Z", "visibility": "private", "self":
"/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3", "min_disk": 0, "protected":
false, "id": "7350cdc6-8531-4366-8380-7fada969b1c3", "file": "/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3/file",
"checksum": null, "owner": "123ac695d4db400a9001b91bb3b8aa46", "virtual_size":
null, "min_ram": 0, "schema": "/v2/schemas/image"}'
http_version:
recorded_at: Fri, 11 Sep 2015 11:03:58 GMT
- request:
method: put
uri: http://devstack.openstack.stack:9292/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3/tags/tag1
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 204
message: ''
headers:
Content-Type:
- text/html; charset=UTF-8
Content-Length:
- '0'
X-Openstack-Request-Id:
- req-req-0efcc015-5f84-4b18-bbba-224301cae481
Date:
- Fri, 11 Sep 2015 11:04:07 GMT
body:
encoding: US-ASCII
string: ''
http_version:
recorded_at: Fri, 11 Sep 2015 11:03:59 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '556'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-bfcbfc73-6a35-4b2f-ae77-8cf109fa0b98
Date:
- Fri, 11 Sep 2015 11:04:07 GMT
body:
encoding: US-ASCII
string: ! '{"status": "queued", "name": "foobar3", "tags": ["tag1"], "container_format":
"ovf", "created_at": "2015-09-11T11:04:07Z", "size": null, "disk_format":
"vmdk", "updated_at": "2015-09-11T11:04:07Z", "visibility": "private", "self":
"/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3", "min_disk": 0, "protected":
false, "id": "7350cdc6-8531-4366-8380-7fada969b1c3", "file": "/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3/file",
"checksum": null, "owner": "123ac695d4db400a9001b91bb3b8aa46", "virtual_size":
null, "min_ram": 0, "schema": "/v2/schemas/image"}'
http_version:
recorded_at: Fri, 11 Sep 2015 11:03:59 GMT
- request:
method: put
uri: http://devstack.openstack.stack:9292/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3/tags/tag2
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 204
message: ''
headers:
Content-Type:
- text/html; charset=UTF-8
Content-Length:
- '0'
X-Openstack-Request-Id:
- req-req-52a5adf2-c7cc-4a3b-9a50-213a6ea34693
Date:
- Fri, 11 Sep 2015 11:04:08 GMT
body:
encoding: US-ASCII
string: ''
http_version:
recorded_at: Fri, 11 Sep 2015 11:03:59 GMT
- request:
method: put
uri: http://devstack.openstack.stack:9292/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3/tags/tag3
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 204
message: ''
headers:
Content-Type:
- text/html; charset=UTF-8
Content-Length:
- '0'
X-Openstack-Request-Id:
- req-req-32ef90e3-bdc0-4d53-aa1a-4b60482015f6
Date:
- Fri, 11 Sep 2015 11:04:08 GMT
body:
encoding: US-ASCII
string: ''
http_version:
recorded_at: Fri, 11 Sep 2015 11:03:59 GMT
- request:
method: put
uri: http://devstack.openstack.stack:9292/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3/tags/tag4
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 204
message: ''
headers:
Content-Type:
- text/html; charset=UTF-8
Content-Length:
- '0'
X-Openstack-Request-Id:
- req-req-8a9013df-1129-4b2b-aba8-ec2602086f5e
Date:
- Fri, 11 Sep 2015 11:04:08 GMT
body:
encoding: US-ASCII
string: ''
http_version:
recorded_at: Fri, 11 Sep 2015 11:03:59 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '580'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-ba3ddd55-34cb-4aad-8f74-aad9527df092
Date:
- Fri, 11 Sep 2015 11:04:08 GMT
body:
encoding: US-ASCII
string: ! '{"status": "queued", "name": "foobar3", "tags": ["tag4", "tag1",
"tag2", "tag3"], "container_format": "ovf", "created_at": "2015-09-11T11:04:07Z",
"size": null, "disk_format": "vmdk", "updated_at": "2015-09-11T11:04:08Z",
"visibility": "private", "self": "/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3",
"min_disk": 0, "protected": false, "id": "7350cdc6-8531-4366-8380-7fada969b1c3",
"file": "/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3/file", "checksum":
null, "owner": "123ac695d4db400a9001b91bb3b8aa46", "virtual_size": null, "min_ram":
0, "schema": "/v2/schemas/image"}'
http_version:
recorded_at: Fri, 11 Sep 2015 11:03:59 GMT
- request:
method: delete
uri: http://devstack.openstack.stack:9292/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3/tags/tag2
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 204
message: ''
headers:
Content-Type:
- text/html; charset=UTF-8
Content-Length:
- '0'
X-Openstack-Request-Id:
- req-req-0542336e-f5ff-4a0d-9c2d-26c24bda4dd9
Date:
- Fri, 11 Sep 2015 11:04:08 GMT
body:
encoding: US-ASCII
string: ''
http_version:
recorded_at: Fri, 11 Sep 2015 11:03:59 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '572'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-d8d89ec3-7d94-420f-862e-098a708fb5cc
Date:
- Fri, 11 Sep 2015 11:04:08 GMT
body:
encoding: US-ASCII
string: ! '{"status": "queued", "name": "foobar3", "tags": ["tag4", "tag1",
"tag3"], "container_format": "ovf", "created_at": "2015-09-11T11:04:07Z",
"size": null, "disk_format": "vmdk", "updated_at": "2015-09-11T11:04:08Z",
"visibility": "private", "self": "/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3",
"min_disk": 0, "protected": false, "id": "7350cdc6-8531-4366-8380-7fada969b1c3",
"file": "/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3/file", "checksum":
null, "owner": "123ac695d4db400a9001b91bb3b8aa46", "virtual_size": null, "min_ram":
0, "schema": "/v2/schemas/image"}'
http_version:
recorded_at: Fri, 11 Sep 2015 11:03:59 GMT
- request:
method: delete
uri: http://devstack.openstack.stack:9292/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3/tags/tag1
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 204
message: ''
headers:
Content-Type:
- text/html; charset=UTF-8
Content-Length:
- '0'
X-Openstack-Request-Id:
- req-req-2f76841a-a250-4e01-af8f-b599857b5ba2
Date:
- Fri, 11 Sep 2015 11:04:08 GMT
body:
encoding: US-ASCII
string: ''
http_version:
recorded_at: Fri, 11 Sep 2015 11:03:59 GMT
- request:
method: delete
uri: http://devstack.openstack.stack:9292/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3/tags/tag3
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 204
message: ''
headers:
Content-Type:
- text/html; charset=UTF-8
Content-Length:
- '0'
X-Openstack-Request-Id:
- req-req-79e21f00-8a2f-4ca6-8694-72f98b84a507
Date:
- Fri, 11 Sep 2015 11:04:08 GMT
body:
encoding: US-ASCII
string: ''
http_version:
recorded_at: Fri, 11 Sep 2015 11:03:59 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '556'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-538b07e3-f55a-4791-8885-849c6d665958
Date:
- Fri, 11 Sep 2015 11:04:08 GMT
body:
encoding: US-ASCII
string: ! '{"status": "queued", "name": "foobar3", "tags": ["tag4"], "container_format":
"ovf", "created_at": "2015-09-11T11:04:07Z", "size": null, "disk_format":
"vmdk", "updated_at": "2015-09-11T11:04:08Z", "visibility": "private", "self":
"/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3", "min_disk": 0, "protected":
false, "id": "7350cdc6-8531-4366-8380-7fada969b1c3", "file": "/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3/file",
"checksum": null, "owner": "123ac695d4db400a9001b91bb3b8aa46", "virtual_size":
null, "min_ram": 0, "schema": "/v2/schemas/image"}'
http_version:
recorded_at: Fri, 11 Sep 2015 11:04:00 GMT
- request:
method: delete
uri: http://devstack.openstack.stack:9292/v2/images/7350cdc6-8531-4366-8380-7fada969b1c3
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 204
message: ''
headers:
Content-Type:
- text/html; charset=UTF-8
Content-Length:
- '0'
X-Openstack-Request-Id:
- req-req-5d283c2e-e9d0-4555-b3c5-2028087428be
Date:
- Fri, 11 Sep 2015 11:04:08 GMT
body:
encoding: US-ASCII
string: ''
http_version:
recorded_at: Fri, 11 Sep 2015 11:04:00 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images?name=foobar3
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '82'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-84c6d158-1d7e-4c73-b84e-4b5d8d1005a2
Date:
- Fri, 11 Sep 2015 11:04:08 GMT
body:
encoding: US-ASCII
string: ! '{"images": [], "schema": "/v2/schemas/images", "first": "/v2/images?name=foobar3"}'
http_version:
recorded_at: Fri, 11 Sep 2015 11:04:00 GMT
- request:
method: get
uri: http://devstack.openstack.stack:9292/v2/images?name=foobar3
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- fog-core/1.32.1
Content-Type:
- application/json
Accept:
- application/json
X-Auth-Token:
- e9723aaaf8f24e8fb2d6aee7a33a4d13
response:
status:
code: 200
message: ''
headers:
Content-Length:
- '82'
Content-Type:
- application/json; charset=UTF-8
X-Openstack-Request-Id:
- req-req-7a4a0490-b0ba-4c79-aeea-df636052486e
Date:
- Fri, 11 Sep 2015 11:04:08 GMT
body:
encoding: US-ASCII
string: ! '{"images": [], "schema": "/v2/schemas/images", "first": "/v2/images?name=foobar3"}'
http_version:
recorded_at: Fri, 11 Sep 2015 11:04:00 GMT
recorded_with: VCR 2.9.3

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,285 @@
require 'fog/openstack/image_v2'
if RUBY_VERSION =~ /1.8/
require File.expand_path('../shared_context', __FILE__)
else
require_relative './shared_context'
end
RSpec.describe Fog::Image::OpenStack do
spec_data_folder = 'spec/fog/openstack/image_v2'
include_context 'OpenStack specs with VCR'
before :all do
setup_vcr_and_service(
:vcr_directory => spec_data_folder,
# :service_class => Fog::Image::OpenStack::V2
:service_class => Fog::Image::OpenStack # No need to be explicit - Fog will choose the latest available version
)
end
def cleanup_image image, image_name=nil, image_id=nil
# Delete the image
image.destroy if image
image_by_id = @service.images.find_by_id(image_id) rescue false if image_id
image_by_id.destroy if image_by_id
@service.images.all(:name => image_name).each do |image|
image.destroy
end if image_name
# Check that the deletion worked
expect { @service.images.find_by_id image_id }.to raise_error(Fog::Image::OpenStack::NotFound) if image_id
expect(@service.images.all(:name => image_name).length).to be 0 if image_name
end
it "CRUD & list images" do
VCR.use_cassette('image_v2_crud') do
image_name = 'foobar'
image_rename = 'baz'
expect(@service.images.all).to_not be_nil
begin
# Create an image called foobar
foobar_image = @service.images.create(:name => image_name)
foobar_id = foobar_image.id
expect(@service.images.all(:name => image_name).length).to be 1
expect(foobar_image.status).to eq 'queued'
# Rename it to baz
foobar_image.update(:name => image_rename) # see "Patch images" test below - for now this will be a simple synthesis of a JSON patch with op = 'replace'
expect(foobar_image.name).to eq image_rename
baz_image = @service.images.find_by_id foobar_id
expect(baz_image).to_not be_nil
expect(baz_image.id).to eq foobar_id
expect(baz_image.name).to eq image_rename
# Read the image freshly by listing images filtered by the new name
images = @service.images.all(:name => image_rename)
expect(images.length).to be 1
expect(images.first.id).to eq baz_image.id
ensure
cleanup_image baz_image
@service.images.all.select { |image| [image_name, image_rename].include? image.name }.each do |image|
image.destroy
end
# Check that the deletion worked
expect(@service.images.all.select { |image| [image_name, image_rename].include? image.name }.length).to be 0
end
end
end
it "Image creation with ID" do
VCR.use_cassette('image_v2_create_id') do
image_name = 'foobar_id'
# Here be dragons - highly recommend not to supply an ID when creating
begin
# increment this identifier when running test more than once, unless the VCR recording is being used
identifier = '11111111-2222-3333-aaaa-bbbbbbccccdf'
# Create an image with a specified ID
foobar_image = @service.images.create(:name => 'foobar_id', :id => identifier)
foobar_id = foobar_image.id
expect(@service.images.all(:name => image_name).length).to be 1
expect(foobar_image.status).to eq 'queued'
expect(foobar_id).to eq identifier
get_image = @service.images.find_by_id(identifier)
expect(get_image.name).to eq image_name
ensure
cleanup_image foobar_image, image_name, foobar_id
end
end
end
it "Image creation with specified location" do
VCR.use_cassette('image_v2_create_location') do
begin
# Create image with location of image data
pending "Figure out 'Create image with location of image data'"
fail
ensure
end
end
end
it "Image upload & download in bulk" do
VCR.use_cassette('image_v2_upload_download') do
image_name = 'foobar_up1'
begin
image_path = "#{spec_data_folder}/minimal.ova" # "no-op" virtual machine image, 80kB .ova file containing 64Mb dynamic disk
foobar_image = @service.images.create(:name => image_name,
:container_format => 'ovf',
:disk_format => 'vmdk'
)
foobar_id = foobar_image.id
# Upload data from File or IO object
foobar_image.upload_data File.new(image_path, 'r')
# Status should be saving or active
expect(@service.images.find_by_id(foobar_id).status).to satisfy { |value| ['saving', 'active'].include? value }
# Get an IO object from which to download image data - wait until finished saving though
while @service.images.find_by_id(foobar_id).status == 'saving' do
sleep 1
end
expect(@service.images.find_by_id(foobar_id).status).to eq 'active'
# Bulk download
downloaded_data = foobar_image.download_data
expect(downloaded_data.size).to eq File.size(image_path)
ensure
cleanup_image foobar_image, image_name
end
end
end
it "Deactivates and activates an image" do
VCR.use_cassette('image_v2_activation') do
image_name = 'foobar3a'
image_path = "spec/fog/openstack/image_v2/minimal.ova" # "no-op" virtual machine image, 80kB .ova file containing 64Mb dynamic disk
begin
# Create an image called foobar2
foobar_image = @service.images.create(:name => image_name,
:container_format => 'ovf',
:disk_format => 'vmdk'
)
foobar_id = foobar_image.id
foobar_image.upload_data File.new(image_path, 'r')
while @service.images.find_by_id(foobar_id).status == 'saving' do
sleep 1
end
foobar_image.deactivate
expect { foobar_image.download_data }.to raise_error(Excon::Errors::Forbidden)
foobar_image.reactivate
expect { foobar_image.download_data }.not_to raise_error
ensure
cleanup_image foobar_image, image_name
end
end
end
it "Adds and deletes image tags" do
VCR.use_cassette('image_v2_tags') do
image_name = 'foobar3'
begin
# Create an image
foobar_image = @service.images.create(:name => image_name,
:container_format => 'ovf',
:disk_format => 'vmdk'
)
foobar_id = foobar_image.id
foobar_image.add_tag 'tag1'
expect(@service.images.find_by_id(foobar_id).tags).to contain_exactly('tag1')
foobar_image.add_tags ['tag2', 'tag3', 'tag4']
expect(@service.images.find_by_id(foobar_id).tags).to contain_exactly('tag1', 'tag2', 'tag3', 'tag4')
foobar_image.remove_tag 'tag2'
expect(@service.images.find_by_id(foobar_id).tags).to contain_exactly('tag1', 'tag3', 'tag4')
foobar_image.remove_tags ['tag1', 'tag3']
expect(@service.images.find_by_id(foobar_id).tags).to contain_exactly('tag4')
ensure
cleanup_image foobar_image, image_name
end
end
end
it "CRUD and list image members" do
VCR.use_cassette('image_v2_member_crudl') do
image_name = 'foobar4'
tenant_id = 'tenant1'
begin
# Create an image called foobar
foobar_image = @service.images.create(:name => image_name)
foobar_id = foobar_image.id
expect(foobar_image.members.size).to be 0
foobar_image.add_member tenant_id
expect(foobar_image.members.size).to be 1
member = foobar_image.member tenant_id
expect(member).to_not be_nil
expect(member['status']).to eq 'pending'
member['status'] = 'accepted'
foobar_image.update_member member
expect(foobar_image.member(tenant_id)['status']).to eq 'accepted'
foobar_image.remove_member member['member_id']
expect(foobar_image.members.size).to be 0
ensure
cleanup_image foobar_image, image_name
end
end
end
it "Gets JSON schemas for 'images', 'image', 'members', 'member'" do
VCR.use_cassette('image_v2_schemas') do
pending 'Fetching JSON schemas: to be implemented'
fail
end
end
it "CRUD resource types" do
VCR.use_cassette('image_v2_resource_type_crud') do
pending 'CRUD resource types: to be implemented'
fail
end
end
it "CRUD namespace metadata definition" do
VCR.use_cassette('image_v2_namespace_metadata_crud') do
pending 'CRUD namespace metadata definition: to be implemented'
fail
end
end
it "CRUD property metadata definition" do
VCR.use_cassette('image_v2_property_metadata_crud') do
pending 'CRUD property metadata definition: to be implemented'
fail
end
end
it "CRUD object metadata definition" do
VCR.use_cassette('image_v2_object_metadata_crud') do
pending 'CRUD object metadata definition: to be implemented'
fail
end
end
it "CRUD tag metadata definition" do
VCR.use_cassette('image_v2_tag_metadata_crud') do
pending 'CRUD tag metadata definition: to be implemented'
fail
end
end
it "CRUD schema metadata definition" do
VCR.use_cassette('image_v2_schema_metadata_crud') do
pending 'CRUD schema metadata definition: to be implemented'
fail
end
end
it "Creates, lists & gets tasks" do
VCR.use_cassette('image_v2_task_clg') do
pending 'Creates, lists & gets tasks: to be implemented'
fail
end
end
end

View File

@ -0,0 +1,74 @@
require 'fog/openstack/identity_v3'
require 'fog/openstack/image_v2'
RSpec.describe Fog::Image::OpenStack do
it "Upload/download image data using chunked IO" do
if ENV['OS_AUTH_URL'] # We only run this against a live system, because VCR's use of Webmock stops Excon :response_block from working correctly
@os_auth_url = ENV['OS_AUTH_URL']
# allow us to ignore dev certificates on servers
Excon.defaults[:ssl_verify_peer] = false if ENV['SSL_VERIFY_PEER'] == 'false'
# setup the service object
@service = Fog::Image::OpenStack.new({
:openstack_auth_url => "#{@os_auth_url}/auth/tokens",
:openstack_region => ENV['OS_REGION_NAME'] || 'RegionOne',
:openstack_api_key => ENV['OS_PASSWORD'] || 'password',
:openstack_username => ENV['OS_USERNAME'] || 'admin',
:openstack_domain_name => ENV['OS_USER_DOMAIN_NAME'] || 'Default',
:openstack_project_name => ENV['OS_PROJECT_NAME'] || 'admin'
}) unless @service
spec_data_folder = 'spec/fog/openstack/image_v2'
begin
####
## Upload & download data using request/response blocks so we can stream data effectively
####
image_path = "#{spec_data_folder}/minimal.ova" # "no-op" virtual machine image, 80kB .ova file containing 64Mb dynamic disk
foobar_image = @service.images.create(:name => 'foobar_up2',
:container_format => 'ovf',
:disk_format => 'vmdk'
)
foobar_id = foobar_image.id
data_file = File.new(image_path, 'r')
chunker = lambda do
# Excon.defaults[:chunk_size] defaults to 1048576, ie 1MB
# to_s will convert the nil received after everything is read to the final empty chunk
data_file.read(Excon.defaults[:chunk_size]).to_s
end
foobar_image.upload_data(:request_block => chunker)
# Make sure the upload is finished
while @service.images.find_by_id(foobar_id).status == 'saving' do
sleep 1
end
expect(@service.images.find_by_id(foobar_id).status).to eq 'active'
size = 0
read_block = lambda do |chunk, remaining, total|
size += chunk.size
end
foobar_image.download_data(:response_block => read_block)
expect(size).to eq File.size(image_path)
ensure
# Delete the image
foobar_image.destroy if foobar_image
@service.images.all(:name => 'foobar_up2').each do |image|
image.destroy
end
# Check that the deletion worked
expect { @service.images.find_by_id foobar_id }.to raise_error(Fog::Image::OpenStack::NotFound) if foobar_id
expect(@service.images.all(:name => 'foobar_up2').length).to be 0
end
end
end
end

View File

@ -3,6 +3,9 @@ require 'rspec/expectations'
require 'vcr'
require 'fog/openstack/identity'
require 'fog/openstack/identity_v3'
require 'fog/openstack/image'
require 'fog/openstack/image_v1'
require 'fog/openstack/image_v2'
require 'fog/openstack/network'
#
@ -40,7 +43,7 @@ RSpec.shared_context 'OpenStack specs with VCR' do
Fog.interval = 0
# use an auth URL that matches our VCR recordings (IdentityV2 for most
# services, but IdentityV3 test obviously needs IdentityV3 auth URL)
if [Fog::Identity::OpenStack::V3, Fog::Network::OpenStack].include? @service_class
if [Fog::Identity::OpenStack::V3, Fog::Image::OpenStack, Fog::Image::OpenStack::V1, Fog::Network::OpenStack].include? @service_class
@os_auth_url = 'http://devstack.openstack.stack:5000/v3'
else
@os_auth_url = 'http://devstack.openstack.stack:5000/v2.0'