Completes #10: list_addresses

This commit is contained in:
Mark Maglana
2013-09-06 18:35:20 -07:00
parent c1e46a45f9
commit 97e7f2c099
3 changed files with 211 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
module Aviator
define_request :list_addresses do
meta :provider, :openstack
@@ -10,28 +10,37 @@ module Aviator
link 'documentation',
'http://docs.openstack.org/api/openstack-compute/2/content/List_Addresses-d1e3014.html'
param :id, required: true
link 'documentation',
'http://docs.openstack.org/api/openstack-compute/2/content/List_Addresses_by_Network-d1e3118.html'
param :id, required: true
param :networkID, required: false
def headers
h = {}
unless self.anonymous?
h['X-Auth-Token'] = session_data[:access][:token][:id]
end
h
end
def http_method
:get
end
def url
service_spec = session_data[:access][:serviceCatalog].find{|s| s[:type] == service.to_s }
"#{ service_spec[:endpoints][0][:publicURL] }/servers/#{ params[:id] }/ips"
url = "#{ service_spec[:endpoints][0][:publicURL] }/servers/#{ params[:id] }/ips"
url += "/#{ params[:networkID] }" if params[:networkID]
url
end
end

View File

@@ -84,7 +84,9 @@ class Aviator::Test
validate_attr :optional_params do
klass.optional_params.must_equal []
klass.optional_params.must_equal [
:networkID
]
end
@@ -117,7 +119,7 @@ class Aviator::Test
response.body.wont_be_nil
response.body[:addresses].wont_be_nil
response.headers.wont_be_nil
end
end
validate_response 'an invalid server id is provided' do
@@ -130,6 +132,28 @@ class Aviator::Test
response.status.must_equal 404
response.body.wont_be_nil
response.headers.wont_be_nil
end
validate_response 'a networkID parameter is provided' do
server_id = session.compute_service.request(:list_servers).body[:servers].first[:id]
response = session.compute_service.request :list_addresses do |params|
params[:id] = server_id
end
network_id = response.body[:addresses].keys.first
response = session.compute_service.request :list_addresses do |params|
params[:id] = server_id
params[:networkID] = network_id
end
response.status.must_equal 200
response.body.wont_be_nil
response.body.keys.wont_be_empty
response.headers.wont_be_nil
end
end

View File

@@ -0,0 +1,167 @@
---
http_interactions:
- request:
method: post
uri: <OPENSTACK_ADMIN_HOST_URI>:5000/v2.0/tokens
body:
encoding: UTF-8
string: ! '{"auth":{"passwordCredentials":{"username":"<OPENSTACK_MEMBER_USERNAME>","password":"<OPENSTACK_MEMBER_PASSWORD>"},"tenantName":"<OPENSTACK_MEMBER_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:
- '2701'
date:
- Sat, 07 Sep 2013 01:25:11 GMT
connection:
- close
body:
encoding: US-ASCII
string: ! '{"access": {"token": {"issued_at": "2013-09-07T01:25:11.854217",
"expires": "2013-09-07T07:25:11Z", "id": "f92e36d540b541ab9346c9b9167f7e24",
"tenant": {"description": "<OPENSTACK_MEMBER_TENANTNAME>", "enabled": true,
"id": "eb87dfa8fdec48678b0f0b0f80b44677", "name": "<OPENSTACK_MEMBER_TENANTNAME>"}},
"serviceCatalog": [{"endpoints": [{"adminURL": "<OPENSTACK_ADMIN_HOST_URI>:8774/v2/eb87dfa8fdec48678b0f0b0f80b44677",
"region": "RegionOne", "internalURL": "<OPENSTACK_ADMIN_HOST_URI>:8774/v2/eb87dfa8fdec48678b0f0b0f80b44677",
"id": "430279a1221947c3ae56339b069f1b34", "publicURL": "<OPENSTACK_ADMIN_HOST_URI>:8774/v2/eb87dfa8fdec48678b0f0b0f80b44677"}],
"endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL":
"<OPENSTACK_ADMIN_HOST_URI>:9292", "region": "RegionOne", "internalURL": "<OPENSTACK_ADMIN_HOST_URI>:9292",
"id": "0704bbb682c349cd8bad917183e7a7dd", "publicURL": "<OPENSTACK_ADMIN_HOST_URI>:9292"}],
"endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL":
"<OPENSTACK_ADMIN_HOST_URI>:8777", "region": "RegionOne", "internalURL": "<OPENSTACK_ADMIN_HOST_URI>:8777",
"id": "94a8dead81c34afbaa8ae5e163b8b0c5", "publicURL": "<OPENSTACK_ADMIN_HOST_URI>:8777"}],
"endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints":
[{"adminURL": "<OPENSTACK_ADMIN_HOST_URI>:8776/v1/eb87dfa8fdec48678b0f0b0f80b44677",
"region": "RegionOne", "internalURL": "<OPENSTACK_ADMIN_HOST_URI>:8776/v1/eb87dfa8fdec48678b0f0b0f80b44677",
"id": "2aedb2fe28114b86a13c48e8bef42b77", "publicURL": "<OPENSTACK_ADMIN_HOST_URI>:8776/v1/eb87dfa8fdec48678b0f0b0f80b44677"}],
"endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints":
[{"adminURL": "<OPENSTACK_ADMIN_HOST_URI>:8773/services/Admin", "region":
"RegionOne", "internalURL": "<OPENSTACK_ADMIN_HOST_URI>:8773/services/Cloud",
"id": "308574230d4a427a996d1f9c6e602e14", "publicURL": "<OPENSTACK_ADMIN_HOST_URI>:8773/services/Cloud"}],
"endpoints_links": [], "type": "ec2", "name": "nova_ec2"}, {"endpoints": [{"adminURL":
"<OPENSTACK_ADMIN_HOST_URI>:35357/v2.0", "region": "RegionOne", "internalURL":
"<OPENSTACK_ADMIN_HOST_URI>:5000/v2.0", "id": "04e2c1aa204048529cd859b111362d46",
"publicURL": "<OPENSTACK_ADMIN_HOST_URI>:5000/v2.0"}], "endpoints_links":
[], "type": "identity", "name": "keystone"}], "user": {"username": "<OPENSTACK_MEMBER_USERNAME>",
"roles_links": [], "id": "400351b4991d40d79434539b4cee9d36", "roles": [{"name":
"_member_"}, {"name": "Member"}], "name": "<OPENSTACK_MEMBER_USERNAME>"},
"metadata": {"is_admin": 0, "roles": ["9fe2ff9ee4384b1894a90878d3e92bab",
"972b832749e5458cafe44d40d5b0e895"]}}}'
http_version:
recorded_at: Sat, 07 Sep 2013 01:25:12 GMT
- request:
method: get
uri: <OPENSTACK_ADMIN_HOST_URI>:8774/v2/eb87dfa8fdec48678b0f0b0f80b44677/servers
body:
encoding: US-ASCII
string: ''
headers:
Content-Type:
- application/json
User-Agent:
- Faraday v0.8.8
X-Auth-Token:
- f92e36d540b541ab9346c9b9167f7e24
response:
status:
code: 200
message:
headers:
x-compute-request-id:
- req-44b04237-2da3-45de-982d-e70a8f8eacd7
content-type:
- application/json
content-length:
- '390'
date:
- Sat, 07 Sep 2013 01:25:13 GMT
connection:
- close
body:
encoding: US-ASCII
string: ! '{"servers": [{"id": "7ff01c2a-325d-4c05-ac77-5f76df18962a", "links":
[{"href": "<OPENSTACK_ADMIN_HOST_URI>:8774/v2/eb87dfa8fdec48678b0f0b0f80b44677/servers/7ff01c2a-325d-4c05-ac77-5f76df18962a",
"rel": "self"}, {"href": "<OPENSTACK_ADMIN_HOST_URI>:8774/eb87dfa8fdec48678b0f0b0f80b44677/servers/7ff01c2a-325d-4c05-ac77-5f76df18962a",
"rel": "bookmark"}], "name": "Aviator Testing"}]}'
http_version:
recorded_at: Sat, 07 Sep 2013 01:25:13 GMT
- request:
method: get
uri: <OPENSTACK_ADMIN_HOST_URI>:8774/v2/eb87dfa8fdec48678b0f0b0f80b44677/servers/7ff01c2a-325d-4c05-ac77-5f76df18962a/ips
body:
encoding: US-ASCII
string: ''
headers:
Content-Type:
- application/json
User-Agent:
- Faraday v0.8.8
X-Auth-Token:
- f92e36d540b541ab9346c9b9167f7e24
response:
status:
code: 200
message:
headers:
x-compute-request-id:
- req-458cab2e-e23c-4bc6-93ff-9e50ab8833aa
content-type:
- application/json
content-length:
- '108'
date:
- Sat, 07 Sep 2013 01:25:14 GMT
connection:
- close
body:
encoding: US-ASCII
string: ! '{"addresses": {"novanetwork_5": [{"version": 4, "addr": "10.3.5.3"},
{"version": 4, "addr": "10.50.3.43"}]}}'
http_version:
recorded_at: Sat, 07 Sep 2013 01:25:15 GMT
- request:
method: get
uri: <OPENSTACK_ADMIN_HOST_URI>:8774/v2/eb87dfa8fdec48678b0f0b0f80b44677/servers/7ff01c2a-325d-4c05-ac77-5f76df18962a/ips/novanetwork_5
body:
encoding: US-ASCII
string: ''
headers:
Content-Type:
- application/json
User-Agent:
- Faraday v0.8.8
X-Auth-Token:
- f92e36d540b541ab9346c9b9167f7e24
response:
status:
code: 200
message:
headers:
x-compute-request-id:
- req-c27e1e00-8843-4664-b6a3-68bae4075f1e
content-type:
- application/json
content-length:
- '93'
date:
- Sat, 07 Sep 2013 01:25:15 GMT
connection:
- close
body:
encoding: US-ASCII
string: ! '{"novanetwork_5": [{"version": 4, "addr": "10.3.5.3"}, {"version":
4, "addr": "10.50.3.43"}]}'
http_version:
recorded_at: Sat, 07 Sep 2013 01:25:15 GMT
recorded_with: VCR 2.5.0