Cleanup deprecation warnings from using share proxy properties in API

The API code emits a ton of deprecation warnings from the view builder
code using deprecated properties on the share DB object which proxies
to the share instance, so this changes the code to use the share.instance
property instead.

Note that since the tests are mocking out the share as a dict in a lot of
places, we have to handle accessing the instance as a dict entry rather
than an attribute on a sqlalchemy object. Because of this, the wrapper
class in the stubs module needed to be updated to actually work like a
dict container. This is done by extending the abstract base class
collections.Mapping and overriding the update method. Now the runtime
code can access attributes on the share like a dict (which old tests are
still using outside of the stubs module) or an attribute like would be
the case with the sqlalchemy object.

Partial-Bug: #1510507

Change-Id: I114b67dfeef0f46022230f91c6807a69ea9175a2
This commit is contained in:
Matt Riedemann
2016-02-15 14:39:33 -08:00
parent 29cbef0532
commit fa0ec89b5e
8 changed files with 105 additions and 51 deletions

View File

@@ -37,7 +37,7 @@ class ShareUnmanageMixin(object):
try:
share = self.share_api.get(context, id)
if share.get('share_server_id'):
if share['instance'].get('share_server_id'):
msg = _("Operation 'unmanage' is not supported for shares "
"that are created on top of share servers "
"(created with share-networks).")