Add v3 api samples for availability_zone

This patch adds api sample tests and api samples for availability_zone.
Because the detail's response use host name as the key of dict and samples
tests didn't support replacing key with variable, so startup nova's service
with specific hostname instead of uuid.

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

Change-Id: I9090a73a8293f26d63744a10d7ffbfc887e37e7c
This commit is contained in:
He Jie Xu 2013-10-22 15:38:37 +08:00
parent 79d0ce6171
commit 4d293357b7
18 changed files with 479 additions and 8 deletions

View File

@ -0,0 +1,69 @@
{
"availability_zone_info": [
{
"hosts": {
"cells": {
"nova-cells": {
"active": true,
"available": true,
"updated_at": null
}
},
"cert": {
"nova-cert": {
"active": true,
"available": true,
"updated_at": null
}
},
"conductor": {
"nova-conductor": {
"active": true,
"available": true,
"updated_at": null
}
},
"consoleauth": {
"nova-consoleauth": {
"active": true,
"available": true,
"updated_at": null
}
},
"network": {
"nova-network": {
"active": true,
"available": true,
"updated_at": null
}
},
"scheduler": {
"nova-scheduler": {
"active": true,
"available": true,
"updated_at": null
}
}
},
"zone_name": "internal",
"zone_state": {
"available": true
}
},
{
"hosts": {
"compute": {
"nova-compute": {
"active": true,
"available": true,
"updated_at": null
}
}
},
"zone_name": "nova",
"zone_state": {
"available": true
}
}
]
}

View File

@ -0,0 +1,64 @@
<?xml version='1.0' encoding='UTF-8'?>
<availability_zones xmlns:os-availability-zone="http://docs.openstack.org/compute/ext/availabilityzone/api/v3">
<availability_zone name="internal">
<zone_state available="True"/>
<hosts>
<host name="network">
<services>
<service name="nova-network">
<service_state available="True" active="True" updated_at="None"/>
</service>
</services>
</host>
<host name="conductor">
<services>
<service name="nova-conductor">
<service_state available="True" active="True" updated_at="None"/>
</service>
</services>
</host>
<host name="cells">
<services>
<service name="nova-cells">
<service_state available="True" active="True" updated_at="None"/>
</service>
</services>
</host>
<host name="cert">
<services>
<service name="nova-cert">
<service_state available="True" active="True" updated_at="None"/>
</service>
</services>
</host>
<host name="scheduler">
<services>
<service name="nova-scheduler">
<service_state available="True" active="True" updated_at="None"/>
</service>
</services>
</host>
<host name="consoleauth">
<services>
<service name="nova-consoleauth">
<service_state available="True" active="True" updated_at="None"/>
</service>
</services>
</host>
</hosts>
<metadata/>
</availability_zone>
<availability_zone name="nova">
<zone_state available="True"/>
<hosts>
<host name="compute">
<services>
<service name="nova-compute">
<service_state available="True" active="True" updated_at="None"/>
</service>
</services>
</host>
</hosts>
<metadata/>
</availability_zone>
</availability_zones>

View File

@ -0,0 +1,11 @@
{
"availability_zone_info": [
{
"hosts": null,
"zone_name": "nova",
"zone_state": {
"available": true
}
}
]
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<availability_zones xmlns:os-availability-zone="http://docs.openstack.org/compute/ext/availabilityzone/api/v3">
<availability_zone name="nova">
<zone_state available="True"/>
<metadata/>
</availability_zone>
</availability_zones>

View File

@ -0,0 +1,17 @@
{
"server" : {
"name" : "new-server-test",
"image_ref" : "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
"flavor_ref" : "http://openstack.example.com/openstack/flavors/1",
"os-availability-zone:availability_zone" : "test"
"metadata" : {
"My Server Name" : "Apache1"
},
"personality" : [
{
"path" : "/etc/banner.txt",
"contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
}
]
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<server xmlns="http://docs.openstack.org/compute/api/v1.1" xmlns:os-availability-zone="http://docs.openstack.org/compute/ext/availabilityzone/api/v3" image_ref="http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b" flavor_ref="http://openstack.example.com/openstack/flavors/1" name="new-server-test" os-availability-zone:availability_zone="test">
<metadata>
<meta key="My Server Name">Apache1</meta>
</metadata>
<personality>
<file path="/etc/banner.txt">
ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp
dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k
IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs
c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g
QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo
ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv
dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy
c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6
b25zLiINCg0KLVJpY2hhcmQgQmFjaA==
</file>
</personality>
</server>

View File

@ -0,0 +1,16 @@
{
"server": {
"admin_password": "a2apKsfp7Rom",
"id": "e88c3898-e971-42e5-8325-b7ff921efb15",
"links": [
{
"href": "http://openstack.example.com/v3/servers/e88c3898-e971-42e5-8325-b7ff921efb15",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/e88c3898-e971-42e5-8325-b7ff921efb15",
"rel": "bookmark"
}
]
}
}

View File

@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" id="eb1657bd-f530-4077-b885-c54701898cc9" admin_password="sxQ5ZbjnTjzg">
<metadata/>
<atom:link href="http://openstack.example.com/v3/servers/eb1657bd-f530-4077-b885-c54701898cc9" rel="self"/>
<atom:link href="http://openstack.example.com/servers/eb1657bd-f530-4077-b885-c54701898cc9" rel="bookmark"/>
</server>

View File

@ -78,10 +78,16 @@ class _IntegratedTestBase(test.TestCase):
nova.tests.image.fake.stub_out_image_service(self.stubs)
self.flags(scheduler_driver='nova.scheduler.'
'chance.ChanceScheduler')
self._setup_services()
self._start_api_service()
# set up services
self.api = self._get_test_client()
self.useFixture(cast_as_call.CastAsCall(self.stubs))
def _setup_services(self):
self.conductor = self.start_service('conductor',
manager=CONF.conductor.manager)
manager=CONF.conductor.manager)
self.compute = self.start_service('compute')
self.cert = self.start_service('cert')
self.consoleauth = self.start_service('consoleauth')
@ -89,12 +95,6 @@ class _IntegratedTestBase(test.TestCase):
self.scheduler = self.start_service('scheduler')
self.cells = self.start_service('cells', manager=CONF.cells.manager)
self._start_api_service()
self.api = self._get_test_client()
self.useFixture(cast_as_call.CastAsCall(self.stubs))
def tearDown(self):
self.osapi.stop()
nova.tests.image.fake.FakeImageService_reset()

View File

@ -0,0 +1,69 @@
{
"availability_zone_info": [
{
"hosts": {
"consoleauth": {
"nova-consoleauth": {
"active": true,
"available": true,
"updated_at": null
}
},
"cert": {
"nova-cert": {
"active": true,
"available": true,
"updated_at": null
}
},
"conductor": {
"nova-conductor": {
"active": true,
"available": true,
"updated_at": null
}
},
"cells": {
"nova-cells": {
"active": true,
"available": true,
"updated_at": null
}
},
"scheduler": {
"nova-scheduler": {
"active": true,
"available": true,
"updated_at": null
}
},
"network": {
"nova-network": {
"active": true,
"available": true,
"updated_at": null
}
}
},
"zone_name": "internal",
"zone_state": {
"available": true
}
},
{
"hosts": {
"compute": {
"nova-compute": {
"active": true,
"available": true,
"updated_at": null
}
}
},
"zone_name": "nova",
"zone_state": {
"available": true
}
}
]
}

View File

@ -0,0 +1,64 @@
<?xml version='1.0' encoding='UTF-8'?>
<availability_zones xmlns:os-availability-zone="http://docs.openstack.org/compute/ext/availabilityzone/api/v3">
<availability_zone name="internal">
<zone_state available="True"/>
<hosts>
<host name="network">
<services>
<service name="nova-network">
<service_state available="True" active="True" updated_at="None"/>
</service>
</services>
</host>
<host name="consoleauth">
<services>
<service name="nova-consoleauth">
<service_state available="True" active="True" updated_at="None"/>
</service>
</services>
</host>
<host name="scheduler">
<services>
<service name="nova-scheduler">
<service_state available="True" active="True" updated_at="None"/>
</service>
</services>
</host>
<host name="cells">
<services>
<service name="nova-cells">
<service_state available="True" active="True" updated_at="None"/>
</service>
</services>
</host>
<host name="cert">
<services>
<service name="nova-cert">
<service_state available="True" active="True" updated_at="None"/>
</service>
</services>
</host>
<host name="conductor">
<services>
<service name="nova-conductor">
<service_state available="True" active="True" updated_at="None"/>
</service>
</services>
</host>
</hosts>
<metadata/>
</availability_zone>
<availability_zone name="nova">
<zone_state available="True"/>
<hosts>
<host name="compute">
<services>
<service name="nova-compute">
<service_state available="True" active="True" updated_at="None"/>
</service>
</services>
</host>
</hosts>
<metadata/>
</availability_zone>
</availability_zones>

View File

@ -0,0 +1,11 @@
{
"availability_zone_info": [
{
"hosts": null,
"zone_name": "nova",
"zone_state": {
"available": true
}
}
]
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<availability_zones xmlns:os-availability-zone="http://docs.openstack.org/compute/ext/availabilityzone/api/v3">
<availability_zone name="nova">
<zone_state available="True"/>
<metadata/>
</availability_zone>
</availability_zones>

View File

@ -0,0 +1,17 @@
{
"server" : {
"name" : "new-server-test",
"image_ref" : "%(host)s/openstack/images/%(image_id)s",
"flavor_ref" : "%(host)s/openstack/flavors/1",
"os-availability-zone:availability_zone": "nova",
"metadata" : {
"My Server Name" : "Apache1"
},
"personality" : [
{
"path" : "/etc/banner.txt",
"contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
}
]
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<server xmlns="http://docs.openstack.org/compute/api/v1.1" xmlns:os-availability-zone="http://docs.openstack.org/compute/ext/availabilityzone/api/v3" image_ref="%(host)s/openstack/images/%(image_id)s" flavor_ref="%(host)s/openstack/flavors/1" name="new-server-test" os-availability-zone:availability_zone="nova">
<metadata>
<meta key="My Server Name">Apache1</meta>
</metadata>
<personality>
<file path="/etc/banner.txt">
ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp
dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k
IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs
c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g
QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo
ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv
dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy
c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6
b25zLiINCg0KLVJpY2hhcmQgQmFjaA==
</file>
</personality>
</server>

View File

@ -0,0 +1,16 @@
{
"server": {
"admin_password": "%(password)s",
"id": "%(id)s",
"links": [
{
"href": "http://openstack.example.com/v3/servers/%(uuid)s",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/%(uuid)s",
"rel": "bookmark"
}
]
}
}

View File

@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" id="%(id)s" admin_password="%(password)s">
<metadata/>
<atom:link href="%(host)s/v3/servers/%(uuid)s" rel="self"/>
<atom:link href="%(host)s/servers/%(uuid)s" rel="bookmark"/>
</server>

View File

@ -0,0 +1,53 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# 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 oslo.config import cfg
from nova.tests.integrated.v3 import test_servers
CONF = cfg.CONF
CONF.import_opt('manager', 'nova.cells.opts', group='cells')
class AvailabilityZoneJsonTest(test_servers.ServersSampleBase):
extension_name = "os-availability-zone"
def _setup_services(self):
self.conductor = self.start_service('conductor',
host='conductor', manager=CONF.conductor.manager)
self.compute = self.start_service('compute', host='compute')
self.cert = self.start_service('cert', host='cert')
self.consoleauth = self.start_service('consoleauth',
host='consoleauth')
self.network = self.start_service('network', host='network')
self.scheduler = self.start_service('scheduler', host='scheduler')
self.cells = self.start_service('cells', host='cells',
manager=CONF.cells.manager)
def test_availability_zone_list(self):
response = self._do_get('os-availability-zone')
self._verify_response('availability-zone-list-resp', {}, response, 200)
def test_availability_zone_detail(self):
response = self._do_get('os-availability-zone/detail')
self._verify_response('availability-zone-detail-resp', {}, response,
200)
def test_availability_zone_post(self):
self._post_server()
class AvailabilityZoneXmlTest(AvailabilityZoneJsonTest):
ctype = "xml"