Merge "Add V3 API samples for security-groups"

This commit is contained in:
Jenkins 2013-09-26 18:04:07 +00:00 committed by Gerrit Code Review
commit 234e0a346f
17 changed files with 534 additions and 0 deletions

View File

@ -0,0 +1,62 @@
{
"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-09-25T03:29:13Z",
"flavor": {
"id": "1",
"links": [
{
"href": "http://openstack.example.com/flavors/1",
"rel": "bookmark"
}
]
},
"host_id": "0e312d6763795d572ccd716973fd078290d9ec446517b222d3395660",
"id": "f6961f7a-0133-4f27-94cd-901dca4ba426",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]
},
"key_name": null,
"links": [
{
"href": "http://openstack.example.com/v3/servers/f6961f7a-0133-4f27-94cd-901dca4ba426",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/f6961f7a-0133-4f27-94cd-901dca4ba426",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"progress": 0,
"security_groups": [
{
"name": "test"
}
],
"status": "ACTIVE",
"tenant_id": "openstack",
"updated": "2013-09-25T03:29:14Z",
"user_id": "fake"
}
}

View File

@ -0,0 +1,22 @@
<?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-09-25T03:29:14Z" user_id="fake" name="new-server-test" created="2013-09-25T03:29:14Z" tenant_id="openstack" access_ip_v4="" progress="0" host_id="a41e10b8b76a145704a8d4cd340fc14a7e005188ecc475aaea04de44" id="0c2e89e5-491a-4416-ae48-e77edfb04705" access_ip_v6="" key_name="None">
<image id="70a599e0-31e7-49b7-b260-868f441e862b">
<atom:link href="http://glance.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/0c2e89e5-491a-4416-ae48-e77edfb04705" rel="self"/>
<atom:link href="http://openstack.example.com/servers/0c2e89e5-491a-4416-ae48-e77edfb04705" rel="bookmark"/>
<security_groups>
<security_group name="test"/>
</security_groups>
</server>

View File

@ -0,0 +1,17 @@
{
"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=="
}
],
"os-security-groups:security_groups": [{"name": "test"}]
}
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<server xmlns:os-security-groups="http://docs.openstack.org/compute/ext/securitygroups/api/v3" 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/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>
<os-security-groups:security_groups>
<security_group name="test" />
</os-security-groups:security_groups>
</server>

View File

@ -0,0 +1,21 @@
{
"server": {
"admin_pass": "ki8cbWeZdxH6",
"id": "2dabdd93-ced7-4607-a542-2516de84e0e5",
"links": [
{
"href": "http://openstack.example.com/v3/servers/2dabdd93-ced7-4607-a542-2516de84e0e5",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/2dabdd93-ced7-4607-a542-2516de84e0e5",
"rel": "bookmark"
}
],
"security_groups": [
{
"name": "test"
}
]
}
}

View File

@ -0,0 +1,9 @@
<?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="c7edb38c-18bf-4522-8ddc-3af9dd3ab513" admin_pass="55v3adHeAzSM">
<metadata/>
<atom:link href="http://openstack.example.com/v3/servers/c7edb38c-18bf-4522-8ddc-3af9dd3ab513" rel="self"/>
<atom:link href="http://openstack.example.com/servers/c7edb38c-18bf-4522-8ddc-3af9dd3ab513" rel="bookmark"/>
<security_groups>
<security_group name="test"/>
</security_groups>
</server>

View File

@ -0,0 +1,64 @@
{
"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-09-25T03:29:11Z",
"flavor": {
"id": "1",
"links": [
{
"href": "http://openstack.example.com/flavors/1",
"rel": "bookmark"
}
]
},
"host_id": "afeeb125d4d37d0a2123e3144a20a6672fda5d4b6cb85ec193430d82",
"id": "1b94e3fc-1b1c-431a-a077-6b280fb720ce",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]
},
"key_name": null,
"links": [
{
"href": "http://openstack.example.com/v3/servers/1b94e3fc-1b1c-431a-a077-6b280fb720ce",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/1b94e3fc-1b1c-431a-a077-6b280fb720ce",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"progress": 0,
"security_groups": [
{
"name": "test"
}
],
"status": "ACTIVE",
"tenant_id": "openstack",
"updated": "2013-09-25T03:29:12Z",
"user_id": "fake"
}
]
}

View File

@ -0,0 +1,24 @@
<?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-09-25T03:29:12Z" user_id="fake" name="new-server-test" created="2013-09-25T03:29:11Z" tenant_id="openstack" access_ip_v4="" progress="0" host_id="a26871d6b20ffd0c27cebe72624fb2547be453c746edde9df33161f1" id="c7edb38c-18bf-4522-8ddc-3af9dd3ab513" access_ip_v6="" key_name="None">
<image id="70a599e0-31e7-49b7-b260-868f441e862b">
<atom:link href="http://glance.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/c7edb38c-18bf-4522-8ddc-3af9dd3ab513" rel="self"/>
<atom:link href="http://openstack.example.com/servers/c7edb38c-18bf-4522-8ddc-3af9dd3ab513" rel="bookmark"/>
<security_groups>
<security_group name="test"/>
</security_groups>
</server>
</servers>

View File

@ -0,0 +1,58 @@
{
"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": "%(glance_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",
"security_groups": [{"name": "test"}],
"key_name": null
}
}

View File

@ -0,0 +1,22 @@
<?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="" key_name="None">
<image id="%(uuid)s">
<atom:link href="%(glance_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"/>
<security_groups>
<security_group name="test" />
</security_groups>
</server>

View File

@ -0,0 +1,17 @@
{
"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=="
}
],
"os-security-groups:security_groups": [{"name": "test"}]
}
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<server xmlns:os-security-groups="http://docs.openstack.org/compute/ext/securitygroups/api/v3" xmlns="http://docs.openstack.org/compute/api/v1.1" image_ref="%(glance_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>
<os-security-groups:security_groups>
<security_group name="test" />
</os-security-groups:security_groups>
</server>

View File

@ -0,0 +1,17 @@
{
"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"
}
],
"security_groups": [{"name": "test"}]
}
}

View File

@ -0,0 +1,9 @@
<?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"/>
<security_groups>
<security_group name="test" />
</security_groups>
</server>

View File

@ -0,0 +1,59 @@
{
"servers": [
{
"updated": "%(timestamp)s",
"created": "%(timestamp)s",
"access_ip_v4": "",
"access_ip_v6": "",
"addresses": {
"private": [
{
"addr": "%(ip)s",
"version": 4,
"mac_addr": "aa:bb:cc:dd:ee:ff",
"type": "fixed"
}
]
},
"flavor": {
"id": "1",
"links": [
{
"href": "%(host)s/flavors/1",
"rel": "bookmark"
}
]
},
"host_id": "%(hostid)s",
"id": "%(uuid)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(glance_host)s/images/%(uuid)s",
"rel": "bookmark"
}
]
},
"links": [
{
"href": "%(host)s/v3/servers/%(id)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",
"user_id": "fake",
"security_groups": [{"name": "test"}],
"key_name": null
}]
}

View File

@ -0,0 +1,24 @@
<?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" key_name="None">
<image id="%(uuid)s">
<atom:link href="%(glance_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" addr="%(ip)s" type="fixed" 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"/>
<security_groups>
<security_group name="test" />
</security_groups>
</server>
</servers>

View File

@ -0,0 +1,65 @@
# 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.network.security_group import neutron_driver
from nova.tests.integrated.v3 import test_servers
def fake_get(*args, **kwargs):
nova_group = {}
nova_group['id'] = 'fake'
nova_group['description'] = ''
nova_group['name'] = 'test'
nova_group['project_id'] = 'fake'
nova_group['rules'] = []
return nova_group
def fake_get_instance_security_groups(*args, **kwargs):
return [{'name': 'test'}]
class SecurityGroupsJsonTest(test_servers.ServersSampleBase):
extension_name = 'os-security-groups'
def setUp(self):
self.flags(security_group_api=('neutron'))
super(SecurityGroupsJsonTest, self).setUp()
self.stubs.Set(neutron_driver.SecurityGroupAPI, 'get', fake_get)
self.stubs.Set(neutron_driver.SecurityGroupAPI,
'get_instance_security_groups',
fake_get_instance_security_groups)
def test_server_create(self):
self._post_server()
def test_server_get(self):
uuid = self._post_server()
response = self._do_get('servers/%s' % uuid)
subs = self._get_regexes()
subs['hostid'] = '[a-f0-9]+'
self._verify_response('server-get-resp', subs, response, 200)
def test_server_detail(self):
self._post_server()
response = self._do_get('servers/detail')
subs = self._get_regexes()
subs['hostid'] = '[a-f0-9]+'
self._verify_response('servers-detail-resp', subs, response, 200)
class SecurityGroupsXmlTest(SecurityGroupsJsonTest):
ctype = 'xml'