From 68dd3a71d9e0d250bdb890d6b7e19ee33b2d5ab5 Mon Sep 17 00:00:00 2001 From: Mark Maglana Date: Wed, 4 Sep 2013 20:59:57 -0700 Subject: [PATCH 1/3] Update environment.yml for travis-ci --- test/environment.yml.travis-ci | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/environment.yml.travis-ci b/test/environment.yml.travis-ci index 836488b..7bb4f2a 100644 --- a/test/environment.yml.travis-ci +++ b/test/environment.yml.travis-ci @@ -14,9 +14,9 @@ common: &common openstack_admin: <<: *common auth_credentials: - username: admin - password: mypassword - tenantName: admin + username: aviatortest_admin + password: aviatortest_password_admin + tenantName: aviatortest_project_admin # This is expected by the test suite. You may change its values freely # as long as the name 'openstack_member' doesn't change and the user's @@ -24,6 +24,6 @@ openstack_admin: openstack_member: <<: *common auth_credentials: - username: nonadmin - password: mypassword - tenantName: nonadminproject + username: aviatortest_member + password: aviatortest_password_member + tenantName: aviatortest_project_member From ac8962a5102057ce562d39710d928e4ae03d632e Mon Sep 17 00:00:00 2001 From: Mark Maglana Date: Wed, 4 Sep 2013 23:45:54 -0700 Subject: [PATCH 2/3] Initial implementation for #9 --- .../compute/v2/public/create_server.rb | 60 +++++ .../compute/v2/public/create_server_test.rb | 175 ++++++++++++++ ..._response_when_parameters_are_provided.yml | 182 ++++++++++++++ ...en_the_adminPass_parameter_is_provided.yml | 182 ++++++++++++++ ...hen_the_flavorRef_parameter_is_invalid.yml | 135 +++++++++++ .../returns_the_correct_value_for_body_.yml | 142 +++++++++++ ...returns_the_correct_value_for_headers_.yml | 142 +++++++++++ ...rns_the_correct_value_for_http_method_.yml | 142 +++++++++++ .../returns_the_correct_value_for_url_.yml | 222 ++++++++++++++++++ 9 files changed, 1382 insertions(+) create mode 100644 lib/aviator/openstack/compute/v2/public/create_server.rb create mode 100644 test/aviator/openstack/compute/v2/public/create_server_test.rb create mode 100644 test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_parameters_are_provided.yml create mode 100644 test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_the_adminPass_parameter_is_provided.yml create mode 100644 test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_the_flavorRef_parameter_is_invalid.yml create mode 100644 test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_body_.yml create mode 100644 test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_headers_.yml create mode 100644 test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_http_method_.yml create mode 100644 test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_url_.yml diff --git a/lib/aviator/openstack/compute/v2/public/create_server.rb b/lib/aviator/openstack/compute/v2/public/create_server.rb new file mode 100644 index 0000000..9dc81b9 --- /dev/null +++ b/lib/aviator/openstack/compute/v2/public/create_server.rb @@ -0,0 +1,60 @@ +module Aviator + + define_request :create_server do + + meta :provider, :openstack + meta :service, :compute + meta :api_version, :v2 + meta :endpoint_type, :public + + link 'documentation', + 'http://docs.openstack.org/api/openstack-compute/2/content/CreateServers.html' + + param :adminPass, required: false + param :imageRef, required: true + param :flavorRef, required: true + param :metadata, required: false + param :name, required: true + param :networks, required: false + param :personality, required: false + + + def body + p = { + server: { + flavorRef: params[:flavorRef], + imageRef: params[:imageRef], + name: params[:name] + } + } + + p[:server][:adminPass] = params[:adminPass] if params[:adminPass] + + p + end + + + def headers + h = {} + + unless self.anonymous? + h['X-Auth-Token'] = session_data[:access][:token][:id] + end + + h + end + + + def http_method + :post + end + + + def url + service_spec = session_data[:access][:serviceCatalog].find{|s| s[:type] == service.to_s } + "#{ service_spec[:endpoints][0][:publicURL] }/servers" + end + + end + +end diff --git a/test/aviator/openstack/compute/v2/public/create_server_test.rb b/test/aviator/openstack/compute/v2/public/create_server_test.rb new file mode 100644 index 0000000..fee4d17 --- /dev/null +++ b/test/aviator/openstack/compute/v2/public/create_server_test.rb @@ -0,0 +1,175 @@ +require 'test_helper' + +class Aviator::Test + + describe 'aviator/openstack/compute/v2/public/create_server' do + + def create_request(session_data = get_session_data) + image_id = session.compute_service.request(:list_images).body[:images].first[:id] + flavor_id = session.compute_service.request(:list_flavors).body[:flavors].first[:id] + + klass.new(session_data) do |params| + params[:imageRef] = image_id + params[:flavorRef] = flavor_id + params[:name] = 'Aviator Server' + end + end + + + def get_session_data + session.send :auth_info + end + + + def helper + Aviator::Test::RequestHelper + end + + + def klass + @klass ||= helper.load_request('openstack', 'compute', 'v2', 'public', 'create_server.rb') + end + + + def session + unless @session + @session = Aviator::Session.new( + config_file: Environment.path, + environment: 'openstack_member' + ) + @session.authenticate + end + + @session + end + + + validate_attr :anonymous? do + klass.anonymous?.must_equal false + end + + + validate_attr :api_version do + klass.api_version.must_equal :v2 + end + + + validate_attr :body do + request = create_request + + klass.body?.must_equal true + request.body?.must_equal true + request.body.wont_be_nil + end + + + validate_attr :endpoint_type do + klass.endpoint_type.must_equal :public + end + + + validate_attr :headers do + headers = { 'X-Auth-Token' => get_session_data[:access][:token][:id] } + + request = create_request + + request.headers.must_equal headers + end + + + validate_attr :http_method do + create_request.http_method.must_equal :post + end + + + validate_attr :optional_params do + klass.optional_params.must_equal [ + :adminPass, + :metadata, + :networks, + :personality + ] + end + + + validate_attr :required_params do + klass.required_params.must_equal [ + :imageRef, + :flavorRef, + :name + ] + end + + + validate_attr :url do + service_spec = get_session_data[:access][:serviceCatalog].find{|s| s[:type] == 'compute' } + url = "#{ service_spec[:endpoints][0][:publicURL] }/servers" + + image_id = session.compute_service.request(:list_images).body[:images].first[:id] + flavor_id = session.compute_service.request(:list_flavors).body[:flavors].first[:id] + + + request = create_request do |params| + params[:imageRef] = image_id + params[:flavorRef] = flavor_id + params[:name] = 'Aviator Server' + end + + request.url.must_equal url + end + + + validate_response 'parameters are provided' do + image_id = session.compute_service.request(:list_images).body[:images].first[:id] + flavor_id = session.compute_service.request(:list_flavors).body[:flavors].first[:id] + + response = session.compute_service.request :create_server do |params| + params[:imageRef] = image_id + params[:flavorRef] = flavor_id + params[:name] = 'Aviator Server' + end + + response.status.must_equal 202 + response.body.wont_be_nil + response.body[:server].wont_be_nil + response.headers.wont_be_nil + end + + + validate_response 'the flavorRef parameter is invalid' do + image_id = session.compute_service.request(:list_images).body[:images].first[:id] + + response = session.compute_service.request :create_server do |params| + params[:imageRef] = image_id + params[:flavorRef] = 'invalidvalue' + params[:name] = 'Aviator Server' + end + + response.status.must_equal 400 + response.body.wont_be_nil + response.headers.wont_be_nil + end + + + validate_response 'the adminPass parameter is provided' do + image_id = session.compute_service.request(:list_images).body[:images].first[:id] + flavor_id = session.compute_service.request(:list_flavors).body[:flavors].first[:id] + admin_pass = '4d764cc09a88b3' + + response = session.compute_service.request :create_server do |params| + params[:imageRef] = image_id + params[:flavorRef] = flavor_id + params[:name] = 'Aviator Server' + params[:adminPass] = admin_pass + end + + response.status.must_equal 202 + response.body.wont_be_nil + response.body[:server].wont_be_nil + response.body[:server][:adminPass].must_equal admin_pass + response.headers.wont_be_nil + end + + end + +end \ No newline at end of file diff --git a/test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_parameters_are_provided.yml b/test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_parameters_are_provided.yml new file mode 100644 index 0000000..2638a3f --- /dev/null +++ b/test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_parameters_are_provided.yml @@ -0,0 +1,182 @@ +--- +http_interactions: +- request: + method: post + uri: :5000/v2.0/tokens + body: + encoding: UTF-8 + string: ! '{"auth":{"passwordCredentials":{"username":"","password":""},"tenantName":""}}' + 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: + - '2654' + date: + - Thu, 05 Sep 2013 04:56:32 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"access": {"token": {"issued_at": "2013-09-05T04:56:32.371849", + "expires": "2013-09-05T10:56:32Z", "id": "21784f2f51174334b5768e2215d86307", + "tenant": {"description": "Used for Aviator testing/development ", "enabled": + true, "id": "d770443fc60a410c843dc12b98ac8135", "name": ""}}, + "serviceCatalog": [{"endpoints": [{"adminURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135", + "region": "RegionOne", "internalURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135", + "id": "6bb597a3738045f4b2c51a7702037cab", "publicURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135"}], + "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": + ":9292", "region": "RegionOne", "internalURL": ":9292", + "id": "2985945e07b74103bb2dfef7e426cd43", "publicURL": ":9292"}], + "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": + ":8777", "region": "RegionOne", "internalURL": ":8777", + "id": "370119dd80e84894bfe83d766fd467dd", "publicURL": ":8777"}], + "endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints": + [{"adminURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135", + "region": "RegionOne", "internalURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135", + "id": "2492a6f5fa80466d9312e51a8f79b638", "publicURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135"}], + "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": + [{"adminURL": ":8773/services/Admin", "region": + "RegionOne", "internalURL": ":8773/services/Cloud", + "id": "1f68f3ce931946c788e487443e772fb2", "publicURL": ":8773/services/Cloud"}], + "endpoints_links": [], "type": "ec2", "name": "nova_ec2"}, {"endpoints": [{"adminURL": + ":35357/v2.0", "region": "RegionOne", "internalURL": + ":5000/v2.0", "id": "12c722e9b9fb471fbea83c6157c0123a", + "publicURL": ":5000/v2.0"}], "endpoints_links": + [], "type": "identity", "name": "keystone"}], "user": {"username": "", + "roles_links": [], "id": "447527294dae4a1788d36beb0db99c00", "roles": [{"name": + "Member"}], "name": ""}, "metadata": {"is_admin": + 0, "roles": ["f970c227c0ee4512899606886348f67f"]}}}' + http_version: + recorded_at: Thu, 05 Sep 2013 04:56:36 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/images + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - 21784f2f51174334b5768e2215d86307 + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-ef32ecbe-5803-4df7-9bfe-d144cc25a5be + content-type: + - application/json + content-length: + - '565' + date: + - Thu, 05 Sep 2013 04:56:34 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"images": [{"id": "d4c7103f-f6d9-425e-8435-fc6f11e22ab8", "links": + [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "bookmark"}, {"href": "http://10.50.2.1:9292/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "64Bit + Ubuntu 12.04"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 04:56:36 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/flavors + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - 21784f2f51174334b5768e2215d86307 + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-28b52651-d763-4af5-a259-784813f6afbd + content-type: + - application/json + content-length: + - '1075' + date: + - Thu, 05 Sep 2013 04:56:35 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"flavors": [{"id": "2", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/2", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/2", + "rel": "bookmark"}], "name": "m1.small"}, {"id": "3", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/3", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/3", + "rel": "bookmark"}], "name": "m1.medium"}, {"id": "4", "links": [{"href": + ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/4", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/4", + "rel": "bookmark"}], "name": "m1.large"}, {"id": "5", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/5", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/5", + "rel": "bookmark"}], "name": "m1.xlarge"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 04:56:37 GMT +- request: + method: post + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/servers + body: + encoding: UTF-8 + string: ! '{"server":{"flavorRef":"2","imageRef":"d4c7103f-f6d9-425e-8435-fc6f11e22ab8","name":"Aviator + Server"}}' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - 21784f2f51174334b5768e2215d86307 + response: + status: + code: 202 + message: + headers: + x-compute-request-id: + - req-bc44754b-8b47-40c0-ad99-8e3df81953ad + location: + - :8774/v2/d770443fc60a410c843dc12b98ac8135/servers/c7ebe064-0623-4765-a7b5-00862ffc848f + content-type: + - application/json + content-length: + - '462' + date: + - Thu, 05 Sep 2013 04:56:36 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"server": {"security_groups": [{"name": "default"}], "OS-DCF:diskConfig": + "MANUAL", "id": "c7ebe064-0623-4765-a7b5-00862ffc848f", "links": [{"href": + ":8774/v2/d770443fc60a410c843dc12b98ac8135/servers/c7ebe064-0623-4765-a7b5-00862ffc848f", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/servers/c7ebe064-0623-4765-a7b5-00862ffc848f", + "rel": "bookmark"}], "adminPass": "iuu34Vu8tfBW"}}' + http_version: + recorded_at: Thu, 05 Sep 2013 04:56:39 GMT +recorded_with: VCR 2.5.0 diff --git a/test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_the_adminPass_parameter_is_provided.yml b/test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_the_adminPass_parameter_is_provided.yml new file mode 100644 index 0000000..d06b0fd --- /dev/null +++ b/test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_the_adminPass_parameter_is_provided.yml @@ -0,0 +1,182 @@ +--- +http_interactions: +- request: + method: post + uri: :5000/v2.0/tokens + body: + encoding: UTF-8 + string: ! '{"auth":{"passwordCredentials":{"username":"","password":""},"tenantName":""}}' + 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: + - '2654' + date: + - Thu, 05 Sep 2013 05:44:39 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"access": {"token": {"issued_at": "2013-09-05T05:44:39.722969", + "expires": "2013-09-05T11:44:39Z", "id": "ae1d299baf26484295ee3527b7736f2e", + "tenant": {"description": "Used for Aviator testing/development ", "enabled": + true, "id": "d770443fc60a410c843dc12b98ac8135", "name": ""}}, + "serviceCatalog": [{"endpoints": [{"adminURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135", + "region": "RegionOne", "internalURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135", + "id": "6bb597a3738045f4b2c51a7702037cab", "publicURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135"}], + "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": + ":9292", "region": "RegionOne", "internalURL": ":9292", + "id": "2985945e07b74103bb2dfef7e426cd43", "publicURL": ":9292"}], + "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": + ":8777", "region": "RegionOne", "internalURL": ":8777", + "id": "370119dd80e84894bfe83d766fd467dd", "publicURL": ":8777"}], + "endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints": + [{"adminURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135", + "region": "RegionOne", "internalURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135", + "id": "2492a6f5fa80466d9312e51a8f79b638", "publicURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135"}], + "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": + [{"adminURL": ":8773/services/Admin", "region": + "RegionOne", "internalURL": ":8773/services/Cloud", + "id": "1f68f3ce931946c788e487443e772fb2", "publicURL": ":8773/services/Cloud"}], + "endpoints_links": [], "type": "ec2", "name": "nova_ec2"}, {"endpoints": [{"adminURL": + ":35357/v2.0", "region": "RegionOne", "internalURL": + ":5000/v2.0", "id": "12c722e9b9fb471fbea83c6157c0123a", + "publicURL": ":5000/v2.0"}], "endpoints_links": + [], "type": "identity", "name": "keystone"}], "user": {"username": "", + "roles_links": [], "id": "447527294dae4a1788d36beb0db99c00", "roles": [{"name": + "Member"}], "name": ""}, "metadata": {"is_admin": + 0, "roles": ["f970c227c0ee4512899606886348f67f"]}}}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:44:39 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/images + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - ae1d299baf26484295ee3527b7736f2e + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-080310a1-5c98-45c4-ac48-f296949e1b93 + content-type: + - application/json + content-length: + - '565' + date: + - Thu, 05 Sep 2013 05:44:43 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"images": [{"id": "d4c7103f-f6d9-425e-8435-fc6f11e22ab8", "links": + [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "bookmark"}, {"href": "http://10.50.2.1:9292/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "64Bit + Ubuntu 12.04"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:44:43 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/flavors + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - ae1d299baf26484295ee3527b7736f2e + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-767c1a0f-21c2-4129-8d0c-21eed2b3413a + content-type: + - application/json + content-length: + - '1075' + date: + - Thu, 05 Sep 2013 05:44:43 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"flavors": [{"id": "2", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/2", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/2", + "rel": "bookmark"}], "name": "m1.small"}, {"id": "3", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/3", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/3", + "rel": "bookmark"}], "name": "m1.medium"}, {"id": "4", "links": [{"href": + ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/4", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/4", + "rel": "bookmark"}], "name": "m1.large"}, {"id": "5", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/5", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/5", + "rel": "bookmark"}], "name": "m1.xlarge"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:44:43 GMT +- request: + method: post + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/servers + body: + encoding: UTF-8 + string: ! '{"server":{"flavorRef":"2","imageRef":"d4c7103f-f6d9-425e-8435-fc6f11e22ab8","name":"Aviator + Server","adminPass":"4d764cc09a88b3"}}' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - ae1d299baf26484295ee3527b7736f2e + response: + status: + code: 202 + message: + headers: + x-compute-request-id: + - req-47a817f5-95d9-4125-8a66-99cecdc19049 + location: + - :8774/v2/d770443fc60a410c843dc12b98ac8135/servers/a7e8fe92-8336-433e-a36f-94f1fcbdd27f + content-type: + - application/json + content-length: + - '464' + date: + - Thu, 05 Sep 2013 05:44:45 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"server": {"security_groups": [{"name": "default"}], "OS-DCF:diskConfig": + "MANUAL", "id": "a7e8fe92-8336-433e-a36f-94f1fcbdd27f", "links": [{"href": + ":8774/v2/d770443fc60a410c843dc12b98ac8135/servers/a7e8fe92-8336-433e-a36f-94f1fcbdd27f", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/servers/a7e8fe92-8336-433e-a36f-94f1fcbdd27f", + "rel": "bookmark"}], "adminPass": "4d764cc09a88b3"}}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:44:45 GMT +recorded_with: VCR 2.5.0 diff --git a/test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_the_flavorRef_parameter_is_invalid.yml b/test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_the_flavorRef_parameter_is_invalid.yml new file mode 100644 index 0000000..1830ccc --- /dev/null +++ b/test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_the_flavorRef_parameter_is_invalid.yml @@ -0,0 +1,135 @@ +--- +http_interactions: +- request: + method: post + uri: :5000/v2.0/tokens + body: + encoding: UTF-8 + string: ! '{"auth":{"passwordCredentials":{"username":"","password":""},"tenantName":""}}' + 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: + - '2654' + date: + - Thu, 05 Sep 2013 05:22:03 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"access": {"token": {"issued_at": "2013-09-05T05:22:03.769760", + "expires": "2013-09-05T11:22:03Z", "id": "f8765dd9ae5a4a3ab62487b25dd2fb18", + "tenant": {"description": "Used for Aviator testing/development ", "enabled": + true, "id": "d770443fc60a410c843dc12b98ac8135", "name": ""}}, + "serviceCatalog": [{"endpoints": [{"adminURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135", + "region": "RegionOne", "internalURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135", + "id": "6bb597a3738045f4b2c51a7702037cab", "publicURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135"}], + "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": + ":9292", "region": "RegionOne", "internalURL": ":9292", + "id": "2985945e07b74103bb2dfef7e426cd43", "publicURL": ":9292"}], + "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": + ":8777", "region": "RegionOne", "internalURL": ":8777", + "id": "370119dd80e84894bfe83d766fd467dd", "publicURL": ":8777"}], + "endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints": + [{"adminURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135", + "region": "RegionOne", "internalURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135", + "id": "2492a6f5fa80466d9312e51a8f79b638", "publicURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135"}], + "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": + [{"adminURL": ":8773/services/Admin", "region": + "RegionOne", "internalURL": ":8773/services/Cloud", + "id": "1f68f3ce931946c788e487443e772fb2", "publicURL": ":8773/services/Cloud"}], + "endpoints_links": [], "type": "ec2", "name": "nova_ec2"}, {"endpoints": [{"adminURL": + ":35357/v2.0", "region": "RegionOne", "internalURL": + ":5000/v2.0", "id": "12c722e9b9fb471fbea83c6157c0123a", + "publicURL": ":5000/v2.0"}], "endpoints_links": + [], "type": "identity", "name": "keystone"}], "user": {"username": "", + "roles_links": [], "id": "447527294dae4a1788d36beb0db99c00", "roles": [{"name": + "Member"}], "name": ""}, "metadata": {"is_admin": + 0, "roles": ["f970c227c0ee4512899606886348f67f"]}}}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:22:03 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/images + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - f8765dd9ae5a4a3ab62487b25dd2fb18 + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-25918786-9b80-40c0-bd3d-f9a962fb6cfb + content-type: + - application/json + content-length: + - '565' + date: + - Thu, 05 Sep 2013 05:22:05 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"images": [{"id": "d4c7103f-f6d9-425e-8435-fc6f11e22ab8", "links": + [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "bookmark"}, {"href": "http://10.50.2.1:9292/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "64Bit + Ubuntu 12.04"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:22:05 GMT +- request: + method: post + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/servers + body: + encoding: UTF-8 + string: ! '{"server":{"flavorRef":"invalidvalue","imageRef":"d4c7103f-f6d9-425e-8435-fc6f11e22ab8","name":"Aviator + Server"}}' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - f8765dd9ae5a4a3ab62487b25dd2fb18 + response: + status: + code: 400 + message: + headers: + content-length: + - '71' + content-type: + - application/json; charset=UTF-8 + x-compute-request-id: + - req-ba103658-46fa-40d5-a027-ab6f393e95fe + date: + - Thu, 05 Sep 2013 05:22:05 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"badRequest": {"message": "Invalid flavorRef provided.", "code": + 400}}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:22:05 GMT +recorded_with: VCR 2.5.0 diff --git a/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_body_.yml b/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_body_.yml new file mode 100644 index 0000000..43ba9a3 --- /dev/null +++ b/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_body_.yml @@ -0,0 +1,142 @@ +--- +http_interactions: +- request: + method: post + uri: :5000/v2.0/tokens + body: + encoding: UTF-8 + string: ! '{"auth":{"passwordCredentials":{"username":"","password":""},"tenantName":""}}' + 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: + - '2654' + date: + - Thu, 05 Sep 2013 04:56:42 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"access": {"token": {"issued_at": "2013-09-05T04:56:42.579448", + "expires": "2013-09-05T10:56:42Z", "id": "f7ad798847d14e7ea25d3c48a0fe0c9d", + "tenant": {"description": "Used for Aviator testing/development ", "enabled": + true, "id": "d770443fc60a410c843dc12b98ac8135", "name": ""}}, + "serviceCatalog": [{"endpoints": [{"adminURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135", + "region": "RegionOne", "internalURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135", + "id": "6bb597a3738045f4b2c51a7702037cab", "publicURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135"}], + "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": + ":9292", "region": "RegionOne", "internalURL": ":9292", + "id": "2985945e07b74103bb2dfef7e426cd43", "publicURL": ":9292"}], + "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": + ":8777", "region": "RegionOne", "internalURL": ":8777", + "id": "370119dd80e84894bfe83d766fd467dd", "publicURL": ":8777"}], + "endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints": + [{"adminURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135", + "region": "RegionOne", "internalURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135", + "id": "2492a6f5fa80466d9312e51a8f79b638", "publicURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135"}], + "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": + [{"adminURL": ":8773/services/Admin", "region": + "RegionOne", "internalURL": ":8773/services/Cloud", + "id": "1f68f3ce931946c788e487443e772fb2", "publicURL": ":8773/services/Cloud"}], + "endpoints_links": [], "type": "ec2", "name": "nova_ec2"}, {"endpoints": [{"adminURL": + ":35357/v2.0", "region": "RegionOne", "internalURL": + ":5000/v2.0", "id": "12c722e9b9fb471fbea83c6157c0123a", + "publicURL": ":5000/v2.0"}], "endpoints_links": + [], "type": "identity", "name": "keystone"}], "user": {"username": "", + "roles_links": [], "id": "447527294dae4a1788d36beb0db99c00", "roles": [{"name": + "Member"}], "name": ""}, "metadata": {"is_admin": + 0, "roles": ["f970c227c0ee4512899606886348f67f"]}}}' + http_version: + recorded_at: Thu, 05 Sep 2013 04:56:44 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/images + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - f7ad798847d14e7ea25d3c48a0fe0c9d + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-d6fa17f6-9d30-4042-82a1-01ba7bf0785f + content-type: + - application/json + content-length: + - '565' + date: + - Thu, 05 Sep 2013 04:56:50 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"images": [{"id": "d4c7103f-f6d9-425e-8435-fc6f11e22ab8", "links": + [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "bookmark"}, {"href": "http://10.50.2.1:9292/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "64Bit + Ubuntu 12.04"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 04:56:52 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/flavors + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - f7ad798847d14e7ea25d3c48a0fe0c9d + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-ac9f72df-215e-469b-95db-d9eeca91ecef + content-type: + - application/json + content-length: + - '1075' + date: + - Thu, 05 Sep 2013 04:56:51 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"flavors": [{"id": "2", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/2", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/2", + "rel": "bookmark"}], "name": "m1.small"}, {"id": "3", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/3", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/3", + "rel": "bookmark"}], "name": "m1.medium"}, {"id": "4", "links": [{"href": + ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/4", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/4", + "rel": "bookmark"}], "name": "m1.large"}, {"id": "5", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/5", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/5", + "rel": "bookmark"}], "name": "m1.xlarge"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 04:56:53 GMT +recorded_with: VCR 2.5.0 diff --git a/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_headers_.yml b/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_headers_.yml new file mode 100644 index 0000000..e454baa --- /dev/null +++ b/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_headers_.yml @@ -0,0 +1,142 @@ +--- +http_interactions: +- request: + method: post + uri: :5000/v2.0/tokens + body: + encoding: UTF-8 + string: ! '{"auth":{"passwordCredentials":{"username":"","password":""},"tenantName":""}}' + 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: + - '2654' + date: + - Thu, 05 Sep 2013 05:11:18 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"access": {"token": {"issued_at": "2013-09-05T05:11:18.256205", + "expires": "2013-09-05T11:11:18Z", "id": "6059edf91ce3484eb19f1fed7a3c712d", + "tenant": {"description": "Used for Aviator testing/development ", "enabled": + true, "id": "d770443fc60a410c843dc12b98ac8135", "name": ""}}, + "serviceCatalog": [{"endpoints": [{"adminURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135", + "region": "RegionOne", "internalURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135", + "id": "6bb597a3738045f4b2c51a7702037cab", "publicURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135"}], + "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": + ":9292", "region": "RegionOne", "internalURL": ":9292", + "id": "2985945e07b74103bb2dfef7e426cd43", "publicURL": ":9292"}], + "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": + ":8777", "region": "RegionOne", "internalURL": ":8777", + "id": "370119dd80e84894bfe83d766fd467dd", "publicURL": ":8777"}], + "endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints": + [{"adminURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135", + "region": "RegionOne", "internalURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135", + "id": "2492a6f5fa80466d9312e51a8f79b638", "publicURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135"}], + "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": + [{"adminURL": ":8773/services/Admin", "region": + "RegionOne", "internalURL": ":8773/services/Cloud", + "id": "1f68f3ce931946c788e487443e772fb2", "publicURL": ":8773/services/Cloud"}], + "endpoints_links": [], "type": "ec2", "name": "nova_ec2"}, {"endpoints": [{"adminURL": + ":35357/v2.0", "region": "RegionOne", "internalURL": + ":5000/v2.0", "id": "12c722e9b9fb471fbea83c6157c0123a", + "publicURL": ":5000/v2.0"}], "endpoints_links": + [], "type": "identity", "name": "keystone"}], "user": {"username": "", + "roles_links": [], "id": "447527294dae4a1788d36beb0db99c00", "roles": [{"name": + "Member"}], "name": ""}, "metadata": {"is_admin": + 0, "roles": ["f970c227c0ee4512899606886348f67f"]}}}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:11:20 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/images + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - 6059edf91ce3484eb19f1fed7a3c712d + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-27a71c08-5942-405f-bbe1-aded8331f6dd + content-type: + - application/json + content-length: + - '565' + date: + - Thu, 05 Sep 2013 05:11:23 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"images": [{"id": "d4c7103f-f6d9-425e-8435-fc6f11e22ab8", "links": + [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "bookmark"}, {"href": "http://10.50.2.1:9292/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "64Bit + Ubuntu 12.04"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:11:23 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/flavors + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - 6059edf91ce3484eb19f1fed7a3c712d + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-b277a242-a4d9-4ffc-be41-0a79ebe7ec86 + content-type: + - application/json + content-length: + - '1075' + date: + - Thu, 05 Sep 2013 05:11:24 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"flavors": [{"id": "2", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/2", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/2", + "rel": "bookmark"}], "name": "m1.small"}, {"id": "3", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/3", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/3", + "rel": "bookmark"}], "name": "m1.medium"}, {"id": "4", "links": [{"href": + ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/4", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/4", + "rel": "bookmark"}], "name": "m1.large"}, {"id": "5", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/5", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/5", + "rel": "bookmark"}], "name": "m1.xlarge"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:11:24 GMT +recorded_with: VCR 2.5.0 diff --git a/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_http_method_.yml b/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_http_method_.yml new file mode 100644 index 0000000..34ac7a9 --- /dev/null +++ b/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_http_method_.yml @@ -0,0 +1,142 @@ +--- +http_interactions: +- request: + method: post + uri: :5000/v2.0/tokens + body: + encoding: UTF-8 + string: ! '{"auth":{"passwordCredentials":{"username":"","password":""},"tenantName":""}}' + 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: + - '2654' + date: + - Thu, 05 Sep 2013 04:56:38 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"access": {"token": {"issued_at": "2013-09-05T04:56:38.920579", + "expires": "2013-09-05T10:56:38Z", "id": "9f8357f22d7245bfb50aae17ecce1577", + "tenant": {"description": "Used for Aviator testing/development ", "enabled": + true, "id": "d770443fc60a410c843dc12b98ac8135", "name": ""}}, + "serviceCatalog": [{"endpoints": [{"adminURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135", + "region": "RegionOne", "internalURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135", + "id": "6bb597a3738045f4b2c51a7702037cab", "publicURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135"}], + "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": + ":9292", "region": "RegionOne", "internalURL": ":9292", + "id": "2985945e07b74103bb2dfef7e426cd43", "publicURL": ":9292"}], + "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": + ":8777", "region": "RegionOne", "internalURL": ":8777", + "id": "370119dd80e84894bfe83d766fd467dd", "publicURL": ":8777"}], + "endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints": + [{"adminURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135", + "region": "RegionOne", "internalURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135", + "id": "2492a6f5fa80466d9312e51a8f79b638", "publicURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135"}], + "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": + [{"adminURL": ":8773/services/Admin", "region": + "RegionOne", "internalURL": ":8773/services/Cloud", + "id": "1f68f3ce931946c788e487443e772fb2", "publicURL": ":8773/services/Cloud"}], + "endpoints_links": [], "type": "ec2", "name": "nova_ec2"}, {"endpoints": [{"adminURL": + ":35357/v2.0", "region": "RegionOne", "internalURL": + ":5000/v2.0", "id": "12c722e9b9fb471fbea83c6157c0123a", + "publicURL": ":5000/v2.0"}], "endpoints_links": + [], "type": "identity", "name": "keystone"}], "user": {"username": "", + "roles_links": [], "id": "447527294dae4a1788d36beb0db99c00", "roles": [{"name": + "Member"}], "name": ""}, "metadata": {"is_admin": + 0, "roles": ["f970c227c0ee4512899606886348f67f"]}}}' + http_version: + recorded_at: Thu, 05 Sep 2013 04:56:40 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/images + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - 9f8357f22d7245bfb50aae17ecce1577 + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-019c8971-1d11-420a-bf04-7e3563f21c93 + content-type: + - application/json + content-length: + - '565' + date: + - Thu, 05 Sep 2013 04:56:40 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"images": [{"id": "d4c7103f-f6d9-425e-8435-fc6f11e22ab8", "links": + [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "bookmark"}, {"href": "http://10.50.2.1:9292/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "64Bit + Ubuntu 12.04"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 04:56:42 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/flavors + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - 9f8357f22d7245bfb50aae17ecce1577 + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-1b22653b-c573-41b1-b919-3b655b931f3c + content-type: + - application/json + content-length: + - '1075' + date: + - Thu, 05 Sep 2013 04:56:41 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"flavors": [{"id": "2", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/2", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/2", + "rel": "bookmark"}], "name": "m1.small"}, {"id": "3", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/3", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/3", + "rel": "bookmark"}], "name": "m1.medium"}, {"id": "4", "links": [{"href": + ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/4", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/4", + "rel": "bookmark"}], "name": "m1.large"}, {"id": "5", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/5", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/5", + "rel": "bookmark"}], "name": "m1.xlarge"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 04:56:43 GMT +recorded_with: VCR 2.5.0 diff --git a/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_url_.yml b/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_url_.yml new file mode 100644 index 0000000..6427cb1 --- /dev/null +++ b/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_url_.yml @@ -0,0 +1,222 @@ +--- +http_interactions: +- request: + method: post + uri: :5000/v2.0/tokens + body: + encoding: UTF-8 + string: ! '{"auth":{"passwordCredentials":{"username":"","password":""},"tenantName":""}}' + 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: + - '2654' + date: + - Thu, 05 Sep 2013 05:11:25 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"access": {"token": {"issued_at": "2013-09-05T05:11:25.378477", + "expires": "2013-09-05T11:11:25Z", "id": "23878334d51b4b24b41e78dc5e7f926b", + "tenant": {"description": "Used for Aviator testing/development ", "enabled": + true, "id": "d770443fc60a410c843dc12b98ac8135", "name": ""}}, + "serviceCatalog": [{"endpoints": [{"adminURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135", + "region": "RegionOne", "internalURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135", + "id": "6bb597a3738045f4b2c51a7702037cab", "publicURL": ":8774/v2/d770443fc60a410c843dc12b98ac8135"}], + "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": + ":9292", "region": "RegionOne", "internalURL": ":9292", + "id": "2985945e07b74103bb2dfef7e426cd43", "publicURL": ":9292"}], + "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": + ":8777", "region": "RegionOne", "internalURL": ":8777", + "id": "370119dd80e84894bfe83d766fd467dd", "publicURL": ":8777"}], + "endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints": + [{"adminURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135", + "region": "RegionOne", "internalURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135", + "id": "2492a6f5fa80466d9312e51a8f79b638", "publicURL": ":8776/v1/d770443fc60a410c843dc12b98ac8135"}], + "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": + [{"adminURL": ":8773/services/Admin", "region": + "RegionOne", "internalURL": ":8773/services/Cloud", + "id": "1f68f3ce931946c788e487443e772fb2", "publicURL": ":8773/services/Cloud"}], + "endpoints_links": [], "type": "ec2", "name": "nova_ec2"}, {"endpoints": [{"adminURL": + ":35357/v2.0", "region": "RegionOne", "internalURL": + ":5000/v2.0", "id": "12c722e9b9fb471fbea83c6157c0123a", + "publicURL": ":5000/v2.0"}], "endpoints_links": + [], "type": "identity", "name": "keystone"}], "user": {"username": "", + "roles_links": [], "id": "447527294dae4a1788d36beb0db99c00", "roles": [{"name": + "Member"}], "name": ""}, "metadata": {"is_admin": + 0, "roles": ["f970c227c0ee4512899606886348f67f"]}}}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:11:25 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/images + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - 23878334d51b4b24b41e78dc5e7f926b + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-ca819fc7-9f8a-4373-aba1-ff64d72c6e88 + content-type: + - application/json + content-length: + - '565' + date: + - Thu, 05 Sep 2013 05:11:28 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"images": [{"id": "d4c7103f-f6d9-425e-8435-fc6f11e22ab8", "links": + [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "bookmark"}, {"href": "http://10.50.2.1:9292/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "64Bit + Ubuntu 12.04"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:11:28 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/flavors + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - 23878334d51b4b24b41e78dc5e7f926b + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-17eec3a7-769c-4227-9e34-34f4186f7bdb + content-type: + - application/json + content-length: + - '1075' + date: + - Thu, 05 Sep 2013 05:11:29 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"flavors": [{"id": "2", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/2", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/2", + "rel": "bookmark"}], "name": "m1.small"}, {"id": "3", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/3", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/3", + "rel": "bookmark"}], "name": "m1.medium"}, {"id": "4", "links": [{"href": + ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/4", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/4", + "rel": "bookmark"}], "name": "m1.large"}, {"id": "5", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/5", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/5", + "rel": "bookmark"}], "name": "m1.xlarge"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:11:29 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/images + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - 23878334d51b4b24b41e78dc5e7f926b + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-ae744264-340a-40bf-961b-406a428cc178 + content-type: + - application/json + content-length: + - '565' + date: + - Thu, 05 Sep 2013 05:11:32 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"images": [{"id": "d4c7103f-f6d9-425e-8435-fc6f11e22ab8", "links": + [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "rel": "bookmark"}, {"href": "http://10.50.2.1:9292/d770443fc60a410c843dc12b98ac8135/images/d4c7103f-f6d9-425e-8435-fc6f11e22ab8", + "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "64Bit + Ubuntu 12.04"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:11:32 GMT +- request: + method: get + uri: :8774/v2/d770443fc60a410c843dc12b98ac8135/flavors + body: + encoding: US-ASCII + string: '' + headers: + Content-Type: + - application/json + User-Agent: + - Faraday v0.8.8 + X-Auth-Token: + - 23878334d51b4b24b41e78dc5e7f926b + response: + status: + code: 200 + message: + headers: + x-compute-request-id: + - req-c918d57d-071b-4009-9010-c9839485ce0a + content-type: + - application/json + content-length: + - '1075' + date: + - Thu, 05 Sep 2013 05:11:32 GMT + connection: + - close + body: + encoding: US-ASCII + string: ! '{"flavors": [{"id": "2", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/2", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/2", + "rel": "bookmark"}], "name": "m1.small"}, {"id": "3", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/3", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/3", + "rel": "bookmark"}], "name": "m1.medium"}, {"id": "4", "links": [{"href": + ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/4", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/4", + "rel": "bookmark"}], "name": "m1.large"}, {"id": "5", "links": [{"href": ":8774/v2/d770443fc60a410c843dc12b98ac8135/flavors/5", + "rel": "self"}, {"href": ":8774/d770443fc60a410c843dc12b98ac8135/flavors/5", + "rel": "bookmark"}], "name": "m1.xlarge"}]}' + http_version: + recorded_at: Thu, 05 Sep 2013 05:11:32 GMT +recorded_with: VCR 2.5.0 From ad849e27a754d9827d2d0bb3c6e7c6fc25f12c1a Mon Sep 17 00:00:00 2001 From: Mark Maglana Date: Wed, 4 Sep 2013 23:54:18 -0700 Subject: [PATCH 3/3] Add missing parameters to create_server body --- .../compute/v2/public/create_server.rb | 10 +++- .../compute/v2/public/create_server_test.rb | 56 ++++++++++--------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/lib/aviator/openstack/compute/v2/public/create_server.rb b/lib/aviator/openstack/compute/v2/public/create_server.rb index 9dc81b9..8a10c53 100644 --- a/lib/aviator/openstack/compute/v2/public/create_server.rb +++ b/lib/aviator/openstack/compute/v2/public/create_server.rb @@ -10,6 +10,8 @@ module Aviator link 'documentation', 'http://docs.openstack.org/api/openstack-compute/2/content/CreateServers.html' + param :accessIPv4, required: false + param :accessIPv6, required: false param :adminPass, required: false param :imageRef, required: true param :flavorRef, required: true @@ -27,9 +29,11 @@ module Aviator name: params[:name] } } - - p[:server][:adminPass] = params[:adminPass] if params[:adminPass] - + + [:adminPass, :metadata, :personality, :networks, :accessIPv4, :accessIPv6].each do |key| + p[:server][key] = params[key] if params[key] + end + p end diff --git a/test/aviator/openstack/compute/v2/public/create_server_test.rb b/test/aviator/openstack/compute/v2/public/create_server_test.rb index fee4d17..b564f33 100644 --- a/test/aviator/openstack/compute/v2/public/create_server_test.rb +++ b/test/aviator/openstack/compute/v2/public/create_server_test.rb @@ -7,7 +7,7 @@ class Aviator::Test def create_request(session_data = get_session_data) image_id = session.compute_service.request(:list_images).body[:images].first[:id] flavor_id = session.compute_service.request(:list_flavors).body[:flavors].first[:id] - + klass.new(session_data) do |params| params[:imageRef] = image_id params[:flavorRef] = flavor_id @@ -19,8 +19,8 @@ class Aviator::Test def get_session_data session.send :auth_info end - - + + def helper Aviator::Test::RequestHelper end @@ -29,8 +29,8 @@ class Aviator::Test def klass @klass ||= helper.load_request('openstack', 'compute', 'v2', 'public', 'create_server.rb') end - - + + def session unless @session @session = Aviator::Session.new( @@ -39,10 +39,10 @@ class Aviator::Test ) @session.authenticate end - + @session end - + validate_attr :anonymous? do klass.anonymous?.must_equal false @@ -56,7 +56,7 @@ class Aviator::Test validate_attr :body do request = create_request - + klass.body?.must_equal true request.body?.must_equal true request.body.wont_be_nil @@ -84,6 +84,8 @@ class Aviator::Test validate_attr :optional_params do klass.optional_params.must_equal [ + :accessIPv4, + :accessIPv6, :adminPass, :metadata, :networks, @@ -99,52 +101,52 @@ class Aviator::Test :name ] end - - + + validate_attr :url do service_spec = get_session_data[:access][:serviceCatalog].find{|s| s[:type] == 'compute' } url = "#{ service_spec[:endpoints][0][:publicURL] }/servers" - + image_id = session.compute_service.request(:list_images).body[:images].first[:id] flavor_id = session.compute_service.request(:list_flavors).body[:flavors].first[:id] - - + + request = create_request do |params| params[:imageRef] = image_id params[:flavorRef] = flavor_id params[:name] = 'Aviator Server' end - + request.url.must_equal url end - - + + validate_response 'parameters are provided' do image_id = session.compute_service.request(:list_images).body[:images].first[:id] - flavor_id = session.compute_service.request(:list_flavors).body[:flavors].first[:id] - + flavor_id = session.compute_service.request(:list_flavors).body[:flavors].first[:id] + response = session.compute_service.request :create_server do |params| params[:imageRef] = image_id params[:flavorRef] = flavor_id params[:name] = 'Aviator Server' end - + response.status.must_equal 202 response.body.wont_be_nil response.body[:server].wont_be_nil response.headers.wont_be_nil end - - + + validate_response 'the flavorRef parameter is invalid' do image_id = session.compute_service.request(:list_images).body[:images].first[:id] - + response = session.compute_service.request :create_server do |params| params[:imageRef] = image_id params[:flavorRef] = 'invalidvalue' params[:name] = 'Aviator Server' end - + response.status.must_equal 400 response.body.wont_be_nil response.headers.wont_be_nil @@ -153,23 +155,23 @@ class Aviator::Test validate_response 'the adminPass parameter is provided' do image_id = session.compute_service.request(:list_images).body[:images].first[:id] - flavor_id = session.compute_service.request(:list_flavors).body[:flavors].first[:id] + flavor_id = session.compute_service.request(:list_flavors).body[:flavors].first[:id] admin_pass = '4d764cc09a88b3' - + response = session.compute_service.request :create_server do |params| params[:imageRef] = image_id params[:flavorRef] = flavor_id params[:name] = 'Aviator Server' params[:adminPass] = admin_pass end - + response.status.must_equal 202 response.body.wont_be_nil response.body[:server].wont_be_nil response.body[:server][:adminPass].must_equal admin_pass response.headers.wont_be_nil end - + end end \ No newline at end of file