Fix logic for aggregate_metadata_get_by_host_with_key test case

After deleting a3 metadata, it is the host that once has such metadata
should be tested.

Change-Id: I79c40aa977911cd327d478ad8d9f147e19325017
Remove warn log in quota function on API layer

An API layer function in quotas print warn message when in input
is not valid, it's useless since an exception will be raised.

Change-Id: I707416aae29e56ad1c7d2cc55ca8c662bf5547f5
Ignore InstanceNotFound while getting console output

During we cold-migrating or resizing an instance to another host,
or during deleting it, the get_console_output method may raise an
InstanceNotFound excetpion if the instance is not on the hypervisor,
this is an expected error, so we should add it to expected
exceptions list in compute manager.

Closes-bug: #1292339
Change-Id: I23a99438d73826f01ff5662130dcbfa72dc39a6e
Improved logs for add/remove security group rules.

Added more details - protocol and port information to AUDIT log
messages on add/remove rule actions for security groups.

Change-Id: Ib446a63976dade90c51c13f30367a3ee17a739ea
Closes-Bug: #1154303
XenAPI: Calculate disk_available_least

The disk_available_least item is now needed for the tempest test.
Calculate based on the virtual-allocation from the SR.

Change-Id: I1a08f229de7cd77d4798472c82304247fae290e5
Closes-bug: 1300242
Rename instance_actions v3 to server_actions

* Renames the os-instance_actions v3 plugin to os-server-actions
* Also modifies api specific tests and expected user input JSON
* DocImpact only for v3 Nova api documentation for this plugin.

Closes-Bug: #1206032

DocImpact

Change-Id: Id5049e10f5ef540d0d8e3871d800e9d9cb33da73
Remove unnecessary passing of task_state to check_instance_state

Remove cases where task_state=[None] was passed to check_instance_state
when that is essentially the default value anyway

Change-Id: I49b6449b9ae43a5cfcf5a1ccac5ee9a64d2b3f3c
remove unneeded call to network_api on rebuild_instance

When rebuilding an instance we call the network_api and which results in
calling neutron and updating the info cache. We do not actually need to
do this as we can get the nw_info directly from the instance's info cache.

Change-Id: I2bcc2f15b1e5bb52d972098c7bc3e12f160b6feb
Closes-bug: 1294914
Fix the explanations of HTTPNotFound for keypair's API

Gets the "explanation" from HTTPNotFound exception and returns
correct message. the commit Ia784e09cda986a421e83c2820dfd0a2267867cdd
has fixed this kind of bug already, but this bug is remained.

Closes-Bug: #1307338
Change-Id: I6811eecba86938e4253f437b7677cb7e4468fd67
VMWare - Check for compute node before triggering destroy

While booting an instance, if Claim on that compute node is not successful
compute manager triggers a call to destroy instance. Destroy fails since the
compute node (Cluster/ESX host) is set only after claim is successful.
Hence the check for node is made before destroy, to ensure that exception
does not get thrown. This ensures that the instance gets rescheduled
Closes-Bug: #1307408

Change-Id: Iaaf931e9c1e6cf046497e2c64952f92e802ad4be
VMware: remove unused variable

The flag was never used since it was added in commit
24d609447399e468937f8a278854690864ffabcd

Change-Id: Ia034ccff1220783c2dd8c37c76fce24063f12682
Deprecate nova-manage flavor subcommand

The nova client already has the following flavor commands:

flavor-access-add    Add flavor access for the given tenant.
flavor-access-list   Print access information about the given flavor.
flavor-access-remove Remove flavor access for the given tenant.
flavor-create        Create a new flavor
flavor-delete        Delete a specific flavor
flavor-key           Set or unset extra_spec for a flavor.
flavor-list          Print a list of available 'flavors' (sizes of
flavor-show          Show details about the given flavor.

This covers what nova-manage flavor was providing so let's deprecate the
legacy nova-manage subcommand and mark it for removal in the K release.

There is not a bug or blueprint for this. The flavor subcommand is
completely duplicated in nova client. It is accessing the database
directly and we want to move to using flavor objects which would go
through conductor. So this could be considered part of the objects
conversion for flavors.

For some other commands like service, db and host it makes sense to
leave those so you can access the database before the api service is
running, but that's not the case for flavors.

UpgradeImpact: nova-manage flavor command is deprecated, use nova client

Change-Id: I8709bc9af4e490142e44c6dc61fd0aaa3a392b68
Add helper method to determine disk size from instance properties

Add a _disk_size_from_instance method which by using the disk name
determine the size of the disk refered in the instance properties.
Update the method finish_migration to use this new helper.

Change-Id: I45bd3804fdabff35189421d01a0503c886c24a4c
Related-Bug: #1298975
Xen: Retry plugin call after connection reset

When using the call_plugin_serialized_with_retry session method it will
retry if the plugin raises a RetryableError, but not if it loses the
connection to xenapi.  This adds a retry for the 'Connection reset by
peer' error that is occasionally seen.

Change-Id: Ibb36a0170e0e807ad7a4198df7b6e574c4279bed
Closes-Bug: #1200591
Make instance_exists() take an instance, not instance_name

Some virt drivers may not support/need to use instance.name and have
a different way to find out if an instance exists. NOTE: this still
uses dict access on instance, as the _run_instance() path is not
converted to Instance objects yet.

NOTE: This also removes a duplicate call to self._lookup_by_name()
in libvirt's resume_state_on_host_boot(). It was calling
self.instance_exists() and then self._lookup_by_name(), but instance_exists()
calls _lookup_by_name() itself.

Change-Id: I701cb5416ec47262268d1a088018b6be2774d1c5
Correct the log in conductor unshelve_instance

The log in conductor unshelve_instance is not correct, this patch
adjust it.

Change-Id: I9706862fa39d3c9cb5af0d412368546b504bc4a5
XenAPI: Use local rsync rather than remote if possible

Using ssh depends on the host being set up to be able to SSH into
itself which is not a common scenario.  While this is unavoidable for
the current implementation of resize across multiple hosts, if there
is a single host (i.e. a test scenario) or the resize is restricted
to the same host then we can succeed without SSH access

Dependency on Ia310e31d31aaf5c979e41c64af8223202a18e03a is because the
tests will always fail without Ia310 therefore this fix cannot be tested
without taking Ia310 as well.

Closes-bug: 1308064

Change-Id: I15802a1d97d380b1c5b74fc9f92ece2494fe789a
Fix a typo in compute/manager::remove_volume_connection()

A typo made in the placement of a paren in a recent refactoring
resulted in definitely broken code. Unfortunately, this was not
in a tested path and so went unnoticed. This adds a test and fixes
the problem.

Change-Id: Id24169894ffda6da0301d1dc38b2f2bb29ebbd58
Remove comments and to-do for quota inconsistency

There are comments for quota inconsistency in function
_complete_deletion and considering race conditions.

_complete_deletion was called by _complete_partial_deletion
and_delete_instance only if the instance state is DELETED
compute can enter _complete_partial_deletion
while if _complete_deletion called in _delete_instance,
that means instance vm state already become DELETED

also, if the _delete_instance was called with instance
state SOFT_DELETED, the quotas.rollback() will be called
it will make quotas.commit later take no effect
since the quotas.reservations is already None

so there is no race conditions and the comments can be removed

Change-Id: Iddb9e5197ca7ca9bd4692d63bb5c7f9a2ab44be5
Partial-Bug: #1296414
VMware: spawn refactor - phase 1 - get_vif_info

get_vif_info converts OpenStacks nova network_info
into a data structure that is used to prepare the
configuration spec for the instance that is being deployed.

partial blueprint vmware-spawn-refactor

Change-Id: I5d1535e84de44a995e1605d0d5b850c9756612de