Remove rootwrap module

We use oslo.rootwrap now.

Change-Id: I4534ed17499909287df3707441c4a69e35ac509b
Fix retyping attached volumes requiring migration

Modifies retype method so that volume db entry only updated if the
volume isn't migrated.

The migrate_volume_completion method is made responsible for detaching
the old volume and attaching the new one. This takes the requirement
from nova because the calls need to be done in a certain order which
isn't guaranteed when performed by nova.

attach_volume now marks the migration_status as complete because it is
the final action by cinder.

Change-Id: Ia15636893be4f0077a4f75e746a8ab1a8798c44b
Partial-Bug: 1316079
Don't use ModelBase.save() inside of transaction

'with session.begin()' makes some operations in one transaction.
session.begin() returns a transaction instance, then does some operations,
and will commit or rollback automatically before leaving the block.
ModelBase.save() always submit a commit, and that is not expected.
When we get a persistent object from database, we just modify the
object inside of block 'with session.begin()' and sqlalchemy will
update it, don't need method session.add() or ModelBase.save().

Closes-Bug: #1224429
Change-Id: I4af58e98b2783d3945d92e57680d58e7ae356a67
Fix docstring for snapshots API

For some reason, the snapshots controller class' introductory
docstring stated that it was the volume API controller.
This patch changes it to say:
"The Snapshots API controller for the OpenStack API."

Change-Id: I8c9827939bbc7acf93282db854a40501f3fea399
Support Volume Num Weighter

Currently cinder support choosing volume backend according to
free_capacity and allocated_capacity. Volume Num Weighter is
that scheduler could choose volume backend based on volume number
in volume backend, which could provide another mean to help
improve volume-backends' IO balance and volumes' IO performance,
see details in ref [1] and [2].

blueprint support-volume-num-weighter

Ref:
[1]https://blueprints.launchpad.net/cinder/+spec/support-volume-num-weighter
[2]https://review.openstack.org/#/c/99683/

Change-Id: Id9275ed954f1b35ee8d7bee0f0b61cc3a7c48f63
Only warn about deprecation warnings once

Instead of repeatly emitting data about which
modules are deprecated again and again just warn
about those deprecation once and then never warn
about them again.

This is a good thing to have, and will be needed
as taskflow moves one of its classes used in cinder
to a new and longer-term location and will emit
deprecation about the usage of the old location.

Change-Id: I962f9bab920a03eca235c9e4591d367687e44954
Add cinder-manage cmd to update host column

If you deploy Cinder as per the default using the docs,
you can't later decide to add backends using the
multi-backend functionality. The reason is that multi-backend
is implemented by appending a backend-name to the host entry.

So if you convert the config to multi-backend the hostname
for any volumes that you have created are no longer
associated with a valid volume-driver (ie you can no
longer perform operations including delete on these
volumes).

In addition, in the case of using a SAN attached backend if
one redeploys their cinder-volume service to another node
they'll have the same issue.

This patch adds a cinder-manage command that will go through
volumes that are located on a specified host and update
the host column on each of them.

Change-Id: I8758fb8ef3fccbba2a598240c42d625b997e2db6
Closes-Bug: 1320688
Ensure rbd connect exception is properly caught

If the rbd driver fails to connect to Ceph the exception
was not being properly caught resulting in the volume
remaining in the 'creating' state until the corresponding
task eventually times out (on top of the time it took
for the connect to fail).

Also added config option for rados connect timeout.

DocImpact: new config option 'rados_connect_timout'
Closes-Bug: 1211839
Change-Id: I5e6eaaaf6bed3e139ff476ecf9510ebe214a83f9
3PAR Only remove FC Zone on last volume detach

This patch checks to make sure that we don't
include the initiator_target_map in the return
of terminate_connection if there are volumes
still attached for a particular host.  The
FibreChannel ZoneManager doesn't remove zones
if there isn't an initiator_target_map in the
return of terminate_connection.

Change-Id: I98db5adb6da38454933a6e4b78085193f1d37680
Partial-Bug: #1308318
Merge "Add cinder-manage cmd to update host column"
Add optional_args to fix Volume Import failure

Commit 971a63bd9cf675a00bce1244ec101577b5c17cac added a new
parameter 'optional_args' to execute method of QuotaReserveTask
and QuotaCommitTask. So the new parameter should be needed where
those Tasks are used. This changed volume create task flow to
provide the new parameter. We need the samiliar change to get_flow
method in cinder/volume/flows/manager/manage_existing.py

Trigger EMC VNX CI

Change-Id: Ifed7bd146eec82ba35c2b2c19e9bacd2259ae3ed
Closes-Bug: #1334086
Merge "Don't use ModelBase.save() inside of transaction"
Merge "Add optional_args to fix Volume Import failure"
Fix host option isn't set when using multiple backend

When using multiple volume backend, and volume driver is
cinder.volume.drivers.block_device.BlockDeviceDriver, host
option isn't set so a call to get volumes of a host returns none,
This patch changes to use self.host instead of self.configuration.host

Change-Id: Ide34ed29adad14b778b1a7388e9dc313241fa243
Closes-Bug: 1332909
Merge "3PAR Only remove FC Zone on last volume detach"
Merge "Ensure rbd connect exception is properly caught"
Merge "Fix docstring for snapshots API"
Restore osapi_volume_workers config option

osapi_volume_worker was introduced when enabling multi-process API
support for Cinder. However, this config option was accidentally
dropped in commit 464277220ddb800ac69562649fde62e5ca9358c4
(https://review.openstack.org/#/c/67657/20/cinder/service.py).
As a result, the value in cinder.conf wouldn't be honored.  This
change restore this config option.

Closes-bug: #1335295

Change-Id: Ib2d8532d3e6d0f48da0bc4dd6f6e64bfff8973ea
Merge "Remove rootwrap module"
Replace tearDown with addCleanup - Part 3

Replace tearDown with addCleanup in some cinder unit tests.

Infra team has indicated that tearDown should not be used and should
be replaced with addCleanup in all places.

Implements blueprint replace-teardown-with-addcleanup

Change-Id: I8469ffb5c896d40f9979cd6d1f8da81be763ec14