Add API sample tests to os-network

Partially implements blueprint nova-api-samples
Bug 1070170

Change-Id: I24c708e59e4fe5fcc17be0ae9b7fcb294278a175
Refactor code for setting up libvirt disk mappings

Currently the libvirt disk bus is fixed at the time the driver
is started. The get_guest_storage_config and _create_image
methods thus use some variables initialized in the libvirt
driver constructor to determine disk bus / dev name mappings.

It will shortly become possible to configure a different disk
bus per instance, which invalidates the current assumptions
in the code. A further complication is that the _create_image
and get_guest_storage_config methods needs to duplicate each
others logic for determining disk mapping.

To simplify the current code and make it more make flexible
introduce a new 'blockinfo.py' module in libvirt, and with
it a 'get_disk_mapping' method & associated helper APIs. This
method is responsible for examining the instance type and
block device info dicts and figuring out the complete list of
disks that will be attached to the guest & their optimal
disk bus + dev name values. This info is returned in a dict
and then passed to _create_image and get_guest_storage_config

Thus the logic for determining disk dev names is now isolated
in one single place, separate from the main driver code, so
it has no need to rely on state in the driver object.

Many, many test cases are added to try to thoroughly validate
the disk mapping code, since there are a huge set of possible
configurations the user may request, making it easy to break
the code accidentally.

Blueprint: libvirt-custom-hardware
Change-Id: I645e69fcc7088674f063f619b2acbbee94d7ba61
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Allow disk driver to be chosen per image

This allows for an image in glance to be annotated with a
property describing the required disk / cdrom bus type.

eg

  # glance image-update \
           --property disk_bus=ide \
           --property cdrom_bus=ide \
           f16-x86_64-openstack-sda

Valid bus values vary per the libvirt_type setting:

 qemu/kvm: 'virtio', 'scsi', 'ide', 'usb'
 xen: 'xen', 'ide'
 uml: 'uml'

Requesting an unsupported disk bus will cause the guest
instance to fail to launch.

DocImpact
Blueprint: libvirt-custom-hardware
Change-Id: Ibc20b843ceccf374eae246384a3f246cc1c52a28
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Merge "Add API sample tests to os-network"
Merge "Refactor code for setting up libvirt disk mappings"
Merge "Allow disk driver to be chosen per image"