Resolve the following RemovedIn20Warning warning:
Using strings to indicate relationship names in Query.join() is
deprecated and will be removed in SQLAlchemy 2.0. Please use the
class-bound attribute directly.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I155b4ce4b605720c8335d465124fd32cc973a737
after testing using an assert for DML without a transaction,
we can now turn autocommit off. enginefacade should be used
completely now
Change-Id: I2ee07c7e41ea43c2ab24a4a095550dd0b5fe47dd
Thankfully the APIs being migrated here were _mostly_ sharing sessions
already, so we can simply migrate from public (decorated) methods to
private methods with minimal fuss.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: Id1b555e48106662d15e8c50567a5f3acecf6a8f1
We need to maintain these on quotas (for now) but not on other
operations.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I991d6127c14b5f06ca9ca8e6caccbc392e639b42
We migrate both of these at the same time since a share replica is
effectively a share instance with only the 'replica_state' field set. As
such, they share many common DB APIs.
These are mostly trivial to migrate. Just a lot of refactoring to create
private methods, avoiding nested transactions.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I267e2e0fac0b4130f8836de276082788fbd8d454
Export locations are usually too difficult to memo
rize.Currently, there is no way to determine the
export location before the share is created, so
users wait until the share creation request gets
completed, and then they check the export
locations to mount the share. The generated
export locations are often not human readable
and it is hard to memorize and control them.
Implements: bp/human-readable-export-locations
Change-Id: I72ac7e24ddd4330d76cafd5e7f78bac2b0174883
'_share_get_query' isn't really necessary and makes the code a little
trickier to read. Remove it.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I4089c28a53846afdd8b6baa911de0120ce004ae3
Share network subnet is deleted during share network deletion which was
missing earlier causing lots of stale db entries.
Change-Id: Idb58b4ca389cfb1aaf8f9f1f8aa2fd15979c4872
Closes-bug: #2037422
Well, most of them. Two are left out since they call into 'share_*' APIs
and that's a whole other bag of string. We'll tackle those later.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I170a406d4eb236d9921113270b58657a6ddaad0a
Another set of APIs that are commonly used from other APIs. Add private
versions of these that we can call without worrying about them creating
new sessions on us.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I37f5a058dd1dec8e1a6ba129f121de12c0f2f3e1
We are currently running this outside of the main session of many APIs.
This is tough to do when the session is created as a decorator. Make
life easier by using a decorator, which allows us to use a separate
context and separate session.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I95187d5b9bc21120c74b6784489c1b0dbbf337da
We migrate these two at the same time since they're so intertwined.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I23255a4a361602b602bca8349b5948efd147178d
This is an important helper in the migration to enginefacade since
'share_get' is currently used in so many other functions. We must move
a 'get_session' call out of '_share_get_query' so that we won't
inadvertently ignore the session stored in the context.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: Iffe9e46ca707ef8cca3fe878faa29b62b924ab42
This better aligns with 'export_location_metadata_*' APIs. The plural
'export_locations_get*' APIs are renamed to 'export_location_get_all*'.
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I14f2b834e7ac2d8be86f9d7e381706cadbb79eb8
Rename a number of APIs to use singular, rather than plural, like every
other API uses:
- share_instances_status_update ->
share_instance_status_update
- share_instances_get_all ->
share_instance_get_all
- share_instances_get_all_by_host ->
share_instance_get_all_by_host
- share_instances_get_all_by_share_network ->
share_instance_get_all_by_share_network
- share_instances_get_all_by_share_server ->
share_instance_get_all_by_share_server
- share_instances_get_all_by_share ->
share_instance_get_all_by_share
- share_instances_get_all_by_share_group_id ->
share_instance_get_all_by_share_group_id
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: Ic48fe0d1631a6e1a8ee9a50741cc1b31c9187c37
Currently, delete of share network leaves security service associations
behind it. DB purge job can't process them because they are constrained
to soft-deleted networks. Proposed patch fixes both formation of
orphaned associations and seamless purging of them.
Closes-Bug: #2029366
Change-Id: I9593dd6e89b2d290d3919c92d209132e1cec84f0
Previsously, when trying to manage a share server with a given
identifier, the db API checked if the identifier is a substring
of any existing identifier and if it is True, it raised an
InvalidInput Exception.
Now, the InvalidInput expception is raised only if the
identifier is a suffix of any existing identifier and it is
ignored when it is just a preffix. Some queries from the
sqlalchemy API share_server_search_by_identifier method
were edited to implement this change.
Depends-On: I14df0c9c7326ac49274699dc0ef1adb99570784b
Closes-bug: #1982429
Change-Id: I4b340ef116625f28e431b069f399771fd29a8de9
Share/Snapshot list API returns count of shares/snapshotsi along-with
list of resource objects. The list returned by API contains correct
entries of shares/snapshots but it returns the wrong count as it
ShareInstances/SnapshotInstances. So filter queries by unique
share_id/snapshot_id.
Closes-bug: #2033604
Change-Id: I13c415767b0d126563f9553df415de564b3901d6
This reverts commit e885852648.
Reason for revert: This change is breaking drivers that are able to thin provisioning shares. The shares join in the sqlalchemy/api is not working properly, as the share doesn't have an attribute called shares. The join should be performed differently.
Change-Id: Ia5b4e0d57294c3972f55f4fa9a2750ab0251f7bf
Access rules rules allow API will now take three additional
parameters:
- lock_visibility: when True, only services, administrators and
the same user will be able to see the content of ``access_to`` and
access_key.
- lock_deletion: when True, the access rule will be locked for
deletion. Only services, administrators or the user that placed
the lock will be able to drop the access rule.
- lock_reason: a reason for the lock. This parameter should only
be provided in the presence of at least one of the former
parameters.
In order to delete an access rule that is currently locked, the
requester will need to specify ``unrestrict=True`` in the request.
In case a service placed the restrictions, only the own service or
the system administrator will be able to release it.
This change also implements filters to the access list API. It is
now possible to filter access rules based on `access_to`,
`access_type`, `access_level` and `access_key`.
DocImpact
Change-Id: Iea422c9d6bc99a81cd88c5f4b7055d6a1cf97fdc
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>