Commit Graph

20 Commits

Author SHA1 Message Date
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
Goutham Pacha Ravi 6303741be2 [RBAC] Return 404 if share is inaccessible
When a user is prevented from listing a non-public
share, the API service would return a 403 Forbidden.
This isn't consistent with the API SIG's guidance
on resources restricted by virtue of RBAC policy since
users with malicious intent may use the signal to
mean that the resource exists.

Depends-On: I27fdd7dfffeb15965b66dbb3f6b1568c11ff9ad4
Change-Id: I7e05dcb343c932cc7fec8d395919053d0a1801ce
Closes-Bug: #1901210
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
2022-09-15 09:41:16 -07:00
Maurice Escher aa9f03d542 Add missing `updated_at` field in share-instance show.
Share_replicas (which are internally share_instances with replica_state
not null) have "updated_at" in its view/API call. However same field is
missing in share-instance show command.

Closes-Bug: #1965122

Change-Id: Ia69f3615d82e0044e3e9f81556dc8355637ef146
2022-04-06 12:38:39 +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
Zuul be262aaa99 Merge "Advertise v2 API routes without project_id" 2021-02-05 22:26:55 +00:00
Goutham Pacha Ravi 263d5438f0 Advertise v2 API routes without project_id
Manila APIs have had the requirement to include
project_id in the URLs since the very beginning.
This comes from an old assumption that our APIs
would be differentiated per-tenant on the cloud,
and we would allow different kinds of API endpoints
(public, admin, internal, etc). While it is possible
to set up different endpoints against the API
service, the same and complete API is exposed at
each of these endpoints.

We don't _need_ the project_id information that
we receive in the URL for any of our APIs to
function. We rather authorize tenants by gathering
information from the Identity service (Keystone)
and wrapping that into a RequestContext object
that we then rely on to ensure namespace isolation.

Removing the requirement for "project_id" simplifies
our API endpoint structure in the service catalog
as well as provides a way for system scoped users
to interact with manila without having to declare
their project.

In order to make project_id optional in urls, the
possible values of project_id have to be constrained.
This change introduces a new configuration option
so deployers may control that. This configuration
option defaults to accepting UUIDs with and without
dashes.

Since manila can be used in standalone deployments
without the need for Keystone, this change introduces
a noauth middleware that can work without project_id
in the URL paths.

The API version has been incremented to signal this
change to end users. When 2.60 is available, deployments
may drop "project_id" in the service catalog endpoint
for Manila and end users applications can stop needing
it as well (if they don't already rely on the service
catalog for this data).

APIImpact
Implements: bp remove-project-id-from-urls
Change-Id: I5127e150e8a71e621890f30dba6720b3932cf583
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
2021-02-04 23:20:19 -08:00
haixin 3831e5500f remove usage of six library from unit tests
Replace six with Python 3 style code.

Change-Id: I5077e71663f6b60bd774f30fcf64b36d4078cf8e
2021-01-28 10:47:40 +08:00
Goutham Pacha Ravi 598223985a Use unittest.mock instead of third party lib
mock was adopted into standard python
in version 3.3 [1]. Since manila no longer
supports python2.7, we can use the inbuilt
mock package rather than the third party
lib.

Fix some issues with imports that weren't
following our import conventions of grouping
imports [3]

Add a hacking test to ensure we don't regress
on this.

[1] https://docs.python.org/3/library/unittest.mock.html
[2] http://lists.openstack.org/pipermail/openstack-discuss/2020-March/013281.html
[3] https://docs.openstack.org/hacking/latest/user/hacking.html#imports

Co-Authored-By: Sean McGinnis <sean.mcginnis@gmail.com>
Change-Id: If857a49fbf526983e712282a25d7e8bef5093533
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
2020-04-17 16:24:27 -07:00
Douglas Viroel 6c47b193b0 Create share from snapshot in another pool or backend
This patch enables the creation of a share from snapshot
specifying another pool or backend. In the scheduler, a
new filter and weigher were implemented in order to consider
this operation if the backend supports it. Also, a new
field called 'progress' was added in the share and share
instance. The 'progress' field indicates the status
of the operation create share from snapshot (in percentage).
Finally, a new periodic task was added in order to constantly
check the share status.

Partially-implements: bp create-share-from-snapshot-in-another-pool-or-backend

DOCImpact
Change-Id: Iab13a0961eb4a387a502246e5d4b79bc9046e04b
Co-authored-by: carloss <ces.eduardo98@gmail.com>
Co-authored-by: dviroel <viroel@gmail.com>
2020-04-09 11:15:22 -03:00
Goutham Pacha Ravi 0d8310ec7a Fix version selector when for proxy-style URLs
When manila API is served behind a proxy, the
"script_name" in the request can have the proxy
component in it. So, this patch fixes the version
selection logic by looking for the version in the
script name string instead of equivalence.

In addition, this patch adds some missing unit
tests and fixes tests that invoke a mocked
wsgi app for testing request context.

Change-Id: I0363d7174f3d7ddefa8ced59b182faed665e9c36
Partial-Bug: #1815038
Closes-Bug: #1818081
2019-03-11 16:42:25 +00:00
Zuul 199c9cbee7 Merge "Delete unused test check" 2018-06-12 17:29:55 +00:00
zhongjun 6d29762f87 Delete unused test check
TrivialFix

Change-Id: Id93a5062c48e99afc22594f05cbf29cffce2494e
2018-06-09 22:34:35 +00:00
Goutham Pacha Ravi fd23a6387c Use class name in invocation of super
Fix pylint E103 warning raised by usage of
self.__class__ to refer to the derived class
in super() methods.

self.__class__ is a reasonable first argument
to super() in any method of a class, as long
as the method is not going to be invoked in
derived classes.

Python3 removes this ambiguity by not requiring
arguments for the super() method.

[1] https://docs.pylint.org/en/1.6.0/features.html#id33

Change-Id: I6071b6cfd8cff2be3853d739f71b94da990cda97
2018-06-06 17:47:18 -07:00
zhongjun f1fbc5952d Add export-location filter in share and share instance list API
Share and share instance list API will accept new query string parameter
'export_location'. It can pass path and id of export_location to
retrieve shares filtered.

APIImpact

Partly-implement: BP support-filter-share-by-export-location
Change-Id: I5fdf6d89d0b6c7fa182ddfaac60979bc6c0fc2a6
2017-06-29 18:06:21 +00:00
zhongjun a08bb6a240 Fix share instance list API display error
The share instances echo will be covered by share instance links
when we run share instance list with limit number API.
Now change _collection_name to _collection_links when we want to
to show instances_links. Then the share instances echo will not
be covered by share instance links.

APIImpact
Change-Id: Ic3f272ab8e6e557c914440fb3dfb938151fc461e
Closes-bug: #1611699
2017-05-24 17:39:13 +08:00
zhongjun 052b100be5 Remove unused self.context
Remove unused self.context

TrivialFix
Change-Id: I03ae35b67e76b382b04747541afab0e4f574942b
2017-05-10 09:25:38 +08:00
yanjun.fu 6965a73ab2 Allow share status reset to migration status
Fix the status of the share instances cannot be reset to "migrating"
and "migrating_to" in server

APIImpact
Add two status "migrating" and "migrating_to" in share status.

Change-Id: Ia23c13f62997d99495d9ecca066475565d9bfc87
Closes-Bug: #1650774
2016-12-28 20:26:00 +08:00
Goutham Pacha Ravi f858e537dd Share Replication API and Scheduler Support
This patch provides the scheduler support to filter share
backends matching replication capabilities reported by the
hosts and the replication_type extra_spec provided via the
share_type during share creation.

It also adds wsgi routes, API endpoints and driver entry
routines to support the actions: list, show, create, delete
and promote share replicas. It augments the ShareInstance
DB model with a 'replica_state' attribute and the Share DB
Model with 'replication_type' attribute to support these
workflows.

Replica states are periodically updated from the respective
backends that the replicas are created on.

APIImpact
Impact on existing APIs:
In Microversion 2.11, the /shares APIs return 2 additional
fields during index and show calls for each share: 'has_replicas'
and 'replication_type'. Similarly, the field 'replica_state' is
added to the API response for /share-instances.
Also, deletion of a share that has replicas is forbidden,
returning error code 403.

DocImpact

Co-Authored-By: Alex Meade <mr.alex.meade@gmail.com>

Implements: blueprint manila-share-replication

Change-Id: I10515d55b1291c34777a31d8c6a3a1954f551235
2016-02-11 19:45:37 +00:00
Valeriy Ponomaryov dcbdcf3534 Implement export location metadata feature
Some upcoming features require more than one export location and
possibility to mark them with specific labels like fast/slow or
rw/ro.

So, implement 'export locations metadata' feature:
- It allows to set any key-value pairs for each export location.
- These key-value pairs can be set only by share manager using
  response from various share driver methods.
- Example of update is implemented using Generic driver
  "create_instance" method.
- Metadata can be updated for any export location in any place
  of share manager where db function "share_export_locations_update"
  is called.
- Keys from export location metadata table will be added to 'share' and
  'share instances' views as export location attributes.

Also:
- Add new attr 'is_admin_only' for existing export locations model.
  If set to True, then only admins will be able to see them. Unless
  policy is changed.
- Add APIs for reading export locations by share and share instance IDs.
- Remove 'export_location' and 'export_locations' attrs
  from 'share' and 'share instance' views.
- Bump microversion as new APIs implemented.

APIImpact

Implements bp export-location-metadata

Change-Id: I36d1aa8d9302e097ffb08d239cf7a81101d2c1cb
2016-01-15 12:29:12 +02:00
vponomaryov 31a19b1fb3 Move API module 'share_instances' under v2 dir
Share instances API has min version as 2.3 and considered as v2-only.
But now it is stored under v1 dir for no reason.
Move it to proper dir and remove from v1 router because it could not
be used using v1 API anyway.

Change-Id: I1e3c306b31235cd422ac339df56147439a7bbace
Closes-Bug: #1521999
2015-12-02 14:07:55 +02:00