Hyper-V:Preserve config drive image after the instance is resized

If we configure config_drive_cdrom=True in nova.conf,
the config drive image will be lost after the instance
is resized on hyperV. This is because nova compute will
not copy the disk file if the file's ResourceSubType
is not 'Virtual Hard Disk'.

This commit adds 'Virtual CD/DVD Disk' into disk_resources
to preserve the config drive image after the instance is
resized.

Closes-Bug: #1250324

Change-Id: Ia125a8b132d194ddc2230754fd1b813698b410a8
Ensure that headers are utf8, not unicode

Although the api.openstack.wsgi.ResponseObject converted the headers to
utf8 strings to comply with RFC for HTTP this was not enough, since some
responses that contained unicode strings were returned, causing an error
when running nova behind an http server like Apache. This change ensures
that headers are always an utf8 encoded string.

Closes-Bug: 1254017

Change-Id: I980326f1f15907bf57060acdd132011254289079
Allow run_image_cache_manager_pass to hit db slave

Deployments that have a slave_connection configured can offload
read queries there. For deployments with no slave behavior
remains the same.

Change-Id: Ic443913883d80bdbc95385f8d3e21c0d855bb7db
Partially-implements: blueprint periodic-tasks-to-db-slave
libvirt: move unnecesary comment

Remove a commented out line of code that was not used.

Change-Id: Ie4a331c8b0d1352be82a48d6a666aafb74f7dc6b
Define "supported_instances" for fake compute

Allow fake computes to deploy images with hypervisor_type
defined and set to "fake" and by extension to be used in
multi hypervisor_type deployments.
Mixing fake and "real" computes on the same OpenStack
deployment allows to create many fake instances and some
working instances for testing applications on top of
OpenStack (ie: fake instances for stress tests, working
ones for functional tests).

Closes-bug: #1260771
Change-Id: Idc337c4a7ed024f236ca2b60d91e2c30f7d54536
Remove copyright from empty files in nova

Sync I9043bf2f646de880afccbb64e47b257aba3ca599 to nova

According to policy change in HACKING:
http://docs.openstack.org/developer/hacking/#openstack-licensing
empty files should no longer contain copyright notices.

Change-Id: Id194e118dfdd140fda4fd00d2398d7818d590257
Partial-Bug: #1262424
Use (# of CPUs) workers by default

Update the default value of the worker configuration options to be
equal to the number of CPUs on the system.  This is the most common
value that should be used to get ideal performance from nova-conductor
or nova-api.

The following options are updated in this change:

    [default]
    ec2_workers=
    osapi_compute_workers=
    metadata_workers=

    [conductor]
    workers=

DocImpact
UpgradeImpact

Change-Id: Id8009b5fd37cef03ca66cb5bf44211039ac895ba
Use block_device_info at post_live_migration_at_destination

post_live_migration_at_destination make libvirt.xml to destination
host. when execute (live) block migration for vm made by bootable
volume, method post_live_migration_at_destination write a
libvirt.xml in destination host.
but it missed block disk information so moved libvirt.xml always
has a wrong disk information.
I add block_device_info in blockinfo.get_disk_info at
post_live_migration_at_destination.
This change will make libvirt.xml with valid block disk information.

Change-Id: I31b3f2ef5f03f9ef61524bdb7ae089b18e4cd254
Closes-Bug: 1271780
Compact pre-Icehouse database migrations <= 190.

Compacts the pre-Icehouse database migrations <= 190 into a
single migration (190_havana.py).

Pre-Icehouse users will now need to upgrade to Havana before
running any Icehouse migrations.

Tested on MySQL and PostgreSQL schemas on Fedora 19 to ensure the
new compacted migration generates an identical schema to the
previous migrate scripts in Havana.

Specific changes include:

 1) Drop migrations 181 - 184 which synced up shadow table changes.
   We now accomodate these changes in the base migration.

 2) Rename unique contraints per 185_rename_unique_constraints.py

 3) Add a new BDM table format.

 4) Add instance groups tables.

 5) add reason column to service

 6) add cells unique constraint

 7) add security groups unique constraint

Change-Id: Ibf2289f37c2376f3bd564728db5400859523c619
Implements: blueprint compact-havana-db-migrations
Compact pre-Icehouse database migrations <= 200.

Compacts the pre-Icehouse database migrations <= 200 into a
single migration (200_havana.py).

Pre-Icehouse users will now need to upgrade to Havana before
running any Icehouse migrations.

Tested on MySQL and PostgreSQL schemas on Fedora 19 to ensure the
new compacted migration generates an identical schema to the
previous migrate scripts in Havana.

Specific changes include:

  1) Add unique constraint on quotas.

  2) cleanup virtual_interfaces unique constraints

  3) Remove a bunch of volume tables (cinder cleanup)

  4) Indexes cleanup per 194_fix_152_migration_indexes.py

  5) Add unique constraint on fixed_ips.address.

  6) Add unique constraint on services columns.

  7) Add unique constraint on agent_builds columns.

  8) Add unique constraint on console_pools columns.

  9) Add unique constraint on aggregate_hosts columns.

  10) Add transport_url column to cells. (removes RPC columns)

Implements: blueprint compact-havana-db-migrations

Change-Id: Ie14e9e5de6d7d43ebabfc4680ed6434d08ecee49
Compact pre-Icehouse database migrations <= 210.

Compacts the pre-Icehouse database migrations <= 210 into a
single migration (210_havana.py).

Pre-Icehouse users will now need to upgrade to Havana before
running any Icehouse migrations.

Tested on MySQL and PostgreSQL schemas on Fedora 19 to ensure the
new compacted migration generates an identical schema to the
previous migrate scripts in Havana.

Specific changes include:

 1) Add more indexes for SQLite DB (per 201).

 2) Add unique constraint on instance_type_extra_specs.

 3) Add project_user_quotas, indexes, and constraints.

 4) Add indexes to reservations.

 5) Add locked by to instances.

 6) Add cleaned column to instances.

 7) Add host_ip/supported_instances to compute_nodes.

 8) Add missing Fkeys.

 9) Fix project_user_quotas_user_id_deleted index.

Implements: blueprint compact-havana-db-migrations

Change-Id: I63e00cd29eb4c26717b5ebd7a1ff11a01c0085de
Finish compacting pre-Icehouse database migrations

Compacts the pre-Icehouse database migrations into a
single migration (216_havana.py).

Pre-Icehouse users will now need to upgrade to Havana before
running any Icehouse migrations.

Tested on MySQL and PostgreSQL schemas on Fedora 19 to ensure the
new compacted migration generates an identical schema to the
previous migrate scripts in Havana.

Specific changes include:

  1) Add aggregate metadata unique constraint.

  2) Fix migrations index (add deleted column).

  3) Add pci_devices table.

  4) fix migrations_instance_uuid_and_status_idx index.

Implements: blueprint compact-havana-db-migrations

Change-Id: Id96e13b0ed65837761bd173c9e32ebcc1ff5f376
Make service workers gracefully handle service creation race

Right now, service workers can race to create their service record
in the database. This makes a NotFound...Exists pattern not fail
when the service record shows up due to a successful sibling.

Change-Id: I3e912beeb953c85189f44171d958e9402abc01ae
Add Network object

This adds a Network object to provide services and modeling
for nova-network and its use of the current SQLAlchemy Network
model.

Related to blueprint nova-network-objects

Change-Id: I7f943cda32fc98b3b03cdbb5d68e0c741053afaa
Make obj_to_primitive() handle netaddr types

This makes base.obj_to_primitive() handle netaddr.IPAddress() and
netaddr.IPNetwork() objects so that they properly become strings
in the primitive format, which provides compatibility with existing
network dicts.

Related to blueprint nova-network-objects

Change-Id: I098d775a2a792073b2777495d665846f399ecf3e
Make nova-network use Network to create networks

This makes nova-network manager use the Network.create() method
to do the work of creating networks. It also makes the rpcapi
use the NovaObjectSerializer since this is the first change that
makes nova-network return or take an object via RPC.

Related to blueprint nova-network-objects

Change-Id: Ida9a05ac249ff168075f87e5dbdad6bc23e69561
VMware: Only include connected hosts in cluster stats

Currently the driver includes all hosts connected to VC
(including disconnected hosts) when calculating available
vcpus. The patch enforces that the reported available stats
only include resources of hosts that are connected to the
VC.

Note: A host can be connected to a VC, but have a disconnected
host state

Change-Id: Iba9d80f894cc2b7471a7f9c87b7367fd93bacb48
Closes-Bug: 1257998
Docker Set Container name to Instance ID

Docker has named container since 0.7. In order to make it easier for the
admin to troubleshoot and find container set the container name to the nova
instance UUID. Addtional the name is prefixed with nova.

Example: nova-d7553842-2424-4471-98a7-92a1db70033b

DocImpact - Docker driver requires Docker 0.7 or newer.

Change-Id: I4f12734663e726b08f53400fdfcfb8d31401490d
Blueprint:
https://blueprints.launchpad.net/nova/+spec/docker-name-instance-id
Adds ephemeral_key_uuid field to instance

Patch adds a field to instance for storing the uuid of
the key used to encrypt instance's ephemeral storage.

Implements: blueprint encrypt-ephemeral-storage
Change-Id: Id5b1e272d4461875bb231839e4714d3ed0899d3f
Adds dmcrypt utility module

Patch adds a module for manipulating dmcrypt devices.

Implements: blueprint encrypt-ephemeral-storage
Change-Id: I308b9f26c382b332c02f13aa1d5f0a830e9ef277