Commit Graph

144 Commits

Author SHA1 Message Date
Stephen Finucane 2a9ac87cc4 Add job to test with SQLAlchemy master (2.x)
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: Ib67538ebd0f8ebbea5a700343f52655b0f7fecd4
2024-04-10 16:41:55 -04:00
Stephen Finucane 16b02bc706 tests: Don't (always) auto-create snapshot instances
If we are manually creating these things, we don't want any
automatically created. This is a latent issue that was being exposed by
SQLAlchemy 2.0's tweaked session management.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I9d760ebbfcca176a39b44f20fb92e16eaf6284c5
2024-04-06 09:51:36 +01:00
Stephen Finucane 1330a5e34a db: Remove 'get_session'
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I2a1a8b8eb933fc750ff8b3fc9d7ff1c7686625e6
2024-04-03 16:22:19 +01:00
Stephen Finucane d581714351 db: Remove session arguments from AZ methods
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I38ae324d5edb3705b559c3706d6888f08473a633
2024-04-03 11:29:58 +01:00
Stephen Finucane b8f5d6199d db: Migrate "share * access" APIs to enginefacade
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I590f4c7f78851b20a339294b820d0c223e298f3d
2024-04-02 14:12:34 +01:00
Stephen Finucane 685acf6013 db: Migrate "share snapshot", "share snapshot instance" APIs to enginefacade
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
2024-04-02 14:11:07 +01:00
Stephen Finucane 36549c8b97 db: Migrate "share instance", "share replica" APIs to enginefacade
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
2023-10-31 11:41:49 +00:00
Kiran Pawar 558288e00a Add support for share/snapshot deferred deletion
Implements: bp/deferred-deletion
Change-Id: I9e55e1706fc0c3d9f65f73e13ba2a20f355c74f4
2024-03-12 14:22:25 +00:00
Takashi Kajinami b488f42332 Bump hacking
hacking 3.1.x is too old.

Change-Id: Ic5131276ac1d1a1a959d0a5b16398ae12fae0c18
2024-01-27 23:57:00 +09:00
Kiran Pawar cd767dd468 Delete share network subnet during network deletion
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
2023-10-11 11:28:05 +00:00
Stephen Finucane db9f5dfe02 db: Convert '_ensure_availability_zone_exists' to decorator
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
2023-09-28 10:21:35 +01:00
Stephen Finucane 8b148ebd41 db: Rename 'share_export_location_*' to 'export_location_*'
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
2023-09-27 16:31:07 +01:00
Stephen Finucane 204215722e db: Rename 'share_instances_*' to 'share_instance_*'
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
2023-09-27 16:20:17 +01:00
Stephen Finucane 2a3bbe9be8 db: Rename some methods
Rename a number of APIs for consistency purposes:

- get_all_expired_transfers ->
    transfer_get_all_expired
- get_all_expired_shares ->
    share_get_all_expired
- get_shares_in_recycle_bin_by_share_server ->
    share_get_all_soft_deleted
- get_shares_in_recycle_bin_by_network ->
    share_get_all_soft_deleted_by_network
- share_transfer_get ->
    transfer_get

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I805ed06feefd189768cf4b0fec9b8ff011694216
2023-09-27 16:14:29 +01:00
Zuul 45b24d2b87 Merge "Fix count in the response of shares/snapshots list API" 2023-09-20 19:38:33 +00:00
Raffaela Cunha f7402cbf27 Fixes share server manager match of identifiers
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
2023-09-19 15:30:59 -03:00
Kiran Pawar 9e835496dc Fix count in the response of shares/snapshots list API
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
2023-09-19 13:48:30 +00:00
Zuul bb09ec1a8f Merge "Set "updated_at" field on access rules" 2023-09-14 17:31:45 +00:00
Zuul da95114610 Merge "Update Share backup APIs and add api ref" 2023-08-28 21:48:33 +00:00
Kiran Pawar 3a2d220f8a Update Share backup APIs and add api ref
- Follow up change to fix suggestions from earlier pull request i.e.
  https://review.opendev.org/c/openstack/manila/+/343980 .
- Add API-ref docs
- Rename column availability_zone to availability_zone_id in
  share_backups table.

Implement: blueprint share-backup
Closes-bug: #2031311
Change-Id: Ice01ab7892b1eb52b3202f2c79957977f73f3aca
2023-08-25 13:15:05 +00:00
silvacarloss 0f82690ddd Allow restricting access rules fields and deletion
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
2023-08-24 14:53:06 -03: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
Goutham Pacha Ravi 234d26cdec Set "updated_at" field on access rules
Closes-Bug: #2031193
Change-Id: I9f9f32401d4af4d40b8beb271fa2c9b5ea24105e
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
2023-08-11 17:12:23 -07:00
zhongjun 0b99fdaa9a Implement share backup
Add share backup feature in Data Copy Service and
Share Service. It will allow the user to create, restore
and delete backups as well as listing backups and showing
the details of a specific backup.

APIImpact
DOCImpact

Change-Id: I7d10cf47864cd21932315375d84dc728ff738f23
Implement: blueprint share-backup
2023-08-10 11:11:42 +00:00
Kiran Pawar 0e7812657b Add count info in 'snapshot list' API
Added support for display count info in share snapshot
list&detail APIs:

1. /v2/snapshots?with_count=True
2. /v2/snapshots/detail?with_count=True

New microversion added 2.79

Closes-bug: #2024556
Change-Id: I37d8ca9022e2ea2c107c6695e20e951d7950043a
2023-07-25 08:33:15 +00:00
Zuul e31be16130 Merge "fix to get soft-deleted objects on db model query" 2023-07-17 21:33:47 +00:00
Kiran Pawar 37278df338 Fix duplicate entries in share_server_backend_details
share_server_backend_details_set() add entries in db table without
checking existing entries with given combinaton of share_server_id
and key. This causes duplicate records. Fix it by validating presence
of share server id and key.

Closes-bug: #2024658
Change-Id: I58dcd9716cf95d0d696c13a4c831df787726bcda
2023-06-22 15:01:12 +00:00
Stephen Finucane c4306e04bc db: Migrate "share server" APIs to enginefacade
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I2e114c54d679a78208ada1821109187b2f645e76
2023-04-14 16:59:36 +01:00
Stephen Finucane 2984c7145a db: Migrate quota sync APIs to enginefacade
Another beefy one, owing to how intertwined these all are. The only
unusual thing is that we have a number of methods that are only used by
the quota sync functionality. One was exposed in 'manila.db.api' and
more were not prefixed with an underscore indicating they were private.
Since these aren't used outside this module, we can mark them all as
private and remove the sole unused public API from 'manila.db.api'.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I9771dbae4663461c79e5f9bcef730af2b928212d
2023-04-14 16:59:31 +01:00
Maurice Escher 99b00c9825
fix to get soft-deleted objects on db model query
read_deleted option
'yes' indicates deleted records are visible,
'only' indicates that *only* deleted records are visible.

Change-Id: I9be0f8127fac6c2294891d209195d9d0711a907b
Closes-Bug: #2015094
2023-04-04 16:09:35 +02:00
Felipe Rodrigues 43de2e8fb5 Metadata for Share Network Subnet Resource
This change adds metadata controller for Share Network Subnets
resource. Bumps microversion to 2.78.

The subnet metadata is passed down to the driver together
with the network_info object.

APIImpact
Partially-implements: bp/metadata-for-share-resources

Change-Id: I8d5a03eb127941a84eea5e6e9bdf76b3489f17a8
2023-02-17 15:42:45 -03:00
haixin b4a0fd9af0 Update micversion to 2.77, support share transfer between project
user can create a transfer for a share. will return transfer id
and auth_key. another user can use transfer_id and auth_key to
accept this share. salt of transfer and auth_key compute crypt_hash
by sha1. then compare with crypt_hash in db.

APIImpact
DocImpact

Partially-Implements: blueprint transfer-share-between-project

Change-Id: I8facf9112a6b09e6b7aed9956c0a87fb5f1fc31f
2023-02-17 16:05:01 +08:00
Kiran Pawar 858939c190 Add 'default_ad_site' field to security service object
Allows to configure optional field 'default_ad_site' from version 2.76.
Restrict to make sure either server or 'default_at_site' provided, but
not both.

APIImpact
Relates-bug: #1988146

Change-Id: I8e21e9170eace134a51efed84de1ccc58eb7eaaa
2023-02-16 09:28:28 +00:00
Zuul c5cf2b9820 Merge "db: Migrate "service" APIs to enginefacade" 2023-01-19 01:40:39 +00:00
Kiran Pawar ba5455cbd6 Fix tests for 'share-network' param in share replica create
Fix suggestions from
https://review.opendev.org/c/openstack/manila/+/804578

Closes-Bug: #1925486
Change-Id: I92d5ed80fb659526dff795cf474826bed45a1d19
2023-01-10 16:33:48 +00:00
Stephen Finucane 83a7fdf010 db: Migrate "service" APIs to enginefacade
Migrate service-related APIs from the legacy enginefacade to the modern
context-based enginefacade. This one is a little tricky as it highlights
two issues.

* The models in 'manila.db.sqlalchemy.models' do not match those created
  by the migrations. This causes us issues since we apply the former
  rather than running migrations when creating our database via the
  DatabaseFixture, which means we're not actually testing against what
  our customers see. One gap is closed here in order to get newly added
  test working as expected but there's a larger issue that needs to be
  addressed at a later date.

* We are using a pattern of "try to create and retrieve on failure"
  rather than "try to get and create on failure" when determining
  whether to create availability zone records. This works where each
  operation results in a new transaction but does not when the
  transaction is shared. We switch this.

With these two issues addressed, the rest of the migration is relatively
straightforward.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: Icfe4b225e216dfda46366af1eb3820b193befa0f
2022-12-21 12:10:32 +00:00
Ashley Rodriguez 206885a3e9 Metadata for Share Snapshots Resource
This change adds metadata controller for Snapshots resource
Bumps microversion to 2.73

APIImpact
Partially-implements: bp/metadata-for-share-resources

Change-Id: I91151792d033a4297557cd5f330053d78895eb78
2022-09-09 14:12:02 +00:00
Zuul 1115e412c0 Merge "Add "share-network" option for replica create API." 2022-08-30 01:48:27 +00:00
kpdev b49605945a Add "share-network" option for replica create API.
Share replica create API does not allow to specify share network and
forces to use parent share's share network. This is problem for some
use-cases, e.g. migration from one share network to another share
network via replication is not possible. Fixed by allowing to pass
'share-network' option for share replica create API and make sure both
parent share-network and user provided share-network will have same
security service association.

Partial-Bug: #1925486
Change-Id: I9049dcd418fbb16d663ab8ed27b90c765fafc5d3
2022-08-15 11:01:08 +00:00
Felipe Rodrigues 8dc6235b5f Fix available share servers to be reused
The change [1] modified the function
`share_server_get_all_by_host_and_share_subnet_valid` adding the
status option. However, it removed the actual filter from the query
wrongly. As result, the method is returning all share servers without
taking the status in account.

This patch reverts that change and also creating a new one for
collecting all share servers no matter their states.

[1] https://review.opendev.org/c/openstack/manila/+/825110

Closes-Bug: #1978962
Change-Id: I8d9437eafde67407ba5e337dd495fdb74eefec70
2022-06-16 12:11:27 -03:00
Ashley Rodriguez 2c1456b3f2 Shares Metadata follow-up patch
Addresses some comments from initial patch here [1].
Also addresses a regression regarding get_metadata_item or show_metadata
and the response keys as shown in this bug [2].

[1]: https://review.opendev.org/c/openstack/manila/+/824648
[2]: https://bugs.launchpad.net/manila/+bug/1968069

Closes-Bug: #1968069
Change-Id: Ib5a62599b84ba55617071f8bcd8e2a1a11b2537b
2022-04-14 21:05:59 +00:00
Ashley Rodriguez 266c8012e7 Metadata for Share Resource
This change adds metadata controller for Shares resource

APIImpact
Partially-implements: bp/metadata-for-share-resources

Change-Id: I76d26f4ddce7570463efd896b571b1e1a9222ca5
2022-03-04 20:57:48 +00:00
Felipe Rodrigues 2b57d15c64 Add multiple subnets per AZ support
Manila can now configure a share network with multiple subnets
in an availability zone. Also, it can add a new subnet for an
availability that has share servers, which will triger an update
share server allocations.

Changes:
- API:
  - Bump version to 2.70.
  - setup share network with multiple subents per az.
  - Block manage server with multiple subnets.
  - Allow add subnet for in-use share servers.
  - `share_network_subnet_id` is dropped from ShareServer view
  - `share_network_subnet_ids` is added in ShareServer view
  - `network_allocation_update_support` is added to ShareServer and
    ShareNetwork views.
  - Add a check operation for share network subnet create.

- DB:
  - Remove `share_network_subnet_id` from share_servers.
  - Create mapping table `share_server_share_network_subnet_mappings`.
  - Fix queries with new db design.
  - Add migration downgrade and upgrade alembic.
  - Add `share_network_subnet_id` to the NetworkAllocations.

- Scheduler:
  - Change `AvailabilityZoneFilter` to take in account if the
    host supports the allocation required by the setup request.

- Manager:
  - Bump RPC API version.
  - `_setup_server` allocating multiple subnets.
  - Modify signature of driver `_setup_server` interface, passing a
    list of `network_info` for each subnet.
  - Share server DB creation to inform a list of subnets and
    create with `network_allocation_update_support`.
  - Implement `check_update_share_server_network_allocations` and
    `update_share_server_network_allocations`.

- Drivers:
  - For legacy compatibility, all drivers implementing `_setup_server`
    consume the first element of the `network_ino`.
  - Dummy Driver:
    - Implement `_setup_server` with new signature as multiple subnet.
    - Modify the `backend_details` to save allocations for all subnets.
    - Report update allocation and share server multiple subnet support.
    - Implement `check_update_share_server_network_allocations` and
      `update_share_server_network_allocations` interfaces.

Signed-off-by: Felipe Rodrigues <felipefuty01@gmail.com>
Co-Authored-By: Andre Beltrami <debeltrami@gmail.com>
Co-Authored-By: Fábio Oliveira <fabioaurelio1269@gmail.com>
Co-Authored-By: Nahim Alves de Souza <nahimsouza@outlook.com>
Co-Authored-By: Caique Mello <caique_mellosbo@hotmail.com>

DocImpact
APIImpact
Partially-Implements: blueprint multiple-share-network-subnets

Change-Id: I7de9de4ae509182e9494bba604979cce03acceec
2022-03-03 02:31:11 +00:00
haixin d51eb05c05 Update micversion to API2.69, Manila share support Recycle Bin
Add support share Recycle Bin, the end user can soft delete
share to Recycle Bin, and can restore the share within 7 days,
otherwise the share will be deleted automatically.

DocImpact
APIImpact
Partially-Implements: blueprint manila-share-support-recycle-bin

Change-Id: Ic838eec5fea890be6513514053329b1d2d86b3ba
2022-02-19 02:02:06 +08:00
haixin de72cd4736 Optimize the query logic for share network list
1: As admin user, query share network list with specified
   "security_service_id" and "project_id" search opts, will
   get wrong result.
2: put "created_since", "created_before" search opts into database to
   Increase query speed

Closes-Bug: #1923008
Change-Id: I49e412cb6c98fcda67531ff915b3b4c3edc64476
2021-09-10 19:23:25 +00:00
Zuul f56a326da8 Merge "Add generic fuzzy matching logic to the database layer" 2021-08-13 04:05:28 +00:00
haixin e032c13bfb Add generic fuzzy matching logic to the database layer
share snap list, Fuzzy query by name or description is supported, but
the current implementation is first get all the shares, then In the API
layer, the for loop is used to achieve fuzzy matching, if the num of
shares is big,
It will seriously affect the speed of fuzzy matching.Therefore, we
should let the database do the matching to speed up the query.
Moving the pagination params (limit, offset, sorting) to the database
layer for snapshot list, to optimize query speed.

Closes-Bug:#1881865
Partial-Bug:#1831094

Change-Id: I283e78c9e7c2dd626d94cf6c1b01d4e2f9ae8097
2021-07-29 15:07:52 +08:00
songwenping 8ee8ee15b1 Replace assertDictMatch with assertDictEqual method in tests
assertDictMatch was introduced for Python 2.6 only.
Python 2.7+ contains assertDictEqual.

Closes-Bug: #1646433
Change-Id: I41738cc0bd90656508fc6ff390072b55130cc6fc
2021-07-14 01:32:08 +00:00
dengzhaosen 6185e66056 Drop support for SQLite < 3.7
Both Ubuntu 18.04 [1] and CentOS 8 [2] provide sufficiently new versions
of SQLite that make this check unnecessary now.

[1] https://packages.ubuntu.com/bionic/sqlite3
[2] http://mirror.centos.org/centos/7/os/x86_64/Packages/

Change-Id: I49fec5b9521f292df38c54bf5ddcb993d2e13d5c
2021-05-05 01:44:05 +00:00
Zuul a556e640eb Merge "Remove unused model properties and increase unit test coverage" 2021-03-26 01:03:42 +00:00