Fix swap_volumes

The attach and detach calls to cinder are better handled by cinder this
patch removes them. There is another patch against this bug to modify
cinder.

The attach call is being made against the new volume after the
migrate_volume_completion request. This means it may be done after the
new volume ID in the db has been deleted.

The detach call is being run at the end on the old ID and so may end up
detaching the migrated volume from cinder's perspective.

Change-Id: I3f2d98e9e473905a3de2f02e00c92ae3065e6ae7
Partial-Bug: 1316079
Add warning to periodic_task with interval 0

In Ia227f4c4e69ecf361ab02d1d17a3010303650104, warnings were
added for several options but instance_delete_interval was
left out by mistake.

Closes-Bug: #1188226
Change-Id: I20b396d664e40252743cac4f2a49f4f34882b32f
Update InstanceInvalidState output

Update InstanceInvalidState output because the original format
is not valid and will lead to none readable output.

Change-Id: I8481facd8100ce9a6f87ea208c06d99016a89534
consistently set status as REBUILD when rebuilding

Consider an instance is in SHUTOFF status(stopped). When a rebuild
is issued on this instance, the status does not display as REBUILD.

Similarly, when a rebuild is issued on an instance and the operation
fails, the instance turns to ERROR state. Now if we issue a rebuild
again, the status does not display as REBUILD.

This patch fixes the above mentioned issues by displaying the correct
status i.e REBUILD.

Change-Id: Id11c9d31683a049c61fd751dc0ddabaf22c96cb9
Closes-Bug: #1362733
libvirt: add _get_launch_flags helper method in unit test

In libvirt driver , we have some logic to generate launch_flags in
method _create_domain_and_network, but in unit test we hard code
launch_flags with '0'. This may lead unit test failure in actual test.
We can't extract the logic to a method in libvirt/driver.py, so add
a helper method with same logic for unit test.

Change-Id: I39ce0162b856daf18488e006b0e424c11811e0c0
Use image metadata from source volume of a snapshot

When booting an instance with the block device mapping V2 API and
source=snapshot, the image metadata is not retrieved and stored in
instance system_metadata.  Metadata is not exposed on a volume snapshot
so it is grabbed from the volume that the snapshot is from.

Change-Id: I96d6c2198b2f94470ab9dfee5e4bddb13992d8d5
Closes-bug: #1375478
Merge "Fix swap_volumes"
Merge "Update InstanceInvalidState output"
Merge "Add warning to periodic_task with interval 0"
Merge "Use image metadata from source volume of a snapshot"
Merge "consistently set status as REBUILD when rebuilding"
Merge "libvirt: add _get_launch_flags helper method in unit test"