Add V3 API samples for consoles

Partially implements blueprint v3-api-unittests

Change-Id: I84ee6ca7d7c7113e97b7eadde6eeac104bffb6ff
This commit is contained in:
He Jie Xu
2013-09-10 17:56:11 +08:00
committed by Gerrit Code Review
parent b35d0f95be
commit 80374ffbbc
21 changed files with 226 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
{
"console": {
"console_type": "fake",
"host": "fake",
"id": 1,
"instance_name": "instance-00000001",
"password": "C4jBpJ6x",
"port": 5999
}
}

View File

@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<console>
<console_type>fake</console_type>
<port>5999</port>
<instance_name>instance-00000001</instance_name>
<host>fake</host>
<password>qM3ZwY5a</password>
<id>1</id>
</console>

View File

@@ -0,0 +1,8 @@
{
"consoles": [
{
"console_type": "fake",
"id": 1
}
]
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<consoles>
<console>
<console_type>fake</console_type>
<id>1</id>
</console>
</consoles>

View 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=="
}
]
}
}

View 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>

View File

@@ -0,0 +1,16 @@
{
"server": {
"admin_pass": "C3r5xKS73Y7S",
"id": "3f19c120-f64a-4faf-848e-33900b752f83",
"links": [
{
"href": "http://openstack.example.com/v3/servers/3f19c120-f64a-4faf-848e-33900b752f83",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/3f19c120-f64a-4faf-848e-33900b752f83",
"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="fe57373d-9410-4c24-bd03-7e9323c26718" admin_pass="VR3kG8JMfPhZ">
<metadata/>
<atom:link href="http://openstack.example.com/v3/servers/fe57373d-9410-4c24-bd03-7e9323c26718" rel="self"/>
<atom:link href="http://openstack.example.com/servers/fe57373d-9410-4c24-bd03-7e9323c26718" rel="bookmark"/>
</server>

View File

@@ -0,0 +1 @@
{"console": {"console_type": "fake", "port": 5999, "instance_name": "instance-00000001", "host": "fake", "password": "%(password)s", "id": 1}}

View File

@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<console>
<id>1</id>
<port>5999</port>
<host>fake</host>
<password>%(password)s</password>
<console_type>fake</console_type>
<instance_name>instance-00000001</instance_name>
</console>

View File

@@ -0,0 +1 @@
{"consoles": [{"console_type": "fake", "id": 1}]}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<consoles>
<console>
<id>1</id>
<console_type>fake</console_type>
</console>
</consoles>

View File

@@ -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=="
}
]
}
}

View File

@@ -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>

View File

@@ -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"
}
]
}
}

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_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>

View File

@@ -0,0 +1,60 @@
# 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 test_servers
class ConsolesSamplesJsonTest(test_servers.ServersSampleBase):
sample_dir = "consoles"
def setUp(self):
super(ConsolesSamplesJsonTest, self).setUp()
self.flags(console_public_hostname='fake')
self.flags(console_host='fake')
self.flags(console_driver='nova.console.fake.FakeConsoleProxy')
self.console = self.start_service('console', host='fake')
def _create_consoles(self, server_uuid):
response = self._do_post('servers/%s/consoles' % server_uuid,
'consoles-create-req', {})
self.assertEqual(response.status, 201)
def test_create_consoles(self):
uuid = self._post_server()
self._create_consoles(uuid)
def test_list_consoles(self):
uuid = self._post_server()
self._create_consoles(uuid)
response = self._do_get('servers/%s/consoles' % uuid)
self._verify_response('consoles-list-get-resp', {}, response, 200)
def test_console_get(self):
uuid = self._post_server()
self._create_consoles(uuid)
response = self._do_get('servers/%s/consoles/1' % uuid)
subs = self._get_regexes()
self._verify_response('consoles-get-resp', subs, response, 200)
def test_console_delete(self):
uuid = self._post_server()
self._create_consoles(uuid)
response = self._do_delete('servers/%s/consoles/1' % uuid)
self.assertEqual(response.status, 202)
class ConsolesSamplesXmlTest(ConsolesSamplesJsonTest):
ctype = 'xml'