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
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
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
Use mtu setting from table instead of flag

Adds mtu to argument lists of key methods and configuration of vlan
interface. Also adds deprecation notice to the "help" info for the file
based network_device_mtu configuration property.

Partially-implements blueprint better-support-for-multiple-networks

Change-Id: Ia401eb95ce8c81d104e59b0348e3474655b9a992
Handle InstanceUserDataTooLarge at api layer

compute layer might raise InstanceUserDataTooLarge exception,
this patch catches the exception at API layer and handle it.

Closes-Bug: #1338473

Change-Id: I881e526eaa51ab28316f643430d904f620123d56
sync periodic_task fix from incubator

Set the value of time the periodic task was last run to a multiple of the
spacing value rather than the actual last time run. This ensures tasks runs
regularly but avoids synchronizing that interval with other nodes.

This patch also removes the coalescing of tasks which are _nearby_ (0.2
seconds away).

4dbd3aa Make periodic tasks run on regular spacing interval
21249f1 Fix parenthesis typo misunderstanding in periodic_task

Change-Id: I8873545578f104fd204fbc25493350128b2bc8d4
Object-ify APIv2 agents extension

This makes the APIv2 agents extension use the Agent object instead
of direct database access.

Related to blueprint compute-manager-objects-juno

Change-Id: I79d68be5d14c8af0f96164608f6c535530ef6d5e
Object-ify APIv3 agents extension

This converts the APIv3 agents extension to use the Agent object
instead of direct-to-database queries.

Related to blueprint compute-manager-objects-juno

Change-Id: I780c96bc32e7d457f8af73d941894b7d3ba08d98
Improve BlockDeviceMapping object cells awareness

This patch makes BlockDeviceMapping object methods that are creating and
updating the database more aware of the cells. There are 2 changes that
are good to distinguish between:

 - create() will _never_ work in the API cell and will raise an
   ObjectActionError.
 - save() and destroy() are now aware in which cell they are being
   called and do not attempt to propagate it upwards

This is currently a no-op change as we don not currently use objects in
any of the code that will run in the top cell. This is in fact
preparation for transiting the API code to using BlockDeviceMapping
objects.

Change-Id: Ic5806c844f2deab734011d68f5da316903000f67
Resolve import dependency in consoleauth service

If you attempt to access an instance's noVNC console on the
horizon dashboard, an AttributeError is thrown, complaining
about 'module' object having no attribute 'InstanceInfoCache'.
This is because the objects are not registered by the consoleauth
service. This patch fixes this import dependency by registering
all objects so it could be used by the consoleauth service.

Change-Id: I4f9b922a077076b156833590762106d5cd2ad276
Closes-Bug: #1337447
Fix duplicate definitions of variables/methods

Found these with a static analysis tool. Removed a bad
cut-n-paste of 2 test methods. Changed test method names
slightly to ensure they run

Change-Id: I15a90d0447e8038683a36766138d8db088cb4136
Remove duplicate keys from dictionaries

Found using a static analysis tool. Removed the duplicate key/value
pair as it was unnecessary.

Change-Id: Iab6374031c2af65d66c9d54fcb68c3a94603d43b
libvirt: more efficient method to list domains on host

The current libvirt driver code uses the legacy APIs for
enumerating domains on a host. These have a number of
problems

 - O(N) APIs calls are required to list N domains which
   is slow as number of domains increases
 - Race wrt start/stop of guests gives many problems
     - Domains guest lost between listDomainsIDs() and
       listDefinedDomains()
     - Domains disappear before lookupById/Name is
       called
     - Disagreement between numOfDomains and listDomainsIDs
       and numOfDefinedDomains and listDefinedDomains

Blueprint: libvirt-domain-listing-speedup
Change-Id: Id31f3071dfb10e33c51501b860a03f8975bbe812
Remove duplicate python-pip from Fedora devref setup doc

This just removes the duplicate python-pip from the list
of packages to install via yum when setting up a development
environment on Fedora/RHEL.

Change-Id: I3bd0aa7230c29a97845d744f6522bd2ffd1bf130
Add aggregates.rst to devref index

aggregates.rst was the only devref document that wasn't included in any
toctree.

Change-Id: I3e4392d2571b954d4553ca8e50b02053db4b5d99
Prevent max_count > 1 and specified ip address as input

Previously, if one did:
   nova boot --num-instances 2 --nic net-id=<net_id>,v4-fixed-ip=10.0.0.17
this would result in all of the instances failing to boot because neither
nova-network or neutron allows multiple instances to have the same ip_address.
This patch fixes this from occuring by checking for this and raising an error
to the caller from nova-api.

Change-Id: I7e44d58e66aeb10fb15c3553072f988f65ab823b
Closes-bug: 1318754
Merge "Handle InstanceUserDataTooLarge at api layer"