Adds API sample test for Flavors Extra Data extension.

Change-Id: I65f8ed10dc5c1d31f848ad3fdc5c63e17fdc518f
This commit is contained in:
Tiago Mello 2012-09-10 21:04:46 -03:00
parent 3a671cd7de
commit 223b9f19e5
17 changed files with 418 additions and 0 deletions

View File

@ -0,0 +1,20 @@
{
"flavor": {
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 0,
"id": "1",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"ram": 512,
"vcpus": 1
}
}

View File

@ -0,0 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="0" vcpus="1" ram="512" name="m1.tiny" id="1" OS-FLV-EXT-DATA:ephemeral="0">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/1" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/1" rel="bookmark"/>
</flavor>

View File

@ -0,0 +1,94 @@
{
"flavors": [
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 0,
"id": "1",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"ram": 512,
"vcpus": 1
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 20,
"id": "2",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/2",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/2",
"rel": "bookmark"
}
],
"name": "m1.small",
"ram": 2048,
"vcpus": 1
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 40,
"id": "3",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/3",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/3",
"rel": "bookmark"
}
],
"name": "m1.medium",
"ram": 4096,
"vcpus": 2
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 80,
"id": "4",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/4",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/4",
"rel": "bookmark"
}
],
"name": "m1.large",
"ram": 8192,
"vcpus": 4
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 160,
"id": "5",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/5",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/5",
"rel": "bookmark"
}
],
"name": "m1.xlarge",
"ram": 16384,
"vcpus": 8
}
]
}

View File

@ -0,0 +1,23 @@
<?xml version='1.0' encoding='UTF-8'?>
<flavors xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1">
<flavor disk="0" vcpus="1" ram="512" name="m1.tiny" id="1" OS-FLV-EXT-DATA:ephemeral="0">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/1" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/1" rel="bookmark"/>
</flavor>
<flavor disk="20" vcpus="1" ram="2048" name="m1.small" id="2" OS-FLV-EXT-DATA:ephemeral="0">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/2" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/2" rel="bookmark"/>
</flavor>
<flavor disk="40" vcpus="2" ram="4096" name="m1.medium" id="3" OS-FLV-EXT-DATA:ephemeral="0">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/3" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/3" rel="bookmark"/>
</flavor>
<flavor disk="80" vcpus="4" ram="8192" name="m1.large" id="4" OS-FLV-EXT-DATA:ephemeral="0">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/4" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/4" rel="bookmark"/>
</flavor>
<flavor disk="160" vcpus="8" ram="16384" name="m1.xlarge" id="5" OS-FLV-EXT-DATA:ephemeral="0">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/5" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/5" rel="bookmark"/>
</flavor>
</flavors>

View File

@ -0,0 +1,12 @@
{
"flavor": {
"OS-FLV-EXT-DATA:ephemeral": 30,
"disk": 10,
"id": "666",
"name": "flavortest",
"ram": 1024,
"rxtx_factor": 2,
"swap": 5,
"vcpus": 2
}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<flavor xmlns="http://docs.openstack.org/compute/api/v1.1"
xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1"
name="testflavor1"
ram="1024"
vcpus="2"
disk="10"
id="666"
swap="5"
rxtx_factor="2"
OS-FLV-EXT-DATA:ephemeral="30" />

View File

@ -0,0 +1,20 @@
{
"flavor": {
"OS-FLV-EXT-DATA:ephemeral": 30,
"disk": 10,
"id": "666",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/666",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/666",
"rel": "bookmark"
}
],
"name": "flavortest",
"ram": 1024,
"vcpus": 2
}
}

View File

@ -0,0 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="10" vcpus="2" ram="1024" name="testflavor1" id="666" OS-FLV-EXT-DATA:ephemeral="30">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/666" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/666" rel="bookmark"/>
</flavor>

View File

@ -0,0 +1,20 @@
{
"flavor": {
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 0,
"id": "1",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"ram": 512,
"vcpus": 1
}
}

View File

@ -0,0 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="0" vcpus="1" ram="512" name="m1.tiny" id="1" OS-FLV-EXT-DATA:ephemeral="0">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/1" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/1" rel="bookmark"/>
</flavor>

View File

@ -0,0 +1,94 @@
{
"flavors": [
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 0,
"id": "1",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
],
"name": "m1.tiny",
"ram": 512,
"vcpus": 1
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 20,
"id": "2",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/2",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/2",
"rel": "bookmark"
}
],
"name": "m1.small",
"ram": 2048,
"vcpus": 1
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 40,
"id": "3",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/3",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/3",
"rel": "bookmark"
}
],
"name": "m1.medium",
"ram": 4096,
"vcpus": 2
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 80,
"id": "4",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/4",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/4",
"rel": "bookmark"
}
],
"name": "m1.large",
"ram": 8192,
"vcpus": 4
},
{
"OS-FLV-EXT-DATA:ephemeral": 0,
"disk": 160,
"id": "5",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/5",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/5",
"rel": "bookmark"
}
],
"name": "m1.xlarge",
"ram": 16384,
"vcpus": 8
}
]
}

View File

@ -0,0 +1,23 @@
<?xml version='1.0' encoding='UTF-8'?>
<flavors xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1">
<flavor disk="0" vcpus="1" ram="512" name="m1.tiny" id="1" OS-FLV-EXT-DATA:ephemeral="0">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/1" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/1" rel="bookmark"/>
</flavor>
<flavor disk="20" vcpus="1" ram="2048" name="m1.small" id="2" OS-FLV-EXT-DATA:ephemeral="0">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/2" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/2" rel="bookmark"/>
</flavor>
<flavor disk="40" vcpus="2" ram="4096" name="m1.medium" id="3" OS-FLV-EXT-DATA:ephemeral="0">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/3" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/3" rel="bookmark"/>
</flavor>
<flavor disk="80" vcpus="4" ram="8192" name="m1.large" id="4" OS-FLV-EXT-DATA:ephemeral="0">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/4" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/4" rel="bookmark"/>
</flavor>
<flavor disk="160" vcpus="8" ram="16384" name="m1.xlarge" id="5" OS-FLV-EXT-DATA:ephemeral="0">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/5" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/5" rel="bookmark"/>
</flavor>
</flavors>

View File

@ -0,0 +1,12 @@
{
"flavor": {
"OS-FLV-EXT-DATA:ephemeral": 30,
"disk": 10,
"id": "666",
"name": "flavortest",
"ram": 1024,
"rxtx_factor": 2,
"swap": 5,
"vcpus": 2
}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<flavor xmlns="http://docs.openstack.org/compute/api/v1.1"
xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1"
name="testflavor1"
ram="1024"
vcpus="2"
disk="10"
id="666"
swap="5"
rxtx_factor="2"
OS-FLV-EXT-DATA:ephemeral="30" />

View File

@ -0,0 +1,20 @@
{
"flavor": {
"OS-FLV-EXT-DATA:ephemeral": 30,
"disk": 10,
"id": "666",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/flavors/666",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/flavors/666",
"rel": "bookmark"
}
],
"name": "flavortest",
"ram": 1024,
"vcpus": 2
}
}

View File

@ -0,0 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="10" vcpus="2" ram="1024" name="testflavor1" id="666" OS-FLV-EXT-DATA:ephemeral="30">
<atom:link href="http://openstack.example.com/v2/openstack/flavors/666" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/flavors/666" rel="bookmark"/>
</flavor>

View File

@ -511,3 +511,41 @@ class ServerStartStopJsonTest(ServersSampleBase):
class ServerStartStopXmlTest(ServerStartStopJsonTest):
ctype = 'xml'
class FlavorsExtraDataJsonTest(ApiSampleTestBase):
extension_name = ('nova.api.openstack.compute.contrib.flavorextradata.'
'Flavorextradata')
def _get_flags(self):
f = super(FlavorsExtraDataJsonTest, self)._get_flags()
f['osapi_compute_extension'] = FLAGS.osapi_compute_extension[:]
# Flavorextradata extension also needs Flavormanage to be loaded.
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.flavormanage.Flavormanage')
return f
def test_flavors_extra_data_get(self):
response = self._do_get('flavors/1')
subs = self._get_regexes()
return self._verify_response('flavors-extra-data-get-resp', subs,
response)
def test_flavors_extra_data_list(self):
response = self._do_get('flavors/detail')
subs = self._get_regexes()
return self._verify_response('flavors-extra-data-list-resp', subs,
response)
def test_flavors_extra_data_post(self):
response = self._do_post('flavors',
'flavors-extra-data-post-req',
{})
self.assertEqual(response.status, 200)
subs = self._get_regexes()
return self._verify_response('flavors-extra-data-post-resp',
subs, response)
class FlavorsExtraDataXmlTest(FlavorsExtraDataJsonTest):
ctype = 'xml'