Add VolumeMapping object for use in EC2

The EC2 code has a table mapping volume UUIDs to EC2 IDs.  This patch
creates the Nova object for this so that we can remove direct use of
these db.api calls from the EC2 code.

Change-Id: I80e5d9c8e33c1f0c5ef8a9f7c54935c8c329ed25
ec2: create volume mapping using nova object

Update the EC2 code that creates a mapping in the db between the
volume UUID and an EC2 ID to use the nova object for this.

Change-Id: I2b02c9f639519a7835ffcf27be704b4810334e6d
ec2utils: Use VolumeMapping object

Update ec2utils to use the VolumeMapping object instead of direct db
API calls for getting the ec2 ID to UUID mappings.

Change-Id: Id653fc16fffc1c416379087228a0b053b8868cac
Add warning to periodic_task with interval 0

The behaviour of Oslo's @periodic_task decorator is that
a repeat interval of 0 means that the method will be
called regularly.  Several Nova methods which use that
decorator also have code for returning early (ie no-op)
if the interval is 0.  This is inconsistent for users, and
means there is timing-related code where it doesn't belong.

This patch adds a warning when a user takes a value of 0
from config and uses it as an interval in a @periodic_task.

Ideally all code will use Oslo's convention that 0 means
run at the default rate and a negative interval will mean
"don't run".  After this warning has been in place for a full
release cycle that can be the case.

Change-Id: Ia227f4c4e69ecf361ab02d1d17a3010303650104
DocImpact: Warns of upcoming change to behaviour when
           *_interval is set to 0
Closes-Bug: #1272830
Partial-Bug: #1276203
Remove unnecessary wrapper for 5 compute APIs

There are 5 APIs in compute layer:
check_instance_shared_storage
change_instance_metadata
add_fixed_ip_to_instance
remove_fixed_ip_from_instance
reset_network
has unnecessary wrapper, this patch removed them

reverts_task_state is a wrapper to restore instance task state
when some thing wrong in executing the task,
change_instance_metadata, add_fixed_ip_to_instance
remove_fixed_ip_from_instance, reset_network doesn't change the state,
so no need to wrap it

wrap_instance_fault is a wrapper to catch the exception related to
instances, check_instance_shared_storage is not related to it

Change-Id: I2c4779c01854c2c8bac40e7379ad2fc4d0a7478a
objects: restore some datetime field comments

The datetime coercion code in nova.objects.utils had a couple of
helpful comments which were lost when the code was refactored into
nova.objects.fields.

Change-Id: If23320dd8780a1947ad4d5946c55e1e8794b782f
VMware: spawn refactor - phase 1 - execute_create_vm

Moves the inner function "execute_create_vm" from the spawn method
to vm_util. Additionally, return the vm_ref after VM creation so
an extra call to retrieve the vm_ref does not need to take place
after the fact.

partial blueprint vmware-spawn-refactor
Co-authored-by: Tracy Jones <tjones@vmware.com>

Change-Id: I67c3c8c14b6c01b160611cc001d51f1da29ffb24
Merge "Add warning to periodic_task with interval 0"
Optimize validate_networks to query neutron only when needed

This patch optimizes validate_networks so that it only queries neutron
when needed. Previously, this method would perform an additional net_list,
list_ports, and show_quota regardless if a request contains only
port_ids. If a request only contains port ids we do not need to check neutron
for quota as these ports are already allocated.

Change-Id: Ia7abc7d95b663f165fc95385dda3bab13b7a43e6
Closes-bug: #1291565
Merge "VMware: spawn refactor - phase 1 - execute_create_vm"
Merge "Add VolumeMapping object for use in EC2"
Merge "ec2: create volume mapping using nova object"
Merge "ec2utils: Use VolumeMapping object"
Merge "Optimize validate_networks to query neutron only when needed"
Remove use of service_* conductor calls from xenapi host.py

This removes use of some service calls in the conductor by xenapi's
host.py module and replaces them with object usage. Existing tests
are sufficient to confirm the same behavior remains.

Related to blueprint virt-objects-juno

Change-Id: I908cca4fa1d297c5c9b1d84ae7ebe7452a30ba12
Add create() method to InstanceFault object

This allows creating InstanceFaults through the object interface.

Related to blueprint virt-objects-juno

Change-Id: Iedde2e220127778fa6252d310f9e73c8506f605e
Merge "objects: restore some datetime field comments"
Remove conductor usage from add_instance_fault_from_exc()

This makes add_instance_fault_from_exc() use the InstanceFault
object instead of a raw conductor call. This is actually a
minor change except that all callers of this method must now
stop passing the conductor API, and tests must return something
valid from the mocked call.

Related to blueprint virt-objects-juno

Change-Id: I49b17c1ef3d14fd36f016c37d88287e62126bf68
Deprecate instance_fault_create() from conductor

This method is no longer used and is deprecated for Juno.

Related to blueprint virt-objects-juno

Change-Id: Ib7feb215e0c79524be272315a235a4745339860d
Merge "Remove unnecessary wrapper for 5 compute APIs"