Fix OS-DCF:diskconfig XML handling

Removes string to bool conversion for the OS-DCF:diskconfig
attribute during XML deserialising as the diskconfig extension
expects a string (MANUAL or AUTO) not a bool.

Fixes bug 1152439

Change-Id: Id9a5c2559a2891c2a21c437c9a5a534b9885c9bf
Fixes instance task_state being left as migrating

In a cross-hypervisor environment, such as KVM + Hyper-v. After negative test
which live migrate a KVM instance to Hyper-v host, there will be an exception
InvalidHypervisorType. As a result, the instance task_state is being
left as migrating. That leaves the instance in a broken state and most of the
requests on the instance will fail.

Actually, there are some other exceptions will cause this issue as well, such
as UnableToMigrateToSelf, DestinationHypervisorTooOld. All of them are thrown
from the driver of scheduler during live migration. But obviously, if the live
migration fails at the schedule stage, the task_state of the target instance
should be updated to None.

Fixes Bug: 1153283

Change-Id: Ide4b48653268c8dbe31de6964814830d2e82a5ba
Remove the usage of instance['extra_specs'].

Instance type extra specs is remove from instance dict, so use inst_type['extra_specs']
instead of instance['extra_specs'].

fix bug #1146253

Change-Id: I1d3542e5142f490269607b779daa507f9d7b36e4
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
Drop gzip flag from tar command for OVF archives

Fixes bug 1154253

Change-Id: I3880d9b187dc25d2ff44fe502eec4d1e0bce4218
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