Commit Graph

33 Commits

Author SHA1 Message Date
Pavlo Shchelokovskyy f1e255b4d3 Add default to read_deleted in context's from_dict
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
2023-08-30 15:30:45 +00:00
Goutham Pacha Ravi f641577d8a Resource Locks: Support for share deletion lock
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>
2023-08-18 10:47:25 -07:00
Stephen Finucane a84284afd5 db: Use oslo_db.sqlalchemy.enginefacade
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
2022-12-21 11:05:58 +00:00
Goutham Pacha Ravi 00133f93ae Drop "system_scope" from context constructor
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>
2021-02-25 11:02:07 -08:00
Goutham Pacha Ravi c97f89f6e5 Catch up to changes in RequestContext
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>
2021-02-15 17:01:13 -08:00
zhongjun b21c3d68a4 [policy in code] Add support for share instance export location resource
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
2017-11-16 04:39:00 +00:00
Arne Wiebalck 38c1eaede5 Remove warnings for dropped context arguments
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
2016-10-26 22:52:36 +02:00
Tom Barron 4c3c7e5fa4 Fix context warning spam of scheduler and share logs
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
2016-05-17 05:35:09 -04:00
Tom Barron f52d032be3 Fix Manila RequestContext.to_dict() AttributeError
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
2016-05-14 08:37:36 -04:00
Ronald Bradford e3f20e2455 Define context.roles with base class
In Ia575ba803a0fb70f39146bd75d381ed19414bd23, oslo.context (2.2.0)
added roles support in the context itself. This passing roles as to
super()__init__.

Change-Id: I22bf58dcbb5955eef7b37e76b909211f972c71ee
2016-02-25 19:35:04 +00:00
Ronald Bradford f46df15d64 Subclass context from oslo_context base class
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
2016-02-25 17:32:39 +00:00
Jenkins 5a4a029e44 Merge "Replace deprecated [logger/LOG].warn with warning" 2016-01-09 05:32:59 +00:00
huayue 44fc3021d4 Replace deprecated [logger/LOG].warn with warning
Python 3 deprecated the logger.warn method, see:
https://docs.python.org/3/library/logging.html#logging.warning, so we
prefer to use warning to avoid DeprecationWarning.

Change-Id: I6b09f67bb63fbdf31903ec175db012fc50e87f16
Closes-Bug: 1508442
2016-01-08 10:32:47 +08:00
Jenkins 6ece846b65 Merge "Use isoformat() instead of timeutils.strtime()" 2016-01-07 11:12:41 +00:00
Matt Riedemann e86ebb1e39 Pop off user/tenant kwargs in RequestContext init
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
2015-12-21 13:34:51 -08:00
houming-wang bcdf1e3dce Use isoformat() instead of timeutils.strtime()
From the latest oslo.utils code[1], timeutils.strtime() is deprecated.
We should use isoformat() instead.
[1]https://github.com/openstack/oslo.utils/blob/master/oslo_utils/timeutils.py#L81

Change-Id: I036c127d060762afb51db38910a82d7418e6ed88
Closes-Bug: #1527450
2015-12-17 23:00:13 -05:00
Valeriy Ponomaryov 1215e192b9 Remove unused oslo-incubator modules
Remove module 'fileutils' as unused and remove usage of module 'local' with
similar code from library 'oslo_context'.

Change-Id: I03b9077456cfe84d61fb3f6d37f033d6a107e5a0
2015-04-25 16:24:09 +00:00
Valeriy Ponomaryov 63a0504c21 Use oslo_log lib
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
2015-02-08 10:42:40 +00:00
Thomas Bechtold 071d0b59c1 Switch to using oslo_* instead of oslo.*
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
2015-01-27 09:19:50 +01:00
li,chen 8ea7ac4913 Use oslo.context lib
Use "context" code from oslo instead of our own implementation.
See: https://github.com/openstack/oslo.context

Implements blueprint oslo-context

Change-Id: I344b3c6e46abbdb6ea4d844c771265eadbeb22f9
2014-12-20 14:32:07 +08:00
Your Name d37290ce76 Fix context.elevated
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
2014-11-20 21:26:08 +02:00
Andreas Jaeger 15641fba88 Convert files to use _LE and friends
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
2014-10-31 09:47:59 +01:00
Andreas Jaeger 2ad967a6fd Use oslo.utils
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
2014-10-21 14:39:48 +02:00
Andreas Jaeger 7b659fc4e0 Use oslo.i18n
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
2014-10-19 19:21:03 +02:00
Jenkins fcdcb719b3 Merge "Use 'generate_request_id' func from common code" 2014-10-12 15:59:15 +00:00
Your Name e022398bd4 Use 'generate_request_id' func from common code
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
2014-10-07 05:24:22 -04:00
Marc Koderer ecf603bc05 Remove vim headers
As discussed in [1] remove all vim headers from manila files.

[1]: http://lists.openstack.org/pipermail/openstack-dev/2013-October/017353.html

Change-Id: I341486c66ffe4dad7db8608fdc66868ceb7ad95a
Closes-Bug: #1229324
2014-10-06 15:00:27 +02:00
Andreas Jaeger 5b76212da4 Fix some LOG invocations and messages
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
2014-09-03 07:03:00 +02:00
Andreas Jaeger 8203c51081 Flake8: Fix and enable H404
Fix and enable flake8 test H404:
H404  multi line docstring should start without a leading new line

Change-Id: I13dc13bb5e81d65300680df094cde538c7a6f6df
Partial-Bug: #1333290
2014-08-27 10:47:45 +00:00
Valeriy Ponomaryov 8abe92efa9 py3: use six.string_types instead of basestring
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
2014-07-25 06:02:44 +00:00
Andrei V. Ostapenko fbde9ae88f Adds cinder api needed for generic driver implementation
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
2014-02-10 10:10:29 +02:00
Yulia Portnova 4e2f27c11a Replaced cinder with manila 2013-09-04 15:45:32 +03:00
Yulia Portnova dc4ce932ed Renamed cinder to manila.
Fixed setup.py, fixed bin scripts.
2013-09-02 09:59:07 +03:00