Currently this method cannot be used widely due to its parameters. It
requires device_info - the dict which can not be easily obtained in many
cases. Since it is often needed to figure out if an instance is booted
from volume, and the method name is "appropriate", this sometimes leads
to errors (when string result of get_instance_disk_info is passed as an
argument to _is_booted_from_volume; see also Id5901254).
This patch makes _is_booted_from_volume to use standard
block_device_info structure, which is accessible in almost any driver
method.
libvirt: Delete duplicate check when live-migrating
A year ago a useless check was added: I7989128d
The above patch was aimed to enable live-migration when
instance is booted from volume and has not local disk
by adding a new check.
However, the same check has been already checked in
_is_shared_block_storage method.
The last part of the _is_shared_block_storage method does
the same that above patch does:
- check whether the instance is booted from volume
- check whether the instance has not a local disk
Also this check calls _is_booted_from_volume incorrectly.
Parameter disk_mapping of _is_booted_from_volume must be a dict, but
this check specifies a string instead.
And finally introduced _has_local_disk method is wrong, because
it does not take into accont disk.ephN names.
This change reverts I7989128d, improves and simplifies related tests.
zhaolihui [Tue, 1 Nov 2016 08:09:04 +0000 (16:09 +0800)]
Fix pci_alias that include white spaces
When the PCI alias was getting translated to a PCI request,
all the white spaces were getting removed. So the pci_passthrough:alias
specified in the flavor never matched the device in pci_alias.
This patch fixes the bug by only stripping the white spaces
at the beginning or the end of the elements
Matthew Booth [Fri, 17 Jun 2016 12:05:24 +0000 (13:05 +0100)]
libvirt: Don't re-resize disks in finish_migration()
finish_migration is called by finish_resize() in compute manager,
which has updated the instance size and flavor before calling us. This
means that _create_image has already resized disks and (where
possible) their contained filesystems by calling cache() with the
correct size. That makes the additional resize in finish_migration a
no-op.
Matthew Booth [Fri, 17 Jun 2016 09:29:49 +0000 (10:29 +0100)]
libvirt: Never copy a swap disk during cold migration
We previously didn't copy a swap disk if we were resizing it, and
instead recreated it on the remote end. With this change we never
copy a swap disk, even if we aren't resizing it. This is more
efficient and less surprising.
Matthew Booth [Wed, 22 Jun 2016 13:41:09 +0000 (14:41 +0100)]
libvirt: Rename Backend snapshot and image
snapshot and image didn't accurately describe what the methods did.
snapshot in particular suggested that the returned object was in some
way specific to a snapshot, whereas snapshot was simply the only user.
We also take the opportunity to rename all variables we touch in
driver to refer to disks rather than images.
Matthew Booth [Thu, 7 Jul 2016 14:29:45 +0000 (15:29 +0100)]
libvirt: Cleanup test_create_configdrive
This test made a tortured trip into _create_image_helper without using
much of its functionality. We pull this out and have it call
_create_configdrive directly.
This leaves _create_image_helper with only a single caller:
test_create_image_with_flavor_swap. This test is almost identical in
purpose to the much better test_create_image_with_swap and
test_create_image_with_legacy_swap_resizing. We refactor
test_create_image_with_swap to use ddt to cover all 3 cases, and
remove _create_image_helper.
This introduces the first use of ddt in Nova tests. It is already in
global-requirements. It was approved for use in Nova tests during the
Ocata contributor meetup:
Matthew Booth [Wed, 6 Jul 2016 09:38:31 +0000 (10:38 +0100)]
libvirt: Test disk creation in test_hard_reboot
This test was asserting a call to _create_images_and_backing in a way
that didn't validate the data passed in any way. We update this to
instead validate that the expected disks are created.
This test highlights a bug in _create_images_and_backing, which is
passing a full path in place of a disk name. This will be fixed by
removing the call to _create_images_and_backing in a subsequent
commit.
This also allows us to validate the future removal of the call to
_create_images_and_backing.
Matthew Booth [Fri, 1 Jul 2016 16:09:39 +0000 (17:09 +0100)]
libvirt: Rewrite _test_finish_migration
Rewrite the finish_migration tests in anticipation of a major update.
Apart from switching from mox to mock, the principal change is that
we're now mocking at the backend boundary rather than the
_create_image boundary, which means we can test what we do to
individual disks. In the updated finish_migration we no longer use
_create_image, so making this change in advance allows us to see the
functional changes more clearly.
Timofey Durakov [Thu, 1 Dec 2016 08:58:18 +0000 (11:58 +0300)]
Fix for live-migration job
Commit 9293ac0 to devstack-plugin-ceph altered
CEPH_LOOPBACK_DISK_SIZE_DEFAULT variable initialization
This fix added source for setting this variable in correct way.
Support detach interface with same MAC from instance
When detach_interface nova uses <interface> XML generated
from scatch, which is missing the PCI device information that
libvirt would use to uniquely identify devices.
In case instance has mutiple interfaces with same MAC address.
Libvirt will failed with below error message:
libvirtError: operation failed: multiple devices matching
mac address fa:16:3e:60:46:1f found
This patch fixes this problem by provide a new function
get_interface_by_cfg, this function uses cfg generated by
nova.virt.libvirt.vif.get_config as parameter,
return a LibvirtConfigGuestInterface object.
Also added function format_dom for
LibvirtConfigGuestDeviceAddressPCI, which will be used to
generate pci address for LibvirtConfigGuestInterface.
Matt Riedemann [Fri, 4 Nov 2016 14:39:57 +0000 (10:39 -0400)]
libvirt: prefer cinder rbd auth values over nova.conf
In the case that the ceph storage backing volumes is different
from the one backing ephemeral storage in nova, the auth values
in the rbd connection_info could be different and not work if
we are using the nova.conf values for ephemeral storage.
This change makes the volume connection config code for rbd
prefer the cinder connection_info values if they exist, and
only falls back to nova config values if cinder doesn't have
anything set.
The LibvirtNetVolumeDriver is handling both rbd and
sheepdog (iscsi) connections. The auth config logic
is mingling both backends which is really confusing.
For example, the iscsi protocol only defines auth_method,
auth_username and auth_password. It does not set an
auth_enabled value in the connection_info['data'] dict.
This change simplifies the logic involved for setting
the auth config by decoupling the rbd/iscsi handlers.
A follow-up change will build on this to fix the
rbd auth config to prefer the cinder volume connection_info
auth data over the local config for nova in the case
that different cinder backends are used for ephemeral
and block storage.
int32bit [Wed, 23 Nov 2016 10:21:16 +0000 (18:21 +0800)]
Fix wait for detach code to handle 'disk not found error'
Currently, the code does an initial detach from the persistent and
transient domains in one call, then follows up with a call of the
retryable function, which first checks the domain xml before retrying
the transient domain detach. If the transient domain detach (which is
asynchronous) completes after we checked the domain xml, trying to
detach it again will raise a LibvirtError exception. Then, our loop
code in `_do_wait_and_retry_detach` doesn't catch it and will respond
with error. We should be handling the `disk not found error` from
libvirt and consider the job complete.
If live_migration_inbound_addr is set in nova.conf, value of the option
will be saved under target_connect_addr in migrate_data. Unfortunately,
the type of value saved in target_connect_addr is unicode, therefore
when creating URI for live migration over dedicated interface we are
ending up with unicode type which is not acceptable by libvirt. To fix
the issue let's convert URI explictly back to string.
Dan Smith [Tue, 29 Nov 2016 15:05:17 +0000 (07:05 -0800)]
Never pass boolean deleted to instance_create()
This explicitly converts the deleted flag to an integer (which will
always be zero) at Instance.create() time. We already require it to
be False, but if set, we will pass the boolean instead of an integer,
which will confuse some (self-respecting) DBMs.
Maho Koshiya [Thu, 13 Oct 2016 08:23:24 +0000 (17:23 +0900)]
Add os-start/stop functional negative tests
The negative tests of os-start/stop API are not covered enough
in functional tests. We want to add the conflict tests of when
this API runs in the unexpected state of server.
* Case of os-start API, the server status must be SHUTOFF.
* Case of os-stop API, the server status must be ACTIVE or ERROR.
ChangBo Guo(gcb) [Thu, 17 Nov 2016 10:55:53 +0000 (18:55 +0800)]
Port ironic unit tests to Python 3
* Use sorted(dict.keys()) because dict.keys() has no sort() method
on Python 3
* Dicts are not orderable in Python 3, need work around. For more
information, please see:
http://stackoverflow.com/questions/22333388/dicts-are-not-orderable-in-python-3
Victor Stinner [Wed, 22 Jun 2016 09:24:27 +0000 (11:24 +0200)]
Port test_metadata to Python 3
* convert_password(): on Python 3, decode password from UTF-8 if it
is a byte string
* convert_password(): don't modify password in the loop body, use an
index increased at each iteration. This is a minor cleanup,
unrelated to Python 3.
* ec2_md_print() now returns byte strings unchanged. On Python 3,
str(bytes) uses "b'...'" format which is not the expected result
(or it raises a BytesWarinng exception when using python3 -bb).
* Replace the base64 module with oslo_serialization.base64 to control
the output type (bytes or text) on Python 2 and Python 3.
* _make_cache_key(): on Python 3, don't encode the host to UTF-8.
Python 3 requires text.
* MetadataRequestHandler: on Python 3, encode HTTP body to UTF-8 if
the body type is Unicode.
* test_metadata:
- encode hmac.new() parameters using encodeutils.to_utf8()
- use response.text rather than response.body to compare with
Unicode string
- use a byte strings for the instance identifier
- fix some Unicode versus bytes issues
Matt Riedemann [Mon, 28 Nov 2016 21:45:58 +0000 (16:45 -0500)]
Fix expected_attrs kwarg in server_external_events
The Instance.get_by_uuid method takes an expected_attrs
kwarg which needs to be a list or tuple, not just any old
iterable like a string. Because of how the underlying
Instance object code massages this value, it's not a hard
failure but does mean you don't join the columns you expect
when getting the instance.
This makes it a list and makes sure the stub in the unit
tests is checking for valid values.
Dan Smith [Mon, 28 Nov 2016 15:24:21 +0000 (07:24 -0800)]
Check deleted flag in Instance.create()
An attempt to create an instance with the deleted flag set will
not work as intended, especially from instance.create(), which
can't properly pass the yet-to-be-determined deleted=id protocol.
This makes Instance.create() throw an error like the one for
being already created, and fixes the one test where we depend
on this working.
Sylvain Bauza [Mon, 28 Nov 2016 17:36:53 +0000 (18:36 +0100)]
Default deleted if the instance from BuildRequest is not having it
We should already have the rehydrated instance having the deleted field being
set. That field is also a BooleanField type, so we should never try to cast it
from an integer (even if we support it). Instead, we need to make sure that if
the field is not set for any reason (mostly because an Instance wasn't persisted
before we persisted the BuildRequest object that was nesting it), then we would
default the deleted field to False.
Markus Zoeller [Tue, 22 Nov 2016 16:08:14 +0000 (17:08 +0100)]
libvirt: Acquire TCP ports for console during live migration
During a live migration process we reserve serial ports on
destination host and update domain XML during migration to
use the new reserved ports from destination.
If the migration succeeds we release ports on the source host.
If the migration fails we release reserved ports on the
destination host.
Roman Podoliaka [Thu, 3 Nov 2016 10:51:48 +0000 (12:51 +0200)]
vif: allow for creation of multiqueue taps in vrouter
This extends the work done in libvirt-virtio-net-multiqueue bp to
allow for enabling multiqueue mode for vrouter VIFs (OpenContrail).
In case of vrouter mechanism is slightly different and a tap device
created by nova-compute must already be in the multiqueue mode,
when it's passed to vrouter.
Implements blueprint vif-vrouter-multiqueue
Co-Authored-By: Michal Dubiel <md@semihalf.com>
Change-Id: I7b20650c8a772fdaa05707e0dfe27ad32481a2d3
Currently the value return from 'utils.aggregate_metadata_get_by_host'
is a type of collections.defaultdict(set). That said all the values
are 'set' not 'String'. Unfortunately, most of test cases related to
aggregate filters are using it with in incorrect way. This patch fixes
it and adds an extra test case to verify it.
Co-Authored-By: Fei Long Wang <flwang@catalyst.net.nz>
Change-Id: I12f033a66ed31cd624bda47be944bab6c841dbf5