Commit Graph

32 Commits

Author SHA1 Message Date
Eric Harney e28e1a2f41 Move trace methods from utils to volume_utils
This continues moving code only used by volume
drivers or the volume manager to volume_utils.

The result of this is that fewer drivers import
cinder.utils (and everything it imports), and less code
is loaded by non-volume cinder code (api service,
cinder-manage, etc.)

Closes-Bug: #1912278
Change-Id: I5aa82cf0de4c70f53ddc998bf25e64f4ad8f5774
2021-02-12 20:16:55 +00:00
Eric Harney de789648e5 Rename volume/utils.py to volume/volume_utils.py
Much of our code renames this at import already --
just name it "volume_utils" for consistency, and
to make code that imports other modules named "utils"
less confusing.

Change-Id: I3cdf445ac9ab89b3b4c221ed2723835e09d48a53
2019-09-09 15:00:07 -04:00
yenai 6f93d64ff0 Add empty check before using zone driver
When initiator_target_map is {}, it really means we don't need to
do anything with zone driver.

Change-Id: I1cb1e7b38fb24624d5a0aeb9d5f31e4b008128a9
2019-02-14 09:47:08 +08:00
Walter A. Boring IV 3b28cb2a10 FC: refactor fczm utils decorators to functions
This patch changes the Fibre Channel Zone Manager
utility decorators to functions.   Those functions
now have to be called manually.   The intention of this
is to unify how the FC drivers are to be declared and
used vs. the iSCSI.  No more magic decorators for FC
drivers only.

Change-Id: I8e6e964e3694654b8ba93fe432a0dd49fa5e1df0
2018-04-16 16:23:59 -07:00
Gorka Eguileor 43b1209f2a Fix: Incorrect replication status on clusters
When running a replicated service in a cluster, the replication_status
field in the Cluster DB table doesn't get updated in some cases, making
the cluster look like it's non replicated:

- When starting a new clustered replicated service cluster.
- When enabling replication on an already clustered service.

The reason for that is that the service and cluster creation happens on
the Service's __init__ method, while the replication status isn't known
until later, when the start method in the service calls the manager's
init_host_with_rpc, where the manager updates the service DB entry.

This patch adds an update for the replication field to the cluster table
in that same place, making sure we have the right data.

Closes-Bug: #1758024
Change-Id: I0d2fded62372a2fc5f49538133c5b66694dccc77
2018-03-22 12:01:40 +01:00
xing-yang 32e67f3119 Tiramisu: Add groups param to failover_host
failover_host is the interface for Cheesecake.
Currently it passes volumes to the failover_host
interface in the driver. If a backend supports both
Cheesecase and Tiramisu, it makes sense for the driver
to failover a group instead of individual volumes if a
volume is in a replication group. So this patch passes
groups to the failover_host interface in the driver in
addition to volumes so driver can decide whether to
failover a replication group.

Change-Id: I9842eec1a50ffe65a9490e2ac0c00b468f18b30a
Partially-Implements: blueprint replication-cg
2017-07-10 09:30:13 -07:00
junboli aea33343c6 Use SnapshotStatus enum field
The SnapshotStatus and SnapshotStatusField have been defined already, This
change just replace the omissive snapshot status string with snapshot enum
field.
Follow up https://review.openstack.org/#/c/284825/

Change-Id: I175398bcad863eaead8b35095d7ff84f9f63aadb
Partial-Implements: bp cinder-object-fields
2017-07-03 13:44:23 +00:00
xing-yang 18744ba199 Tiramisu: replication group support
This patch adds support for replication group.
It is built upon the generic volume groups.
It supports enable replication, disable replication,
failover replication, and list replication targets.

Client side patch is here:
    https://review.openstack.org/#/c/352229/

To test this server side patch using the client side patch:
export OS_VOLUME_API_VERSION=3.38

Make sure the group type has group_replication_enabled or
consistent_group_replication_enabled set in group specs,
and the volume types have replication_enabled set in extra specs
(to be compatible with Cheesecake).

cinder group-type-show my_group_type
+-------------+---------------------------------------+
| Property    | Value                                 |
+-------------+---------------------------------------+
| description | None                                  |
| group_specs | group_replication_enabled : <is> True |
| id          | 66462b5c-38e5-4a1a-88d6-7a7889ffec55  |
| is_public   | True                                  |
| name        | my_group_type                         |
+-------------+---------------------------------------+

cinder type-show my_volume_type
+---------------------------------+--------------------------------------+
| Property                        | Value                                |
+---------------------------------+--------------------------------------+
| description                     | None                                 |
| extra_specs                     | replication_enabled : <is> True      |
| id                              | 09c1ce01-87d5-489e-82c6-9f084107dc5c |
| is_public                       | True                                 |
| name                            | my_volume_type                       |
| os-volume-type-access:is_public | True                                 |
| qos_specs_id                    | None                                 |
+---------------------------------+--------------------------------------+

Create a group:
cinder group-create --name my_group my_group_type my_volume_type
cinder group-show my_group

Enable replication group on the primary storage:
    cinder group-enable-replication my_group
Expected results: replication_status becomes “enabled”.

Failover replication group to the secondary storage.
If secondary-backend-id is not specified, it will go to the
secondary-backend-id configured in cinder.conf:
    cinder group-failover-replication my_group
If secondary-backend-id is specified (not “default”), it will go to
the specified backend id:
    cinder group-failover-replication my_group
--secondary-backend-id <backend_id>
Expected results: replication_status becomes “failed-over”.

Run failover replication group again to fail the group back to
the primary storage:
    cinder group-failover-replication my_group
--secondary-backend-id default
Expected results: replication_status becomes “enabled”.

Disable replication group:
    cinder group-disable-replication my_group
Expected results: replication_status becomes “disabled”.

APIImpact
DocImpact
Implements: blueprint replication-cg

Change-Id: I4d488252bd670b3ebabbcc9f5e29e0e4e913765a
2017-04-30 22:49:13 -04:00
Arnon Yaari e01f24fe3b Rename AddFCZone and RemoveFCZone according to PEP 8
The project adheres to PEP 8, so decorators should be named
with underscores (like functions) and not with upper camel
case (like classes)

Change-Id: Ifa38e5d327c2b1a2cdd77ceb2cbc2a9be468bce8
2017-01-09 11:22:19 +02:00
Ivan Kolodyazhny adcc5c7ff0 Add logging to FakeLoggingVolumeDriver
Now each method is wrapped with utils.trace_method to get logs during
tests and debugging if needed.

Change-Id: I2d84716eeb2a528bc2d0cb230fda051704a32737
2016-11-29 14:25:36 +00:00
xing-yang 642a1c7014 Add functional tests for groups
This patch adds functional tests for groups. It includes the
following tests:

- Create and delete a group
- Create and delete a group snapshot
- Create a group from a group snapshot
- Create a group from a source group
- List and show group and group snapshot

Partial-Implements: blueprint generic-volume-group
Change-Id: If6b139c70e1996ed8db8ea5dff21501adee0f857
2016-07-21 20:46:33 -04:00
Ivan Kolodyazhny f5fa8c73f0 Merge two fake drivers into the one FakeLoggingVolumeDriver
Two different fake drivers for unit-tests look confusing. We are able to
test anything we want with only one fake driver.

Current LoggingVolumeDriver doesn't actually log anything. It just
stores all drivers actions in a list.

Now, we can add real logging to FakeLoggingVolumeDriver and use it both
for unit and functional tests.

It's a first patch in a series for unit tests refactoring. More manager
and LVM driver tests will be proposed in a following patches.

Change-Id: I383bcdb531c7d52c0fdbb6875de73f1274a92854
2016-09-09 14:37:21 +00:00
John Griffith 9286ab42ab Move fake_driver to tests root dir
The fake driver is now being used for both unit and
functional tests.  It also now has a FakeGate driver to
add some things that aren't supported by all drivers
(including the reference as well as ceph and others).

This patch just moves the fake_driver.py file from
tests/unit to tests as it's not specifically a unit test
object.  This isn't a big deal, but makes things a bit more
clear and obvious that there's a useful fake that can be
used in a number of places.

Some of the other fakes could likely be moved as well, but
this one is a start.

Change-Id: Ia5e8608832c0753a4ced8690fa285184c5b8c0c1
2016-07-26 09:08:43 -06:00
John Griffith cbcbc90cf6 Move unit tests into dedicated directory
This patch moves all of the existing cinder/tests into
cinder unit tests.  This is being done to make way for
the addition of cinder/tests/functional.

Yes, this is going to cause significant pain with
any changes that haven't merged behind it in terms
of rebase, but there's no real alternative.  We have
to rip the band-aid off at some point, and early in L
seems like a great time to do it.

Change-Id: I63b0f89474b3c139bdb89589abd85319d2aa61ec
2015-04-21 18:40:40 -06:00
Ivan Kolodyazhny 5980da5d88 Use oslo.log instead of oslo-incubator
log module was removed from oslo-incubator after oslo.log released.

Change-Id: I205d0625c502cb462919edc76d12091edcc21b1b
Implements: blueprint port-oslo-incubator-to-oslo-log
Partial-Bug: #1381563
2015-03-11 21:45:04 -05:00
Anton Arefiev 753f83cd17 Import only modules: H302
H302 PEP8 check should be enabled to make core more clean
and readable and consistent with OpenStack Hacking rules.

Change-Id: Ie189f2418d12800a46664705eacfc127e7269f45
Partial-Bug: #1407162
2015-02-25 11:50:09 +02:00
John Griffith 9651f54714 Transition LVM Driver to use Target Objects
This patch refactors the LVM Driver to take a
seperate Target object instead of mixing the
control and data path implementations inside the
driver itself.

It removes the volume/iscsi.py and brick/iscsis/*
files which were duplicating code and actually
very messy in terms of where calls were actually
being implemented.

Change-Id: I43190d1dac33748fe55fa00f260f32ab209be656
2015-01-02 13:13:42 -07:00
Mike Mason 9ad858c9c9 Implementing the use of _L’x’/i18n markers
Placing the _Lx markers back into the code. No other cleaner solution has
has been implemented. Patches will be submitted in a series of sub
directories and in a fashion that is manageable.
eighth commit of this kind
This is the last run through to pick up the ones that were missed

Change-Id: Ifd9d647175a840939bf01fa3bcecfa6384965e3b
Closes-Bug: #1384312
2014-12-09 10:03:29 +00:00
James Carey ac33ad9ec9 Use oslo.i18n
oslo.i18n provides the i18n function that were provided by
oslo-incubator's gettextutils module.

Change-Id: I1f361a8321fb02f03b4f3f3e2ef688fcf19514a3
2014-08-08 17:26:41 -05:00
Jay S. Bryant eafcc41e82 Explicitly import _() in Cinder code
To ensure that logs are properly translated and logged to
the Cinder log files (using the Cinder message catalogs)
we need to explicitly import _() in any python files that
use the _() function.

Closes-bug: 1306275
Related-Blueprint: i18n-enablement
Change-Id: I3cf1f1d63d5f8bd8ffd007104691f914e3fd8538
2014-07-16 23:41:05 -05:00
Walter A. Boring IV 824de4a01d Ensure FC ZoneManager is called
This patch ensures that the FC ZoneManager
is called during for all cases in Cinder
that does a volume attach/detach for FC
enabled drivers.
The problem was that we had code in the volume
manager that manually called the ZoneManager,
after initialize_connection and terminate_connection,
but other places in Cinder were not calling the
ZoneManager.
This patch creates 2 new decorators that can
be used for any driver's initialize_connection
and terminate_connection call.   The decorator
checks to make sure that the return value is for
a fibre_channel attachment and then calls the
ZoneManager's add_connection or delete_connection.
Change-Id: Ie3ae70785f500a140003ad3a8495e0ddc3516ea8
Closes-Bug: 1321798
2014-07-07 16:19:03 -07:00
Christian Berendt 5061ab9586 debug level logs should not be translated
According to the OpenStack translation policy available at
https://wiki.openstack.org/wiki/LoggingStandards debug messages
should not be translated. Like mentioned in several changes in
Nova by garyk this is to help prioritize log translation.

This patch adds a new hacking check - N319 - that ensures all
debug log messages don't have translations.

Change-Id: Id9c2715f25c8f2ea52235aba4bd1583655391584
Implements: blueprint debug-translation-removal
Closes-Bug: #1318713
2014-06-18 09:03:02 -06:00
Dirk Mueller 45a3b4471d Changed header from LLC to Foundation based on trademark policies
Fixes: Bug 1214176

Change-Id: Ieda1a75992abec647c267faa7727f5da4f7a88a3
2013-09-10 17:26:42 +02:00
Zhi Yan Liu 900851ffe3 Adding Read-Only volume attaching support to Cinder
1. Adding an API extension to allow clients set volume Read-Only flag on
demand.
2. Require client to provide and be aware of volume attaching mode when
they call 'os-attach' API.
3. Adding a 'access_mode' field to connection info which
'os-initialize_connection' API returned. This field should be used by
client such as Nova to use correct mode accessing attached volume.
Currently access mode can be 'rw' or 'ro'.
4. In future, the driver within Cinder need to ensure the volume be
exposed under the correct access mode which connection info described,
for example backend should set volume to readonly mode when connection
info ask client using 'ro' access mode consume attached volume. That
means Read-Only is not only a attaching mode but also a status for a
volume.

blueprint read-only-volumes

Change-Id: I4c84614d6541d5f7c358abadb957da7b8c3d9c48
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2013-08-29 01:25:19 +08:00
Jenkins e0048c6924 Merge "Fix python 3 pep8 errors for print" 2013-08-22 21:23:26 +00:00
John Griffith 878ac164a3 Fix python 3 pep8 errors for print
The new auto-pulled requirements files exposed
python 3 compat issues in a number of modules.
We added these to tox.ini ignore temporarily,
this change updates the print routines in bin/cinder
and removes the debug cruft that was in the unit tests.

Will update requirements and test-requirements
appropriately in a follow up patch.

Change-Id: I76ea24f4dc1f61c4f8a1d202b0554c90daf2c9cc
2013-08-21 16:59:22 -06:00
John Griffith b69990682b Refactor LVM driver to use Brick VG utility
Refactor the LVM driver to utilize bricks LVM
module.  This includes significant modification to
tests and fake objects related to testing.

implements blueprint: refactor-lvm-and-iscsi-driver

Change-Id: I94e41abf90d0c5b77e732d40ed8b81b0a2f5d7dd
2013-08-16 16:45:52 -06:00
Shlomi Sasson 1dd09a955b Adding support for iSER transport protocol
DocImpact

Implements: blueprint add-iser-support-to-cinder
Change-Id: I55fb7add68151141be571cb9004389951851226b
2013-08-05 16:17:36 +03:00
Pádraig Brady bb06ebd0f6 support a configurable volume wiping method
Add a clear_volume() method that is called from delete_method().
This is only implemented at present for the base LVM driver.
This new clear_volume() method now supports these config vars:

  volume_clear = none, zero, shred
  volume_clear_size = size_in_MiB

'zero' is the default method and unchanged from previously.
'none' is used if security isn't a concern, or there is
  independent volume scrubbing.
'shred' is for more security conscious situations where
an overwrite count is required. Currently this defaults to 3 passes.

size_in_MiB can be used to limit the cleared area to the first
part of the volume, which can greatly speed up the operation,
and can be useful with encrypted volumes for example where
overwritting the encryption keys at the start is sufficient.

Fixes bug: 1022511
Change-Id: I7312678ff5d66156578501483a1b74e2a69e19a0
2013-01-15 16:26:59 +00:00
Avishay Traeger 5f41390dde Factor out LVM code.
Currently volume drivers inherit from VolumeDriver and ISCSIDriver,
which contain LVM-specific code. The LVM-specific functions are
generally overridden. The problem is that there is no place for
generic code for all drivers to inherit, which the LVM driver can
override. This patch basically makes the VolumeDriver and ISCSIDriver
classes mostly empty and moves the LVM-specific code to lvm.py. Also,
moved the global _iscsi_location() and _iscsi_authentication()
functions into the new LVMISCSIDriver class since nobody else used
them.

Change-Id: I067c975de97913bdc39086ad203cddef0c393c7a
Implements: blueprint factor-out-lvm-code
2013-01-13 08:28:19 +02:00
clayg 956731973e Add admin only action for force detach
This action calls the same methods nova would after it successfully
detaches a volume.  By exposing it to the administrator it makes it's
easier to repair un-syncronized state between services.  Generally when
the host is no longer attached, but the volume state is wrong.

Future work: The Iscsi based drivers don't seem to use
initialize_connection and terminate_connection to create the export for
the volume.  This would be more useful with drivers that do that.

I added the force parameter to terminate_connection for drivers that may
want to differintiate between a normal terminate and the force detach.

Future Nova work:  Nova will want an admin action to update the bdm
tables - today it's a bit of nova-manage shell work.

Change-Id: Icc1cff0f50a5ace9ebdae62c85524ee8d6ec23e0
2012-11-07 12:09:48 -06:00
Nirmal Ranganathan bad23ceff8 Splitting out volume drivers in driver.py
Moved RBDDriver, SheepdogDriver into their own respective driver
files under cinder/volume/drivers/*. Moved FakeISCSIDriver and
LoggingVolumeDriver into a fake driver file under the tests,
since that's the only place where those are used.

Implements bp driver-cleanup

Change-Id: I39d91ac8e498a9e42c5443db16706203b988444b
2012-11-06 20:22:45 -07:00