Run instance root device determination fix.

Legacy bdm in incoming parameters contains a number of devices
specified by their names (e.g. "vdb" or "/dev/vdc").
Current code considers "vda" as root device and doesn't work on
"/dev/vda", for example.
This fix extracts the last significant character (digits
are skipped in "..sda1")  from the name like "a", "b", "c" and
selects the root device by checking for "a".

Change-Id: Iebaa117bb747d30ac9ceabd8805740dec9d1355c
Closes-Bug: #1322180
libvirt: virt rescue method now supports objects

Commit a37a96fd13b933123e80ad24e37fc37d73c16059 ensured
that the compute API and manager are now getting objects
for the rescue method.

This patch adds support to the virt driver code.

Change-Id: I2ae89f937b1983a2b0599e2eded343aa8358dbba
libvirt: virt unrescue method now supports objects

Commit 65ad230af5ece020822fa963dd30fd641a54ae91 ensured
that the compute API and manager are now getting objects
for the unrescue method.

This patch adds support to the virt driver code.

Change-Id: I5cca3fa997042b164c21fe2a13c2311f4b18ec06
Add subnet routes to network_info when Neutron is used

This change adds subnet routes to the network_info.

Extensions and future code will now have access to subnet routes.

Change-Id: I0827494dd5c95eb596e526204a2d94fcda2bb0dc
Closes-bug: #1315207
Fix cold-migrate missing retry info after scheduling

If the resize failed, nova-compute will try to rescheduling this resize
task. But the retry info is missed at resize compute task. This patch
add the retry info back.

Change-Id: I1b60704955e2fb218d047394dd20afe7f971c03d
Make remove_volume_connection() use objects

Changes the remove_volume_connection() method in compute manager
to take objects.

Related to blueprint compute-manager-objects-juno

Change-Id: I4fabee87df409accd947db3d5b429f7e871c2d60
Replace assert* with more suitable asserts in tests

The following replacements were done in unit tests to
 have clearer messages in case of failure:
- assertTrue(a == b or a == c) with assertIn(a, [b, c])
- assertTrue(type(a) == dict) with assertIsInstance(a, dict)
- assertTrue(type(a) == int) with assertIsInstance(a, int)

Also assertTrue with several conditions was splitted.

Change-Id: Id6e5db9ead8d8dceb9f416c1b55280855d25e604
Replace assertTrue/False with assertEqual/NotEqual

The following replacements were done in tests to have
clearer messages in case of failure:
- assertTrue(* == *) with assertEqual
- assertTrue(* != *) with assertNotEqual
- assertFalse(* == *) with assertNotEqual

Change-Id: Idbb1a292cf8545b87728fa2b815c67f923ef6efa
Forcibly set libvirt uri in baremetal virtual power driver

To ensure the baremetal virtual power driver is able to control
all the available libvirt domains when connecting to the remote
libvirtd host, we enforce virsh to use the 'qemu:///system' uri.

Enforcing it to 'qemu:///system' should not break existing
deployments while also fixing issues appearing when it is not
set, see tripleo bug 1226310.

Finally, while the uri is an actual config parameter for the Ironic ssh
driver, Nova baremetal is in soft freeze so it seemed more appropriate to
just avoid polluting the config file with deprecated, obscure settings.

Change-Id: I1c956bb9fa6fd365ebeea42d374c800455293e2b
Related-Bug: #1226310
api: remove unused function

Change-Id: I2ef2711d2ceffd3a3c375a137ff07f9ad0e18aeb
VMware: create utility function for reconfiguring a VM

A utility method has been created that simplifies the process of
reconfiguring a VM.

Change-Id: I184e2483726e29819164175493cfd1559592358b
libvirt: test setting of CPU tuning data

The setting of the libvirt guest <cputune> data from the
flavor extra_specs quota parameter was never tested. In
fixing this omission, it was noticed that the data was
incorrectly passed around as a string instead of an int.

Change-Id: Ie8b31feddf6c546eb05ca00ead5c56bcd535dd84
libvirt: introduce separate class for cpu tune XML config

Instead of just setting attributes against the main
LibvirtConfigGuest object, have a LibvirtConfigGuestCPUTune
object. This is more flexible when we have to add support
for further cpu tuning attributes.

Blueprint: virt-driver-cpu-pinning
Change-Id: Id3667752fcbbfe3e55ee221fd2cd364d5cfb2f80
vmware: remove unused delete_disk fake vim method

This is unused since the driver moved away from using DeleteVirtualDisk
in I786365847673e5192a21b654cba951b2e7a6f291

Change-Id: I126b4c069178720250f0dc7fcb924cd3c6c450e5
vmwareapi: remove unused fake vim logout method

Unused since I50acb4f1e85650f4c6dffe1a1d25842601be96bf removed the
__del__ implementation from the session.

Change-Id: Id3bc92d0c029eb86a43a67de7b9f2311d3a8e20c
Fix error in rescue rpcapi that prevents sending objects

The change restores the rescue_instance rpc's ability to send
instance objects from version 3.11 onwards, that was inadvertently
broken by https://review.openstack.org/#/c/62314

Unit test modified to check that rpc version passes instance object
instead of dict.

Change-Id: Icffea82da623d3aab4661554b33bd5959bfe2bd8
Closes-Bug: #1327145
Fix run_instance() rpc method to pass instance object

Change I8a206f63cab1e4f939d2c97c258312a8fa540aff converted run_instance()
to use instance objects, but although it changed the rpc version to 3.27
it didn't update the rpcapi method, so at the moment it still passes a
dict.

Related to blueprint compute-manager-objects-juno

Change-Id: I0e511a5c4f1adce901f8812a935b98886c216dc9
Update compute rpcapi tests to use instance object instead of dict

Bugs such as 1327145 when the rpc code is accidentally reverted
to passing dicts instead of objects are not currently detected by
the unit tests because these are always called with a dict.

This change updates all compute rpcapi unit test cases to pass
an instance object to all cases where the version has been
converted to objects, so that such issues are now detected.

Related to blueprint compute-manager-objects-juno

Change-Id: I9b974e3a8e8e6dcbf87b1bdc854f05e94e7a35ce
Enforce task_state is None in ec2 create_image stop instance wait loop

We're hitting races in the gate where the instance.vm_state is STOPPED
but the task_state is POWERING_OFF so when the compute_api.start method
is called, we're in an invalid task state and fail.

The compute manager's stop_instance method is correctly setting the
vm_state to STOPPED and the task_state to None when the instance is
powered off via the virt driver, so we must be hitting this from races
in the ec2 API as noted in the TODO above the method definition.

This change simply checks the task_state in addition to the vm_state
in the wait loop before continuing. The error message is also updated
for context by including the instance uuid, vm_state and task_state,
and removes the timeout value in the message since it was in
milliseconds, not seconds, to begin with.

There is already a unit test that covers this change (which was racing,
hence the bug). There are no changes to that unit test since it's really
an integration test that's running through the compute API and compute
manager code, so the fix tests itself.

Closes-Bug: #1334345

Change-Id: I13f0c743cadda6439ae15607a9ef6e4e4985626d
Clean conntrack records when removing floating ip

Established connections via floating ip won't get disconnected after
disassociating.
This patch move clean_conntrack from migration code to remove_floating_ip to
make sure that established connections on floating ip will get interrupted
immediately after disassociating.

Change-Id: I88d258ea39ea7c76e4cc60a636eb1e3e6aaa6f22
Closes-Bug: #1334938