Scheduler: remove test scheduling methods that are not used

The test code no longer uses the following methods:
 - fake_get_group_filtered_hosts
 - fake_get_group_filtered_affinity_hosts

This patch removes those methods.

Change-Id: I0a005fb1301ce78cc2ec365429015c08d58f446e
Ignore errors when deleting non-existing vifs

If an instance fails during its network creation (for example
if the network-vif-plugged event doesn't arrive in time) a
subsequent delete will also fail when it tries to delete the
vif, leaving the instance in a Error(deleting) state.

This can be avoided by including the "--if-exists" option to
the ovs-vsctl command so that the command doesn't fail if the
vif doesn't exist.

Change-Id: Ic613c9d6e0619f51fcd931e62f6d6bce404ebe81
Closes-bug: #1308544
Fix wrong quota calculation when deleting a resizing instance

When deleting a resizing instance that has not yet finished resizing,
quotas should be adjusted for the old flavor type. Instead it
incorrectly use values from the new flavor.

This was previously fixed in bug 1099729, but has since resurfaced
with the change to use objects in delete methods.

Change-Id: I9bc68abc0d86784c642483dd0cc46c6b9c6a0c69
Closes-Bug: #1277422
Fix CIDR values denoting hosts in PostgreSQL

We use PostgreSQL INET type to store both hosts IP addresses
and CIDR addresses of IP subnets. PostgreSQL actually has
INET and CIDR data types, which work a bit different.

The one thing they are different at, is the representation of
retrieved values denoting a single host in IP subnet (i. e. an
IP address followed by a netmask which has a value of /32 for
IPv4 address and /128 for IPv6 appropriately): if such value
is stored in column of type INET, it will be returned by SELECT
without a netmask part, so instead of 37.37.37.37/32 one will
receive 37.37.37.37.

For more details, please see:
http://www.postgresql.org/docs/8.2/static/datatype-net-types.html

While existing behaviour is completely OK, it depends on DB backend
which is used. To ensure, that CIDR values denoting a single host in IP
subnet, have the same representation in spite of chosen DB backend,
an SQLAlchemy model hook is provided, which adds a netmask value of /32
or /128 for retrieved values of IPv4 or IPv6 addresses appropriately.

Blueprint: db-api-tests-on-all-backends
Co-Authored-By: Roman Podolyaka <rpodolyaka@mirantis.com>

Change-Id: If36f0f9133b6c7cc6f20ba189a9f5b65001811d1
Mask block_device_info auth_password in virt driver debug logs

The block_device_info object can have an auth_password key which is
getting logged at debug level in several virt drivers so we need to
sanitize the message getting logged.

Adds tests to ensure the logged messages are properly sanitized.

Note that bug 1321785 was opened to track the long-term design issues
with storing the password in the block_device_info dict since this can
crop up elsewhere if it's logged.  The immediate fix here is to mask
what's already exposed.

Closes-Bug: #1319943

Change-Id: I0eae07ce3f0f39861eb97ec3dec44895386c7d04
Align internal image API with volume and network

First part of standardizing the nova internal image API with the API
objects for volume and network. This patch creates a nova.image.api.API
object that matches the signature of nova.network.api.API and
nova.volume.cinder.API for CRUD operations on image records. The
existing unit tests were enough to fully cover the new code paths, since
much of this patch simply aligned the internal image API calls and API
object with that of the other submodules.

The next in this patch series will work on cleaning up the remainder of
places in nova that directly call on nova.image.glance methods, as well
as the untouched download/upload handling.

Change-Id: I67e7c9d841e5bad82cdca8f7048eaa57f0cfbb2f
Partially-implements: blueprint standardize-nova-image
Catch missing Glance image attrs with None

Glance is known to drop values from its response if they don't resolve to true.
 Previously in I67b7dd16a94fe60d873c012f6bd246ab24500d5a the None catch was
 removed as this WILL cause a call to glance for missing value and
 optimizations where made to attempt to pre-cache values that can be missing
 in expected ways. However there are still situations that can't be optimized.

Notably this can occur with disk_format, container_format, name, deleted,
 and checksum.

Test adapted from I85c42f8351763da201021a22f5ff0ebd62c6b2db by Mike Perez

Closes-bug #1308058
Co-Author: Mike Perez <thingee@gmail.com>

Change-Id: Icddead6f746d4d3ba652858eaae425acce8c177d
Fix nova image-show with queued image

Currently, the nova image-show command cannot be used with queued images,
because they don't have certain attributes set yet. Nova will raise
AttributeError, which causes a 500 to be returned from the API.

Change-Id: I7d73b891545492e3e247eebdf02507cb630eb250
Closes-bug: #1321186
Fix ReservationTestCase on PostgreSQL

ReservationTestCase setUp() uses a hard coded id value
of quota usage, which might be different if a DB is not
recreated for each test case. Refactor tests a bit to use
a common setUp().

Blueprint: db-api-tests-on-all-backends

Co-Authored-By: Roman Podoliaka <rpodolyaka@mirantis.com>
Change-Id: I7e8ce94fa36392a508375ca3626ff0a8441a7066
Fix InstanceActionTestCase on PostgreSQL/MySQL

test_instance_action_get_by_instance_and_action() of
InstanceActionTestCase mistakenly uses the same value
of request_id and then relies on SQLite specific order
of retrieved rows to grab a required value. This causes
test to fail on MySQL and PostgreSQL.

Blueprint: db-api-tests-on-all-backends

Co-Authored-By: Roman Podoliaka <rpodolyaka@mirantis.com>
Change-Id: I6e3e100627ef7efc31c41aaa5a38d45e828fcf39
Inject expected results for IBM Power when testing bus

There's no support for ide in IBM Power, and this test is
failing when it's being running in Power.
This patch inject the expected value in
test_xml_disk_bus_ide_and_virtio and
test_xml_disk_bus_ide when it's tested in Power
platform, so, when architecture is Power, the injected value
replace the ide by scsi.

Change-Id: I2db1ade0e049c3471989b121b9497bc5124ea567
Catch InstanceNotFound exception if migration fails

When a VM with an attached iSCSI disk fails to migrate, the rollback methods
does not detach the disk from target host. What happens is _lookup_by_name()
fails, since the VM does not exist on the target host. In detach_volume(), it
is supposed to print a warning based on the correct error code being returned,
instead of throwing the exception. However, this is not happening, because
_lookup_by_name() throws an InstanceNotFound exception, rather than a
libvirt.libvirtError exception. So we also need to catch InstanceNotFound
exception, so that detach_volume() can continue to execute as expected.

Change-Id: I396c23d8137bf1e2834769c5483d2494506949ad
Closes-Bug: #1321082
Imported Translations from Transifex

Change-Id: I7c01802e8331316112bd9296bd01419e92405178
Merge "Fix wrong quota calculation when deleting a resizing instance"
Merge "Ignore errors when deleting non-existing vifs"
Merge "Fix CIDR values denoting hosts in PostgreSQL"
Merge "Fix ReservationTestCase on PostgreSQL"
Merge "Fix InstanceActionTestCase on PostgreSQL/MySQL"
Merge "Scheduler: remove test scheduling methods that are not used"
Merge "Catch InstanceNotFound exception if migration fails"