Fix EC2 instance type for a volume backed instance.

EC2 reports 'instance-store' type for a volume backed instance
which was booted with short root device name (no '/dev/' prefix).

This fix make instance type detection independent of addition
'dev' prefix to the instance root device name.

Change-Id: I6c2be09eaa91341e401bbc128b3efc79c60e345e
Closes-Bug: #1324400
Cells: Update set_admin_password for objects

Cells code was calling the compute/api set_admin_password method with an
old-world style instance and failing on the task_state attribute access.
This adds set_admin_password to the list of methods handled via the
cells RPC redirect method which is objects compatible.

Change-Id: I12e212260ed62dc9380202de31fda928a9498dcb
Closes-Bug: #1335315
libvirt: improve unit test time

There were unit tests that were taking more than 4 seconds.

nova.tests.virt.libvirt.test_driver.LibvirtConnTestCase.test_clean_shutdown_failure    5.091
nova.tests.virt.libvirt.test_driver.LibvirtConnTestCase.test_clean_shutdown_with_retry 4.093

TrivialFix

Change-Id: I75cdb74dca69a1e31d6b974148c9590328c362e1
Closes-bug: #1366549
Remove exclude coverage regex from coverage job

This commit removes the regex to exclude the coverage extension from
the tox coverage job. The regex was needed for the unit tests on the
coverage extension, (which would mock out coverage) however that
extension has since been removed from nova. So we no longer need to
exclude tests that don't exist anymore.

Change-Id: I45685b1113ecc78eda92f13755ff2274ff517829
Make sure libvirt VIR_ERR_NO_DOMAIN errors are handled correctly

Some libvirt VIR_ERR_NO_DOMAIN errors leak outside of the libvirt
driver, which may result in instances being set to ERROR state.

Make sure such errors are either ignored (during destroy) or
otherwise turned into InstanceNotFound errors.

Change-Id: I0ac2989062247a05162825760367488f4f90bd04
Closes-Bug: #1368404
virt: use compute.virttype constants and validate virt type

Where we have hardcoded hypervisor types, use compute.hvtype
constants. Where we get hypervisor types from external systems,
validate them against the list of acceptable names.

The Xen hypervisor is reporting a virt type of 'xapi' for
supported instances which is confusing the virtualization
type with the hypervisor API access method. It should be
reporting 'xen' as the virtualization type.

On the other side, the ImagePropertiesFilter will canonicalize
the hvtype it fetches from image metadata, so that 'xapi' gets
remapped to 'xen' during comparison.

Upgrade-impact: the hyervisor type will intentionally no longer
  distinguish libvirt Xen from XenAPI within a compute cloud.
  The driver name should be used instead
Closes-bug: #1348623
Change-Id: I2c740e8eb068a5d93ba5f72292fb30d899931ea5
Don't swallow exceptions in deallocate_port_for_instance

This uses the new _delete_ports method to (1) still
ignore 404 errors but also (2) raise up non-404 errors
from the neutron client when deleting the port fails as
we shouldn't be masking over this since the nova-api
call wouldn't be failing even though the underlying
operation failed.

Change-Id: Id05ea47ba03e0b60ae3a296920159e8189f9dd55
Related-Bug: #1292243
check network ambiguity before external network auth

This change refactors the logic in the neutronv2 api to check for
network ambiguity before checking permission to attach external
network. In the scenario when there is a network available in the
client's tenant and an external shared network available in a
different tenant, the client was receiving a Forbidden error
because the external network was in the list of available networks
even though the client did have access to the other network in the
list.

With this change, the client receives a NetworkAmbiguous error instead
the same scenario, as they could succeed in booting an instance while
specifying --nic with the net-id of the network they can access.

Closes-Bug: #1364344

Change-Id: Ia94c25ff0ffd6a368da272fc6d883986156a0362
Improve secgroup create error message

Fixes secgroup create API so that when it is passed a name
or description field which is an empty string the error message
specifies which field is of the incorrect format.

Change-Id: Ieff67438965a735f2328390125bb4e66aec5e83d
Closes-Bug: 1369358
libvirt: avoid 30 second long test in LXC mount setup

The test_create_propagates_exceptions test case in the libvirt
driver test has a 30 second delay while disk setup times out.

  File "nova/virt/libvirt/driver.py", line 4412, in _create_domain_and_network
    disk_info):
  File "/usr/lib64/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "nova/virt/libvirt/driver.py", line 4308, in _lxc_disk_handler
    self._create_domain_setup_lxc(instance, block_device_info, disk_info)
  File "nova/virt/libvirt/driver.py", line 4260, in _create_domain_setup_lxc
    use_cow=use_cow)
  File "nova/virt/disk/api.py", line 386, in setup_container
    dev = img.mount()
  File "nova/virt/disk/api.py", line 306, in mount
    if mounter.do_mount():
  File "nova/virt/disk/mount/api.py", line 218, in do_mount
    status = self.get_dev() and self.map_dev() and self.mnt_dev()
  File "nova/virt/disk/mount/nbd.py", line 120, in get_dev
    return self._get_dev_retry_helper()
  File "nova/virt/disk/mount/api.py", line 121, in _get_dev_retry_helper
    time.sleep(2)

Mock out the _create_domain_setup_lxc & _create_domain_cleanup_lxc
methods to avoid exercising this codepath which is irrelevant to the
goals of the test case.

Resolves-bug: #1369537
Change-Id: Ic860f83ac0b3b7242658640618b223d89c4db253
Merge "virt: use compute.virttype constants and validate virt type"
Merge "Fix EC2 instance type for a volume backed instance."
Merge "check network ambiguity before external network auth"
Merge "Improve secgroup create error message"
Merge "Don't swallow exceptions in deallocate_port_for_instance"
Merge "Cells: Update set_admin_password for objects"
Merge "Make sure libvirt VIR_ERR_NO_DOMAIN errors are handled correctly"
Merge "libvirt: improve unit test time"
Merge "Remove exclude coverage regex from coverage job"
Merge "libvirt: avoid 30 second long test in LXC mount setup"