this is follow-up to Ic94323658c89df1c1ff32f511ca23502317d0f00
currently the defaults in __init__ and from_dict of RequestContext
for read_deleted property are different:
- in __init__ it is 'no'
- in from_dict, it is effectively None.
And at the same time, this property is not allowed to be None.
As a result, the new _sanitize_context in oslo.messaging can not create
a sanitized context copy with error
read_deleted can only be one of 'no', 'yes' or 'only', not None
Related-Bug: #2030976
Change-Id: Ifb660688c590fb1c32cbe0ae03e0ea444f19cbb8
Add CRUD APIs for resource locks with support
for preventing deletion of shares (applies to
soft-deletions and unmanage operations as well).
Change-Id: I146bc09e4e8a39797e22458ff6860346e11e592e
Implements: bp/allow-locking-shares-against-deletion
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
Start down the road towards migrating from the legacy engine facade
by...creating a legacy engine facade. No, really, this is better since
it allows us to start migrating actual calls from manually creating
sessions to using context-based sessions. This is similar to change
Idae54a17567b558352031ecc573d83ab8b8f04b9 from cinder and the
'sqlalchemy-20' series in cinder (and nova, and placement) provide a
blueprint for what we'll eventually do here.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I2e4963522be910ae4a3eb113a27e007ea1c380c3
Manila's RequestContext base class was
recently refactored to allow arbitrary
keyword arguments to be passed on to the
base Context class in oslo_context. This
was done so that we don't have to maintain
every new addition to Context within manila
code since that layer may change as the
middleware components (keystonemiddleware, for
example) evolve outside of manila.
During this refactor, "system_scope" was
inadvertently added as a separate keyword
argument, and it wasn't being passed to the
base class, causing system scoped users to
not be represented correctly in the API.
We can drop this parameter and allow it to
flow transparently through "kwargs".
Change-Id: I88b664c631eddced4ee1fcdf34cf05222cb73662
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
RequestContext has a helpful "from_environ"
method that can handle all possible combinations
of auth information users can send our way
when manila is deployed with its Keystone auth
middleware. We could switch to that, so that
we don't have to maintain support for the
full list of current and deprecated auth
configuration options in our auth
middleware.
While we're there, we can also update the
"to_dict" and "from_dict" methods in manila's
context class to match the information we need.
Change-Id: I5d554caf82a1fc4f1dcfede3ea61159ddaeb342e
Closes-Bug: #1602081
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
This is the basic patch which consits of the framework
code for default policy in code feature as well as
share instance export location resource.
Partial-Implements: blueprint policy-in-code
Change-Id: Iedde7a4a674a60e760b47d5eb2973f42d79226d8
This patch removes the warning messages for dropped arguments upon
context setup. They are of limited use and dropping them should
increase the readability of the logs.
Change-Id: I8003dd576a575be4d87e69ef5459009eeb15fabe
Closes-Bug: #1607444
Manila share and scheduler logs are littered with warnings about dropped
kwargs when creating request context. Here is an example:
2016-04-18 17:08:16.103 WARNING manila.context [-] Arguments dropped
when creating context: {u'read_only': False, u'domain': None,
u'show_deleted': False, u'user_identity':
u'6133ebc001384629a4a9ecfc630bb26b 21b76a623d104713845b686526c10720 - -
-', u'project_domain': None, u'resource_uuid': None, u'user_domain':
None}.
These are currently "just noise". Their meaning is not evident without
code study, and they cause confusion and alarm to cloud operators,
resulting in unnecessary support calls and ultimately in a reduction
in value and credibility of our logging system.
In manila share log these messages occur on every CRUD operation.
In manila scheduler the situation is even worse as they occur on every
periodic capabilities/capacity update.
Fix this spam by only sending this warning when we receive truly
unexpected kwargs by following the nova fix [1] for essentially
the same issue in that project.
Closes-Bug: #1582346
[1] Ia47d4909d2656d6fc4c1179659b8098bba3235d3
Change-Id: Ieba91b42ef680b353dbb326667580bf482ff8d48
During context initialization RequestContext.to_dict() method
may be triggered before all Manila specific keys have been set
in the context, in which case an AttributeError is raised.
Fix to_dict() method to set None values for the Manila specific
keys in the context when these attributes have not yet been
set.
Change-Id: I95381cd0e5478e516c0f6a77f1284c3b5b83d492
Closes-Bug: #1561559
Closes-Bug: #1567043
In Ia575ba803a0fb70f39146bd75d381ed19414bd23, oslo.context (2.2.0)
added roles support in the context itself. This passing roles as to
super()__init__.
Change-Id: I22bf58dcbb5955eef7b37e76b909211f972c71ee
As part of providing app agnostic parameters for oslo.log all logging
for TC approved projects need to use and subclass oslo.context
RequestContext to utilize new get_logging_values() method.
Closes-Bug: #1545033
Implements: blueprint app-agnostic-logging-parameters [1]
[1] https://blueprints.launchpad.net/oslo.log/+spec/app-agnostic-logging-parameters
Change-Id: Id08a5274d0d7289b1a57c726468f45e1159c4b29
The RequestContextSerializer uses the to_dict and from_dict
methods and to_dict is storing user/tenant fields which end
up unaccounted for in the RequestContext constructor kwargs
which means we log a warning every time we hydrate the
context - which is a lot (~89K times in 2 days of CI runs).
This change simply pops the user/tenant from kwargs before
logging the warning and uses them in case user_id or
project_id are None for some reason, which is similar to what
Nova's RequestContext does.
Change-Id: I57b4854d60d5758a67df5edcdcddeeb0a4ad886d
Closes-Bug: #1528348
Remove module 'fileutils' as unused and remove usage of module 'local' with
similar code from library 'oslo_context'.
Change-Id: I03b9077456cfe84d61fb3f6d37f033d6a107e5a0
Module 'log' from oslo-incubator was removed after release of oslo_log library.
So, start using oslo_log, but keep oslo-incubator code yet other common modules
within Manila codebase use it.
Implements bp use-oslo-log-lib
Change-Id: I88224f7c2bd99adb78140dfc3fa73cea437f29cd
The oslo team is recommending everyone to switch to the
non-namespaced versions of libraries. Updating the hacking
rule to include a check to prevent oslo.* import from
creeping back in.
oslo.messaging is the only exception because this package doesn't
currently support non-namespaced imports.
Change-Id: I3987e651bc880c8ffa7c0105df0298679dcd3a43
Use "context" code from oslo instead of our own implementation.
See: https://github.com/openstack/oslo.context
Implements blueprint oslo-context
Change-Id: I344b3c6e46abbdb6ea4d844c771265eadbeb22f9
Replace copy.copy() with copy.deepcopy() in 'elevated' method of RequestContext
class to remove addition of admin role to original context that can be used by
malicious users.
Change-Id: Ie28acd9c6c9c75ab00f440b49996a1de7523158b
Closes-bug: #1386932
LOG.warn etc. should be translated separately and thus messages need to
be marked with _LW for LOG.warn, _LI for LOG.info and _LE for LOG.errors
and LOG.exception.
Mark all LOG invocations with proper translation marker.
Use ',' instead of '%' when adding variables to log messages to allow
lazy evaluation.
Add new hacking checks for these.
Change-Id: I31d3ee50f30c63d7d647b1c2b1eae50bf96f0c74
Change usage of modules that are deprecated in oslo-incubator.
Use the corresponding module from oslo.utils.
A followup patch will sync with oslo-incubator and remove the now
obsolete modules.
Change-Id: I4f949de57e333832dcc7c1e256ce82e2db0144cb
Partial-Bug: #1382189
oslo.i18n provides the i18n function that were provided by
oslo-incubator's gettextutils module
Import _ where needed, oslo.i18n deprecated the builtin method.
Closes-Bug: #1382187
Change-Id: I12aa1c725aa4bb52a9aa46e9c3d2b303839de48b
There are two reasons to use it:
1) Removal of duplication
2) In Python 3, webob will return bytes, so we need to fix
'generate_request_id' func so that it also returns bytes.
The behaviour is unchanged in Python 2.
Partially implements use-common-code
Change-Id: I4627e290c0b5c71fcfdbd1f88c5f592385bdd4f5
LOG.xxx("Hello %s" % xyz) should be LOG.xxx("Hello %s", xyz).
This allows the logging package to skip creating the
formatted log message if the message is not going to be emitted because
of the current log level.
The change touches error, warning and info LOG messages.
Adjust test suite for the above change since LOG now uses two parameters
instead of one.
Fix grammar, add missing "." to log messages in some places.
Change-Id: I86404c34502f07ed6dbda1c82b13db888c60f074
Fix and enable flake8 test H404:
H404 multi line docstring should start without a leading new line
Change-Id: I13dc13bb5e81d65300680df094cde538c7a6f6df
Partial-Bug: #1333290
six is the canonical compatibility library for supporting Python 2 and 3
in a single codebase.
The basestring was removed in Python 3 and we should use 'six.string_types'
instead of 'basestring' to make code compatible with py 2 and 3 as well.
Partially-implements blueprint py3-compatibility
Change-Id: Idb452afdc2a828089627e14f90c53f3967ceb2ad
Generic driver will use cinder volumes as back-end for shares,
so this patch adds a module for interacting with cinder.
Partially implements: bp generic-driver
Change-Id: Ide3d98efa8cf38994548934ad445f3561f5e3106