Fix incorrect root partition size and compatible volume name

When using rbd backend, it needs to resize volume size if size presents. Else
we will get wrong image size.

Rbd volume always uses uuid as the main pattern of volume name, now change to
it is necessary.

Fix bug 1219658

Change-Id: I3dc8d639b066eac35d190b8d4687c41c9f4d5824
Remove compute_api_class config option

This option was deprecated in Havana and can now be removed.  Its only
use was for changing out the API class if cells was in use.
Technically, it used to be possible to configure an arbitrary compute
API class.  However, that would have been an unsupported setup, and has
been completely broken since 9f902c7e17249cf5af1504f31d80c0247a02fe20
anyway.

As a part of this change, the cell_type configuration option needed a
default value.  I set it to 'compute'.  My reasoning was that you would
have more compute cells than API cells, so might as well set it to the
more common case.

Change-Id: I5ec44f84267a700da16b350e686eee886e0d1183
fix missing host when unshelving

An instance has the hostname of the host on which it is running.
The hostname is deleted when shelving. However, the hostname is not
recreated when unshelving.

This patch sets the hostname when unshelving.

Change-Id: I2e431718198321c46b9335e6fb7ab7be3943fab6
Closes-Bug: #1237868
Check for None when cleaning PCI dev usage

The PCI manager needs to check for instance UUIDs mapped to
None when cleaning up it's internal claims/allocations maps.

Also adds a check so the claims dict doesn't map to None in
the first place.  There was already a check like this when
setting a value in the allocations dict.

Closes-Bug: #1238374

Change-Id: I7ac010f7d50ad85c145e536cfd48e07c8f4602d3
Sanitize passwords when logging payload in wsgi

adminPass (or admin_pass) can be either part of a json object or
an xml element or xml attribute. The patch includes
regexps to support all these cases and adds tests
as well

Change-Id: Ic119f986a03863c1d13b566b4c005f3bc77d83d0
Closes-Bug: 1231263
Handle MarkerNotFound better in Flavor API

When the specified marker is not found, we should catch the
MarkerNotFound exception and respond with a HTTP 400 Bad
Request with sufficient information back to the user. This
will avoid spilling unwanted tracebacks in the logs as well.

Change-Id: I90a658384f8814096271a193a0f3abd028062b5d
Partial-Bug: 1238519
xenapi: stop agent errors stopping build

We should still report agent errors, but they should not stop a server
from building, because that server still may be ready to use.

Once this change is in place, we can look to selectively add back in
certain errors that fail the build, as we decide what makes sense on a
case by case basis.

Fixes bug 1233548
Change-Id: I32b9e8dbc6e28a045ac8ef159afe1cf74b7ac6fb
Use `versionutils.is_compatible` for Dom0 plugin

Related-Oslo-Commit: d7d74a752e34d5249fa47c8e8252da491d46012a
Change-Id: Iffb19f186fe2b239361fc342de0042acfa5e098d
Send notifications on keypair create/delete

A service external to Nova may wany to know when users add or delete
keypairs.  This patch adds create and delete notifications to the
KeypairAPI.

Implements blueprint keypair-notifications

Change-Id: I8e0d74e73b1980689c11d9e3567b9883018951cc
Fix scheduler rpcapi deprecated method comment

A comment was added for 2.10 about deprecating a method.  It's not
necessary to bump the version... and the manager side wasn't bumped.
It's still at 2.9.

Just remove the reference to the 2.10 version.

Change-Id: I52857f5a2e472dbdf13b9b6a51a9e8f401ea6452
Fix i18n issue for nova/virt/baremetal/virtual_power_driver.py

There are some log messages in virtual_power_driver.py does not
support i18n, we need to update code to support it.

Closes-bug: #1228449

Change-Id: I6642309bd0e08e356a13d134ac0c743159af2520
Adds V3 API samples for attach-interfaces

Adds api sample tests and api samples for attach interfaces

Partially implements blueprint v3-api-unittests
Partially implements blueprint v3-api-specification

Change-Id: I54088cca1b83a8b92620062840606f2340a528c9
Fix DB API mismatch with sqlalchemy API

We added a sqlalchemy columns_to_join argument to the
security_group_get_by_name() method, but didn't punch it through
the toplevel DB API. This patch adds that so that they match.

Change-Id: I6fe8d876834036e6fbd79d60f3d7d696d7cf4b83
Make SecurityGroup receive context

This fixes the SecurityGroup._from_db_object() method to take and set
a context, like most everything else.

Change-Id: Ie86df2cf264a1e75353599a8f9f693ef5fb15bc5
Fixes Hyper-V snapshot spawning issue

In Hyper-V, snapshoting an instance and then spawning a new
one using the resulted snapshot image with the same flavor,
will result an Hyper-V Exception.

Hyper-V will get the request to resize the base image to it's
actual size, leading to an error.

The reason is that the logic of the resize_vhd method has been
changed, as it is meant to resize images to the flavor size minus
the image metadata size, thus it's maximum internal size. For this
reason, the way to decide whether the root image should be resized
or not must also be changed.

So, instead of comparing the root image and base image sizes,
we should compare their maximum internal sizes.

Closes-Bug: #1234759

Change-Id: I83d2df76b726d705cedc52a8309a2be7037d6a79
Fixes datastore selection bug

Currently the vmwareapi drivers will only select the first
available datastore it finds, even when there are other
datastores with capacity, it will fill one datastore completely
and then die.

Closes-bug: 1227825

Change-Id: I24f85114ea3f014950c27c0c91a6be352990d263
xenapi: speedup test_wait_for_instance_to_start

Speed up the above test by mocking out greenthread.sleep

Change-Id: Ie5637842bade28d7ed01cbfe39ed2a46edc6e919
xenapi: Speedup vm_util and vmops tests

* Uses NODBTestCase in more places

* Also, adds VMUtilsTestBase so that all new test cases in test_vm_utils will,
by default, not use the database.

Speed up observed from running:

nosetests nova/tests/virt/xenapi/test_vm_utils.py
          nova/tests/virt/xenapi/test_vmops.py

BEFORE: Ran 113 tests in 7.674s
AFTER: Ran 113 tests in 1.873s

Change-Id: Id05ecac90201fba27cbae7480d3119cacd92ec24
xenapi: test_driver should use NoDBTestCase

Change-Id: If75d924accb50dca3cc393c32ddcb9128604fa88
Fix the image name of a shelved server

The shelve feature powers a server off, and creates a snapshot of the
server. The snapshot image name is "instance-XXXXXXXXX-shelved" and it
doesn't contain a server name like the following:

  $ nova list
  +----+------+--------+------------+-------------+------------------+
  | ID | Name | Status | Task State | Power State | Networks         |
  +----+------+--------+------------+-------------+------------------+
  | .. | vm01 | ACTIVE | None       | Running     | private=10.0.0.5 |
  +----+------+--------+------------+-------------+------------------+
  $ nova shelve vm01
  $ nova image-list
  +----+---------------------------------+--------+--------+
  | ID | Name                            | Status | Server |
  +----+---------------------------------+--------+--------+
  | .. | instance-00000004-shelved       | ACTIVE | ..     |
  +----+---------------------------------+--------+--------+
  $

"instance-XXXXXXXXX" is OS-EXT-SRV-ATTR:instance_name, and a non-admin
cannot see it.

This patch changes the name to "<server name>-shelved", so that a non-
admin user can know the server name of a shelved image:

  $ nova image-list
  +----+--------------------+--------+--------+
  | ID | Name               | Status | Server |
  +----+--------------------+--------+--------+
  | .. | vm01-shelved       | ACTIVE | ..     |
  +----+--------------------+--------+--------+
  $

Closes-Bug: 1232991

Change-Id: Idc73658e29cb77dfcc8b046535a36affc1831605