From 7067700bae3d1c9c04824c77b55cf250dd5e7d30 Mon Sep 17 00:00:00 2001 From: Mark Maglana Date: Tue, 27 Aug 2013 21:41:38 -0700 Subject: [PATCH] Add openstack compute list_images --- .../compute/v2/public/list_images.rb | 48 +++++ .../compute/v2/public/list_images_test.rb | 172 ++++++++++++++++++ .../list_images/has_the_correct_body.yml | 63 +++++++ .../list_images/has_the_correct_headers.yml | 63 +++++++ .../list_images/has_the_correct_url.yml | 63 +++++++ ...sponse_when_no_parameters_are_provided.yml | 108 +++++++++++ ..._response_when_parameters_are_provided.yml | 103 +++++++++++ ...onse_when_provided_with_invalid_params.yml | 96 ++++++++++ 8 files changed, 716 insertions(+) create mode 100644 lib/aviator/openstack/compute/v2/public/list_images.rb create mode 100644 test/aviator/openstack/compute/v2/public/list_images_test.rb create mode 100644 test/cassettes/openstack/compute/v2/public/list_images/has_the_correct_body.yml create mode 100644 test/cassettes/openstack/compute/v2/public/list_images/has_the_correct_headers.yml create mode 100644 test/cassettes/openstack/compute/v2/public/list_images/has_the_correct_url.yml create mode 100644 test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_no_parameters_are_provided.yml create mode 100644 test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_parameters_are_provided.yml create mode 100644 test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_provided_with_invalid_params.yml diff --git a/lib/aviator/openstack/compute/v2/public/list_images.rb b/lib/aviator/openstack/compute/v2/public/list_images.rb new file mode 100644 index 0000000..e40b51c --- /dev/null +++ b/lib/aviator/openstack/compute/v2/public/list_images.rb @@ -0,0 +1,48 @@ +define_request :list_images do + + endpoint_type :public + api_version :v2 + http_method :get + + optional_param :show_details + optional_param :server + optional_param :name + optional_param :status + optional_param :changes_since + optional_param :marker + optional_param :limit + optional_param :type + + + + def url + service_spec = session_data[:access][:serviceCatalog].find{|s| s[:type] == 'compute' } + + str = "#{ service_spec[:endpoints][0][:publicURL] }/images" + str += "/detail" if params[:show_details] + + filters = [] + + (optional_params + required_params - [:show_details]).each do |param_name| + query_key = (param_name == :changes_since ? 'changes-since' : param_name) + + filters << "#{ query_key }=#{ params[param_name] }" if params[param_name] + end + + str += "?#{ filters.join('&') }" unless filters.empty? + + str + end + + + def headers + h = {} + + unless self.anonymous? + h['X-Auth-Token'] = session_data[:access][:token][:id] + end + + h + end + +end diff --git a/test/aviator/openstack/compute/v2/public/list_images_test.rb b/test/aviator/openstack/compute/v2/public/list_images_test.rb new file mode 100644 index 0000000..874c022 --- /dev/null +++ b/test/aviator/openstack/compute/v2/public/list_images_test.rb @@ -0,0 +1,172 @@ +require 'test_helper' + +class Aviator::Test + + describe 'aviator/openstack/compute/v2/public/list_images' do + + def create_request(session_data = new_session_data) + klass.new(session_data) + end + + + def new_session_data + service = Aviator::Service.new( + provider: 'openstack', + service: 'identity' + ) + + response = service.request :create_token, RequestHelper.admin_bootstrap_session_data do |params| + auth_credentials = Environment.openstack_admin[:auth_credentials] + auth_credentials.each { |key, value| params[key] = auth_credentials[key] } + end + + response.body + end + + + def helper + Aviator::Test::RequestHelper + end + + + def klass + path = helper.request_path('compute', 'v2', 'public', 'list_images.rb') + klass, request_name = Aviator::Service::RequestBuilder.build(path) + klass + end + + + it 'has the correct endpoint type' do + klass.endpoint_type.must_equal :public + end + + + it 'has the correct api version' do + klass.api_version.must_equal :v2 + end + + + it 'has the correct http method' do + klass.http_method.must_equal :get + end + + + it 'has the correct list of optional parameters' do + klass.optional_params.must_equal [ + :show_details, + :server, + :name, + :status, + :changes_since, + :marker, + :limit, + :type + ] + end + + + it 'has the correct list of required parameters' do + klass.required_params.must_equal [] + end + + + it 'has the correct url' do + session_data = new_session_data + service_spec = session_data[:access][:serviceCatalog].find{|s| s[:type] == 'compute' } + url = "#{ service_spec[:endpoints][0][:publicURL] }/images" + + params = [ + [ :show_details, true ], + [ :name, 'cirros-0.3.1-x86_64-uec-ramdisk' ], + [ :status, 'ACTIVE' ], + [ :type, 'application/vnd.openstack.image' ] + ] + + url += "/detail" if params.first[1] + + filters = [] + + params[1, params.length-1].each { |pair| filters << "#{ pair[0] }=#{ pair[1] }" } + + url += "?#{ filters.join('&') }" unless filters.empty? + + request = klass.new(session_data) do |p| + params.each { |pair| p[pair[0]] = pair[1] } + end + + + request.url.must_equal url + end + + + it 'has the correct headers' do + session_data = new_session_data + + headers = { 'X-Auth-Token' => session_data[:access][:token][:id] } + + request = create_request(session_data) + + request.headers.must_equal headers + end + + + it 'has the correct body' do + klass.body?.must_equal false + create_request.body?.must_equal false + end + + + it 'leads to a valid response when no parameters are provided' do + service = Aviator::Service.new( + provider: 'openstack', + service: 'compute', + default_session_data: new_session_data + ) + + response = service.request :list_images + + response.status.must_equal 200 + response.body.wont_be_nil + response.headers.wont_be_nil + end + + + it 'leads to a valid response when parameters are provided' do + service = Aviator::Service.new( + provider: 'openstack', + service: 'compute', + default_session_data: new_session_data + ) + + response = service.request :list_images do |params| + params[:show_details] = true + params[:name] = "cirros-0.3.1-x86_64-uec-ramdisk" + end + + response.status.must_equal 200 + response.body.wont_be_nil + response.body[:images].length.must_equal 1 + response.headers.wont_be_nil + end + + + it 'leads to a valid response when provided with invalid params' do + service = Aviator::Service.new( + provider: 'openstack', + service: 'compute', + default_session_data: new_session_data + ) + + response = service.request :list_images do |params| + params[:name] = "nonexistentimagenameherpderp" + end + + response.status.must_equal 200 + response.body.wont_be_nil + response.body[:images].length.must_equal 0 + response.headers.wont_be_nil + end + + end + +end \ No newline at end of file diff --git a/test/cassettes/openstack/compute/v2/public/list_images/has_the_correct_body.yml b/test/cassettes/openstack/compute/v2/public/list_images/has_the_correct_body.yml new file mode 100644 index 0000000..86c7ff8 --- /dev/null +++ b/test/cassettes/openstack/compute/v2/public/list_images/has_the_correct_body.yml @@ -0,0 +1,63 @@ +--- +http_interactions: +- request: + method: post + uri: :5000/v2.0/tokens + body: + encoding: UTF-8 + string: ! '{"auth":{"passwordCredentials":{"username":"admin","password":""},"tenantName":"admin"}}' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + response: + status: + code: 200 + message: + headers: + vary: + - X-Auth-Token + content-type: + - application/json + content-length: + - '2648' + date: + - Tue, 27 Aug 2013 17:47:01 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"access": {"token": {"issued_at": "2013-08-27T17:47:01.520468", + "expires": "2013-08-28T17:47:01Z", "id": "65a179bd128946058d75a1514ee07541", + "tenant": {"description": null, "enabled": true, "id": "3cab25130620477b8b03f1bfa8741603", + "name": "admin"}}, "serviceCatalog": [{"endpoints": [{"adminURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603", + "region": "RegionOne", "internalURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603", + "id": "3b72a66bf2f0491bb8dba827cade0d48", "publicURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603"}], + "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:3333", "region": "RegionOne", "internalURL": "http://192.168.56.11:3333", + "id": "482f749b370c40eab8788d6d0bc47f48", "publicURL": "http://192.168.56.11:3333"}], + "endpoints_links": [], "type": "s3", "name": "s3"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:9292", "region": "RegionOne", "internalURL": "http://192.168.56.11:9292", + "id": "0cd5d5d5a0c24721a0392b47c89e3640", "publicURL": "http://192.168.56.11:9292"}], + "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:8777", "region": "RegionOne", "internalURL": "http://192.168.56.11:8777", + "id": "4eb4edec1d2647bfb8ba4f9a5757169d", "publicURL": "http://192.168.56.11:8777"}], + "endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints": + [{"adminURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603", + "region": "RegionOne", "internalURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603", + "id": "009e8a41953d439f845b2a0c0dc28b73", "publicURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603"}], + "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": + [{"adminURL": "http://192.168.56.11:8773/services/Admin", "region": "RegionOne", + "internalURL": "http://192.168.56.11:8773/services/Cloud", "id": "6820836ec6834548bf7b54da0271dded", + "publicURL": "http://192.168.56.11:8773/services/Cloud"}], "endpoints_links": + [], "type": "ec2", "name": "ec2"}, {"endpoints": [{"adminURL": "http://192.168.56.11:35357/v2.0", + "region": "RegionOne", "internalURL": "http://192.168.56.11:5000/v2.0", "id": + "24a95f51f67949e784971e97463ee4d8", "publicURL": "http://192.168.56.11:5000/v2.0"}], + "endpoints_links": [], "type": "identity", "name": "keystone"}], "user": {"username": + "admin", "roles_links": [], "id": "cbbcc4f7aef6435fa2da7e5f0b2f1e97", "roles": + [{"name": "admin"}], "name": "admin"}, "metadata": {"is_admin": 0, "roles": + ["01a81f2dbb3441f1aaa8fe68a7c6f546"]}}}' + http_version: + recorded_at: Wed, 28 Aug 2013 04:35:08 GMT +recorded_with: VCR 2.5.0 diff --git a/test/cassettes/openstack/compute/v2/public/list_images/has_the_correct_headers.yml b/test/cassettes/openstack/compute/v2/public/list_images/has_the_correct_headers.yml new file mode 100644 index 0000000..f9c9b36 --- /dev/null +++ b/test/cassettes/openstack/compute/v2/public/list_images/has_the_correct_headers.yml @@ -0,0 +1,63 @@ +--- +http_interactions: +- request: + method: post + uri: :5000/v2.0/tokens + body: + encoding: UTF-8 + string: ! '{"auth":{"passwordCredentials":{"username":"admin","password":""},"tenantName":"admin"}}' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + response: + status: + code: 200 + message: + headers: + vary: + - X-Auth-Token + content-type: + - application/json + content-length: + - '2648' + date: + - Tue, 27 Aug 2013 14:01:49 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"access": {"token": {"issued_at": "2013-08-27T14:01:49.116717", + "expires": "2013-08-28T14:01:48Z", "id": "2a2881383f4e4e6fa12a9534229060ad", + "tenant": {"description": null, "enabled": true, "id": "3cab25130620477b8b03f1bfa8741603", + "name": "admin"}}, "serviceCatalog": [{"endpoints": [{"adminURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603", + "region": "RegionOne", "internalURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603", + "id": "3b72a66bf2f0491bb8dba827cade0d48", "publicURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603"}], + "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:3333", "region": "RegionOne", "internalURL": "http://192.168.56.11:3333", + "id": "482f749b370c40eab8788d6d0bc47f48", "publicURL": "http://192.168.56.11:3333"}], + "endpoints_links": [], "type": "s3", "name": "s3"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:9292", "region": "RegionOne", "internalURL": "http://192.168.56.11:9292", + "id": "0cd5d5d5a0c24721a0392b47c89e3640", "publicURL": "http://192.168.56.11:9292"}], + "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:8777", "region": "RegionOne", "internalURL": "http://192.168.56.11:8777", + "id": "4eb4edec1d2647bfb8ba4f9a5757169d", "publicURL": "http://192.168.56.11:8777"}], + "endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints": + [{"adminURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603", + "region": "RegionOne", "internalURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603", + "id": "009e8a41953d439f845b2a0c0dc28b73", "publicURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603"}], + "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": + [{"adminURL": "http://192.168.56.11:8773/services/Admin", "region": "RegionOne", + "internalURL": "http://192.168.56.11:8773/services/Cloud", "id": "6820836ec6834548bf7b54da0271dded", + "publicURL": "http://192.168.56.11:8773/services/Cloud"}], "endpoints_links": + [], "type": "ec2", "name": "ec2"}, {"endpoints": [{"adminURL": "http://192.168.56.11:35357/v2.0", + "region": "RegionOne", "internalURL": "http://192.168.56.11:5000/v2.0", "id": + "24a95f51f67949e784971e97463ee4d8", "publicURL": "http://192.168.56.11:5000/v2.0"}], + "endpoints_links": [], "type": "identity", "name": "keystone"}], "user": {"username": + "admin", "roles_links": [], "id": "cbbcc4f7aef6435fa2da7e5f0b2f1e97", "roles": + [{"name": "admin"}], "name": "admin"}, "metadata": {"is_admin": 0, "roles": + ["01a81f2dbb3441f1aaa8fe68a7c6f546"]}}}' + http_version: + recorded_at: Tue, 27 Aug 2013 23:47:41 GMT +recorded_with: VCR 2.5.0 diff --git a/test/cassettes/openstack/compute/v2/public/list_images/has_the_correct_url.yml b/test/cassettes/openstack/compute/v2/public/list_images/has_the_correct_url.yml new file mode 100644 index 0000000..1a97600 --- /dev/null +++ b/test/cassettes/openstack/compute/v2/public/list_images/has_the_correct_url.yml @@ -0,0 +1,63 @@ +--- +http_interactions: +- request: + method: post + uri: :5000/v2.0/tokens + body: + encoding: UTF-8 + string: ! '{"auth":{"passwordCredentials":{"username":"admin","password":""},"tenantName":"admin"}}' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + response: + status: + code: 200 + message: + headers: + vary: + - X-Auth-Token + content-type: + - application/json + content-length: + - '2648' + date: + - Tue, 27 Aug 2013 17:25:32 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"access": {"token": {"issued_at": "2013-08-27T17:25:32.123829", + "expires": "2013-08-28T17:25:32Z", "id": "0ea5ec866312410f8a6e988070a68dde", + "tenant": {"description": null, "enabled": true, "id": "3cab25130620477b8b03f1bfa8741603", + "name": "admin"}}, "serviceCatalog": [{"endpoints": [{"adminURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603", + "region": "RegionOne", "internalURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603", + "id": "3b72a66bf2f0491bb8dba827cade0d48", "publicURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603"}], + "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:3333", "region": "RegionOne", "internalURL": "http://192.168.56.11:3333", + "id": "482f749b370c40eab8788d6d0bc47f48", "publicURL": "http://192.168.56.11:3333"}], + "endpoints_links": [], "type": "s3", "name": "s3"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:9292", "region": "RegionOne", "internalURL": "http://192.168.56.11:9292", + "id": "0cd5d5d5a0c24721a0392b47c89e3640", "publicURL": "http://192.168.56.11:9292"}], + "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:8777", "region": "RegionOne", "internalURL": "http://192.168.56.11:8777", + "id": "4eb4edec1d2647bfb8ba4f9a5757169d", "publicURL": "http://192.168.56.11:8777"}], + "endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints": + [{"adminURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603", + "region": "RegionOne", "internalURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603", + "id": "009e8a41953d439f845b2a0c0dc28b73", "publicURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603"}], + "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": + [{"adminURL": "http://192.168.56.11:8773/services/Admin", "region": "RegionOne", + "internalURL": "http://192.168.56.11:8773/services/Cloud", "id": "6820836ec6834548bf7b54da0271dded", + "publicURL": "http://192.168.56.11:8773/services/Cloud"}], "endpoints_links": + [], "type": "ec2", "name": "ec2"}, {"endpoints": [{"adminURL": "http://192.168.56.11:35357/v2.0", + "region": "RegionOne", "internalURL": "http://192.168.56.11:5000/v2.0", "id": + "24a95f51f67949e784971e97463ee4d8", "publicURL": "http://192.168.56.11:5000/v2.0"}], + "endpoints_links": [], "type": "identity", "name": "keystone"}], "user": {"username": + "admin", "roles_links": [], "id": "cbbcc4f7aef6435fa2da7e5f0b2f1e97", "roles": + [{"name": "admin"}], "name": "admin"}, "metadata": {"is_admin": 0, "roles": + ["01a81f2dbb3441f1aaa8fe68a7c6f546"]}}}' + http_version: + recorded_at: Wed, 28 Aug 2013 04:13:58 GMT +recorded_with: VCR 2.5.0 diff --git a/test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_no_parameters_are_provided.yml b/test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_no_parameters_are_provided.yml new file mode 100644 index 0000000..b64eafa --- /dev/null +++ b/test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_no_parameters_are_provided.yml @@ -0,0 +1,108 @@ +--- +http_interactions: +- request: + method: post + uri: :5000/v2.0/tokens + body: + encoding: UTF-8 + string: ! '{"auth":{"passwordCredentials":{"username":"admin","password":""},"tenantName":"admin"}}' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + response: + status: + code: 200 + message: + headers: + vary: + - X-Auth-Token + content-type: + - application/json + content-length: + - '2648' + date: + - Tue, 27 Aug 2013 14:06:45 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"access": {"token": {"issued_at": "2013-08-27T14:06:45.864188", + "expires": "2013-08-28T14:06:45Z", "id": "f2b24ecf95904d2e8ac0de4c46fd1379", + "tenant": {"description": null, "enabled": true, "id": "3cab25130620477b8b03f1bfa8741603", + "name": "admin"}}, "serviceCatalog": [{"endpoints": [{"adminURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603", + "region": "RegionOne", "internalURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603", + "id": "3b72a66bf2f0491bb8dba827cade0d48", "publicURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603"}], + "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:3333", "region": "RegionOne", "internalURL": "http://192.168.56.11:3333", + "id": "482f749b370c40eab8788d6d0bc47f48", "publicURL": "http://192.168.56.11:3333"}], + "endpoints_links": [], "type": "s3", "name": "s3"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:9292", "region": "RegionOne", "internalURL": "http://192.168.56.11:9292", + "id": "0cd5d5d5a0c24721a0392b47c89e3640", "publicURL": "http://192.168.56.11:9292"}], + "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:8777", "region": "RegionOne", "internalURL": "http://192.168.56.11:8777", + "id": "4eb4edec1d2647bfb8ba4f9a5757169d", "publicURL": "http://192.168.56.11:8777"}], + "endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints": + [{"adminURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603", + "region": "RegionOne", "internalURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603", + "id": "009e8a41953d439f845b2a0c0dc28b73", "publicURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603"}], + "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": + [{"adminURL": "http://192.168.56.11:8773/services/Admin", "region": "RegionOne", + "internalURL": "http://192.168.56.11:8773/services/Cloud", "id": "6820836ec6834548bf7b54da0271dded", + "publicURL": "http://192.168.56.11:8773/services/Cloud"}], "endpoints_links": + [], "type": "ec2", "name": "ec2"}, {"endpoints": [{"adminURL": "http://192.168.56.11:35357/v2.0", + "region": "RegionOne", "internalURL": "http://192.168.56.11:5000/v2.0", "id": + "24a95f51f67949e784971e97463ee4d8", "publicURL": "http://192.168.56.11:5000/v2.0"}], + "endpoints_links": [], "type": "identity", "name": "keystone"}], "user": {"username": + "admin", "roles_links": [], "id": "cbbcc4f7aef6435fa2da7e5f0b2f1e97", "roles": + [{"name": "admin"}], "name": "admin"}, "metadata": {"is_admin": 0, "roles": + ["01a81f2dbb3441f1aaa8fe68a7c6f546"]}}}' + http_version: + recorded_at: Tue, 27 Aug 2013 23:52:34 GMT +- request: + method: get + uri: http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603/images + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - f2b24ecf95904d2e8ac0de4c46fd1379 + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-863dfece-c253-4de1-98a0-a2d41cda9d06 + content-type: + - application/json + content-length: + - '1641' + date: + - Tue, 27 Aug 2013 14:06:46 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"images": [{"id": "c1acec19-1026-45e8-946e-b9e9a261916b", "links": + [{"href": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603/images/c1acec19-1026-45e8-946e-b9e9a261916b", + "rel": "self"}, {"href": "http://192.168.56.11:8774/3cab25130620477b8b03f1bfa8741603/images/c1acec19-1026-45e8-946e-b9e9a261916b", + "rel": "bookmark"}, {"href": "http://10.0.2.15:9292/3cab25130620477b8b03f1bfa8741603/images/c1acec19-1026-45e8-946e-b9e9a261916b", + "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "cirros-0.3.1-x86_64-uec"}, + {"id": "3c2b8955-1a71-4d1c-92a4-e414a172dcb2", "links": [{"href": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603/images/3c2b8955-1a71-4d1c-92a4-e414a172dcb2", + "rel": "self"}, {"href": "http://192.168.56.11:8774/3cab25130620477b8b03f1bfa8741603/images/3c2b8955-1a71-4d1c-92a4-e414a172dcb2", + "rel": "bookmark"}, {"href": "http://10.0.2.15:9292/3cab25130620477b8b03f1bfa8741603/images/3c2b8955-1a71-4d1c-92a4-e414a172dcb2", + "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "cirros-0.3.1-x86_64-uec-ramdisk"}, + {"id": "fa64ed94-caec-4cab-acd6-0c5ae18732a6", "links": [{"href": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603/images/fa64ed94-caec-4cab-acd6-0c5ae18732a6", + "rel": "self"}, {"href": "http://192.168.56.11:8774/3cab25130620477b8b03f1bfa8741603/images/fa64ed94-caec-4cab-acd6-0c5ae18732a6", + "rel": "bookmark"}, {"href": "http://10.0.2.15:9292/3cab25130620477b8b03f1bfa8741603/images/fa64ed94-caec-4cab-acd6-0c5ae18732a6", + "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "cirros-0.3.1-x86_64-uec-kernel"}]}' + http_version: + recorded_at: Tue, 27 Aug 2013 23:52:34 GMT +recorded_with: VCR 2.5.0 diff --git a/test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_parameters_are_provided.yml b/test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_parameters_are_provided.yml new file mode 100644 index 0000000..3acff8f --- /dev/null +++ b/test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_parameters_are_provided.yml @@ -0,0 +1,103 @@ +--- +http_interactions: +- request: + method: post + uri: :5000/v2.0/tokens + body: + encoding: UTF-8 + string: ! '{"auth":{"passwordCredentials":{"username":"admin","password":""},"tenantName":"admin"}}' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + response: + status: + code: 200 + message: + headers: + vary: + - X-Auth-Token + content-type: + - application/json + content-length: + - '2648' + date: + - Tue, 27 Aug 2013 17:28:02 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"access": {"token": {"issued_at": "2013-08-27T17:28:02.980198", + "expires": "2013-08-28T17:28:02Z", "id": "a45ef1f5c8694595b5480d99471ef2e1", + "tenant": {"description": null, "enabled": true, "id": "3cab25130620477b8b03f1bfa8741603", + "name": "admin"}}, "serviceCatalog": [{"endpoints": [{"adminURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603", + "region": "RegionOne", "internalURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603", + "id": "3b72a66bf2f0491bb8dba827cade0d48", "publicURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603"}], + "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:3333", "region": "RegionOne", "internalURL": "http://192.168.56.11:3333", + "id": "482f749b370c40eab8788d6d0bc47f48", "publicURL": "http://192.168.56.11:3333"}], + "endpoints_links": [], "type": "s3", "name": "s3"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:9292", "region": "RegionOne", "internalURL": "http://192.168.56.11:9292", + "id": "0cd5d5d5a0c24721a0392b47c89e3640", "publicURL": "http://192.168.56.11:9292"}], + "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:8777", "region": "RegionOne", "internalURL": "http://192.168.56.11:8777", + "id": "4eb4edec1d2647bfb8ba4f9a5757169d", "publicURL": "http://192.168.56.11:8777"}], + "endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints": + [{"adminURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603", + "region": "RegionOne", "internalURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603", + "id": "009e8a41953d439f845b2a0c0dc28b73", "publicURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603"}], + "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": + [{"adminURL": "http://192.168.56.11:8773/services/Admin", "region": "RegionOne", + "internalURL": "http://192.168.56.11:8773/services/Cloud", "id": "6820836ec6834548bf7b54da0271dded", + "publicURL": "http://192.168.56.11:8773/services/Cloud"}], "endpoints_links": + [], "type": "ec2", "name": "ec2"}, {"endpoints": [{"adminURL": "http://192.168.56.11:35357/v2.0", + "region": "RegionOne", "internalURL": "http://192.168.56.11:5000/v2.0", "id": + "24a95f51f67949e784971e97463ee4d8", "publicURL": "http://192.168.56.11:5000/v2.0"}], + "endpoints_links": [], "type": "identity", "name": "keystone"}], "user": {"username": + "admin", "roles_links": [], "id": "cbbcc4f7aef6435fa2da7e5f0b2f1e97", "roles": + [{"name": "admin"}], "name": "admin"}, "metadata": {"is_admin": 0, "roles": + ["01a81f2dbb3441f1aaa8fe68a7c6f546"]}}}' + http_version: + recorded_at: Wed, 28 Aug 2013 04:16:27 GMT +- request: + method: get + uri: http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603/images/detail?name=cirros-0.3.1-x86_64-uec-ramdisk + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - a45ef1f5c8694595b5480d99471ef2e1 + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-ca4bd32d-1157-40a1-9cbd-8b478befcc7a + content-type: + - application/json + content-length: + - '741' + date: + - Tue, 27 Aug 2013 17:28:03 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"images": [{"status": "ACTIVE", "updated": "2013-07-30T22:31:21Z", + "links": [{"href": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603/images/3c2b8955-1a71-4d1c-92a4-e414a172dcb2", + "rel": "self"}, {"href": "http://192.168.56.11:8774/3cab25130620477b8b03f1bfa8741603/images/3c2b8955-1a71-4d1c-92a4-e414a172dcb2", + "rel": "bookmark"}, {"href": "http://10.0.2.15:9292/3cab25130620477b8b03f1bfa8741603/images/3c2b8955-1a71-4d1c-92a4-e414a172dcb2", + "type": "application/vnd.openstack.image", "rel": "alternate"}], "id": "3c2b8955-1a71-4d1c-92a4-e414a172dcb2", + "OS-EXT-IMG-SIZE:size": 3714968, "name": "cirros-0.3.1-x86_64-uec-ramdisk", + "created": "2013-07-30T22:31:21Z", "minDisk": 0, "progress": 100, "minRam": + 0, "metadata": {}}]}' + http_version: + recorded_at: Wed, 28 Aug 2013 04:16:27 GMT +recorded_with: VCR 2.5.0 diff --git a/test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_provided_with_invalid_params.yml b/test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_provided_with_invalid_params.yml new file mode 100644 index 0000000..1ad5b10 --- /dev/null +++ b/test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_provided_with_invalid_params.yml @@ -0,0 +1,96 @@ +--- +http_interactions: +- request: + method: post + uri: :5000/v2.0/tokens + body: + encoding: UTF-8 + string: ! '{"auth":{"passwordCredentials":{"username":"admin","password":""},"tenantName":"admin"}}' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + response: + status: + code: 200 + message: + headers: + vary: + - X-Auth-Token + content-type: + - application/json + content-length: + - '2648' + date: + - Tue, 27 Aug 2013 14:19:04 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"access": {"token": {"issued_at": "2013-08-27T14:19:04.323634", + "expires": "2013-08-28T14:19:04Z", "id": "7f2ac614da5044fdb0dafd7ffd7b27d2", + "tenant": {"description": null, "enabled": true, "id": "3cab25130620477b8b03f1bfa8741603", + "name": "admin"}}, "serviceCatalog": [{"endpoints": [{"adminURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603", + "region": "RegionOne", "internalURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603", + "id": "3b72a66bf2f0491bb8dba827cade0d48", "publicURL": "http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603"}], + "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:3333", "region": "RegionOne", "internalURL": "http://192.168.56.11:3333", + "id": "482f749b370c40eab8788d6d0bc47f48", "publicURL": "http://192.168.56.11:3333"}], + "endpoints_links": [], "type": "s3", "name": "s3"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:9292", "region": "RegionOne", "internalURL": "http://192.168.56.11:9292", + "id": "0cd5d5d5a0c24721a0392b47c89e3640", "publicURL": "http://192.168.56.11:9292"}], + "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": + "http://192.168.56.11:8777", "region": "RegionOne", "internalURL": "http://192.168.56.11:8777", + "id": "4eb4edec1d2647bfb8ba4f9a5757169d", "publicURL": "http://192.168.56.11:8777"}], + "endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints": + [{"adminURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603", + "region": "RegionOne", "internalURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603", + "id": "009e8a41953d439f845b2a0c0dc28b73", "publicURL": "http://192.168.56.11:8776/v1/3cab25130620477b8b03f1bfa8741603"}], + "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": + [{"adminURL": "http://192.168.56.11:8773/services/Admin", "region": "RegionOne", + "internalURL": "http://192.168.56.11:8773/services/Cloud", "id": "6820836ec6834548bf7b54da0271dded", + "publicURL": "http://192.168.56.11:8773/services/Cloud"}], "endpoints_links": + [], "type": "ec2", "name": "ec2"}, {"endpoints": [{"adminURL": "http://192.168.56.11:35357/v2.0", + "region": "RegionOne", "internalURL": "http://192.168.56.11:5000/v2.0", "id": + "24a95f51f67949e784971e97463ee4d8", "publicURL": "http://192.168.56.11:5000/v2.0"}], + "endpoints_links": [], "type": "identity", "name": "keystone"}], "user": {"username": + "admin", "roles_links": [], "id": "cbbcc4f7aef6435fa2da7e5f0b2f1e97", "roles": + [{"name": "admin"}], "name": "admin"}, "metadata": {"is_admin": 0, "roles": + ["01a81f2dbb3441f1aaa8fe68a7c6f546"]}}}' + http_version: + recorded_at: Wed, 28 Aug 2013 00:04:41 GMT +- request: + method: get + uri: http://192.168.56.11:8774/v2/3cab25130620477b8b03f1bfa8741603/images?name=nonexistentimagenameherpderp + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - 7f2ac614da5044fdb0dafd7ffd7b27d2 + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-5dff9aac-343b-44cc-bbfb-2f2d2b167356 + content-type: + - application/json + content-length: + - '14' + date: + - Tue, 27 Aug 2013 14:19:04 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"images": []}' + http_version: + recorded_at: Wed, 28 Aug 2013 00:04:42 GMT +recorded_with: VCR 2.5.0