Fix bandwidth polling exception.

When the bandwidth polling task tries to update bw usage for an
instance that does not have an entry for the last two periods already
in the bw_usage_cache table, it will throw an exception in the
polling task. This was just a misses 'if' statement.

Also:
xenserver: fix swapped bw data in xs plugin.

This fixes bug 1075255

Change-Id: I44bb143039fcdfc8dacb13b67ae8f79dc5f38777
Decouple EC2 API from using instance id

Continuation of 0dc32690fe158e4cb11c2c9bcc65acaf73b94a7a

Some code in ec2 api use Instance.id rather than InstanceIdMapping.id
directly while converting ec2 id to an instance object. This is very
dangerous if Instance.id is not equal to InstanceIdMapping.id for the
same instance uuid.

To avoid the id mapping confusion, this patch:

 * uses instance_id_mappings.id instead of instances.id
 * uses instance_uuid in ec2utils.id_to_ec2_inst_id
 * removes ec2utils.ec2_instance_id_to_uuid

Change-Id: I22638f667c18eefe542b03e31f1a3aa2ce782db7
Switch from FLAGS to CONF in nova.console

Use the global CONF variable instead of FLAGS. This is purely a cleanup
since FLAGS is already just another reference to CONF.

We leave the nova.flags imports until a later cleanup commit since
removing them may cause unpredictable problems due to config options not
being registered.

Change-Id: I155d363e26260aa402bb918b4d0726502e7e8758
Corrects usage of db.api.network_get

Sets project_only='allow_none' to get the network whose project_id
is None or not.

Fixes bug 1075215

Change-Id: I80622b1f5ccf194b4810bd0560bd0cdb077370df
Switch from FLAGS to CONF in nova.virt

Use the global CONF variable instead of FLAGS. This is purely a cleanup
since FLAGS is already just another reference to CONF.

We leave the nova.flags imports until a later cleanup commit since
removing them may cause unpredictable problems due to config options not
being registered.

Change-Id: Icb61d67965628dca65bda393d4373beab5c5c64a
Merge "Fix bandwidth polling exception."
Remove out-of-date comment

The code now uses excutils, so the comment is out-of-date

Change-Id: If04032999f1408ee8db8238b210d044d0a21f622
Refactor resource tracker claims and test logic.

In preparation for adding resize support to resource tracker:

* Claim class has been factored out of resource tracker.
* Broke out claim testing logic for easier re-use

This patch is pre-work to ease adding resize claims to
resource tracker:

bug 1065267

Change-Id: Ib0b856376417f140dc9ed114913f47a8a790b8a2
Remove unused function require_instance_exists

Change-Id: I9862daebaadca4af0c1ec47ddb66e329cdce98a7
Merge "Refactor resource tracker claims and test logic."
Merge "Decouple EC2 API from using instance id"
Merge "Corrects usage of db.api.network_get"
Merge "Switch from FLAGS to CONF in nova.console"
Merge "Switch from FLAGS to CONF in nova.virt"
Send all aggregate data to remove_aggregate_host.

Update the remove_aggregate_host method of the compute rpc api to take
in all of the aggregate data instead of looking it up from the db in the
compute manager.  This removes a db read from the nova-compute service.

Part of blueprint no-db-compute.

Change-Id: I8da3da264e358c14df97ba34d250e46c6cb577e2
Remove instance_type db lookup in prep_resize.

Remove a db read in prep_resize() by grabbing the instance_type data out
of the instance dict.  The code was unnecessarily looking it up from the
db.

Part of blueprint no-db-compute.

Change-Id: I6e26a8a90f7cfca12426fad2430a0eb73991f42f
Send instance_type to resize_instance.

Send the instance_type as an argument to the resize_instance method in
the compute rpc api.  Previously, the code would look up the new
instance_type's ID that is saved in the migration, and then look up the
instance_type in the db using the ID.  This removes another db read from
the nova-compute service.

Part of blueprint no-db-compute.

Change-Id: Ica45cb94191e9418446056e4fb59d3b9337a41ec