Adds V3 API samples for agents, aggregates and certificates

Adds v3 API samples for the agents, aggregates, and certificates
extensions. Bundling them together to save on review load

Partially implements blueprint v3-api-unittests
Partially implements blueprint v3-api-specification

Change-Id: Iee26fe25b5fd369f2a1f5690ddc095a90526a549
This commit is contained in:
Chris Yeoh 2013-08-12 16:56:26 +09:30
parent a877656e62
commit cc8392f874
49 changed files with 593 additions and 0 deletions

View File

@ -0,0 +1,6 @@
{
"add_host":
{
"host": "21549b2f665945baaa7101926a00143c"
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<add_host host="bdb794e5cdd3447c9132ddd8e5cc3d0b" />

View File

@ -0,0 +1,9 @@
{
"set_metadata":
{
"metadata":
{
"key": "value"
}
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<set_metadata>
<metadata>
<key>value</key>
</metadata>
</set_metadata>

View File

@ -0,0 +1,7 @@
{
"aggregate":
{
"name": "name",
"availability_zone": "nova"
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<aggregate name="name" availability_zone="nova" />

View File

@ -0,0 +1,11 @@
{
"aggregate": {
"availability_zone": "nova",
"created_at": "2013-08-18T12:17:55.751757",
"deleted": 0,
"deleted_at": null,
"id": 1,
"name": "name",
"updated_at": null
}
}

View File

@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<aggregate>
<name>name</name>
<availability_zone>nova</availability_zone>
<deleted>False</deleted>
<created_at>2013-08-18 12:17:56.757058</created_at>
<updated_at>None</updated_at>
<deleted_at>None</deleted_at>
<id>1</id>
</aggregate>

View File

@ -0,0 +1,6 @@
{
"remove_host":
{
"host": "bf1454b3d71145d49fca2101c56c728d"
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<remove_host host="bdb794e5cdd3447c9132ddd8e5cc3d0b" />

View File

@ -0,0 +1,7 @@
{
"aggregate":
{
"name": "newname",
"availability_zone": "nova2"
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<aggregate name="newname" availability_zone="nova2" />

View File

@ -0,0 +1,15 @@
{
"aggregate": {
"availability_zone": "nova2",
"created_at": "2013-08-18T12:17:56.259751",
"deleted": 0,
"deleted_at": null,
"hosts": [],
"id": 1,
"metadata": {
"availability_zone": "nova2"
},
"name": "newname",
"updated_at": "2013-08-18T12:17:56.286720"
}
}

View File

@ -0,0 +1,14 @@
<?xml version='1.0' encoding='UTF-8'?>
<aggregate>
<name>newname</name>
<availability_zone>nova2</availability_zone>
<deleted>False</deleted>
<created_at>2013-08-18 12:17:57.655769</created_at>
<updated_at>2013-08-18 12:17:57.683956</updated_at>
<hosts/>
<deleted_at>None</deleted_at>
<id>1</id>
<metadata>
<availability_zone>nova2</availability_zone>
</metadata>
</aggregate>

View File

@ -0,0 +1,17 @@
{
"aggregate": {
"availability_zone": "nova",
"created_at": "2013-08-18T12:17:56.297823",
"deleted": 0,
"deleted_at": null,
"hosts": [
"21549b2f665945baaa7101926a00143c"
],
"id": 1,
"metadata": {
"availability_zone": "nova"
},
"name": "name",
"updated_at": null
}
}

View File

@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<aggregate>
<name>name</name>
<availability_zone>nova</availability_zone>
<deleted>False</deleted>
<created_at>2013-08-18 12:17:57.255783</created_at>
<updated_at>None</updated_at>
<hosts>
<host>bdb794e5cdd3447c9132ddd8e5cc3d0b</host>
</hosts>
<deleted_at>None</deleted_at>
<id>1</id>
<metadata>
<availability_zone>nova</availability_zone>
</metadata>
</aggregate>

View File

@ -0,0 +1,15 @@
{
"aggregate": {
"availability_zone": "nova",
"created_at": "2013-08-18T12:17:56.380226",
"deleted": 0,
"deleted_at": null,
"hosts": [],
"id": 1,
"metadata": {
"availability_zone": "nova"
},
"name": "name",
"updated_at": null
}
}

View File

@ -0,0 +1,14 @@
<?xml version='1.0' encoding='UTF-8'?>
<aggregate>
<name>name</name>
<availability_zone>nova</availability_zone>
<deleted>False</deleted>
<created_at>2013-08-18 12:17:56.757058</created_at>
<updated_at>None</updated_at>
<hosts/>
<deleted_at>None</deleted_at>
<id>1</id>
<metadata>
<availability_zone>nova</availability_zone>
</metadata>
</aggregate>

View File

@ -0,0 +1,17 @@
{
"aggregates": [
{
"availability_zone": "nova",
"created_at": "2013-08-18T12:17:56.856455",
"deleted": 0,
"deleted_at": null,
"hosts": [],
"id": 1,
"metadata": {
"availability_zone": "nova"
},
"name": "name",
"updated_at": null
}
]
}

View File

@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<aggregates>
<aggregate>
<name>name</name>
<availability_zone>nova</availability_zone>
<deleted>False</deleted>
<created_at>2013-08-18 12:17:57.241412</created_at>
<updated_at>None</updated_at>
<hosts/>
<deleted_at>None</deleted_at>
<id>1</id>
<metadata>
<availability_zone>nova</availability_zone>
</metadata>
</aggregate>
</aggregates>

View File

@ -0,0 +1,16 @@
{
"aggregate": {
"availability_zone": "nova",
"created_at": "2013-08-18T12:17:55.959571",
"deleted": 0,
"deleted_at": null,
"hosts": [],
"id": 1,
"metadata": {
"availability_zone": "nova",
"key": "value"
},
"name": "name",
"updated_at": null
}
}

View File

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='UTF-8'?>
<aggregate>
<name>name</name>
<availability_zone>nova</availability_zone>
<deleted>False</deleted>
<created_at>2013-08-18 12:17:56.891817</created_at>
<updated_at>None</updated_at>
<hosts/>
<deleted_at>None</deleted_at>
<id>1</id>
<metadata>
<key>value</key>
<availability_zone>nova</availability_zone>
</metadata>
</aggregate>

View File

@ -0,0 +1,15 @@
{
"aggregate": {
"availability_zone": "nova",
"created_at": "2013-08-18T12:17:56.990581",
"deleted": 0,
"deleted_at": null,
"hosts": [],
"id": 1,
"metadata": {
"availability_zone": "nova"
},
"name": "name",
"updated_at": null
}
}

View File

@ -0,0 +1,14 @@
<?xml version='1.0' encoding='UTF-8'?>
<aggregate>
<name>name</name>
<availability_zone>nova</availability_zone>
<deleted>False</deleted>
<created_at>2013-08-18 12:17:57.255783</created_at>
<updated_at>None</updated_at>
<hosts/>
<deleted_at>None</deleted_at>
<id>1</id>
<metadata>
<availability_zone>nova</availability_zone>
</metadata>
</aggregate>

View File

@ -0,0 +1,6 @@
{
"add_host":
{
"host": "%(host_name)s"
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<add_host host="%(host_name)s" />

View File

@ -0,0 +1,9 @@
{
"set_metadata":
{
"metadata":
{
"key": "value"
}
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<set_metadata>
<metadata>
<key>value</key>
</metadata>
</set_metadata>

View File

@ -0,0 +1,7 @@
{
"aggregate":
{
"name": "name",
"availability_zone": "nova"
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<aggregate name="name" availability_zone="nova" />

View File

@ -0,0 +1,11 @@
{
"aggregate": {
"availability_zone": "nova",
"created_at": "%(timestamp)s",
"deleted": 0,
"deleted_at": null,
"id": %(aggregate_id)s,
"name": "name",
"updated_at": null
}
}

View File

@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<aggregate>
<name>name</name>
<availability_zone>nova</availability_zone>
<deleted>False</deleted>
<created_at>%(timestamp)s</created_at>
<updated_at>None</updated_at>
<deleted_at>None</deleted_at>
<id>%(aggregate_id)s</id>
</aggregate>

View File

@ -0,0 +1,6 @@
{
"remove_host":
{
"host": "%(host_name)s"
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<remove_host host="%(host_name)s" />

View File

@ -0,0 +1,7 @@
{
"aggregate":
{
"name": "newname",
"availability_zone": "nova2"
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<aggregate name="newname" availability_zone="nova2" />

View File

@ -0,0 +1,15 @@
{
"aggregate": {
"availability_zone": "nova2",
"created_at": "%(timestamp)s",
"deleted": 0,
"deleted_at": null,
"hosts": [],
"id": 1,
"metadata": {
"availability_zone": "nova2"
},
"name": "newname",
"updated_at": "%(timestamp)s"
}
}

View File

@ -0,0 +1,14 @@
<?xml version='1.0' encoding='UTF-8'?>
<aggregate>
<name>newname</name>
<availability_zone>nova2</availability_zone>
<deleted>False</deleted>
<created_at>%(timestamp)s</created_at>
<updated_at>%(timestamp)s</updated_at>
<hosts/>
<deleted_at>None</deleted_at>
<id>1</id>
<metadata>
<availability_zone>nova2</availability_zone>
</metadata>
</aggregate>

View File

@ -0,0 +1,17 @@
{
"aggregate": {
"availability_zone": "nova",
"created_at": "%(timestamp)s",
"deleted": 0,
"deleted_at": null,
"hosts": [
"%(compute_host)s"
],
"id": 1,
"metadata": {
"availability_zone": "nova"
},
"name": "name",
"updated_at": null
}
}

View File

@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<aggregate>
<name>name</name>
<availability_zone>nova</availability_zone>
<deleted>False</deleted>
<created_at>%(timestamp)s</created_at>
<updated_at>None</updated_at>
<hosts>
<host>%(compute_host)s</host>
</hosts>
<deleted_at>None</deleted_at>
<id>1</id>
<metadata>
<availability_zone>nova</availability_zone>
</metadata>
</aggregate>

View File

@ -0,0 +1,15 @@
{
"aggregate": {
"availability_zone": "nova",
"created_at": "%(timestamp)s",
"deleted": 0,
"deleted_at": null,
"hosts": [],
"id": 1,
"metadata": {
"availability_zone": "nova"
},
"name": "name",
"updated_at": null
}
}

View File

@ -0,0 +1,14 @@
<?xml version='1.0' encoding='UTF-8'?>
<aggregate>
<name>name</name>
<availability_zone>nova</availability_zone>
<deleted>False</deleted>
<created_at>%(timestamp)s</created_at>
<updated_at>None</updated_at>
<hosts/>
<deleted_at>None</deleted_at>
<id>1</id>
<metadata>
<availability_zone>nova</availability_zone>
</metadata>
</aggregate>

View File

@ -0,0 +1,17 @@
{
"aggregates": [
{
"availability_zone": "nova",
"created_at": "%(timestamp)s",
"deleted": 0,
"deleted_at": null,
"hosts": [],
"id": 1,
"metadata": {
"availability_zone": "nova"
},
"name": "name",
"updated_at": null
}
]
}

View File

@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<aggregates>
<aggregate>
<name>name</name>
<availability_zone>nova</availability_zone>
<deleted>False</deleted>
<created_at>%(timestamp)s</created_at>
<updated_at>None</updated_at>
<hosts/>
<deleted_at>None</deleted_at>
<id>1</id>
<metadata>
<availability_zone>nova</availability_zone>
</metadata>
</aggregate>
</aggregates>

View File

@ -0,0 +1,16 @@
{
"aggregate": {
"availability_zone": "nova",
"created_at": "%(timestamp)s",
"deleted": 0,
"deleted_at": null,
"hosts": [],
"id": 1,
"metadata": {
"availability_zone": "nova",
"key": "value"
},
"name": "name",
"updated_at": null
}
}

View File

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='UTF-8'?>
<aggregate>
<name>name</name>
<availability_zone>nova</availability_zone>
<deleted>False</deleted>
<created_at>%(timestamp)s</created_at>
<updated_at>None</updated_at>
<hosts/>
<deleted_at>None</deleted_at>
<id>1</id>
<metadata>
<key>value</key>
<availability_zone>nova</availability_zone>
</metadata>
</aggregate>

View File

@ -0,0 +1,15 @@
{
"aggregate": {
"availability_zone": "nova",
"created_at": "%(timestamp)s",
"deleted": 0,
"deleted_at": null,
"hosts": [],
"id": 1,
"metadata": {
"availability_zone": "nova"
},
"name": "name",
"updated_at": null
}
}

View File

@ -0,0 +1,14 @@
<?xml version='1.0' encoding='UTF-8'?>
<aggregate>
<name>name</name>
<availability_zone>nova</availability_zone>
<deleted>False</deleted>
<created_at>%(timestamp)s</created_at>
<updated_at>None</updated_at>
<hosts/>
<deleted_at>None</deleted_at>
<id>1</id>
<metadata>
<availability_zone>nova</availability_zone>
</metadata>
</aggregate>

View File

@ -0,0 +1,85 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Nebula, Inc.
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from nova.tests.integrated.v3 import api_sample_base
class AggregatesSampleJsonTest(api_sample_base.ApiSampleTestBaseV3):
extension_name = "os-aggregates"
def test_aggregate_create(self):
subs = {
"aggregate_id": '(?P<id>\d+)'
}
response = self._do_post('os-aggregates', 'aggregate-post-req', subs)
subs.update(self._get_regexes())
return self._verify_response('aggregate-post-resp',
subs, response, 201)
def test_list_aggregates(self):
self.test_aggregate_create()
response = self._do_get('os-aggregates')
subs = self._get_regexes()
self._verify_response('aggregates-list-get-resp', subs, response, 200)
def test_aggregate_get(self):
agg_id = self.test_aggregate_create()
response = self._do_get('os-aggregates/%s' % agg_id)
subs = self._get_regexes()
self._verify_response('aggregates-get-resp', subs, response, 200)
def test_add_metadata(self):
agg_id = self.test_aggregate_create()
response = self._do_post('os-aggregates/%s/action' % agg_id,
'aggregate-metadata-post-req',
{'action': 'set_metadata'})
subs = self._get_regexes()
self._verify_response('aggregates-metadata-post-resp', subs,
response, 200)
def test_add_host(self):
aggregate_id = self.test_aggregate_create()
subs = {
"host_name": self.compute.host,
}
response = self._do_post('os-aggregates/%s/action' % aggregate_id,
'aggregate-add-host-post-req', subs)
subs.update(self._get_regexes())
self._verify_response('aggregates-add-host-post-resp', subs,
response, 200)
def test_remove_host(self):
self.test_add_host()
subs = {
"host_name": self.compute.host,
}
response = self._do_post('os-aggregates/1/action',
'aggregate-remove-host-post-req', subs)
subs.update(self._get_regexes())
self._verify_response('aggregates-remove-host-post-resp',
subs, response, 200)
def test_update_aggregate(self):
aggregate_id = self.test_aggregate_create()
response = self._do_put('os-aggregates/%s' % aggregate_id,
'aggregate-update-post-req', {})
subs = self._get_regexes()
self._verify_response('aggregate-update-post-resp',
subs, response, 200)
class AggregatesSampleXmlTest(AggregatesSampleJsonTest):
ctype = 'xml'