Organize limits units and per-units constants

During v3 api review there was an agreement that would be nice to move limits
constants to utils file and refactor its usage inside limits api to avoid
unnecessary code duplication.

Also changed TestLimiter class to MockLimiter since that name can be confuse to
some unit test frameworks.

Change-Id: I1b8626e8d1e3257333d4dfee61591fd4cde82bd1
Port cells extension to v3 API Part 1

This changeset only copies the v2 files (implementation and test)
into the appropriate v3 directories unchanged. The copy as-is
will not be loaded by either the v2 or v3 extension loaders. The
second changeset will then make the changes required for it to
work as a v3 extension.

This is being done in order to make reviewing of extension porting
easier as gerrit will display only what is actually changed for v3
rather than entirely new files

Partially implements blueprint nova-v3-api

Change-Id: Ie629ee328d76a1595350b597c7874b430217c769
Enforce sqlite-specific flow in drop_unique_constraint

The nova.db.sqlalchemy.apy.drop_unique_constraint method has a
sqlite-specific flow for dropping unique constraints because it can't
use alter table like mysql or postgresql. The code is explicitly
checking if the db engine is mysql or postgresql and then falls into a
block which assumes the backing db is sqlite. This can cause problems if
the backing db is not sqlite.

This patch simply switches the checks so that the sqlite-specific flow
is only ran if the backing db is sqlite, everything else will default to
the 'alter table' flow.

Change-Id: I23b9bf33d18df3ac36106d5800a8ecdd1a4018df
libvirt fix resize/migrates with swap or ephemeral

Fixes bug 1191608

The code was not properly guarding against backing files not
existing with QCOW2 images. As such, get_disk_backing_file() would
return None, then the subsequent call to basename() on None would
cause an exception.

This bug was introduced with the fix for bug 1185588 and commit
6e768363.

Change-Id: I4b1237ddf01b9398bfdc141180260136b36cae5a
Port fping extension to v3 API Part 1

This changeset only copies the v2 files (implementation and test)
into the appropriate v3 directories unchanged. The copy as-is
will not be loaded by either the v2 or v3 extension loaders. The
second changeset will then make the changes required for it to
work as a v3 extension.

This is being done in order to make reviewing of extension porting
easier as gerrit will display only what is actually changed for v3
rather than entirely new files

Partially implements blueprint nova-v3-api

Change-Id: I55d15ab5f9f59a83dc67bac2d2f41ceee06085d5
Port server_diagnostics extension to v3 API Part1

This changeset only copies the v2 files (implementation and test)
into the appropriate v3 directories unchanged. The copy as-is
will not be loaded by either the v2 or v3 extension loaders. The
second changeset will then make the changes required for it to
work as a v3 extension.

This is being done in order to make reviewing of extension porting
easier as gerrit will display only what is actually changed for v3
rather than entirely new files

Implements blueprint nova-v3-api

Change-Id: I52f906948b5873cf3fdfff14270c7384ee5e7b9f
Don't deallocate network if destroy time out

Fixes bug #1169057
Sames as bug 1180178, if libvirt returns time out error during destroy
an instance, we also can't deallocate the network of the instance,
otherwise the fixed ip of it may be re-used by another new instance,
and resulted in the new instance can't be accessed by the fixed ip.

Change-Id: I04dfd21bb1b7168abc71f39e836126a11dad6d8d
Log xml in libvirt _create_domain failures

When an error occurs defining, launching or enabling hairpin mode on a
libvirt domain, log the xml for reproduction and analysis.

Fixes bug 1183534

Change-Id: Ic8f1d11c5a92779c686b7248895bbc6f2cfdbf0b
Check the instance ID before creating it

At least with libvirt 1.x instance goes into shutdown state
before its ID is changed. This means that there's a race
condition during reboot where nova might try to create an
instance that's already defined. By checking if the ID of
the new and old instance is the same, we avoid that situation
and reiterate on the loop.

The tests for this are added in
I6215f80bd15820dac80151e7063916dbbc21d761

Change-Id: I493b828f0c6848fbadc591be2f47fd1b12fd3a51
Fixes: bug 1181924
Add tests for libvirt's reboot functionality

This patcha adds the missing tests for libvirt drivers reboot method.

Change-Id: I6215f80bd15820dac80151e7063916dbbc21d761
No support for double nested 64 bit guest using VCDriver

64bit instances launched on ESX via the VCDriver will not
support running 64bit guests. There is an option that can
be passed during the vmx creation that will allow for this
to happen. This is very useful if you want to run hypervisors
 (esx, kvm) on top of ESX and then run 64bit VMs on top of
those hypervisors.

Fixes bug 1192256

Change-Id: Id6eb224c97569737cbb41f1b64f61805e1df004e
port Simple_tenant_usage  API into v3 part1

This changeset only copies the v2 files into the appropriate v3
directories unchanged. The copy as-is will not be loaded by either
the v2 or v3 extension loaders. The second changeset will then
make the changes required for it to work as a v3 extension.

This is being tried in order to make reviewing of extension
porting easier as gerrit will display only what is actually
changed for v3 rather than entirely new files.

Partially implements: bp v3-api-extension-versioning

Change-Id: I1618987cc905a6734b409eb9a7fe37c65b6aac28
Remove junk file when ftp transfer failure

During spawn with powervm driver, the image transfer to the IVM host
may fail in some conditions, eg. IVM host doesn't have enough disk
space. It leaves the junk file in IVM host, and this will disturb
next spawn after resolving environment issue, need clean it.

Fixes bug #1188884

Change-Id: I7b8d719995c2702c89cf55cef5f34bde9d01c1b9
Port hypervisor API into v3 part1

This changeset only copies the v2 files into the appropriate v3
directories unchanged. The copy as-is will not be loaded by either
the v2 or v3 extension loaders. The second changeset will then
make the changes required for it to work as a v3 extension.

This is being tried in order to make reviewing of extension
porting easier as gerrit will display only what is actually
changed for v3 rather than entirely new files.

Partially implements: bp v3-api-extension-versioning

Change-Id: I251dc18dda9756574c308a08423fd805a3e91182
Sync db.models.Quota* with migrations.

Blueprint: db-sync-models-with-migrations

Change-Id: Ic97690b650151eb7086cbd40093c0f3c373133e2
Add troubleshoot to baremetal PXE template.

We recently added an optional troubleshoot parameter to
diskimage_builder which defaults to 0 (false).

This commit adds the option to the Nova pxe_config.template
so it will be easier for people to find should they need to
enable troubleshooting mode.
Change-Id: I169a5e3b7a9d80e18e389ae4645d2c5bbdae2a6f
Preserve network order when using ConfigDrive

Pass network_info to be used by InstanceMetadata instead of fetching
it by API and losing originally requested network order. This is
similar to what has been done for "content" where the original data
is lost after the initial call.

This issue only affects the ConfigDrive code path as the original
network_info is used when using file injection.

HyperV and XenApi are still probably affected by the bug but
unaffected by this fix. The fix is the same for these drivers. Simply
pass a network_info and it will be used instead of fetching the
network info by API.

Change-Id: Ie673b725cb47bf491009db99f6cb1258d46b0a69
Fixes: bug #1156844
Port extended status extension to v3 API Part 1

This changeset only copies the v2 implementation file into the
appropriate v3 directory unchanged. The copy as-is will not be
loaded by either the v2 or v3 extension loaders. The second
changeset will then make the changes required for it to work as a
v3 extension.

This is being done in order to make reviewing of extension porting
easier as gerrit will display only what is actually changed for v3
rather than entirely new files.

Partially implements blueprint nova-v3-api

Change-Id: Ia5b80b70a7a459bf973de1c1aea8dc650e763b8d
Revert "fixes nova resize bug when force_config_drive is set."

This reverts commit 8ae97f24b0c806a438456170959ae527ce33ad01

This issue was already tracked and fixed in bug 1163598.
The user's packaged version was just lagging behind the released fix.

Change-Id: I9260ce7b00b0500b168f5a385696361b4f8e73fd
Add AggregateRamFilter

Implements blueprint per-aggregate-resource-ratio

* AggregateRamFilter to support per-aggregate ram_allocation_ratio
* Falls back to global setting if per-aggregate value not found

DocImpact

Change-Id: I93e069f0ac3f595d9a2a17119274c7bfbe8fca31