Adds infra for v3 API sample creation
Adds the required infrastructure for the v3 API sample creation. - v3 API samples and the test cases are in their own v3 directory - API samples from "core" are now put in their own (per plugin) directory rather than in the root directory - Testcases to create api samples are now placed in individual files rather than one giant one. I think it makes it clearer what testcases we do have and avoids merge conflict pain Adds API samples for basic servers interaction Fix for bug in servers.py where if no extension was loaded which extends create xml deserialization an exception would occur (fixed here because it causes the api sample tests ported to fail). Partially implements blueprint v3-api-unittests Change-Id: I653af49dcc499c18f14b6e1764711a9922354069
This commit is contained in:
parent
ab16b4a7b2
commit
6ee525dd7d
56
doc/v3/api_samples/servers/server-get-resp.json
Normal file
56
doc/v3/api_samples/servers/server-get-resp.json
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"server": {
|
||||||
|
"access_ip_v4": "",
|
||||||
|
"access_ip_v6": "",
|
||||||
|
"addresses": {
|
||||||
|
"private": [
|
||||||
|
{
|
||||||
|
"addr": "192.168.0.3",
|
||||||
|
"mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||||
|
"type": "fixed",
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"created": "2013-08-09T05:47:55Z",
|
||||||
|
"flavor": {
|
||||||
|
"id": "1",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://openstack.example.com/flavors/1",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"host_id": "9bc5b8424de645fd39f9edd242992c6be364eddefc936296fad0c582",
|
||||||
|
"id": "4fc3ceca-91ec-47e7-85ee-ce9834e8ddbb",
|
||||||
|
"image": {
|
||||||
|
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://openstack.example.com/v3/servers/4fc3ceca-91ec-47e7-85ee-ce9834e8ddbb",
|
||||||
|
"rel": "self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "http://openstack.example.com/servers/4fc3ceca-91ec-47e7-85ee-ce9834e8ddbb",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"My Server Name": "Apache1"
|
||||||
|
},
|
||||||
|
"name": "new-server-test",
|
||||||
|
"progress": 0,
|
||||||
|
"status": "ACTIVE",
|
||||||
|
"tenant_id": "openstack",
|
||||||
|
"updated": "2013-08-09T05:47:55Z",
|
||||||
|
"user_id": "fake"
|
||||||
|
}
|
||||||
|
}
|
19
doc/v3/api_samples/servers/server-get-resp.xml
Normal file
19
doc/v3/api_samples/servers/server-get-resp.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?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" status="ACTIVE" updated="2013-08-09T06:37:11Z" user_id="fake" name="new-server-test" created="2013-08-09T06:37:11Z" tenant_id="openstack" access_ip_v4="" progress="0" host_id="46dd159c89cba6409878c77977eed49bdf0a76be50885bf4a2010706" id="c20ab09b-1e56-47b4-9195-1ce8f9d40f2d" access_ip_v6="">
|
||||||
|
<image id="70a599e0-31e7-49b7-b260-868f441e862b">
|
||||||
|
<atom:link href="http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b" rel="bookmark"/>
|
||||||
|
</image>
|
||||||
|
<flavor id="1">
|
||||||
|
<atom:link href="http://openstack.example.com/flavors/1" rel="bookmark"/>
|
||||||
|
</flavor>
|
||||||
|
<metadata>
|
||||||
|
<meta key="My Server Name">Apache1</meta>
|
||||||
|
</metadata>
|
||||||
|
<addresses>
|
||||||
|
<network id="private">
|
||||||
|
<ip version="4" type="fixed" addr="192.168.0.3" mac_addr="aa:bb:cc:dd:ee:ff"/>
|
||||||
|
</network>
|
||||||
|
</addresses>
|
||||||
|
<atom:link href="http://openstack.example.com/v3/servers/c20ab09b-1e56-47b4-9195-1ce8f9d40f2d" rel="self"/>
|
||||||
|
<atom:link href="http://openstack.example.com/servers/c20ab09b-1e56-47b4-9195-1ce8f9d40f2d" rel="bookmark"/>
|
||||||
|
</server>
|
16
doc/v3/api_samples/servers/server-post-req.json
Normal file
16
doc/v3/api_samples/servers/server-post-req.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"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",
|
||||||
|
"metadata" : {
|
||||||
|
"My Server Name" : "Apache1"
|
||||||
|
},
|
||||||
|
"personality" : [
|
||||||
|
{
|
||||||
|
"path" : "/etc/banner.txt",
|
||||||
|
"contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
19
doc/v3/api_samples/servers/server-post-req.xml
Normal file
19
doc/v3/api_samples/servers/server-post-req.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<server xmlns="http://docs.openstack.org/compute/api/v1.1" 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">
|
||||||
|
<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>
|
16
doc/v3/api_samples/servers/server-post-resp.json
Normal file
16
doc/v3/api_samples/servers/server-post-resp.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"server": {
|
||||||
|
"admin_pass": "2pXrV3mMFkxH",
|
||||||
|
"id": "f85df75c-cf69-4723-b861-deff54b7cf70",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://openstack.example.com/v3/servers/f85df75c-cf69-4723-b861-deff54b7cf70",
|
||||||
|
"rel": "self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "http://openstack.example.com/servers/f85df75c-cf69-4723-b861-deff54b7cf70",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
6
doc/v3/api_samples/servers/server-post-resp.xml
Normal file
6
doc/v3/api_samples/servers/server-post-resp.xml
Normal 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="6d896124-8af0-4f2b-a033-e8ca22f83810" admin_pass="JqCn8mtbDnj3">
|
||||||
|
<metadata/>
|
||||||
|
<atom:link href="http://openstack.example.com/v3/servers/6d896124-8af0-4f2b-a033-e8ca22f83810" rel="self"/>
|
||||||
|
<atom:link href="http://openstack.example.com/servers/6d896124-8af0-4f2b-a033-e8ca22f83810" rel="bookmark"/>
|
||||||
|
</server>
|
58
doc/v3/api_samples/servers/servers-details-resp.json
Normal file
58
doc/v3/api_samples/servers/servers-details-resp.json
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"access_ip_v4": "",
|
||||||
|
"access_ip_v6": "",
|
||||||
|
"addresses": {
|
||||||
|
"private": [
|
||||||
|
{
|
||||||
|
"addr": "192.168.0.3",
|
||||||
|
"mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||||
|
"type": "fixed",
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"created": "2013-08-09T05:47:55Z",
|
||||||
|
"flavor": {
|
||||||
|
"id": "1",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://openstack.example.com/flavors/1",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"host_id": "c977254e8fbf1c2dd83f283dce24dfdba6f1388d05c9972342472a6f",
|
||||||
|
"id": "b327644d-d61d-49f9-86fd-d56f166e98a8",
|
||||||
|
"image": {
|
||||||
|
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://openstack.example.com/v3/servers/b327644d-d61d-49f9-86fd-d56f166e98a8",
|
||||||
|
"rel": "self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "http://openstack.example.com/servers/b327644d-d61d-49f9-86fd-d56f166e98a8",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"My Server Name": "Apache1"
|
||||||
|
},
|
||||||
|
"name": "new-server-test",
|
||||||
|
"progress": 0,
|
||||||
|
"status": "ACTIVE",
|
||||||
|
"tenant_id": "openstack",
|
||||||
|
"updated": "2013-08-09T05:47:55Z",
|
||||||
|
"user_id": "fake"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
21
doc/v3/api_samples/servers/servers-details-resp.xml
Normal file
21
doc/v3/api_samples/servers/servers-details-resp.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<servers xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1">
|
||||||
|
<server status="ACTIVE" updated="2013-08-09T06:37:11Z" user_id="fake" name="new-server-test" created="2013-08-09T06:37:11Z" tenant_id="openstack" access_ip_v4="" progress="0" host_id="5b894fe4cf74b3847753a3aaee4a543a813ef6a23558737c1812c81a" id="b83bb663-0744-4ec1-a982-d928472f0e5d" access_ip_v6="">
|
||||||
|
<image id="70a599e0-31e7-49b7-b260-868f441e862b">
|
||||||
|
<atom:link href="http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b" rel="bookmark"/>
|
||||||
|
</image>
|
||||||
|
<flavor id="1">
|
||||||
|
<atom:link href="http://openstack.example.com/flavors/1" rel="bookmark"/>
|
||||||
|
</flavor>
|
||||||
|
<metadata>
|
||||||
|
<meta key="My Server Name">Apache1</meta>
|
||||||
|
</metadata>
|
||||||
|
<addresses>
|
||||||
|
<network id="private">
|
||||||
|
<ip version="4" type="fixed" addr="192.168.0.3" mac_addr="aa:bb:cc:dd:ee:ff"/>
|
||||||
|
</network>
|
||||||
|
</addresses>
|
||||||
|
<atom:link href="http://openstack.example.com/v3/servers/b83bb663-0744-4ec1-a982-d928472f0e5d" rel="self"/>
|
||||||
|
<atom:link href="http://openstack.example.com/servers/b83bb663-0744-4ec1-a982-d928472f0e5d" rel="bookmark"/>
|
||||||
|
</server>
|
||||||
|
</servers>
|
18
doc/v3/api_samples/servers/servers-list-resp.json
Normal file
18
doc/v3/api_samples/servers/servers-list-resp.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"id": "204da46b-4fc9-4761-9bab-aa28add417e6",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://openstack.example.com/v3/servers/204da46b-4fc9-4761-9bab-aa28add417e6",
|
||||||
|
"rel": "self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "http://openstack.example.com/servers/204da46b-4fc9-4761-9bab-aa28add417e6",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "new-server-test"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
7
doc/v3/api_samples/servers/servers-list-resp.xml
Normal file
7
doc/v3/api_samples/servers/servers-list-resp.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<servers xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1">
|
||||||
|
<server name="new-server-test" id="6d896124-8af0-4f2b-a033-e8ca22f83810">
|
||||||
|
<atom:link href="http://openstack.example.com/v3/servers/6d896124-8af0-4f2b-a033-e8ca22f83810" rel="self"/>
|
||||||
|
<atom:link href="http://openstack.example.com/servers/6d896124-8af0-4f2b-a033-e8ca22f83810" rel="bookmark"/>
|
||||||
|
</server>
|
||||||
|
</servers>
|
@ -1446,6 +1446,7 @@ class ServersController(wsgi.Controller):
|
|||||||
handler.server_xml_extract_server_deserialize(server_node, server_dict)
|
handler.server_xml_extract_server_deserialize(server_node, server_dict)
|
||||||
|
|
||||||
def server_create_xml_deserialize(self, server_node, server):
|
def server_create_xml_deserialize(self, server_node, server):
|
||||||
|
if list(self.create_xml_deserialize_manager):
|
||||||
self.create_xml_deserialize_manager.map(
|
self.create_xml_deserialize_manager.map(
|
||||||
self._server_create_xml_deserialize_extension_point,
|
self._server_create_xml_deserialize_extension_point,
|
||||||
server_node, server)
|
server_node, server)
|
||||||
|
0
nova/tests/integrated/v3/__init__.py
Normal file
0
nova/tests/integrated/v3/__init__.py
Normal file
80
nova/tests/integrated/v3/api_sample_base.py
Normal file
80
nova/tests/integrated/v3/api_sample_base.py
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
from nova.api.openstack import API_V3_CORE_EXTENSIONS
|
||||||
|
from nova import test
|
||||||
|
from nova.tests import fake_network
|
||||||
|
from nova.tests import fake_utils
|
||||||
|
from nova.tests.integrated import api_samples_test_base
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
|
class ApiSampleTestBaseV3(api_samples_test_base.ApiSampleTestBase):
|
||||||
|
_api_version = 'v3'
|
||||||
|
sample_dir = None
|
||||||
|
extra_extensions_to_load = None
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
extends = []
|
||||||
|
self.flags(use_ipv6=False,
|
||||||
|
osapi_compute_link_prefix=self._get_host(),
|
||||||
|
osapi_glance_link_prefix=self._get_glance_host())
|
||||||
|
if not self.all_extensions:
|
||||||
|
# Set the whitelist to ensure only the extensions we are
|
||||||
|
# interested in are loaded so the api samples don't include
|
||||||
|
# data from extensions we are not interested in
|
||||||
|
whitelist = API_V3_CORE_EXTENSIONS.copy()
|
||||||
|
if self.extension_name:
|
||||||
|
whitelist.add(self.extension_name)
|
||||||
|
if self.extra_extensions_to_load:
|
||||||
|
whitelist.update(set(self.extra_extensions_to_load))
|
||||||
|
|
||||||
|
CONF.set_override('extensions_whitelist', whitelist,
|
||||||
|
'osapi_v3')
|
||||||
|
|
||||||
|
super(ApiSampleTestBaseV3, self).setUp()
|
||||||
|
self.useFixture(test.SampleNetworks())
|
||||||
|
fake_network.stub_compute_with_ips(self.stubs)
|
||||||
|
fake_utils.stub_out_utils_spawn_n(self.stubs)
|
||||||
|
self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_sample_path(cls, name, dirname, suffix=''):
|
||||||
|
parts = [dirname]
|
||||||
|
parts.append('api_samples')
|
||||||
|
if cls.all_extensions:
|
||||||
|
parts.append('all_extensions')
|
||||||
|
elif cls.sample_dir:
|
||||||
|
parts.append(cls.sample_dir)
|
||||||
|
elif cls.extension_name:
|
||||||
|
parts.append(cls.extension_name)
|
||||||
|
parts.append(name + "." + cls.ctype + suffix)
|
||||||
|
return os.path.join(*parts)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_sample(cls, name):
|
||||||
|
dirname = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
dirname = os.path.normpath(os.path.join(dirname, "../../../../doc/v3"))
|
||||||
|
return cls._get_sample_path(name, dirname)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_template(cls, name):
|
||||||
|
dirname = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
return cls._get_sample_path(name, dirname, suffix='.tpl')
|
@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"server": {
|
||||||
|
"access_ip_v4": "",
|
||||||
|
"access_ip_v6": "",
|
||||||
|
"addresses": {
|
||||||
|
"private": [
|
||||||
|
{
|
||||||
|
"addr": "%(ip)s",
|
||||||
|
"mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||||
|
"type": "fixed",
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"created": "%(timestamp)s",
|
||||||
|
"flavor": {
|
||||||
|
"id": "1",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "%(host)s/flavors/1",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"host_id": "%(hostid)s",
|
||||||
|
"id": "%(id)s",
|
||||||
|
"image": {
|
||||||
|
"id": "%(uuid)s",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "%(host)s/images/%(uuid)s",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "%(host)s/v3/servers/%(uuid)s",
|
||||||
|
"rel": "self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "%(host)s/servers/%(uuid)s",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"My Server Name": "Apache1"
|
||||||
|
},
|
||||||
|
"name": "new-server-test",
|
||||||
|
"progress": 0,
|
||||||
|
"status": "ACTIVE",
|
||||||
|
"tenant_id": "openstack",
|
||||||
|
"updated": "%(timestamp)s",
|
||||||
|
"user_id": "fake"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<?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" status="ACTIVE" updated="%(timestamp)s" user_id="fake" name="new-server-test" created="%(timestamp)s" tenant_id="openstack" access_ip_v4="" progress="0" host_id="%(hostid)s" id="%(id)s" access_ip_v6="">
|
||||||
|
<image id="%(uuid)s">
|
||||||
|
<atom:link href="%(host)s/images/%(uuid)s" rel="bookmark"/>
|
||||||
|
</image>
|
||||||
|
<flavor id="1">
|
||||||
|
<atom:link href="%(host)s/flavors/1" rel="bookmark"/>
|
||||||
|
</flavor>
|
||||||
|
<metadata>
|
||||||
|
<meta key="My Server Name">Apache1</meta>
|
||||||
|
</metadata>
|
||||||
|
<addresses>
|
||||||
|
<network id="private">
|
||||||
|
<ip version="4" type="fixed" addr="%(ip)s" mac_addr="aa:bb:cc:dd:ee:ff"/>
|
||||||
|
</network>
|
||||||
|
</addresses>
|
||||||
|
<atom:link href="%(host)s/v3/servers/%(uuid)s" rel="self"/>
|
||||||
|
<atom:link href="%(host)s/servers/%(uuid)s" rel="bookmark"/>
|
||||||
|
</server>
|
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"server" : {
|
||||||
|
"name" : "new-server-test",
|
||||||
|
"image_ref" : "%(host)s/openstack/images/%(image_id)s",
|
||||||
|
"flavor_ref" : "%(host)s/openstack/flavors/1",
|
||||||
|
"metadata" : {
|
||||||
|
"My Server Name" : "Apache1"
|
||||||
|
},
|
||||||
|
"personality" : [
|
||||||
|
{
|
||||||
|
"path" : "/etc/banner.txt",
|
||||||
|
"contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<server xmlns="http://docs.openstack.org/compute/api/v1.1" image_ref="%(host)s/openstack/images/%(image_id)s" flavor_ref="%(host)s/openstack/flavors/1" name="new-server-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>
|
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"server": {
|
||||||
|
"admin_pass": "%(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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -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_pass="%(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>
|
@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"access_ip_v4": "",
|
||||||
|
"access_ip_v6": "",
|
||||||
|
"addresses": {
|
||||||
|
"private": [
|
||||||
|
{
|
||||||
|
"addr": "%(ip)s",
|
||||||
|
"mac_addr": "aa:bb:cc:dd:ee:ff",
|
||||||
|
"type": "fixed",
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"created": "%(timestamp)s",
|
||||||
|
"flavor": {
|
||||||
|
"id": "1",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "%(host)s/flavors/1",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"host_id": "%(hostid)s",
|
||||||
|
"id": "%(id)s",
|
||||||
|
"image": {
|
||||||
|
"id": "%(uuid)s",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "%(host)s/images/%(uuid)s",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "%(host)s/v3/servers/%(uuid)s",
|
||||||
|
"rel": "self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "%(host)s/servers/%(id)s",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"My Server Name": "Apache1"
|
||||||
|
},
|
||||||
|
"name": "new-server-test",
|
||||||
|
"progress": 0,
|
||||||
|
"status": "ACTIVE",
|
||||||
|
"tenant_id": "openstack",
|
||||||
|
"updated": "%(timestamp)s",
|
||||||
|
"user_id": "fake"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<servers xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1">
|
||||||
|
<server status="ACTIVE" updated="%(timestamp)s" host_id="%(hostid)s" name="new-server-test" created="%(timestamp)s" user_id="fake" tenant_id="openstack" access_ip_v4="" access_ip_v6="" progress="0" id="%(id)s">
|
||||||
|
<image id="%(uuid)s">
|
||||||
|
<atom:link href="%(host)s/images/%(uuid)s" rel="bookmark"/>
|
||||||
|
</image>
|
||||||
|
<flavor id="1">
|
||||||
|
<atom:link href="%(host)s/flavors/1" rel="bookmark"/>
|
||||||
|
</flavor>
|
||||||
|
<metadata>
|
||||||
|
<meta key="My Server Name">Apache1</meta>
|
||||||
|
</metadata>
|
||||||
|
<addresses>
|
||||||
|
<network id="private">
|
||||||
|
<ip version="4" type="fixed" addr="%(ip)s" mac_addr="aa:bb:cc:dd:ee:ff"/>
|
||||||
|
</network>
|
||||||
|
</addresses>
|
||||||
|
<atom:link href="%(host)s/v3/servers/%(id)s" rel="self"/>
|
||||||
|
<atom:link href="%(host)s/servers/%(id)s" rel="bookmark"/>
|
||||||
|
</server>
|
||||||
|
</servers>
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"id": "%(id)s",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "%(host)s/v3/servers/%(id)s",
|
||||||
|
"rel": "self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "%(host)s/servers/%(id)s",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "new-server-test"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<servers xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1">
|
||||||
|
<server name="new-server-test" id="%(id)s">
|
||||||
|
<atom:link href="%(host)s/v3/servers/%(id)s" rel="self"/>
|
||||||
|
<atom:link href="%(host)s/servers/%(id)s" rel="bookmark"/>
|
||||||
|
</server>
|
||||||
|
</servers>
|
67
nova/tests/integrated/v3/test_servers.py
Normal file
67
nova/tests/integrated/v3/test_servers.py
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# 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.image import fake
|
||||||
|
from nova.tests.integrated.v3 import api_sample_base
|
||||||
|
|
||||||
|
|
||||||
|
class ServersSampleBase(api_sample_base.ApiSampleTestBaseV3):
|
||||||
|
def _post_server(self):
|
||||||
|
subs = {
|
||||||
|
'image_id': fake.get_valid_image_id(),
|
||||||
|
'host': self._get_host(),
|
||||||
|
}
|
||||||
|
response = self._do_post('servers', 'server-post-req', subs)
|
||||||
|
subs = self._get_regexes()
|
||||||
|
return self._verify_response('server-post-resp', subs, response, 202)
|
||||||
|
|
||||||
|
|
||||||
|
class ServersSampleJsonTest(ServersSampleBase):
|
||||||
|
sample_dir = 'servers'
|
||||||
|
|
||||||
|
def test_servers_post(self):
|
||||||
|
return self._post_server()
|
||||||
|
|
||||||
|
def test_servers_get(self):
|
||||||
|
uuid = self.test_servers_post()
|
||||||
|
response = self._do_get('servers/%s' % uuid)
|
||||||
|
subs = self._get_regexes()
|
||||||
|
subs['hostid'] = '[a-f0-9]+'
|
||||||
|
subs['id'] = uuid
|
||||||
|
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
||||||
|
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
|
||||||
|
self._verify_response('server-get-resp', subs, response, 200)
|
||||||
|
|
||||||
|
def test_servers_list(self):
|
||||||
|
uuid = self._post_server()
|
||||||
|
response = self._do_get('servers')
|
||||||
|
subs = self._get_regexes()
|
||||||
|
subs['id'] = uuid
|
||||||
|
self._verify_response('servers-list-resp', subs, response, 200)
|
||||||
|
|
||||||
|
def test_servers_details(self):
|
||||||
|
uuid = self._post_server()
|
||||||
|
response = self._do_get('servers/detail')
|
||||||
|
subs = self._get_regexes()
|
||||||
|
subs['hostid'] = '[a-f0-9]+'
|
||||||
|
subs['id'] = uuid
|
||||||
|
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
||||||
|
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
|
||||||
|
self._verify_response('servers-details-resp', subs, response, 200)
|
||||||
|
|
||||||
|
|
||||||
|
class ServersSampleXmlTest(ServersSampleJsonTest):
|
||||||
|
ctype = 'xml'
|
Loading…
Reference in New Issue
Block a user