object-ify availability_zones

This change converts availability_zones to use the Aggregate and
Service objects instead of direct database access.

Related to blueprint compute-manager-objects-juno

Change-Id: I2ec7373f063ed728dde2af3b7c8259f4391885bc
Fix error status code for multinic

When passing bad body in a request, most APIs return BadRequest response.
However, multinic API doesn't do it.
This patch fixes the error status code and adds a unit test related to
this change.

This patch's idea most came from
following patch: https://review.openstack.org/#/c/107266/

Change-Id: If1ef2077a0e9823dfc04e4ef5a6dfb02daf1a8dc
Restore ability to delete aggregate metadata

Commit I2c778f2237ba5bd2aa8335a0eae80f3aad3e9157 tightened the
input validation for setting the metadata for an
aggregate. However it also accidentally excluded sending
null as the metadata value which has previously allowed the
deletion of the metadata key rather than an update. This
changeset relaxes the input validation to allow deletion of
aggregate metadata again

Change-Id: I54b91c2d421243e7e7521f2352598f73a258b88a
Closes-Bug: 1334846
Add decorator expected_errors to V3 servers core

All v3 api should use expected_errors to prevent unexpected exception
raised. This patch add decorator expected_errors for v3 servers core.

Change-Id: Ia1fa09d6cf68a65c85ac5fd2aff9b9202d76e7ca
Closes-Bug: #1343778
Fix error status code for agents

When passing bad body in a request, most APIs return BadRequest response.
However, agents API doesn't do it.
This patch fixes the error status code and adds a unit test related to
this change.

This patch's idea most came from
Ken'ichi Ohmichi's patch https://review.openstack.org/#/c/107266/

Change-Id: I9602183ade4d3c0105e2498aebb7e33eb72f86f0
Remove unnecessary error log in cell API

There are unnnecessary error logs in cell API. It tried to log
error for invalid input which is not necessary because we already
raises exception for the bad request.
This patch removes them in both v2/v3 API.

Change-Id: Idd239903aa830f5d8fe50336dfa63a43b617584f
Keep resizing&resized instances when compute init

During compute manager startup init_host is called. One of the
functions there is to delete instance data that doesn't belong
to this host i.e. _destroy_evacuated_instances.
But this function only checks if the local instance belongs to
the host or not. It doesn't check the task_state or vm_state.

In Resize function, user may want to revert or confirm the resize
operations so the instance on source and dest compute node should
be kept. so for RESIZE_MIGRATING, RESIZE_MIGRATED task states and
RESIZED vm state instances, they should be kept in compute node
when the compute restart. This patch adds check for the task
state and vm state before delete the instances.

Closes-Bug: #1330503

Change-Id: I723fa4a8823019391ea83aa189096531032adab1
Catch CannotResizeDisk exception when resize to zero disk

When old flavor's root_gb is not equal 0 and new flavor's root_gb is 0,
the resize() in nova.compute.api will raise CannotResizeDisk.

Move up the new_instance_type check before using.

Closes-Bug: #1340159

Change-Id: I4abf93530cf919af50a88d6049019fb745547257
libvirt: add support for memory backing parameters

Add a libvirt config class for dealing with the XML elements
under the <memoryBacking> section of the guest schema.

Blueprint: virt-driver-large-pages
Change-Id: Icd89508671a8951bed480b901b2d12d44ebb7cab
Make quotas APIv2 extension use Quotas object for create/update

This makes the quotas extension use the Quotas object for the
create/update operations instead of direct database access.

Related to blueprint compute-manager-objects-juno

Change-Id: Ia2db239d721c9ea680e11409e5eefc59e0dee941
Make quotas APIv3 extension use Quotas object for create/update

This makes the quotas extension use the Quotas object for the
create/update operations instead of direct database access.

Related to blueprint compute-manager-objects-juno

Change-Id: I74295a6f8ebca46421eafedbb28e677d2361c2b8
Update database columns nullable to match model

Some columns were created with a different nullable value than the model
defines.

Closes-Bug: 1343331
Change-Id: Iafc72e571648ba1763f457ae00ac84a63c94e0cd
vmwareapi: remove some unused fake vim methods

Rename_Task unused since I92acdd5cd00f739d504738413d3b63a2e17f2866

AcquireCloneTicket and PowerDownHostToStandBy_Task were never used.

Change-Id: I025d121db41ed1f6084364ff1a52eade1c3d6a90
libvirt: remove VIF driver classes deprecated in Icehouse

In Icehouse the old VIF driver classes were set as deprecated
to be removed in Juno. Now they can be finally deleted.

Related-bug: #1302796
Change-Id: I7be735062e6cc6aa54dec1bf43d3cce1ac544988
Remove unused cell_scheduler_method

This key isn't used anywhere in the code (it's use was removed a while ago).

Change-Id: Icf215b5dd0c7b93b336b6bb030f3a9282a0b05bd
Method to filter non-root block device mappings

Adding a generator that would provide a non-root block device
mappings, when it's optional variable exclude_root_mapping is
set to true. Otherwise, all mappings will be returned.

The method will be used to handle LXC volumes, as it's root FS
should be handled differently.

Change-Id: I879916021c3b61f19dd69ff11838dbbac19f72d1
Related-Bug: #1269990
libvirt: removing lxc specific disk mapping

Currently, LXC specific disk mapping is being created, preventing
the attached volumes from being added to the LXC disk mapping.
Removing this part, to allow volumes to be included in mapping.

Related-Bug: #1269990
Change-Id: I97bcff558b6d8876a10adb36c19ab3f4c972a708
Increase min required libvirt to 0.9.11

Increase the min required libvirt version to 0.9.11 since
we require that for libvirt-python from PyPI to build
successfully. Kill off the legacy CPU model configuration
and legacy OpenVSwitch setup code paths only required by
libvirt < 0.9.11

Closes-Bug: #1254727
DocImpact
Change-Id: Ibe8d2117e1246e4097d1bedeadcd6d99618f8400
Pass errors from detach methods back to api proc

The initial implementation of the detach_interface method was built as
cast invocations.  The respective attach method was built as a call
invocation.  What this led to was, if the user attempted to attach an
incorrect port, that error would be passed back up to the API
properly.

However, if the user attempted to detach an invalid interface, the
response from the API would be an HTTP 202 (because the cast assumes
success).  The root error may be logged in the respective nova compute
log, but it did not make its way back up to the user.

This change updates the decorators to the manager methods to update
the instance's fault when the attach or detach encounters an issue.

Change-Id: I111b1c8a492f12587f86ab83825060029605390d
Closes-Bug: #1339098
Do not pass instances without host to compute API

Even if the server external events extension filters out events
whose related instance does not have a host, the corresponding
instance is still sent to the compute API module.
As this might result in KeyError, instance without host should
be filtered out before calling the compute API module.

Change-Id: If5229ec3059076dbc9f4abb6625504e8864c265e
Closes-Bug: #1348584