Add v3 api samples for shelve
Adds api sample tests and api samples for shelve Partially implements blueprint v3-api-unittests Partially implements blueprint v3-api-specification Change-Id: Ib485ab042a340c4672ad01fb35d065fd52889b07
This commit is contained in:
3
doc/v3/api_samples/os-shelve/os-shelve.json
Normal file
3
doc/v3/api_samples/os-shelve/os-shelve.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"shelve": null
|
||||||
|
}
|
2
doc/v3/api_samples/os-shelve/os-shelve.xml
Normal file
2
doc/v3/api_samples/os-shelve/os-shelve.xml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<shelve/>
|
16
doc/v3/api_samples/os-shelve/server-post-req.json
Normal file
16
doc/v3/api_samples/os-shelve/server-post-req.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"server" : {
|
||||||
|
"name" : "new-server-test",
|
||||||
|
"image_ref" : "http://glance.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/os-shelve/server-post-req.xml
Normal file
19
doc/v3/api_samples/os-shelve/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://glance.openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b" flavor_ref="http://openstack.example.com/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/os-shelve/server-post-resp.json
Normal file
16
doc/v3/api_samples/os-shelve/server-post-resp.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"server": {
|
||||||
|
"admin_password": "LJGRdNsvzh6z",
|
||||||
|
"id": "1d08717a-835e-4dca-9bfb-166fa18a6715",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://openstack.example.com/v3/servers/1d08717a-835e-4dca-9bfb-166fa18a6715",
|
||||||
|
"rel": "self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "http://openstack.example.com/servers/1d08717a-835e-4dca-9bfb-166fa18a6715",
|
||||||
|
"rel": "bookmark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
6
doc/v3/api_samples/os-shelve/server-post-resp.xml
Normal file
6
doc/v3/api_samples/os-shelve/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="502790d3-2eec-49f7-8b6f-9eab9f1bdbc8" admin_password="iwDVL7pCcNtG">
|
||||||
|
<metadata/>
|
||||||
|
<atom:link href="http://openstack.example.com/v3/servers/502790d3-2eec-49f7-8b6f-9eab9f1bdbc8" rel="self"/>
|
||||||
|
<atom:link href="http://openstack.example.com/servers/502790d3-2eec-49f7-8b6f-9eab9f1bdbc8" rel="bookmark"/>
|
||||||
|
</server>
|
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"%(action)s": null
|
||||||
|
}
|
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<%(action)s/>
|
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"server" : {
|
||||||
|
"name" : "new-server-test",
|
||||||
|
"image_ref" : "%(glance_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="%(glance_host)s/openstack/images/%(image_id)s" flavor_ref="%(host)s/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_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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@@ -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>
|
55
nova/tests/integrated/v3/test_shelve.py
Normal file
55
nova/tests/integrated/v3/test_shelve.py
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# 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 oslo.config import cfg
|
||||||
|
|
||||||
|
from nova.tests.integrated.v3 import test_servers
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
|
class ShelveJsonTest(test_servers.ServersSampleBase):
|
||||||
|
extension_name = "os-shelve"
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(ShelveJsonTest, self).setUp()
|
||||||
|
# Don't offload instance, so we can test the offload call.
|
||||||
|
CONF.set_override('shelved_offload_time', -1)
|
||||||
|
|
||||||
|
def _test_server_action(self, uuid, action):
|
||||||
|
response = self._do_post('servers/%s/action' % uuid,
|
||||||
|
'os-shelve',
|
||||||
|
{'action': action})
|
||||||
|
self.assertEqual(response.status, 202)
|
||||||
|
self.assertEqual(response.read(), "")
|
||||||
|
|
||||||
|
def test_shelve(self):
|
||||||
|
uuid = self._post_server()
|
||||||
|
self._test_server_action(uuid, 'shelve')
|
||||||
|
|
||||||
|
def test_shelve_offload(self):
|
||||||
|
uuid = self._post_server()
|
||||||
|
self._test_server_action(uuid, 'shelve')
|
||||||
|
self._test_server_action(uuid, 'shelve_offload')
|
||||||
|
|
||||||
|
def test_unshelve(self):
|
||||||
|
uuid = self._post_server()
|
||||||
|
self._test_server_action(uuid, 'shelve')
|
||||||
|
self._test_server_action(uuid, 'unshelve')
|
||||||
|
|
||||||
|
|
||||||
|
class ShelveXmlTest(ShelveJsonTest):
|
||||||
|
ctype = 'xml'
|
Reference in New Issue
Block a user