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
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
Make ssh key injection work with xenapi agent

If there's 'key_data' on an instance, and instance is not Windows, use
file injection to inject /root/.ssh/authorized_keys.  If a user
specifies their own /root/.ssh/authorized_keys via 'injected files',
that will take precedence.

Fixes bug 1152713

Note: Images for Xen that use nova-agent will need to have /root/.ssh
pre-created with modes 0700 on those directories.

DocImpact

Change-Id: I190c6b3f67099061b5316baa45b8bfcd1a5e53f6
Fix issues with cells and resize

There are cases where compute API resizez() is called with 'flavor_id'
as a positional argument, so we need to fix up the cells_api version of
resize() to more closely match the super class.

Also: A recent change for storing instance_type info in system_metadata
happened to make an incorrect change, assuming cells_api was for child
cells.. which it's for the API cell.  It needs to pull the instance type
from the DB just like the super class does.

Fixes bug 1154843

Change-Id: Ifdf2a68c3bff6d27d5f192e2eb73f9b79804c2c7
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
Check keypair destroy result operation

This checks the result of delete operation over keypairs to see if it
affected any row (this is what delete returns), if not raises
KeyPairNotFoundException.

Also adds tests for keypair db api.

Fix bug 1086980

Change-Id: I7e822c0661c563db01040ae2d57aacfe677d72b0
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
Make os-services API extensions consistent.

Updates the os-services API extension so that it is consistent
internally (index and update return similar formats), and so
that it works with the recent novaclient code which sends
the following request body format:

  {"binary": "nova-cert", "host": "nova1"}

Also, updates the response body format of the update call so that it
wraps things in an extra service dict which should make novaclient
happier here as well (and is consistent with other extensions too).

Fixes LP Bug #1147746.

Change-Id: I932160d64fdd3aaeb2ed90a092ecc7a36dcc9665
Add missing API doc for networks-post-req.

Part of the os-tenant-networks API extension.

Fixes LP Bug #1155303.

Change-Id: Ic71a3d108f9401ec81d2c59a6f7ba3ec6ab59dd8
Fix: improve API error responses from os-hosts extension

Modify responses to include the actual host instead of %(host)s.

Resolves bug 1154117.

Change-Id: Ic680403bdf1cb1fc1ac184352f486390fb04a195
Make conductor's quota methods pass project_id properly

Commit 652a487ed9daba9ae97f7df77ae35720322d1af3 added a workaround for
project_id on conductor's quota methods. This fully plumbs project_id
through to the manager (and thus the quota implementation) and removes
the tests that verify the workaround.

Fixes bug 1153795

Change-Id: I7cd5e3de39acfaba7831892aff6c754569c8e1bf
Fix exception message in Networks API extension

Raise exception indicating VLAN is disabled when
trying to associate a network w/ a tenant in cases where
VLAN is not the network manager
Added unit test case
Fixes bug 1075790

Change-Id: I3dcac09fbf06d9f64b18cc52d0b069dc9c0a7370
Update migration 153 for efficiency.

Currently migration 153 inserts 10 rows per instance in the database.
For new/small installations this is relatively quick, but for large
installations this can take some time.

This change modifies the migration to only insert records for
non-deleted instances and makes bulk inserts (10 rows are inserted
with each query, instead of 1 per query) for added speed.

Fixes bug 1155371

Change-Id: I88a6cec2c117368fda6eefd82150106a1542027d
Merge "Do cleaning up resource before rescheduling."
Imported Translations from Transifex

Change-Id: I9e57c57edc56e0bf68797ccfc920a119bb57905f
Merge "Add quotas for fixed ips."
Fix db archiving bug with foreign key constraints.

Fixes bug 1137977

A few Nova tables have foreign key constraints on other tables.
Deleting a row whose id is referenced as an enforced foreign key for
another table results in an error.

The fix is to detect the IntegrityError when we attempt to delete a row,
and exit from archive_deleted_rows_for_table early.  The parent
archive_deleted_rows function will continue deleting from other tables,
including the one whose dependence on this row caused the IntegrityError,
and things will eventually sort themselves out.

Change-Id: I0afdfe0778057abc5fd269a20bfa4c4ca3a7b003