Merge "Add missing share-type user message" into stable/train
This commit is contained in:
commit
db9c1ac4f7
|
@ -80,22 +80,29 @@ class Detail(object):
|
|||
"set to extending_error. This action cannot be re-attempted until "
|
||||
"the status has been rectified. Contact your administrator to "
|
||||
"determine the cause of this failure."))
|
||||
NO_DEFAULT_SHARE_TYPE = (
|
||||
'024',
|
||||
_("No default share type has been made available. "
|
||||
"You must specify a share type for creating shares."))
|
||||
|
||||
ALL = (UNKNOWN_ERROR,
|
||||
NO_VALID_HOST,
|
||||
UNEXPECTED_NETWORK,
|
||||
NO_SHARE_SERVER,
|
||||
NO_ACTIVE_AVAILABLE_REPLICA,
|
||||
NO_ACTIVE_REPLICA,
|
||||
FILTER_AVAILABILITY,
|
||||
FILTER_CAPABILITIES,
|
||||
FILTER_CAPACITY,
|
||||
FILTER_DRIVER,
|
||||
FILTER_IGNORE,
|
||||
FILTER_JSON,
|
||||
FILTER_RETRY,
|
||||
FILTER_REPLICATION,
|
||||
DRIVER_FAILED_EXTEND)
|
||||
ALL = (
|
||||
UNKNOWN_ERROR,
|
||||
NO_VALID_HOST,
|
||||
UNEXPECTED_NETWORK,
|
||||
NO_SHARE_SERVER,
|
||||
NO_ACTIVE_AVAILABLE_REPLICA,
|
||||
NO_ACTIVE_REPLICA,
|
||||
FILTER_AVAILABILITY,
|
||||
FILTER_CAPABILITIES,
|
||||
FILTER_CAPACITY,
|
||||
FILTER_DRIVER,
|
||||
FILTER_IGNORE,
|
||||
FILTER_JSON,
|
||||
FILTER_RETRY,
|
||||
FILTER_REPLICATION,
|
||||
DRIVER_FAILED_EXTEND,
|
||||
NO_DEFAULT_SHARE_TYPE
|
||||
)
|
||||
|
||||
# Exception and detail mappings
|
||||
EXCEPTION_DETAIL_MAPPINGS = {
|
||||
|
|
|
@ -25,6 +25,8 @@ from oslo_log import log
|
|||
|
||||
from manila import exception
|
||||
from manila.i18n import _
|
||||
from manila.message import api as message_api
|
||||
from manila.message import message_field
|
||||
from manila.scheduler.drivers import base
|
||||
from manila.scheduler import scheduler_options
|
||||
from manila.share import share_types
|
||||
|
@ -40,6 +42,7 @@ class FilterScheduler(base.Scheduler):
|
|||
self.cost_function_cache = None
|
||||
self.options = scheduler_options.SchedulerOptions()
|
||||
self.max_attempts = self._max_attempts()
|
||||
self.message_api = message_api.API()
|
||||
|
||||
def _get_configuration_options(self):
|
||||
"""Fetch options dictionary. Broken out for testing."""
|
||||
|
@ -141,6 +144,13 @@ class FilterScheduler(base.Scheduler):
|
|||
" and specify in request body or"
|
||||
" set default_share_type in manila.conf.")
|
||||
LOG.error(msg)
|
||||
self.message_api.create(
|
||||
context,
|
||||
message_field.Action.CREATE,
|
||||
context.project_id,
|
||||
resource_type=message_field.Resource.SHARE,
|
||||
resource_id=request_spec.get('share_id', None),
|
||||
detail=message_field.Detail.NO_DEFAULT_SHARE_TYPE)
|
||||
raise exception.InvalidParameterValue(err=msg)
|
||||
|
||||
share_type['extra_specs'] = share_type.get('extra_specs') or {}
|
||||
|
|
|
@ -23,6 +23,7 @@ from oslo_utils import strutils
|
|||
from manila.common import constants
|
||||
from manila import context
|
||||
from manila import exception
|
||||
from manila.message import message_field
|
||||
from manila.scheduler.drivers import base
|
||||
from manila.scheduler.drivers import filter
|
||||
from manila.scheduler import host_manager
|
||||
|
@ -64,6 +65,29 @@ class FilterSchedulerTestCase(test_base.SchedulerTestCase):
|
|||
# no "share_proto" was specified in the request_spec
|
||||
self.assertNotIn('storage_protocol', retval[0])
|
||||
|
||||
def test___format_filter_properties_no_default_share_type_provided(self):
|
||||
|
||||
sched = fakes.FakeFilterScheduler()
|
||||
create_mock_message = self.mock_object(sched.message_api, 'create')
|
||||
fake_context = context.RequestContext('user', 'project')
|
||||
request_spec = {
|
||||
'share_properties': {'project_id': 'string', 'size': 1},
|
||||
'share_instance_properties': {},
|
||||
'share_type': None,
|
||||
'share_id': 'fake-id1',
|
||||
}
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
sched._format_filter_properties,
|
||||
fake_context, {}, request_spec)
|
||||
|
||||
create_mock_message.assert_called_once_with(
|
||||
fake_context,
|
||||
message_field.Action.CREATE,
|
||||
fake_context.project_id,
|
||||
resource_type=message_field.Resource.SHARE,
|
||||
resource_id='fake-id1',
|
||||
detail=message_field.Detail.NO_DEFAULT_SHARE_TYPE)
|
||||
|
||||
@ddt.data(True, False)
|
||||
def test__format_filter_properties_backend_specified_for_replica(
|
||||
self, has_share_backend_name):
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
New user message now alerts users when attempting to create a new
|
||||
share without identifying a share type, either through request body
|
||||
or by setting a default share type. See `bug #1870280
|
||||
<https://bugs.launchpad.net/manila/+bug/1870280>`_ for more details.
|
Loading…
Reference in New Issue