Commit Graph

33 Commits

Author SHA1 Message Date
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
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
kpdev 0045293942 Add config option to set per_share_size_limit.
This feature allows admin to set share size limit for a project.
The defaults will either come from the default values
set in the quota configuration option or via manila.conf
if the user has configured default values for quotas there.

The quota_per_share_gigabytes defaults to -1["No Limit"] always
unless changed in manila.conf by admin.

Closes-Bug: #1811943

Change-Id: Ida126c8c419b8bf4d2a194f061a0809d52b47ab8
2021-03-09 11:58:17 +01: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
silvacarloss 14d3e268a0 Add share network with multiple subnets
This patch adds the possibility to create share networks with
multiple subnets in Manila. It also updates the share server api
to receive "share_network_subnet_id" instead of "share_network_id".

Each share network subnet must be associated with only one
availability zone. Each share network must have a single default
share network subnet.

DocImpact
APIImpact
Depends-On: I13bb48e7c03e16c26946ccf9d48e80592391a3d1
Partially-implements: bp share-network-multiple-subnets
Change-Id: Id8814a8b26c9b9dcb1fe71d0d7e9b79e8b8a9210
Closes-Bug: #1588144
Co-Authored-By: lseki <luciomitsuru.seki@fit-tecnologia.org.br>
Co-Authored-By: dviroel <viroel@gmail.com>
2019-09-13 11:27:18 -03:00
Rodrigo Barbieri d877b61c5e Add manage/unmanage of shares in DHSS=True
This patch adds Manage/Unmanage of share servers in
Manila. It also updates the Manage Share API to accept
a "share_server_id" parameter, and updates Unmanage
of Share and Snapshots API to allow unmanaging of
shares and snapshots in DHSS=True.

Managed share servers are not deleted automatically
by manila, and if a single share is unmanaged in
DHSS=True, the respective share server will not be
deleted automatically as well.

Managing share servers require that the driver
implements 2 functions:
- get_share_server_network_info: obtain IPs from
  share server.
- manage_server: perform required operations to
  manage and return dict of backend_details.

Unmanaging share servers require that the driver
overrides unmanage_server function.

The IPs obtained from the backend are validated
by the Network plugin, so ports with the exact
IPs must exist in the subnet and admin subnet
associated with the share network specified
when managing the share server (unless
StandaloneNetworkPlugin is used).

It is recommended to rename the backend resource
if possible when managing the share server, to
prevent issues with re-managing a share server
that has already been managed.

This patch bumps the API microversion to 2.49.

APIImpact
DocImpact

Depends-On: I17c74b2aa242918188eeff368232c762a4b31093
Partially-implements: bp manage-unmanage-with-share-servers
Change-Id: I108961e7436ba13550ef2b8f02079c6e599a6166
2019-03-05 16:03:29 -03:00
zhongjun2 0957b33e9b Support metadata for access rule resource
Now only share have metadata property.
We should support it for access rule as well.

DocImpact

Needed-By: https://review.openstack.org/#/c/579534
Needed-By: https://review.openstack.org/#/c/571366

Change-Id: I2f2b3325a09e5af7f7c4e4fa3443259fb69f9771
Implements: bp metadata-for-access-rule
2018-07-20 23:31:48 +08:00
Dustin Schoenbrun bbb14264cb Add exception for no default share type configured
There is a particular scenario when creating a new Manila share,
whether through creating a new share or managing an existing one, where
if no share type was explicitly specified and no default share type was
configured the error message would not substitute the share type ID into
the exception message. This is because, in this case, there was no share
type ID to substitute into the string.

This patch creates a new exception for explicitly handling the case
where there is no default share type and no share type is explicitly
given. It gives an appropriate error message about there not being a
default share type and that there was no share type explicitly given as
well as what would need to be done to remedy the situation.

Change-Id: I068b55d4b77dc24b53fe93d870bb84e1aef661a5
Closes-Bug: #1700346
2017-08-02 15:27:53 -04:00
Valeriy Ponomaryov ba5384f865 Fix creation of share group types using share type names
Before it was possible to create share group types mapping them to
share types using only share type IDs and when we were providing its
names we were getting DB error and HTTP 500 as a response.

Fix it by properly looking for share type by both its unique values -
ID and name. Also, raise proper 404 error when nothing is found.

Add functional tests covering this case.

Change-Id: I216f935383a87f6d679c431bc46cfa8977a6d8ab
Depends-On: Ic555d241f98d0fa027897c69a7115d1be88f6c96
Closes-Bug: #1659625
2017-01-27 20:21:42 +02:00
tpsilva 8d71932c69 Add mountable snapshots support
This new feature gives the user the ability to allow and
deny access to the snapshots, so that they could be mounted in
read-only mode to retrieve files.

APIImpact
DocImpact

Co-Authored-By: Rodrigo Barbieri <rodrigo.barbieri@fit-tecnologia.org.br>
Co-Authored-By: Alyson Rosa <alyson.rosa@fit-tecnologia.org.br>
Co-Authored-By: Miriam Yumi <miriam.peixoto@fit-tecnologia.org.br>

Partially-implements: blueprint manila-mountable-snapshots
Change-Id: I65f398a05f82eef31ec317d70dfa101483b44b30
2017-01-24 17:26:45 -02:00
Goutham Pacha Ravi 94e04c8de2 Data Replication: Ensure Snapshots across replicas
When taking a snapshot of a replicated share,  users would
expect the snapshot to be available across the replicas.
Currently, Manila assumes that drivers will take snapshots
along with the share data.

Different backends implement replication differently. Many
of them assume that replicas are 'in_sync' with the primary
if they have been synchronized within a particular window
of time (sometimes referred to as 'recovery point objective').
Since snapshots are point in time actions on a share, drivers
must ensure that the replication of a snapshot begins as soon
as it is available on the primary/'active' instance.

To ensure that snapshots are indeed available across replicas:
1) Track snapshots across replicas as different
    snapshot instances.
2) Make an 'aggregate_status' property to convey the
    availability of a snapshot across all the active/in_sync
    replicas of a share.
3) Provide all the information necessary for drivers to:
    - Create a snapshot on the primary and send it across
       to all replicas
    - Delete a snapshot on the primary and ensure that it is
       deleted on the replicas as well.
4) Set snapshot instance to 'error' if it was in any transitional
    state when its replica was 'promoted' to become an 'active'
    instance.
5) Pass down snapshot instances during create, delete and update
replica driver calls.
6) Update replica interfaces to pass in snapshot instance data. Always
include 'available' snapshots in the update_replica call to ensure
that drivers confirm their presence on the replica in order to report
that the replica is 'in_sync'.

Also, grab the share_type afresh from parent share/snapshot
to allow 'replication_key' to be copied to the share model during
share creation.

Rename SnapshotNotFound to SnapshotResourceNotFound to
signify a missing snapshot object on backends.

APIImpact
The 'status' attribute of the snapshot is now the 'aggregate_status'
of the instances of the snapshot. No key changes have been made
in the JSON response. However, API actions will be gated against
'aggregate_status' of the snapshot instances when more than one
instance exists.

Closes-Bug: #1546303
Closes-Bug: #1551064

Change-Id: I63203df00904d209e9e92eda7c79206e5ef8d611
2016-03-18 20:29:11 -04:00
Xing Yang c91f27f4e1 Manage and unmanage snapshot
Add APIs to support manage and unmanage share snapshots.
Also add support in the Generic driver.
This only supports for DHSS=False driver mode.

Add provider_location column to the share_snapshots table
to save data used to identify the snapshot on the backend.

Also need to bump microversion.

APIImpact
DocImpact
Change-Id: I87a066173c85d969607d132accd9f0e9bd49c235
Implements: blueprint manage-unmanage-snapshot
2016-02-18 04:09:05 -05: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
Jenkins b2947757e0 Merge "Fix response code for various NotFound exceptions" 2016-01-15 03:42:25 +00:00
daiki kato d29e611c2f Fix response code for various NotFound exceptions
Fix response code for "NotFound"-like Manila exceptions.

- StorageResourceNotFound
- SnapshotNotFound
- ShareResourceNotFound

Change-Id: Ic7be15c2f8951e512de88d1f559ec677ba4bd78e
Closes-Bug: #1525860
2016-01-13 02:57:19 +00:00
daiki kato efc47cf3cf Fix unit test of ShareSnapshotNotFound
Unit test of ShareSnapshotNotFound isn't executed actually.
This patch fixes it.

Change-Id: I1210b10998ee9ab2c1642036747f06902239f0be
2016-01-05 06:56:07 +00:00
Silvan Kaiser 616ffabece Implements ensure_share() in Quobyte driver
Added ensure_share implementation that checks share
availability and re-exports the given share.
Unit tests are added as well as a new ShareResourceNotFound
Exception (with its own unit test).

Change-Id: Ifbb144fa16df5d0ff3560d1a7476b75e5ccf184a
Closes-Bug: #1510552
2015-11-19 12:40:43 +01:00
Yusuke Hayashi 3a1e193e32 Fix order of arguments in assertEqual
Fix incorrect order assertEqual(observed, expected) as below.
  assertEqual(observed, expected) => assertEqual(expected, observed)

Target of this patch:
  manila/tests/test_xxx.py

Change-Id: Idcaf6721ce4d90b34fe834dc0f26763fd0035bd8
Partial-Bug: #1259292
2015-09-29 10:50:02 +09:00
Yusuke Hayashi 4f8224fe27 Fix incorrect variable name in some exception class
At manila.exception:
msg_fmt => message

Reason:
When msg_fmt is passed to parent class, the information is not shown
because parent class expect variable 'message'.

Change-Id: I3e1346e7d6258eac4a5df965e4315090fbfcda0b
Closes-Bug: #1487247
2015-08-21 04:26:05 +00:00
zhongjun 16559b8472 Delete redundant period in ManilaException messages
--Delete redundant period in the command echo.

Change-Id: I0081643b0ba432b327a22473856d06b63f307873
Closes-Bug: #1466062
2015-07-14 14:01:27 +08:00
Bob Callaway d7993fc8ae Rename volume_type to share_type
This change adds support for share_type, share_types, and share_type_id
along side the corresponding volume_type, volume_types and
volume_type_id fields in the API. This change was made as share_type and
its references are more intuitive in comparison to volume_type.
Both entries are returned to ensure API compatibility but preference is
given to share_type[s,_id].

The database migration introduced in this change should work on MySQL
and Postgres, but will not work on SQLite. Because there is no point
in supporting SQLite, tests for it are removed.

Implements blueprint: rename-volume-type-to-share-type

Change-Id: Ifa23ee6520b5238c7de3d5bce7b7bbde02a4a61d
2015-02-14 17:41:22 +00:00
Vladimir Vechkanov 8e045b6ded Change exception thrown by db method
Change exception in db method, because previous one had necessary
parameter which is undefined in db function. The undefined parameter
in the previous exception caused a new exception to be thrown.

Change-Id: I52ccb813d33d7c382f9447252fc5a1017ff625ac
Closes-Bug: #1364394
2014-09-16 04:16:16 -04:00
Andreas Jaeger 8353fd3f38 Transform Exception args to strings when exceptions
Import the following change from Cinder to fix a problem with translated
exceptions.

Co-Authored-By: git-harry <git-harry@live.co.uk>

Author: git-harry <git-harry@live.co.uk>
Date:   Thu Apr 17 10:49:49 2014 +0100

    CinderException args to strings when exceptions

    CinderException message and kwargs are converted to strings if the
    argument is itself an exception.

    Exceptions passed as arguments to CinderException happen in many
    areas
    of the code. This causes an error when oslo.messaging tries to
    serialise
    the exception.

    Change-Id: I1399c939bbca47ab8362ac3bbe0e9a349c6d5572
    Closes-Bug: #1301249

Change-Id: If36f1af0b2e9cc7ec263bdacfe5aa4d49c4c9b85
2014-08-31 07:18:39 +02:00
Andreas Jaeger 9154f3e55b Flake8: Fix E126 and E127
Fix these issues and enable E126 and E127:
E126 continuation line over-indented for hanging indent
E127 continuation line over-indented for visual indent

Also fix a few occurences in the touched files of:
E128 continuation line under-indented for visual indent
H405  multi line docstring summary not separated with an empty line

Partial-Bug: #1333290
Change-Id: If822401fc7e1db49d595a0736a0dff8e00dfd217
2014-08-23 08:43:02 +00:00
Andreas Jaeger 290769f087 Flake8: Fix F401
Fix:
F401 'XXX' imported but unused
Add noqa where needed, remove extra imports otherwise.

Remove F401 from ignore list.

Partial-Bug: #1333290
Change-Id: Ib71f0dd001c4e4899200b5e60b3a38e4a6c40555
2014-08-23 08:42:36 +00:00
vponomaryov 4e5c1847e6 py3.x: Use six.text_type() instead of unicode()
Python 3 doesn't support unicode(), use six.text_type instead.
Partial-Bug: #1284677
Partially-implements blueprint py3-compatibility

Change-Id: I5f66ce70e838fedc955f5284c3c480bc37420107
2014-07-25 06:02:48 +00:00
Julia Varlamova f1f8ca0ad1 Use oslo.db in manila
Use oslo.db library instead of own implementation.

Oslo.db code contains different utils for work with db api, db session,
migrations, test classes for db testing, tools for automatic retry
db.api query if db connection was lost, etc.

Oslo.db code was tested better as it is currently used in many projects,
there will be no need in testing our own implementation.

In many cases our own implementation of work with db duplicates
oslo.db code.

Remove:
- manila/common/sqlalchemyutils.py;
- manila/db/sqlalchemy/utils.py;
- manila/db/sqlalchemy/session.py;
- manila/db/sqlalchemy/migration.py;
- DBError, wrap_db_error, InvalidUnicodeParameter exceptions;
- db_sync, db_version, db_version_control, _find_migrate_repo
function

and replace it with appropriate oslo.db functions.

Add 'joinedload' statement to db queries if necessary.

Fix unit tests, clean up test_migrations.py

Implements bp oslo.db

Change-Id: I48a4da797594cf020f67f78024bd0f86b5abd5ef
2014-07-23 16:26:14 +04:00
vponomaryov 8dd80bdcca Cleaned up exception module and added unittests
Removed unused exceptions and fixed several inheritance
issues, that causes wrong responce codes.

exceptions MigrationNotFound and MigrationNotFoundByStatus
are left, because manila just doesn't have migrations yet.

Change-Id: Icf39422927fc7754c5c47ab717fad178ed44a0dc
Related-Bug: #1325934
2014-06-23 21:02:28 +03:00
Valeriy Ponomaryov ea26ee3c9a Use testtools module instead unittest module
It allows us to use a bunch of skip
decorators, addCleanup method with
2.6 and 2.7 python versions.
Provides more strict usage of setUp
and tearDown methods.

Change-Id: I62144ba43d62e3becb90427d5d6600f97db458df
2014-06-16 09:19:37 +03:00
Christian Berendt 49c880435b change assertEquals to assertEqual
According to http://docs.python.org/2/library/unittest.html
assertEquals is a deprecated alias of assertEqual.

Change-Id: I905d1bd9d3f1273c9724df6d6a36c53772e1a8ed
2014-05-15 13:19:42 +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