Add api samples to cloudpipe extension
Change-Id: I0c9d5ac191c9c9dc6c74f955857aebf7c1952b94
This commit is contained in:
parent
2ba27f66cf
commit
dda508ec6f
5
doc/api_samples/os-cloudpipe/cloud-pipe-create-req.json
Normal file
5
doc/api_samples/os-cloudpipe/cloud-pipe-create-req.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"cloudpipe": {
|
||||
"project_id": "cloudpipe-059f21e3-c20e-4efc-9e7a-eba2ab3c6f9a"
|
||||
}
|
||||
}
|
3
doc/api_samples/os-cloudpipe/cloud-pipe-create-req.xml
Normal file
3
doc/api_samples/os-cloudpipe/cloud-pipe-create-req.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<cloudpipe
|
||||
project_id="cloudpipe-6405f2ca-caf9-493b-a1f6-e55f595d75ab"
|
||||
/>
|
5
doc/api_samples/os-cloudpipe/cloud-pipe-create-resp.json
Normal file
5
doc/api_samples/os-cloudpipe/cloud-pipe-create-resp.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"cloudpipe": {
|
||||
"instance_id": "72afecab-24b0-437e-b1d9-88a83be701b3"
|
||||
}
|
||||
}
|
4
doc/api_samples/os-cloudpipe/cloud-pipe-create-resp.xml
Normal file
4
doc/api_samples/os-cloudpipe/cloud-pipe-create-resp.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<cloudpipe>
|
||||
<instance_id>1a17f615-343b-430f-976a-457c029eddb7</instance_id>
|
||||
</cloudpipe>
|
15
doc/api_samples/os-cloudpipe/cloud-pipe-get-resp.json
Normal file
15
doc/api_samples/os-cloudpipe/cloud-pipe-get-resp.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"cloudpipes": [
|
||||
{
|
||||
"cloudpipe": {
|
||||
"created_at": "2012-09-25T18:18:55Z",
|
||||
"instance_id": "72afecab-24b0-437e-b1d9-88a83be701b3",
|
||||
"internal_ip": "192.168.0.3",
|
||||
"project_id": "cloudpipe-059f21e3-c20e-4efc-9e7a-eba2ab3c6f9a",
|
||||
"public_ip": "127.0.0.1",
|
||||
"public_port": 22,
|
||||
"state": "down"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
12
doc/api_samples/os-cloudpipe/cloud-pipe-get-resp.xml
Normal file
12
doc/api_samples/os-cloudpipe/cloud-pipe-get-resp.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<cloudpipes>
|
||||
<cloudpipe>
|
||||
<public_ip>127.0.0.1</public_ip>
|
||||
<created_at>2012-09-25T18:18:49Z</created_at>
|
||||
<public_port>22</public_port>
|
||||
<state>down</state>
|
||||
<instance_id>1a17f615-343b-430f-976a-457c029eddb7</instance_id>
|
||||
<internal_ip>192.168.0.3</internal_ip>
|
||||
<project_id>cloudpipe-6405f2ca-caf9-493b-a1f6-e55f595d75ab</project_id>
|
||||
</cloudpipe>
|
||||
</cloudpipes>
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"cloudpipe": {
|
||||
"project_id": "%(project_id)s"
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
<cloudpipe
|
||||
project_id="%(project_id)s"
|
||||
/>
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"instance_id": "%(id)s"
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
<cloudpipe>
|
||||
<instance_id>%(uuid)s</instance_id>
|
||||
</cloudpipe>
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"cloudpipes": [
|
||||
{
|
||||
"created_at": "%(timestamp)s",
|
||||
"instance_id": "%(uuid)s",
|
||||
"internal_ip": "%(ip)s",
|
||||
"project_id": "%(project_id)s",
|
||||
"public_ip": "%(ip)s",
|
||||
"public_port": 22,
|
||||
"state": "down"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<cloudpipes>
|
||||
<cloudpipe>
|
||||
<public_ip>%(ip)s</public_ip>
|
||||
<created_at>%(timestamp)s</created_at>
|
||||
<public_port>22</public_port>
|
||||
<state>down</state>
|
||||
<instance_id>%(uuid)s</instance_id>
|
||||
<internal_ip>%(ip)s</internal_ip>
|
||||
<project_id>%(project_id)s</project_id>
|
||||
</cloudpipe>
|
||||
</cloudpipes>
|
@ -20,8 +20,10 @@ import uuid
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from nova.cloudpipe.pipelib import CloudPipe
|
||||
from nova import context
|
||||
from nova import flags
|
||||
from nova.network.manager import NetworkManager
|
||||
from nova.openstack.common import importutils
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova.openstack.common.log import logging
|
||||
@ -987,3 +989,49 @@ class VirtualInterfacesJsonTest(ServersSampleBase):
|
||||
|
||||
class VirtualInterfacesXmlTest(VirtualInterfacesJsonTest):
|
||||
ctype = 'xml'
|
||||
|
||||
|
||||
class CloudPipeSampleJsonTest(ApiSampleTestBase):
|
||||
extension_name = "nova.api.openstack.compute.contrib.cloudpipe.Cloudpipe"
|
||||
|
||||
def setUp(self):
|
||||
super(CloudPipeSampleJsonTest, self).setUp()
|
||||
|
||||
def get_user_data(self, project_id):
|
||||
"""Stub method to generate user data for cloudpipe tests"""
|
||||
return "VVNFUiBEQVRB\n"
|
||||
|
||||
def network_api_get(self, context, network_uuid):
|
||||
"""Stub to get a valid network and its information"""
|
||||
return {'vpn_public_address': '127.0.0.1',
|
||||
'vpn_public_port': 22}
|
||||
|
||||
self.stubs.Set(CloudPipe, 'get_encoded_zip', get_user_data)
|
||||
self.stubs.Set(NetworkManager, "get_network", network_api_get)
|
||||
|
||||
def test_cloud_pipe_create(self):
|
||||
"""Get api samples of cloud pipe extension creation"""
|
||||
FLAGS.vpn_image_id = fake.get_valid_image_id()
|
||||
project = {'project_id': 'cloudpipe-' + str(uuid.uuid4())}
|
||||
response = self._do_post('os-cloudpipe', 'cloud-pipe-create-req',
|
||||
project)
|
||||
self.assertEqual(response.status, 200)
|
||||
subs = self._get_regexes()
|
||||
subs.update(project)
|
||||
subs['image_id'] = FLAGS.vpn_image_id
|
||||
self._verify_response('cloud-pipe-create-resp', subs, response)
|
||||
return project
|
||||
|
||||
def test_cloud_pipe_list(self):
|
||||
"""Get api samples of cloud pipe extension get request"""
|
||||
project = self.test_cloud_pipe_create()
|
||||
response = self._do_get('os-cloudpipe')
|
||||
self.assertEqual(response.status, 200)
|
||||
subs = self._get_regexes()
|
||||
subs.update(project)
|
||||
subs['image_id'] = FLAGS.vpn_image_id
|
||||
return self._verify_response('cloud-pipe-get-resp', subs, response)
|
||||
|
||||
|
||||
class CloudPipeSampleXmlTest(CloudPipeSampleJsonTest):
|
||||
ctype = "xml"
|
||||
|
Loading…
x
Reference in New Issue
Block a user