Read instance resource quota info from "quota" namespace.

Scope all instance resource quota params such as CPU(cpu_shares,cpu_quota,
cpu_period), disk IO(disk_read_bytes_sec,disk_write_bytes_sec etc.),
network bandwidth(vif_inbound_average, vif_outbouand_average) to "quota"
scope in extra_specs, so that it doesn't conflict with compute_capabilities_filter.
after this patch, user should use:

nova flavor-key m1.tiny set quota:cpu_shares=1000 to set parameters.

Fix bug #1146322

DocImpact

Change-Id: I30e550d21f00eb949ee2f3f8fb4d952c10bf8000
Do cleaning up resource before rescheduling.

Fix bug: #1153964

If some exception raised when spawn instance, the instance will be
rescheduled to other host. But just deallocate network before
rescheduling is not enough, like security group filters and volumes
will stay on old host.

So shutdown instance and clean up volumes instead of just deallocate
network before rescheduling.

Change-Id: Ieb6220ae66f0b97a92c50f6998f456968b516fcb
Generalize console error handling during build.

There is a race condition where you can create an instance and then
quickly request a VNC or Spice console before the instance is ready.
The way this went down was different depending on the virt driver in
use.  The libvirt driver would raise InstanceNotFound.  The xenapi
driver would raise InstanceNotReady.

This patch moves the handling of this race that was in the xenapi driver
up to the compute manager.  Now, all of the virt drivers that support
this method (libvirt, xenapi, vmware) will all raise InstanceNotFound in
this case, and the compute manager will convert it into InstanceNotReady
IFF the vm_state is BUILDING.

Related to bug 1154327.

Change-Id: I68f4a6db8aac26c6f731c985d97299ee38c34448
Don't log traceback on expected console error.

When requesting a console before an instance is read (while still
building) we will get an InstanceNotReady exception.  This exception is
raised in the compute manager.  The explanation in the exception will
include the traceback from the manager side.  If we use this as the
explanation, we end up with a traceback in the API log, even though it's
just an INFO log message.

Use a more basic explanation, which is accuately more consistent with
other cases of raising HTTP exceptions, which doesn't include a
traceback.

Fix bug 1154327.

Change-Id: Idca443165983289a0df40970f68f95d5550ce72a
Fix copyright - from LLC to Foundation

one last spot hopefully!

Change-Id: I4d557520a1a7a3e0b13bca7df6c8d06bd850b867
Fixes Hyper-V live migration with attached volumes

Fixes bug: 1153429

The previous Hyper-V driver live migration implementation expects to find iSCSI
devices mounted on the same path on source and destination, which is not an
option in this context.

In order to be able to live migrate instances with attached volumes, this fix
provides the following behavior, based on the creation of a staged VM on the
target, so called "planned" in the Hyper-V documentation and in this patch.

pre_live_migration

The target host logs into the storage targets.

live_migration

The source host:

1) checks and removes a previously created planned VM for the current
   instance if present on the target
2) creates a planned VM on the target by using the Hyper-V WMI API
3) maps the volume devices on the planned VM based on the target host
   devices
4) live migrates the source VM on the planned VM
5) logs off the storage targets on the source

This solution provides live migration of volumes without needing to pause
the VM and detach / attach the volumes, preserving also the atomicity of the
live operation.

In the case in which no volumes are attached to the VM, live migration is
performed without creating explicitly a planned VM, starting from step 4
on the source in the above list.

Unit tests have been added for this scenario.

Change-Id: Ib634b77894f492896d86dce65a7269ece8f3d55b
Resize/Migrate refactoring fixes and test cases

This patch will fix the construction of an scp command to be joined on
spaces. Also adds a parameter in driver.finish_migration to
_create_lpar_instance(), some refactoring that needed to be done in
order to launch the instance on the destination host. This patch fixes
Bug #1153599. This patch also address the tests cases for resize/migrate
functionality for PowerVM. Bug #1133058 is for tracking these test cases

Change-Id: I86c1b697fe5c7d6e4a6c689f75fd5cf737cef5d4
Fixes an iSCSI connector issue in the Hyper-V driver.

It fixes how Hyper-v nova driver is returning iscsi connection
information. It affects the way cinder plugins used that
information to implement ACL based on initiator_name.

Fixes: bug #1153975

Change-Id: I40dc3bba9c9a76585ba9bdd938043d4bfef195c8
Makes safe xml data calls raise 400 http error instead of 500

When we parse incoming XML safely, if there was an error raised it would
be an expat.Expat() error, which would bubble up to the api and turn
into a HTTP 500 (Internal Error)

It turns out that all the places we use the safe_xml parsing are in
Deserializers, close to the API, so in this patch we just change the
error it raises straight to nova.exception.MalformedRequest().

This causes the api to fail with the proper 400 (Malformed Request) when
it encounters corrupt XML. This is caught at
nova.api.openstack.wsgi._process_stack and __call__.

We also take the opportunity to move the new safe parser from nova.utils
to nova.api.openstack.xmlutil as the openstack api is the only thing
that uses it.

Fixes: bug #1133111
Change-Id: Ifa2ed7ee128241cfe8dbcdc5bd75194d96b6cdb5
Merge "Generalize console error handling during build."
Merge "Don't log traceback on expected console error."
Merge "Fix copyright - from LLC to Foundation"
Merge "Read instance resource quota info from "quota" namespace."
Add quotas for fixed ips.

DocImpact: there is now a default quota of 10 fixed ips per tenant.
This will need to be adjusted by deployers if that number does not
meet their needs.

Resolves bug 1125468.

Change-Id: Iffa19583340f80cb2a13ba5fce31f7ff724a52d6
Do not accept invalid keys in quota-update

Check if the keys are valid and respond with HTTPBadRequest
when they are not.

Found a spot in wsgi where we were trying to use xml namespace
as data for the payload, we need to skip them when converting
to json

Fix for LP# 1064864

Change-Id: Ic4a68047adf3ccf2dbac669b1b66d73bfe4d58de
Add the serial to connection info for boot volumes

The serial parameter wasn't being added to volumes specified at
boot time. Added tests. Also cleaned up import in test_compute
to match the rest of the file.

Fixes bug 1148734

Change-Id: I05a623849680c5d0bb530fba4c4e6051d3b000aa
Merge "Makes safe xml data calls raise 400 http error instead of 500"
Fix system_metadata "None" and created_at values

The ill-fated migration 153 converted None instance_type values to
"None" in the database instead of properly making them NULL. This
corrects that by sweeping all of the likely instance_type_% values and
converting "None" to NULL. Also, it adds a belated created_at stamp
to all of the items, which was missing in 153 as well.

It also corrects the 153 migration to avoid polluting things in the
first place for systems that haven't rolled through that yet.

Fixes bug 1152546

Change-Id: I3585463ae15abfd534f2ff070e2974f3cb51d7e8
Merge "Do not accept invalid keys in quota-update"
Don't include traceback when wrapping exceptions

The fix in fa52cb09b2270876c9d9a03106f961be6c9db834 strips tracebacks
from exceptions when returning them to the user, but it still spams
the log with a long traceback. We shouldn't be including the traceback
when we wrap the exception in the first place. Instead we just
include the message.

It also updates the error code to 409 for device in use since this
is actually a conflict.

Fix for:

  bug 1155315
  bug 1103324
  bug 1092610

Change-Id: I95019a3022eb52e0335c455009c13fe229475d03