Merge "Expose VIF net-id attribute in os-virtual-interfaces"
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"virtual_interfaces": [
|
||||||
|
{
|
||||||
|
"id": "cec8b9bb-5d22-4104-b3c8-4c35db3210a6",
|
||||||
|
"mac_address": "fa:16:3e:3c:ce:6f",
|
||||||
|
"net_id": "cec8b9bb-5d22-4104-b3c8-4c35db3210a7"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@@ -19,7 +19,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"status": "CURRENT",
|
"status": "CURRENT",
|
||||||
"version": "2.11",
|
"version": "2.12",
|
||||||
"min_version": "2.1",
|
"min_version": "2.1",
|
||||||
"updated": "2013-07-23T11:33:21Z"
|
"updated": "2013-07-23T11:33:21Z"
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"status": "CURRENT",
|
"status": "CURRENT",
|
||||||
"version": "2.11",
|
"version": "2.12",
|
||||||
"min_version": "2.1",
|
"min_version": "2.1",
|
||||||
"updated": "2013-07-23T11:33:21Z"
|
"updated": "2013-07-23T11:33:21Z"
|
||||||
}
|
}
|
||||||
|
@@ -52,6 +52,7 @@ REST_API_VERSION_HISTORY = """REST API Version History:
|
|||||||
* 2.10 - Allow admins to query, create and delete keypairs owned by any
|
* 2.10 - Allow admins to query, create and delete keypairs owned by any
|
||||||
user.
|
user.
|
||||||
* 2.11 - Exposes forced_down attribute for os-services
|
* 2.11 - Exposes forced_down attribute for os-services
|
||||||
|
* 2.12 - Exposes VIF net-id in os-virtual-interfaces
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# The minimum and maximum versions of the API supported
|
# The minimum and maximum versions of the API supported
|
||||||
@@ -60,7 +61,7 @@ REST_API_VERSION_HISTORY = """REST API Version History:
|
|||||||
# Note(cyeoh): This only applies for the v2.1 API once microversions
|
# Note(cyeoh): This only applies for the v2.1 API once microversions
|
||||||
# support is fully merged. It does not affect the V2 API.
|
# support is fully merged. It does not affect the V2 API.
|
||||||
_MIN_API_VERSION = "2.1"
|
_MIN_API_VERSION = "2.1"
|
||||||
_MAX_API_VERSION = "2.11"
|
_MAX_API_VERSION = "2.12"
|
||||||
DEFAULT_API_VERSION = _MIN_API_VERSION
|
DEFAULT_API_VERSION = _MIN_API_VERSION
|
||||||
|
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
"""The virtual interfaces extension."""
|
"""The virtual interfaces extension."""
|
||||||
|
|
||||||
|
from nova.api.openstack import api_version_request
|
||||||
from nova.api.openstack import common
|
from nova.api.openstack import common
|
||||||
from nova.api.openstack import extensions
|
from nova.api.openstack import extensions
|
||||||
from nova.api.openstack import wsgi
|
from nova.api.openstack import wsgi
|
||||||
@@ -26,11 +27,14 @@ ALIAS = 'os-virtual-interfaces'
|
|||||||
authorize = extensions.os_compute_authorizer(ALIAS)
|
authorize = extensions.os_compute_authorizer(ALIAS)
|
||||||
|
|
||||||
|
|
||||||
def _translate_vif_summary_view(_context, vif):
|
def _translate_vif_summary_view(req, _context, vif):
|
||||||
"""Maps keys for VIF summary view."""
|
"""Maps keys for VIF summary view."""
|
||||||
d = {}
|
d = {}
|
||||||
d['id'] = vif.uuid
|
d['id'] = vif.uuid
|
||||||
d['mac_address'] = vif.address
|
d['mac_address'] = vif.address
|
||||||
|
if (req.api_version_request >=
|
||||||
|
api_version_request.APIVersionRequest("2.12")):
|
||||||
|
d['net_id'] = vif.net_uuid
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
@@ -51,7 +55,7 @@ class ServerVirtualInterfaceController(wsgi.Controller):
|
|||||||
|
|
||||||
vifs = self.network_api.get_vifs_by_instance(context, instance)
|
vifs = self.network_api.get_vifs_by_instance(context, instance)
|
||||||
limited_list = common.limited(vifs, req)
|
limited_list = common.limited(vifs, req)
|
||||||
res = [entity_maker(context, vif) for vif in limited_list]
|
res = [entity_maker(req, context, vif) for vif in limited_list]
|
||||||
return {'virtual_interfaces': res}
|
return {'virtual_interfaces': res}
|
||||||
|
|
||||||
@extensions.expected_errors((404))
|
@extensions.expected_errors((404))
|
||||||
|
@@ -123,3 +123,10 @@ user documentation.
|
|||||||
|
|
||||||
Exposed attribute ``forced_down`` for ``os-services``.
|
Exposed attribute ``forced_down`` for ``os-services``.
|
||||||
Added ability to change the ``forced_down`` attribute by calling an update.
|
Added ability to change the ``forced_down`` attribute by calling an update.
|
||||||
|
|
||||||
|
2.12
|
||||||
|
----
|
||||||
|
|
||||||
|
Exposes VIF ``net-id`` attribute in ``os-virtual-interfaces``.
|
||||||
|
User will be able to get Virtual Interfaces ``net-id`` in Virtual Interfaces
|
||||||
|
list and can determine in which network a Virtual Interface is plugged into.
|
||||||
|
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"virtual_interfaces": [
|
||||||
|
{
|
||||||
|
"id": "%(id)s",
|
||||||
|
"mac_address": "%(mac_addr)s",
|
||||||
|
"net_id": "%(id)s"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@@ -19,7 +19,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"status": "CURRENT",
|
"status": "CURRENT",
|
||||||
"version": "2.11",
|
"version": "2.12",
|
||||||
"min_version": "2.1",
|
"min_version": "2.1",
|
||||||
"updated": "2013-07-23T11:33:21Z"
|
"updated": "2013-07-23T11:33:21Z"
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"status": "CURRENT",
|
"status": "CURRENT",
|
||||||
"version": "2.11",
|
"version": "2.12",
|
||||||
"min_version": "2.1",
|
"min_version": "2.1",
|
||||||
"updated": "2013-07-23T11:33:21Z"
|
"updated": "2013-07-23T11:33:21Z"
|
||||||
}
|
}
|
||||||
|
@@ -44,6 +44,14 @@ class VirtualInterfacesJsonTest(test_servers.ServersSampleBase):
|
|||||||
subs = self._get_regexes()
|
subs = self._get_regexes()
|
||||||
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
|
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
|
||||||
template = 'vifs-list-resp'
|
template = 'vifs-list-resp'
|
||||||
if self._test == 'v2':
|
if (hasattr(self, '_test') and self._test == 'v2'):
|
||||||
template = 'vifs-list-resp-v2'
|
template = 'vifs-list-resp-v2'
|
||||||
self._verify_response(template, subs, response, 200)
|
self._verify_response(template, subs, response, 200)
|
||||||
|
|
||||||
|
|
||||||
|
class VirtualInterfacesJsonV212Test(VirtualInterfacesJsonTest):
|
||||||
|
request_api_version = '2.12'
|
||||||
|
# NOTE(gmann): microversion tests do not need to run for v2 API
|
||||||
|
# so defining scenarios only for v2.12 which will run the original tests
|
||||||
|
# by appending '(v2_12)' in test_id.
|
||||||
|
scenarios = [('v2_12', {})]
|
||||||
|
@@ -66,7 +66,7 @@ EXP_VERSIONS = {
|
|||||||
"v2.1": {
|
"v2.1": {
|
||||||
"id": "v2.1",
|
"id": "v2.1",
|
||||||
"status": "CURRENT",
|
"status": "CURRENT",
|
||||||
"version": "2.11",
|
"version": "2.12",
|
||||||
"min_version": "2.1",
|
"min_version": "2.1",
|
||||||
"updated": "2013-07-23T11:33:21Z",
|
"updated": "2013-07-23T11:33:21Z",
|
||||||
"links": [
|
"links": [
|
||||||
@@ -128,7 +128,7 @@ class VersionsTestV20(test.NoDBTestCase):
|
|||||||
{
|
{
|
||||||
"id": "v2.1",
|
"id": "v2.1",
|
||||||
"status": "CURRENT",
|
"status": "CURRENT",
|
||||||
"version": "2.11",
|
"version": "2.12",
|
||||||
"min_version": "2.1",
|
"min_version": "2.1",
|
||||||
"updated": "2013-07-23T11:33:21Z",
|
"updated": "2013-07-23T11:33:21Z",
|
||||||
"links": [
|
"links": [
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
|
from nova.api.openstack import api_version_request
|
||||||
from nova.api.openstack.compute.legacy_v2.contrib import virtual_interfaces \
|
from nova.api.openstack.compute.legacy_v2.contrib import virtual_interfaces \
|
||||||
as vi20
|
as vi20
|
||||||
from nova.api.openstack.compute import virtual_interfaces as vi21
|
from nova.api.openstack.compute import virtual_interfaces as vi21
|
||||||
@@ -40,11 +41,13 @@ def _generate_fake_vifs(context):
|
|||||||
vif = vif_obj.VirtualInterface(context=context)
|
vif = vif_obj.VirtualInterface(context=context)
|
||||||
vif.address = '00-00-00-00-00-00'
|
vif.address = '00-00-00-00-00-00'
|
||||||
vif.network_id = 123
|
vif.network_id = 123
|
||||||
|
vif.net_uuid = '22222222-2222-2222-2222-22222222222222222'
|
||||||
vif.uuid = '00000000-0000-0000-0000-00000000000000000'
|
vif.uuid = '00000000-0000-0000-0000-00000000000000000'
|
||||||
fake_vifs = [vif]
|
fake_vifs = [vif]
|
||||||
vif = vif_obj.VirtualInterface(context=context)
|
vif = vif_obj.VirtualInterface(context=context)
|
||||||
vif.address = '11-11-11-11-11-11'
|
vif.address = '11-11-11-11-11-11'
|
||||||
vif.network_id = 456
|
vif.network_id = 456
|
||||||
|
vif.net_uuid = '33333333-3333-3333-3333-33333333333333333'
|
||||||
vif.uuid = '11111111-1111-1111-1111-11111111111111111'
|
vif.uuid = '11111111-1111-1111-1111-11111111111111111'
|
||||||
fake_vifs.append(vif)
|
fake_vifs.append(vif)
|
||||||
return fake_vifs
|
return fake_vifs
|
||||||
@@ -60,6 +63,13 @@ class FakeRequest(object):
|
|||||||
|
|
||||||
|
|
||||||
class ServerVirtualInterfaceTestV21(test.NoDBTestCase):
|
class ServerVirtualInterfaceTestV21(test.NoDBTestCase):
|
||||||
|
wsgi_api_version = None
|
||||||
|
expected_response = {
|
||||||
|
'virtual_interfaces': [
|
||||||
|
{'id': '00000000-0000-0000-0000-00000000000000000',
|
||||||
|
'mac_address': '00-00-00-00-00-00'},
|
||||||
|
{'id': '11111111-1111-1111-1111-11111111111111111',
|
||||||
|
'mac_address': '11-11-11-11-11-11'}]}
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ServerVirtualInterfaceTestV21, self).setUp()
|
super(ServerVirtualInterfaceTestV21, self).setUp()
|
||||||
@@ -73,20 +83,16 @@ class ServerVirtualInterfaceTestV21(test.NoDBTestCase):
|
|||||||
self.controller = vi21.ServerVirtualInterfaceController()
|
self.controller = vi21.ServerVirtualInterfaceController()
|
||||||
|
|
||||||
def test_get_virtual_interfaces_list(self):
|
def test_get_virtual_interfaces_list(self):
|
||||||
req = fakes.HTTPRequest.blank('')
|
req = fakes.HTTPRequest.blank('', version=self.wsgi_api_version)
|
||||||
res_dict = self.controller.index(req, 'fake_uuid')
|
res_dict = self.controller.index(req, 'fake_uuid')
|
||||||
response = {'virtual_interfaces': [
|
self.assertEqual(res_dict, self.expected_response)
|
||||||
{'id': '00000000-0000-0000-0000-00000000000000000',
|
|
||||||
'mac_address': '00-00-00-00-00-00'},
|
|
||||||
{'id': '11111111-1111-1111-1111-11111111111111111',
|
|
||||||
'mac_address': '11-11-11-11-11-11'}]}
|
|
||||||
self.assertEqual(res_dict, response)
|
|
||||||
|
|
||||||
def test_vif_instance_not_found(self):
|
def test_vif_instance_not_found(self):
|
||||||
self.mox.StubOutWithMock(compute_api.API, 'get')
|
self.mox.StubOutWithMock(compute_api.API, 'get')
|
||||||
fake_context = context.RequestContext('fake', 'fake')
|
fake_context = context.RequestContext('fake', 'fake')
|
||||||
fake_req = FakeRequest(fake_context)
|
fake_req = FakeRequest(fake_context)
|
||||||
|
fake_req.api_version_request = api_version_request.APIVersionRequest(
|
||||||
|
self.wsgi_api_version)
|
||||||
compute_api.API.get(fake_context, 'fake_uuid',
|
compute_api.API.get(fake_context, 'fake_uuid',
|
||||||
expected_attrs=None,
|
expected_attrs=None,
|
||||||
want_objects=True).AndRaise(
|
want_objects=True).AndRaise(
|
||||||
@@ -105,6 +111,19 @@ class ServerVirtualInterfaceTestV20(ServerVirtualInterfaceTestV21):
|
|||||||
self.controller = vi20.ServerVirtualInterfaceController()
|
self.controller = vi20.ServerVirtualInterfaceController()
|
||||||
|
|
||||||
|
|
||||||
|
class ServerVirtualInterfaceTestV212(ServerVirtualInterfaceTestV21):
|
||||||
|
wsgi_api_version = '2.12'
|
||||||
|
|
||||||
|
expected_response = {
|
||||||
|
'virtual_interfaces': [
|
||||||
|
{'id': '00000000-0000-0000-0000-00000000000000000',
|
||||||
|
'mac_address': '00-00-00-00-00-00',
|
||||||
|
'net_id': '22222222-2222-2222-2222-22222222222222222'},
|
||||||
|
{'id': '11111111-1111-1111-1111-11111111111111111',
|
||||||
|
'mac_address': '11-11-11-11-11-11',
|
||||||
|
'net_id': '33333333-3333-3333-3333-33333333333333333'}]}
|
||||||
|
|
||||||
|
|
||||||
class ServerVirtualInterfaceEnforcementV21(test.NoDBTestCase):
|
class ServerVirtualInterfaceEnforcementV21(test.NoDBTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Reference in New Issue
Block a user