diff --git a/devstack/tempest-dsvm-lxd-rc b/devstack/tempest-dsvm-lxd-rc index b17d9fb6..112e26ef 100644 --- a/devstack/tempest-dsvm-lxd-rc +++ b/devstack/tempest-dsvm-lxd-rc @@ -36,7 +36,7 @@ r="$r|(?:tempest\.scenario\.test_minimum_basic\.TestMinimumBasicScenario\.test_m # XXX: zulcss (18 Oct 2016) nova-lxd does not support booting from ebs volumes r="$r|(?:tempest\.scenario\.test_volume_boot_pattern.*)" - +r="$r|(?:tempest\.api\.compute\.servers\.test_create_server\.ServersTestBootFromVolume)" # XXX: zulcss (18 Oct 2016) tempest test only passes when there is more than 10 lines in the # console output, and cirros LXD consoles have only a single line of output r="$r|(?:tempest\.api\.compute\.servers\.test_server_actions\.ServerActionsTestJSON\.test_get_console_output_with_unlimited_size)" diff --git a/nova/virt/lxd/driver.py b/nova/virt/lxd/driver.py index d750076a..d0b19e11 100644 --- a/nova/virt/lxd/driver.py +++ b/nova/virt/lxd/driver.py @@ -15,6 +15,7 @@ from __future__ import absolute_import +import errno import io import json import os @@ -95,6 +96,30 @@ BASE_DIR = os.path.join( CONF.instances_path, CONF.image_cache_subdirectory_name) +def _last_bytes(file_like_object, num): + """Return num bytes from the end of the file, and remaning byte count. + + :param file_like_object: The file to read + :param num: The number of bytes to return + + :returns: (data, remaining) + """ + + try: + file_like_object.seek(-num, os.SEEK_END) + except IOError as e: + # seek() fails with EINVAL when trying to go before the start of + # the file. It means that num is larger than the file size, so + # just go to the start. + if e.errno == errno.EINVAL: + file_like_object.seek(0, os.SEEK_SET) + else: + raise + + remaining = file_like_object.tell() + return (file_like_object.read(), remaining) + + def _neutron_failed_callback(event_name, instance): LOG.error('Neutron Reported failure on event ' '%(event)s for instance %(uuid)s', @@ -591,7 +616,7 @@ class LXDDriver(driver.ComputeDriver): utils.execute( 'chmod', '755', instance_attrs.container_path, run_as_root=True) with open(console_path, 'rb') as f: - log_data, _ = utils.last_bytes(f, MAX_CONSOLE_BYTES) + log_data, _ = _last_bytes(f, MAX_CONSOLE_BYTES) return log_data def get_host_ip_addr(self): diff --git a/test-requirements.txt b/test-requirements.txt index e14ea6f7..9f44cc4c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -15,3 +15,4 @@ testscenarios>=0.4 # Apache-2.0/BSD testtools>=1.4.0 # MIT os-testr>=0.8.0 # Apache-2.0 nosexcover # BSD +wsgi-intercept>=1.4.1 # MIT License