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
xenapi: deal with reboots while talking to agent

The latest version of the agent has started changing the hostname
through the official windows APIs, when resetnetwork is called. This
means a reboot might happen after resetnetwork.

A reboot happens when polling for the version. Until now we wait for the
call timeout, before fetching the new dom id. This change ensures that
if we spot a reboot, the plugin exits early rather than keeping polling
the wrong dom id.

Turns out its best to wait for the dom_id to change, before trying
to poll the agent again. Once the dom_id in xenapi has been updated,
the xenstore keys are always in place.

Trying too early leads to lots of reboot detections because we are
retrying with the old dom_id. XenServer continues to return the old
dom_id for a little while after the reboot.

Closes-Bug: #1370999

Change-Id: Id0bf5b64f2b271d162db5bbce50167ab1f665c87
VMware: remove unused variable from tests

Commit 6c4b89a2ad51f92707acc01908b63bc507ad8fe7 added a variable
which was never used.

Change-Id: I6d9391359f25feedbdf822a606c07b0ae9a735be
console: make unsupported ws scheme in python < 2.7.4

Due to a bug in python < 2.7.4, urlparse won't parse a query string
in a URL where the scheme is not recognized:

http://bugs.python.org/issue9374

Commit 1dda5ef75a5c141c316639716820b0c37773a9e3 added some tests for
websocketproxy that uses urlparse to get a token but these don't work
on python < 2.7.4 since the scheme in the tests is "ws://".

In the actual code, raise an exception if python < 2.7.4 and an
unsupported URL scheme is used.

DocImpact: The "getting-started-with-vnc-proxy" page in the
"admin-guide-cloud" docs should be updated with a note that the web
proxy console URLs do not support the websocket protocol scheme (ws://)
on python versions less than 2.7.4.

Change-Id: Ib6e0fc4e50c1ea144a9c538099e23597d66b429b
Closes-Bug: #1376078
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
Support message queue clusters in inter-cell communication

Since cells use oslo.messaging to specify and store the message queue URL,
multiple hosts can be specified by manually modifying that URL in the database.
However, there is no way to specify multiple hosts during cell creation phase.
This patch adds a --broker_hosts option to `nova-manage cell create` command,
which is analogous to the rabbit_hosts option in nova.conf and can be used to
specify multiple message queue servers as a comma separated list. Each server
is specified using hostname:port with both being mandatory. The existing
--hostname and --port options continue to remain but are only considered if no
--broker_hosts is specified.
Internally, each host is converted to a oslo.messaging.TransportHost
and added to the generated TransportURL.
This patch also adds unit tests for creation of the TransportHosts from
user given input.

Change-Id: I14de860b1d12f3e2c0169b58651d580792d6ce0e
Closes-Bug: 1178541
VMware: Set vmPathName properly in fake driver

When creating a VM, we pass in config.files.vmPathName as '[ds]'.
However, when this value is subsequently retrieved from a real vSphere
server, it is '[ds] uuid/uuid.vmx'.

This change defaults the value of vmPathName if it's a bare datastore
name to mirror the behaviour of a real vSphere server.

Change-Id: Ide2a4d69fe0ce3214c85b132a8d653f8d5e275f9
Remove baremetal virt driver

This patch removes the baremetal virt driver from nova, which was
deprecated in Juno. It does not aim to perform any of the refactoring
we need to do now that the driver is gone, but is intended as a clean
removal of all the baremetal code itself.

Of specific note are the api_samples tests. We didn't have samples to
test the ironic proxy code, so I removed the baremetal ones for show
and index, resetting that extension back to "untested" status as if it
was new.

Tests that stub out ironic interactions and re-introduce those tests
should be added after this patch.

Change-Id: Ia76e41a8a3b7230701872ae7a1975edc3d9ea847
Fix broken cert revocation

Cert revocation was broken by
32b0adb591f80ad2c5c19519b4ffc2b55dbea672.  os.chdir() never returns
anything, so this method would always raise an exception.  The proper
way to handle an error from os.chdir() is to catch OSError.

There were existing tests for this code, but they conveniently mocked
os.chdir() to return values that are never actually returned.  The
tests were fixed to match the real behavior.

Change-Id: I7549bb60a7d43d53d6f81eecea31cbb9720cc8b6
Closes-bug: #1376368
Break out over-quota processing from quota_reserve()

This moves the over-quota processing out of quota_reserve and into a
private method.

This completes the refactor of the quota_reserve method to isolate the
large chunks of logic into separate private methods.

Closes-Bug: #1369605

Change-Id: Ic910ea042dfe50209f79928e61b3b34b4c734e73
Merge "Support message queue clusters in inter-cell communication"
Merge "console: make unsupported ws scheme in python < 2.7.4"
Merge "Remove baremetal virt driver"
Merge "VMware: Set vmPathName properly in fake driver"
Merge "Fix swap_volumes"
Merge "Update InstanceInvalidState output"