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
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
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
Cells: Fix instance deletes

A regression was introduced with object conversion that caused all
instances to be locally deleted in the API cell when cells is enabled.
This would happen before the child cell was told to delete the instance.

Additionally, if an instance record was created in a child cell but
failed to schedule to a host in such a way that the API cell has
no knowledge of the 'host', the instance would be deleted in the API
cell only.

Also, it appears that we would cast deletes to child cells twice due to
logic duplicated in cells_api.py that exists in api.py.

Closes-Bug: #1240247

Change-Id: I94cfddd9cef2d63b2cb31c0f2dae8e211a4418d9
Remove duplicated test cases

The class ServersControllerCreateTest has the following duplicated
test cases since I091f14a9753059d759ba2f7b05ff33f5abea0f00 :

 * test_create_instance_with_config_drive_disabled
 * test_create_instance_local_href
 * test_create_instance_admin_pass_empty
 * test_create_instance_invalid_personality
 * test_create_location

This patch removes the duplicated test cases.
In addition, this removes the bookhref of test_create_location() also,
because it is not used.

Change-Id: I218d5ff443d4dbcec7520eab0b42e77fbd30eba8
powervm tests: replace assertEquals with assertEqual

In Python 2.6, both assertEqual and assertEquals are
convenience aliases to failUnlessEqual.

In Python 3, failUnlessEqual is explicitly deprecated.

This is part of blueprint assertequal

Change-Id: I978f61e5340ea554ec81118d8d282d10e28fe00d
Add CIDR field type

This field type provides a strong verification that a value
assigned to a CIDR field is valid. This will be used for
the SecurityGroupRuleObject to follow.

Related to blueprint compute-api-objects

Change-Id: Ib62a515eea563da3107a3aed516a51d0ff55ba35
Merge "Fix the image name of a shelved server"
Updated from global requirements

Change-Id: Ica7315effe308bd739e90f885849fac27a3c542b
Updates OpenStack Style Commandments link

The current link in the HACKING file is broken. This references the
correct location for contributors to view.

Change-Id: I3cd4841035400d09a3e3e3369bb3a2a8c4bdee30
A nicer calling convention for object instantiation

This patch makes the base object constructor take some arguments
to streamline the process of creating a new object. By taking
a context and an optional set of keyword args, we can reduce
the lines of code required to create an object from many to, often,
one.

Change-Id: Id85c70d04af500ece48e9c93ee55a8e3d579299d
Merge "xenapi: speedup test_wait_for_instance_to_start"
Merge "xenapi: Speedup vm_util and vmops tests"
Merge "Updates OpenStack Style Commandments link"