Follow-up on 751234 and 750072
Change-Id: I4a9acf9d08791411ccbd0f00dcb1bc053daea6ce
This commit is contained in:
@@ -67,10 +67,12 @@ class Proxy(proxy.Proxy):
|
|||||||
|
|
||||||
:param name_or_id: The name or ID of a flavor.
|
:param name_or_id: The name or ID of a flavor.
|
||||||
:param bool ignore_missing: When set to ``False``
|
:param bool ignore_missing: When set to ``False``
|
||||||
:class:`~openstack.exceptions.ResourceNotFound` will be
|
:class:`~openstack.exceptions.ResourceNotFound` will be raised when
|
||||||
raised when the resource does not exist.
|
the resource does not exist. When set to ``True``, None will be
|
||||||
When set to ``True``, None will be returned when
|
returned when attempting to find a nonexistent resource.
|
||||||
attempting to find a nonexistent resource.
|
:param bool get_extra_specs: When set to ``True`` and extra_specs not
|
||||||
|
present in the response will invoke additional API call to fetch
|
||||||
|
extra_specs.
|
||||||
:returns: One :class:`~openstack.compute.v2.flavor.Flavor` or None
|
:returns: One :class:`~openstack.compute.v2.flavor.Flavor` or None
|
||||||
"""
|
"""
|
||||||
flavor = self._find(_flavor.Flavor, name_or_id,
|
flavor = self._find(_flavor.Flavor, name_or_id,
|
||||||
@@ -111,6 +113,9 @@ class Proxy(proxy.Proxy):
|
|||||||
|
|
||||||
:param flavor: The value can be the ID of a flavor or a
|
:param flavor: The value can be the ID of a flavor or a
|
||||||
:class:`~openstack.compute.v2.flavor.Flavor` instance.
|
:class:`~openstack.compute.v2.flavor.Flavor` instance.
|
||||||
|
:param bool get_extra_specs: When set to ``True`` and extra_specs not
|
||||||
|
present in the response will invoke additional API call to fetch
|
||||||
|
extra_specs.
|
||||||
|
|
||||||
:returns: One :class:`~openstack.compute.v2.flavor.Flavor`
|
:returns: One :class:`~openstack.compute.v2.flavor.Flavor`
|
||||||
:raises: :class:`~openstack.exceptions.ResourceNotFound`
|
:raises: :class:`~openstack.exceptions.ResourceNotFound`
|
||||||
|
@@ -104,9 +104,9 @@ class Flavor(resource.Resource):
|
|||||||
self._action(session, body)
|
self._action(session, body)
|
||||||
|
|
||||||
def get_access(self, session):
|
def get_access(self, session):
|
||||||
"""Lists tenants who have access to a private flavor and adds private
|
"""Lists tenants who have access to a private flavor
|
||||||
flavor access to and removes private flavor access from tenants. By
|
|
||||||
default, only administrators can manage private flavor access. A
|
By default, only administrators can manage private flavor access. A
|
||||||
private flavor has is_public set to false while a public flavor has
|
private flavor has is_public set to false while a public flavor has
|
||||||
is_public set to true.
|
is_public set to true.
|
||||||
|
|
||||||
@@ -119,8 +119,9 @@ class Flavor(resource.Resource):
|
|||||||
|
|
||||||
def fetch_extra_specs(self, session):
|
def fetch_extra_specs(self, session):
|
||||||
"""Fetch extra_specs of the flavor
|
"""Fetch extra_specs of the flavor
|
||||||
|
|
||||||
Starting with 2.61 extra_specs are returned with the flavor details,
|
Starting with 2.61 extra_specs are returned with the flavor details,
|
||||||
before that a separate call is required
|
before that a separate call is required.
|
||||||
"""
|
"""
|
||||||
url = utils.urljoin(Flavor.base_path, self.id, 'os-extra_specs')
|
url = utils.urljoin(Flavor.base_path, self.id, 'os-extra_specs')
|
||||||
microversion = self._get_microversion_for(session, 'fetch')
|
microversion = self._get_microversion_for(session, 'fetch')
|
||||||
|
@@ -487,7 +487,7 @@ class Server(resource.Resource, metadata.MetadataMixin, resource.TagMixin):
|
|||||||
def get_console_url(self, session, console_type):
|
def get_console_url(self, session, console_type):
|
||||||
action = CONSOLE_TYPE_ACTION_MAPPING.get(console_type)
|
action = CONSOLE_TYPE_ACTION_MAPPING.get(console_type)
|
||||||
if not action:
|
if not action:
|
||||||
raise ValueError("Unsupported console type")
|
raise ValueError("Unsupported console type %s" % console_type)
|
||||||
body = {action: {'type': console_type}}
|
body = {action: {'type': console_type}}
|
||||||
resp = self._action(session, body)
|
resp = self._action(session, body)
|
||||||
return resp.json().get('console')
|
return resp.json().get('console')
|
||||||
|
@@ -719,12 +719,11 @@ class TestCompute(TestComputeProxy):
|
|||||||
method_args=["value", "console_type"],
|
method_args=["value", "console_type"],
|
||||||
expected_args=["console_type"])
|
expected_args=["console_type"])
|
||||||
|
|
||||||
def test_create_console(self):
|
@mock.patch('openstack.utils.supports_microversion', autospec=True)
|
||||||
with \
|
@mock.patch('openstack.compute.v2._proxy.Proxy._create', autospec=True)
|
||||||
mock.patch('openstack.utils.supports_microversion') as smv, \
|
@mock.patch('openstack.compute.v2.server.Server.get_console_url',
|
||||||
mock.patch('openstack.compute.v2._proxy.Proxy._create') as rcc, \
|
autospec=True)
|
||||||
mock.patch('openstack.compute.v2.server.Server.get_console_url') \
|
def test_create_console_mv_old(self, sgc, rcc, smv):
|
||||||
as sgc:
|
|
||||||
console_fake = {
|
console_fake = {
|
||||||
'url': 'a',
|
'url': 'a',
|
||||||
'type': 'b',
|
'type': 'b',
|
||||||
@@ -735,12 +734,19 @@ class TestCompute(TestComputeProxy):
|
|||||||
ret = self.proxy.create_console('fake_server', 'fake_type')
|
ret = self.proxy.create_console('fake_server', 'fake_type')
|
||||||
smv.assert_called_once_with(self.proxy, '2.6')
|
smv.assert_called_once_with(self.proxy, '2.6')
|
||||||
rcc.assert_not_called()
|
rcc.assert_not_called()
|
||||||
sgc.assert_called_with(self.proxy, 'fake_type')
|
sgc.assert_called_with(mock.ANY, self.proxy, 'fake_type')
|
||||||
self.assertDictEqual(console_fake, ret)
|
self.assertDictEqual(console_fake, ret)
|
||||||
|
|
||||||
smv.reset_mock()
|
@mock.patch('openstack.utils.supports_microversion', autospec=True)
|
||||||
sgc.reset_mock()
|
@mock.patch('openstack.compute.v2._proxy.Proxy._create', autospec=True)
|
||||||
rcc.reset_mock()
|
@mock.patch('openstack.compute.v2.server.Server.get_console_url',
|
||||||
|
autospec=True)
|
||||||
|
def test_create_console_mv_2_6(self, sgc, rcc, smv):
|
||||||
|
console_fake = {
|
||||||
|
'url': 'a',
|
||||||
|
'type': 'b',
|
||||||
|
'protocol': 'c'
|
||||||
|
}
|
||||||
|
|
||||||
# Test server_remote_console is triggered when mv>=2.6
|
# Test server_remote_console is triggered when mv>=2.6
|
||||||
smv.return_value = True
|
smv.return_value = True
|
||||||
@@ -749,7 +755,8 @@ class TestCompute(TestComputeProxy):
|
|||||||
ret = self.proxy.create_console('fake_server', 'fake_type')
|
ret = self.proxy.create_console('fake_server', 'fake_type')
|
||||||
smv.assert_called_once_with(self.proxy, '2.6')
|
smv.assert_called_once_with(self.proxy, '2.6')
|
||||||
sgc.assert_not_called()
|
sgc.assert_not_called()
|
||||||
rcc.assert_called_with(server_remote_console.ServerRemoteConsole,
|
rcc.assert_called_with(mock.ANY,
|
||||||
|
server_remote_console.ServerRemoteConsole,
|
||||||
server_id='fake_server',
|
server_id='fake_server',
|
||||||
type='fake_type',
|
type='fake_type',
|
||||||
protocol=None)
|
protocol=None)
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
---
|
---
|
||||||
features:
|
features:
|
||||||
- |
|
- |
|
||||||
Add additional compute flavor operations (flavor_add_tenant_access, flavor_remove_tenant_access, get_flavor_access, extra_specs fetching/updating).
|
Add additional compute flavor operations (flavor_add_tenant_access,
|
||||||
other:
|
flavor_remove_tenant_access, get_flavor_access, extra_specs fetching/updating).
|
||||||
- |
|
|
||||||
Merge FlavorDetails into Flavor class.
|
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
---
|
---
|
||||||
features:
|
features:
|
||||||
- |
|
- |
|
||||||
Optimizes compute server console creation by addind older get_server_console method to the server and create_console proxy method calling appropriate method depending on the suported microversion.
|
Optimizes compute server console creation by adding older
|
||||||
|
get_server_console method to the server and create_console proxy method
|
||||||
|
calling appropriate method depending on the supported microversion.
|
||||||
|
Reference in New Issue
Block a user