LVM: Activate Thin Pool LV upon initialization

If the LVM thin pool is not active, space calculation fails,
as data_percent is not known.  Activate the pool upon initialization,
since we intend to use it anyway.

Slightly refactors _get_thin_pool_free_space so that it is clear
which missing/unexpected value is breaking things if a similar error
occurs for some other reason.

Closes-Bug: #1260773

Change-Id: I7cb187746c1ac297b82254c6efa37ba1c5fbb3e1
(cherry picked from commit 6ccc654a0509c4e308713f9e6fd95266cd112c9d)
LVM: Activate source snap LV when cloning from volume

Similar to the change made in:
01a2199 LVM: Activate source LV before cloning from it

Previous change only fixed this issue for clone-from-snapshot.

This activates the source snapshot LV when cloning from volume
as well, fixing the problem where cloning fails due to inability
to open the source LV device.

Related-Bug: 1252423
Closes-Bug: 1260786

(cherry picked from commit 673057320929d33095c998d477c2537567ccf74b)

Change-Id: If48be8516fd71738cb83a91683c33d02f227b9d6
Add default quota class into DB during migration

For some time now use_default_quota_class has been the
default setting for Cinder.  Cinder, however, has not been putting
any defaults for the default quota class into the database.  This
resulted in any command that queried for the default quotas to cause
the message "Deprecated: Default quota for resource: <resource> is set
by the default quota flag: <quota flag>, it is now deprecated.  Please use
the default quota class for default quota."

This commit resolves this issue by setting the default value for volumes,
snapshots and gigabytes in the quota_class table at migration time if there
is not already a class_name of 'default' in the quota_classes table.

Unit tests are included with this commit.

Closes-bug 1233763
Change-Id: I457ed8a9b78492eda22e31dfc198b2ee051d3ece
(cherry picked from commit 7d2641688454d9064b691e4aab4b5d8b14d75305)
Change RBD delete failure log level to warn

This is a recoverable issue in the backend, so we don't have to provide
the message on the error level.

Change-Id: I35711876b2c088ad28f32abd39248dc9a467d00d
Closes-Bug: #1256259
(cherry picked from commit a2f2a0e0d2f9516d86ef5988e083f70804c3977c)
Fixes HP LeftHand driver with Paramiko 1.13.0

With Paramiko 1.13.0, the method exec_command now returns Unicode.
This causes a problem when the driver tries to build the XML returned
from the LeftHand array. The XML header returned from the array defines
the encoding as encoding=UTF-8. Therefore, we must now ensure the
encoding passed to the parser is utf-8.

closes-bug: #1298608
(cherry picked from commit 57e8cdb9dd8e24919bc2243438a6bded53491b3e)

Conflicts:

	cinder/tests/test_hplefthand.py
	cinder/volume/drivers/san/hp_lefthand.py

Change-Id: I7b504626e2d9a0ee2b62820b11f56eb136e31987
vmware: Fixes create volume from image error

While creating a volume with an image specified as the volume source,
the VMDK driver tries creating the volume backing file on each host
in the inventory (one by one; until any attempt succeeds). However,
if the attempted host is in a bad connection state, the volume
creation fails and results in the volume going into error state.
Effectively, user cannot create a volume from image in such scenario.
This patch catches the VimFaultException during backing file
creation, so that driver picks the next available host for volume
creation.

Change-Id: I8ffdb849f41e8c28137ad8c0fa1f86c54b5e6fe9
Closes-Bug: #1326366
Do not show quota of removed volume types in Default Quotas panel

Fixes the issue where quota for removed volume types still show up
in Admin -> Defaults -> Default Quotas view.

Change-Id: I2a822ac08b8347a8d76e8de70deca0e34fafe6e3
Closes-Bug: #1266906
(cherry picked from commit a7b6d82fd170bc594ceff791eb10b900a61c9175)
Merge "vmware: Fixes create volume from image error" into stable/havana
Merge "Change RBD delete failure log level to warn" into stable/havana
Handle volumes no longer existing in resume delete

init_host resumes deletes for volumes with a status of 'deleting'. It
does these sequentially, and sometimes a volume could be deleted under
it, causing a bad stacktrace. This will gracefully handle those
situations and move on. Added coverage for resume volume delete being
successful as well.

Change-Id: I5b30265609b65804f2da77d9daa84b640de7939c
Closes-Bug: #1322340
(cherry picked from commit b8a064f10a4dad097ef40f401015897cf9b424c3)
Merge "Do not show quota of removed volume types in Default Quotas panel" into stable/havana
Updated from global requirements

Change-Id: Id642f0727039484154628bbb7f9ec5f5eda2f633
Merge "Handle volumes no longer existing in resume delete" into stable/havana
Get updated model info on volume transfer

On some drivers CHAP credentials are tied to accounts
which may be unique for each OS and/or backend Tenant.

For example:
  Volume is created with project_id xyz
  Backend creates an account for xyz with specific CHAP

  Volume is transferred to project_id abc

Currently we don't update the model_info, so even though
on the backend we updated the owner and CHAP settings we
never propogated that back up to the DB object so the volume
can't be used by the new owner.

This patch just adds an option to return model_update
on the accept_transfer call to the driver and updates
the db accordingly.

Also adds a call in the SF driver to actually get the
new model info to be fed back to the manager.

Closes-Bug: #1349475

Conflicts:
	cinder/volume/drivers/solidfire.py

Change-Id: Ie0447cdad69c4fbee99b4b6b1d3cacdfdd14137d
(cherry picked from commit 09f6fe636416ac63e1463d14d469af8f93a6ddf0)
Set python hash seed to 0 in tox.ini

New tox (>=1.7.0) sets a random python hash seed by default. This is
generally good for testing because it will help keep projects working
regardless of the hash seed, but cinder unittests don't currently pass
with a random hash seed so set it to the python default seed.

This change will allow us to use new tox again and remove the
restriction on tox<=1.6.1 to run unittests.

Redundant setenvs for specific test envs are removed to prevent them
from overriding the PYTHONHASHSEED value.

Note this change will need to be backported to the stable branches to
keep unittests there working with new tox as well.

Conflicts:
	tox.ini

Change-Id: Ia55031528d082a1b11da6890447c5584e9e27551
(cherry picked from commit 03293715b1e950cf406018058e4c8a514c0f977f)
Merge "Set python hash seed to 0 in tox.ini" into stable/havana
Merge "LVM: Activate Thin Pool LV upon initialization" into stable/havana
Merge "Fixes HP LeftHand driver with Paramiko 1.13.0" into stable/havana
Merge "Add default quota class into DB during migration" into stable/havana
Fix solidfire accept_transfer

Previous fix has a mistake which makes the situation worse.  This change
fix volume['project_id'] and volume['user_id'] and adds unit test for
accept_transfer.

Closes-bug: # 1349475

Conflicts:
	cinder/tests/test_solidfire.py

Change-Id: I7b2bcefa4c8d173689cc63ee5aa9e00397c7f8ca
(cherry picked from commit 5dbdb11e8d8659a6b823c9552052b443050886ca)