Merge lp:~corey.bryant/nova/2014.1.4 into lp:~ubuntu-server-dev/nova/icehouse

Proposed by Corey Bryant
Status: Merged
Merged at revision: 700
Proposed branch: lp:~corey.bryant/nova/2014.1.4
Merge into: lp:~ubuntu-server-dev/nova/icehouse
Diff against target: 728 lines (+132/-526)
9 files modified
debian/changelog (+56/-0)
debian/patches/block-device-mapping-config.patch (+0/-122)
debian/patches/cells-json-store.patch (+0/-76)
debian/patches/disable-websockify-tests.patch (+25/-0)
debian/patches/drop-oslo-utils-usage.patch (+41/-0)
debian/patches/fix-requirements.patch (+6/-6)
debian/patches/libvirt-Handle-unsupported-host-capabilities.patch (+0/-303)
debian/patches/series (+2/-3)
debian/patches/update-run-tests.patch (+2/-16)
To merge this branch: bzr merge lp:~corey.bryant/nova/2014.1.4
Reviewer Review Type Date Requested Status
James Page Needs Fixing
Review via email: mp+253242@code.launchpad.net
To post a comment you must log in.
Revision history for this message
James Page (james-page) wrote :
review: Needs Fixing
lp:~corey.bryant/nova/2014.1.4 updated
701. By Corey Bryant

d/p/update-run-tests.patch: Run tests with default concurrencey.

702. By Corey Bryant

Update patch description for update-run-tests.patch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2014-11-17 17:54:05 +0000
+++ debian/changelog 2015-03-19 16:31:42 +0000
@@ -1,3 +1,59 @@
1nova (1:2014.1.4-0ubuntu1) trusty; urgency=medium
2
3 * Resynchronize with stable/icehouse (cac6472) (LP: #1432608):
4 - [0ff6742] Websocket Proxy should verify Origin header
5 - [c70e1fb] Fix kwargs['instance'] KeyError in @reverts_task_state decorator
6 - [07ec12c] Revert "Eventlet green threads not released back to pool"
7 - [e9cf07b] Compute: Catch binding failed exception while init host
8 - [e275961] Make tests use sha256 as openssl default digest algorithm
9 - [a657582] Eventlet green threads not released back to pool
10 - [4b46a86] Fix image metadata returned for volumes
11 - [58a6393] Check min_ram and min_disk when boot from volume
12 - [c5411d2] Extends use of ServiceProxy to more methods in HostAPI in cells
13 - [1e2abd6] Remove usage of self.__dict__ for message var replacement
14 - [54f9225] only emit deprecation warnings once
15 - [52103be] Fix disconnecting necessary iSCSI sessions issue
16 - [cca94d0] Fix connecting unnecessary iSCSI sessions issue
17 - [ac9f5c7] Fix wrong command for _rescan_multipath
18 - [d7c8e93] Fix unsafe SSL connection on TrustedFilter
19 - [9ecc468] Fix SecurityGroupExists error when booting instances
20 - [33be7d7] Update "num_instance" during delete instance
21 - [3de3f10] Fix nova evacuate issues for RBD
22 - [fe289fb] Fix nova-compute start issue after evacuate
23 - [f781656] Add _security_group_ensure_default() DBAPI method
24 - [8812672] Run build_and_run_instance in a separate greenthread
25 - [b6a080b] Fixes DOS issue in instance list ip filter
26 - [5ab0421] Make the block device mapping retries configurable
27 - [0695e14] Retry on closing of luks encrypted volume in case device is busy
28 - [dffa810] Add @_retry_on_deadlock to _instance_update()
29 - [f086ca3] Nova api service doesn't handle SIGHUP properly
30 - [7cdb643] Fix XML UnicodeEncode serialization error
31 - [98a6c1e] postgresql: use postgres db instead of template1
32 - [155664f] share neutron admin auth tokens
33 - [3e80433] VMware: validate that VM exists on backend prior to deletion
34 - [d71445c] VMWare: Fix VM leak when deletion of VM during resizing
35 - [56b62b7] Sync process utils from oslo
36 - [ddd62ff] VMware: prevent race condition with VNC port allocation
37 - [4174130] Fixes Hyper-V volume mapping issue on reboot
38 - [bfeae68] Fix CellStateManagerFile init to failure
39 - [5ec3cd3] Raise descriptive error for over volume quota
40 - [f9fad7a] Fixes missing ec2 api address disassociate error on failure
41 - [64ec1bf] Fix instance cross AZ check when attaching volumes
42 - [698c821] Ignore errors when deleting non-existing vifs
43 - [8141e7a] libvirt: Handle unsupported host capabilities
44 - [df9ead9] libvirt: Make `fakelibvirt.libvirtError` match
45 - [cac6472] Add _wrap_db_error() support to SessionTransaction.commit()
46 * d/p/drop-oslo-utils-usage.patch: Added to override new oslo.utils dep.
47 * d/p/disable-websockify-tests.patch: Added to disable websockify tests.
48 * d/p/block-device-mapping-config.patch: Dropped. Fixed upstream in [5ab0421].
49 * d/p/libvirt-Handle-unsupported-host-capabilities.patch: Dropped. Fixed
50 upstream in [8141e7a] and [df9ead9].
51 * d/p/cells-json-store.patch: Dropped. Fixed upstream in [bfeae68].
52 * d/p/fix-requirements.patch: Rebased.
53 * d/p/update-run-tests.patch: Run tests with default concurrencey.
54
55 -- Corey Bryant <corey.bryant@canonical.com> Mon, 16 Mar 2015 08:29:39 -0400
56
1nova (1:2014.1.3-0ubuntu2) trusty; urgency=medium57nova (1:2014.1.3-0ubuntu2) trusty; urgency=medium
258
3 [ Corey Bryant ]59 [ Corey Bryant ]
460
=== removed file 'debian/patches/block-device-mapping-config.patch'
--- debian/patches/block-device-mapping-config.patch 2014-11-10 16:31:07 +0000
+++ debian/patches/block-device-mapping-config.patch 1970-01-01 00:00:00 +0000
@@ -1,122 +0,0 @@
1Description: Make the block device mapping retries configurable
2Author: Akash Gangil <akashg1611@gmail.com>
3Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/nova/+bug/1376927
4Forwarded: https://review.openstack.org/#/c/129276/
5diff --git a/nova/compute/manager.py b/nova/compute/manager.py
6index 260a2b7..45e143c 100644
7--- a/nova/compute/manager.py
8+++ b/nova/compute/manager.py
9@@ -120,6 +120,10 @@ compute_opts = [
10 cfg.IntOpt('network_allocate_retries',
11 default=0,
12 help="Number of times to retry network allocation on failures"),
13+ cfg.IntOpt('block_device_allocate_retries',
14+ default=180,
15+ help='Number of times to retry block device'
16+ ' allocation on failures')
17 ]
18
19 interval_opts = [
20@@ -153,7 +157,11 @@ interval_opts = [
21 cfg.IntOpt('instance_delete_interval',
22 default=300,
23 help=('Interval in seconds for retrying failed instance file '
24- 'deletes'))
25+ 'deletes')),
26+ cfg.IntOpt('block_device_allocate_retries_interval',
27+ default=1,
28+ help='Waiting time interval (seconds) between block'
29+ ' device allocation retries on failures')
30 ]
31
32 timeout_opts = [
33@@ -1135,24 +1143,21 @@ class ComputeManager(manager.Manager):
34 instance)
35 return network_info
36
37- def _await_block_device_map_created(self, context, vol_id, max_tries=180,
38- wait_between=1):
39+ def _await_block_device_map_created(self, context, vol_id):
40 # TODO(yamahata): creating volume simultaneously
41 # reduces creation time?
42 # TODO(yamahata): eliminate dumb polling
43- # TODO(harlowja): make the max_tries configurable or dynamic?
44 attempts = 0
45 start = time.time()
46- while attempts < max_tries:
47+ while attempts < CONF.block_device_allocate_retries:
48 volume = self.volume_api.get(context, vol_id)
49 volume_status = volume['status']
50 if volume_status not in ['creating', 'downloading']:
51 if volume_status != 'available':
52 LOG.warn(_("Volume id: %s finished being created but was"
53 " not set as 'available'"), vol_id)
54- # NOTE(harlowja): return how many attempts were tried
55 return attempts + 1
56- greenthread.sleep(wait_between)
57+ greenthread.sleep(CONF.block_device_allocate_retries_interval)
58 attempts += 1
59 # NOTE(harlowja): Should only happen if we ran out of attempts
60 raise exception.VolumeNotCreated(volume_id=vol_id,
61diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
62index f1e334d..81765b4 100644
63--- a/nova/tests/compute/test_compute.py
64+++ b/nova/tests/compute/test_compute.py
65@@ -34,6 +34,8 @@ from oslo import messaging
66 import six
67 from testtools import matchers as testtools_matchers
68
69+from eventlet import greenthread
70+
71 import nova
72 from nova import availability_zones
73 from nova import block_device
74@@ -378,6 +380,8 @@ class ComputeVolumeTestCase(BaseTestCase):
75 lambda *a, **kw: None)
76 self.stubs.Set(self.compute.volume_api, 'check_attach',
77 lambda *a, **kw: None)
78+ self.stubs.Set(greenthread, 'sleep',
79+ lambda *a, **kw: None)
80
81 def store_cinfo(context, *args, **kwargs):
82 self.cinfo = jsonutils.loads(args[-1].get('connection_info'))
83@@ -438,7 +442,9 @@ class ComputeVolumeTestCase(BaseTestCase):
84 mock_get_by_id.assert_called_once_with(self.context, 'fake')
85 self.assertTrue(mock_attach.called)
86
87- def test_await_block_device_created_to_slow(self):
88+ def test_await_block_device_created_too_slow(self):
89+ self.flags(block_device_allocate_retries=2)
90+ self.flags(block_device_allocate_retries_interval=0.1)
91
92 def never_get(context, vol_id):
93 return {
94@@ -449,13 +455,15 @@ class ComputeVolumeTestCase(BaseTestCase):
95 self.stubs.Set(self.compute.volume_api, 'get', never_get)
96 self.assertRaises(exception.VolumeNotCreated,
97 self.compute._await_block_device_map_created,
98- self.context, '1', max_tries=2, wait_between=0.1)
99+ self.context, '1')
100
101 def test_await_block_device_created_slow(self):
102 c = self.compute
103+ self.flags(block_device_allocate_retries=4)
104+ self.flags(block_device_allocate_retries_interval=0.1)
105
106 def slow_get(context, vol_id):
107- while self.fetched_attempts < 2:
108+ if self.fetched_attempts < 2:
109 self.fetched_attempts += 1
110 return {
111 'status': 'creating',
112@@ -467,9 +475,7 @@ class ComputeVolumeTestCase(BaseTestCase):
113 }
114
115 self.stubs.Set(c.volume_api, 'get', slow_get)
116- attempts = c._await_block_device_map_created(self.context, '1',
117- max_tries=4,
118- wait_between=0.1)
119+ attempts = c._await_block_device_map_created(self.context, '1')
120 self.assertEqual(attempts, 3)
121
122 def test_boot_volume_serial(self):
1230
=== removed file 'debian/patches/cells-json-store.patch'
--- debian/patches/cells-json-store.patch 2014-09-30 09:25:52 +0000
+++ debian/patches/cells-json-store.patch 1970-01-01 00:00:00 +0000
@@ -1,76 +0,0 @@
1Description: Fix nova cells failing with a json topology file bug
2Author: Liam Young <liam.young@canonical.com>
3Bug: https://bugs.launchpad.net/nova/+bug/1314677
4Forwarded: https://review.openstack.org/#/c/124811/
5diff --git a/nova/cells/state.py b/nova/cells/state.py
6index b9112bd..1e12450 100644
7--- a/nova/cells/state.py
8+++ b/nova/cells/state.py
9@@ -152,10 +152,7 @@ class CellStateManager(base.Base):
10 cells_config = CONF.cells.cells_config
11
12 if cells_config:
13- config_path = CONF.find_file(cells_config)
14- if not config_path:
15- raise cfg.ConfigFilesNotFoundError(config_files=[cells_config])
16- return CellStateManagerFile(cell_state_cls, config_path)
17+ return CellStateManagerFile(cell_state_cls)
18
19 return CellStateManagerDB(cell_state_cls)
20
21@@ -450,8 +447,11 @@ class CellStateManagerDB(CellStateManager):
22
23
24 class CellStateManagerFile(CellStateManager):
25- def __init__(self, cell_state_cls, cells_config_path):
26- self.cells_config_path = cells_config_path
27+ def __init__(self, cell_state_cls=None):
28+ cells_config = CONF.cells.cells_config
29+ self.cells_config_path = CONF.find_file(cells_config)
30+ if not self.cells_config_path:
31+ raise cfg.ConfigFilesNotFoundError(config_files=[cells_config])
32 super(CellStateManagerFile, self).__init__(cell_state_cls)
33
34 def _cell_data_sync(self, force=False):
35diff --git a/nova/tests/cells/test_cells_state_manager.py b/nova/tests/cells/test_cells_state_manager.py
36index 1c29927..4841e14 100644
37--- a/nova/tests/cells/test_cells_state_manager.py
38+++ b/nova/tests/cells/test_cells_state_manager.py
39@@ -16,12 +16,16 @@
40 Tests For CellStateManager
41 """
42
43+import mock
44+import six
45+
46 from oslo.config import cfg
47
48 from nova.cells import state
49 from nova import db
50 from nova.db.sqlalchemy import models
51 from nova import exception
52+from nova.openstack.common import fileutils
53 from nova import test
54
55
56@@ -78,6 +82,19 @@ class TestCellsStateManager(test.TestCase):
57 state.CellStateManager)
58 self.assertEqual(['no_such_file_exists.conf'], e.config_files)
59
60+ @mock.patch.object(cfg.ConfigOpts, 'find_file')
61+ @mock.patch.object(fileutils, 'read_cached_file')
62+ def test_filemanager_returned(self, mock_read_cached_file, mock_find_file):
63+ mock_find_file.return_value = "/etc/nova/cells.json"
64+ mock_read_cached_file.return_value = (False, six.StringIO({}))
65+ self.flags(cells_config='cells.json', group='cells')
66+ self.assertIsInstance(state.CellStateManager(),
67+ state.CellStateManagerFile)
68+
69+ def test_dbmanager_returned(self):
70+ self.assertIsInstance(state.CellStateManager(),
71+ state.CellStateManagerDB)
72+
73 def test_capacity_no_reserve(self):
74 # utilize entire cell
75 cap = self._capacity(0.0)
76
770
=== added file 'debian/patches/disable-websockify-tests.patch'
--- debian/patches/disable-websockify-tests.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/disable-websockify-tests.patch 2015-03-19 16:31:42 +0000
@@ -0,0 +1,25 @@
1--- a/nova/tests/console/test_websocketproxy.py
2+++ b/nova/tests/console/test_websocketproxy.py
3@@ -16,8 +16,13 @@
4
5
6 import mock
7+import testtools
8+
9+try:
10+ from nova.console import websocketproxy
11+except:
12+ websocketproxy = None
13
14-from nova.console import websocketproxy
15 from nova import exception
16 from nova import test
17 from oslo.config import cfg
18@@ -27,6 +32,7 @@
19
20 class NovaProxyRequestHandlerBaseTestCase(test.TestCase):
21
22+ @testtools.skipIf(websocketproxy is None, "websockify not available")
23 def setUp(self):
24 super(NovaProxyRequestHandlerBaseTestCase, self).setUp()
25
026
=== added file 'debian/patches/drop-oslo-utils-usage.patch'
--- debian/patches/drop-oslo-utils-usage.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/drop-oslo-utils-usage.patch 2015-03-19 16:31:42 +0000
@@ -0,0 +1,41 @@
1Description: Override python-oslo.utils dependency as it's not in trusty.
2Author: Corey Bryant <corey.bryant@canonical.com>
3Bug: https://bugs.launchpad.net/bugs/1432685
4Forwarded: yes
5
6--- a/nova/compute/api.py
7+++ b/nova/compute/api.py
8@@ -26,7 +26,6 @@
9 import uuid
10
11 from oslo.config import cfg
12-from oslo.utils import units
13 import six
14
15 from nova import availability_zones
16@@ -68,6 +67,7 @@
17 from nova.openstack.common import log as logging
18 from nova.openstack.common import strutils
19 from nova.openstack.common import timeutils
20+from nova.openstack.common import units
21 from nova.openstack.common import uuidutils
22 import nova.policy
23 from nova import quota
24--- a/nova/tests/compute/test_compute.py
25+++ b/nova/tests/compute/test_compute.py
26@@ -31,7 +31,6 @@
27 import mox
28 from oslo.config import cfg
29 from oslo import messaging
30-from oslo.utils import units
31 import six
32 from testtools import matchers as testtools_matchers
33
34@@ -69,6 +68,7 @@
35 from nova.openstack.common import jsonutils
36 from nova.openstack.common import log as logging
37 from nova.openstack.common import timeutils
38+from nova.openstack.common import units
39 from nova.openstack.common import uuidutils
40 from nova import policy
41 from nova import quota
042
=== modified file 'debian/patches/fix-requirements.patch'
--- debian/patches/fix-requirements.patch 2014-08-08 17:43:35 +0000
+++ debian/patches/fix-requirements.patch 2015-03-19 16:31:42 +0000
@@ -4,13 +4,13 @@
4--- a/requirements.txt4--- a/requirements.txt
5+++ b/requirements.txt5+++ b/requirements.txt
6@@ -25,9 +25,8 @@6@@ -25,9 +25,8 @@
7 python-neutronclient>=2.3.4,<37 python-neutronclient>=2.3.4,<2.3.11
8 python-glanceclient>=0.9.08 python-glanceclient>=0.9.0,!=0.14.0,<=0.14.2
9 python-keystoneclient>=0.7.09 python-keystoneclient>=0.7.0,<=0.11.2
10-six>=1.6.010-six>=1.6.0
11+six>=1.5.211+six>=1.5.2
12 stevedore>=0.1412 stevedore>=0.14,<1.2
13-websockify>=0.5.1,<0.613-websockify>=0.5.1,<0.6
14 wsgiref>=0.1.214 wsgiref>=0.1.2
15 oslo.config>=1.2.015 oslo.config>=1.2.0,<1.5
16 oslo.rootwrap16 oslo.rootwrap<1.4
1717
=== removed file 'debian/patches/libvirt-Handle-unsupported-host-capabilities.patch'
--- debian/patches/libvirt-Handle-unsupported-host-capabilities.patch 2014-10-03 17:24:01 +0000
+++ debian/patches/libvirt-Handle-unsupported-host-capabilities.patch 1970-01-01 00:00:00 +0000
@@ -1,303 +0,0 @@
1Description: Fix exception when starting LXC containers with libvirt-lxc.
2Author: Chuck Short <zulcss@ubuntu.com>
3Forwarded: Not Needed.
4--- a/nova/tests/virt/libvirt/fakelibvirt.py
5+++ b/nova/tests/virt/libvirt/fakelibvirt.py
6@@ -172,18 +172,76 @@
7
8
9 class libvirtError(Exception):
10- def __init__(self, msg,
11- error_code=VIR_ERR_INTERNAL_ERROR,
12- error_domain=VIR_FROM_QEMU):
13- self.error_code = error_code
14- self.error_domain = error_domain
15- Exception(self, msg)
16+ """This class was copied and slightly modified from
17+ `libvirt-python:libvirt-override.py`.
18+
19+ Since a test environment will use the real `libvirt-python` version of
20+ `libvirtError` if it's installed and not this fake, we need to maintain
21+ strict compatability with the original class, including `__init__` args
22+ and instance-attributes.
23+
24+ To create a libvirtError instance you should:
25+
26+ # Create an unsupported error exception
27+ exc = libvirtError('my message')
28+ exc.err = (libvirt.VIR_ERR_NO_SUPPORT,)
29+
30+ self.err is a tuple of form:
31+ (error_code, error_domain, error_message, error_level, str1, str2,
32+ str3, int1, int2)
33+
34+ Alternatively, you can use the `make_libvirtError` convenience function to
35+ allow you to specify these attributes in one shot.
36+ """
37+ def __init__(self, defmsg, conn=None, dom=None, net=None, pool=None,
38+ vol=None):
39+ Exception.__init__(self, defmsg)
40+ self.err = None
41
42 def get_error_code(self):
43- return self.error_code
44+ if self.err is None:
45+ return None
46+ return self.err[0]
47
48 def get_error_domain(self):
49- return self.error_domain
50+ if self.err is None:
51+ return None
52+ return self.err[1]
53+
54+ def get_error_message(self):
55+ if self.err is None:
56+ return None
57+ return self.err[2]
58+
59+ def get_error_level(self):
60+ if self.err is None:
61+ return None
62+ return self.err[3]
63+
64+ def get_str1(self):
65+ if self.err is None:
66+ return None
67+ return self.err[4]
68+
69+ def get_str2(self):
70+ if self.err is None:
71+ return None
72+ return self.err[5]
73+
74+ def get_str3(self):
75+ if self.err is None:
76+ return None
77+ return self.err[6]
78+
79+ def get_int1(self):
80+ if self.err is None:
81+ return None
82+ return self.err[7]
83+
84+ def get_int2(self):
85+ if self.err is None:
86+ return None
87+ return self.err[8]
88
89
90 class NWFilter(object):
91@@ -219,8 +277,10 @@
92 try:
93 tree = etree.fromstring(xml)
94 except etree.ParseError:
95- raise libvirtError("Invalid XML.",
96- VIR_ERR_XML_DETAIL, VIR_FROM_DOMAIN)
97+ raise make_libvirtError(
98+ libvirtError, "Invalid XML.",
99+ error_code=VIR_ERR_XML_DETAIL,
100+ error_domain=VIR_FROM_DOMAIN)
101
102 definition = {}
103
104@@ -369,7 +429,11 @@
105 123456789L]
106
107 def migrateToURI(self, desturi, flags, dname, bandwidth):
108- raise libvirtError("Migration always fails for fake libvirt!")
109+ raise make_libvirtError(
110+ libvirtError,
111+ "Migration always fails for fake libvirt!",
112+ error_code=VIR_ERR_INTERNAL_ERROR,
113+ error_domain=VIR_FROM_QEMU)
114
115 def attachDevice(self, xml):
116 disk_info = _parse_disk_info(etree.fromstring(xml))
117@@ -380,7 +444,11 @@
118 def attachDeviceFlags(self, xml, flags):
119 if (flags & VIR_DOMAIN_AFFECT_LIVE and
120 self._state != VIR_DOMAIN_RUNNING):
121- raise libvirtError("AFFECT_LIVE only allowed for running domains!")
122+ raise make_libvirtError(
123+ libvirtError,
124+ "AFFECT_LIVE only allowed for running domains!",
125+ error_code=VIR_ERR_INTERNAL_ERROR,
126+ error_domain=VIR_FROM_QEMU)
127 self.attachDevice(xml)
128
129 def detachDevice(self, xml):
130@@ -533,9 +601,11 @@
131 'test:///default']
132
133 if uri not in uri_whitelist:
134- raise libvirtError("libvirt error: no connection driver "
135- "available for No connection for URI %s" % uri,
136- 5, 0)
137+ raise make_libvirtError(
138+ libvirtError,
139+ "libvirt error: no connection driver "
140+ "available for No connection for URI %s" % uri,
141+ error_code=5, error_domain=0)
142
143 self.readonly = readonly
144 self._uri = uri
145@@ -594,16 +664,20 @@
146 def lookupByID(self, id):
147 if id in self._running_vms:
148 return self._running_vms[id]
149- raise libvirtError('Domain not found: no domain with matching '
150- 'id %d' % id,
151- VIR_ERR_NO_DOMAIN, VIR_FROM_QEMU)
152+ raise make_libvirtError(
153+ libvirtError,
154+ 'Domain not found: no domain with matching id %d' % id,
155+ error_code=VIR_ERR_NO_DOMAIN,
156+ error_domain=VIR_FROM_QEMU)
157
158 def lookupByName(self, name):
159 if name in self._vms:
160 return self._vms[name]
161- raise libvirtError('Domain not found: no domain with matching '
162- 'name "%s"' % name,
163- VIR_ERR_NO_DOMAIN, VIR_FROM_QEMU)
164+ raise make_libvirtError(
165+ libvirtError,
166+ 'Domain not found: no domain with matching name "%s"' % name,
167+ error_code=VIR_ERR_NO_DOMAIN,
168+ error_domain=VIR_FROM_QEMU)
169
170 def _emit_lifecycle(self, dom, event, detail):
171 if VIR_DOMAIN_EVENT_ID_LIFECYCLE not in self._event_callbacks:
172@@ -904,14 +978,21 @@
173 'user': 26728850000000L,
174 'iowait': 6121490000000L}
175 else:
176- raise libvirtError("invalid argument: Invalid cpu number")
177+ raise make_libvirtError(
178+ libvirtError,
179+ "invalid argument: Invalid cpu number",
180+ error_code=VIR_ERR_INTERNAL_ERROR,
181+ error_domain=VIR_FROM_QEMU)
182
183 def nwfilterLookupByName(self, name):
184 try:
185 return self._nwfilters[name]
186 except KeyError:
187- raise libvirtError("no nwfilter with matching name %s" % name,
188- VIR_ERR_NO_NWFILTER, VIR_FROM_NWFILTER)
189+ raise make_libvirtError(
190+ libvirtError,
191+ "no nwfilter with matching name %s" % name,
192+ error_code=VIR_ERR_NO_NWFILTER,
193+ error_domain=VIR_FROM_NWFILTER)
194
195 def nwfilterDefineXML(self, xml):
196 nwfilter = NWFilter(self, xml)
197@@ -964,6 +1045,24 @@
198 pass
199
200
201+def make_libvirtError(error_class, msg, error_code=None,
202+ error_domain=None, error_message=None,
203+ error_level=None, str1=None, str2=None, str3=None,
204+ int1=None, int2=None):
205+ """Convenience function for creating `libvirtError` exceptions which
206+ allow you to specify arguments in constructor without having to manipulate
207+ the `err` tuple directly.
208+
209+ We need to pass in `error_class` to this function because it may be
210+ `libvirt.libvirtError` or `fakelibvirt.libvirtError` depending on whether
211+ `libvirt-python` is installed.
212+ """
213+ exc = error_class(msg)
214+ exc.err = (error_code, error_domain, error_message, error_level,
215+ str1, str2, str3, int1, int2)
216+ return exc
217+
218+
219 virDomain = Domain
220
221
222--- a/nova/virt/libvirt/driver.py
223+++ b/nova/virt/libvirt/driver.py
224@@ -77,6 +77,7 @@
225 from nova.openstack.common import excutils
226 from nova.openstack.common import fileutils
227 from nova.openstack.common.gettextutils import _
228+from nova.openstack.common.gettextutils import _LW
229 from nova.openstack.common import importutils
230 from nova.openstack.common import jsonutils
231 from nova.openstack.common import log as logging
232@@ -2888,9 +2889,14 @@
233 # this -1 checking should be removed later.
234 if features and features != -1:
235 self._caps.host.cpu.parse_str(features)
236- except libvirt.VIR_ERR_NO_SUPPORT:
237- # Note(yjiang5): ignore if libvirt has no support
238- pass
239+ except libvirt.libvirtError as ex:
240+ error_code = ex.get_error_code()
241+ if error_code == libvirt.VIR_ERR_NO_SUPPORT:
242+ LOG.warn(_LW("URI %(uri)s does not support full set"
243+ " of host capabilities: " "%(error)s"),
244+ {'uri': self.uri(), 'error': ex})
245+ else:
246+ raise
247 return self._caps
248
249 def get_host_uuid(self):
250--- a/nova/tests/virt/libvirt/test_libvirt.py
251+++ b/nova/tests/virt/libvirt/test_libvirt.py
252@@ -83,7 +83,7 @@
253 try:
254 import libvirt
255 except ImportError:
256- import nova.tests.virt.libvirt.fakelibvirt as libvirt
257+ libvirt = fakelibvirt
258 libvirt_driver.libvirt = libvirt
259
260
261@@ -887,6 +887,42 @@
262 caps = conn.get_host_capabilities()
263 self.assertIn('aes', [x.name for x in caps.host.cpu.features])
264
265+ def test_baseline_cpu_not_supported(self):
266+ conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
267+
268+ # `mock` has trouble stubbing attributes that don't exist yet, so
269+ # fallback to plain-Python attribute setting/deleting
270+ cap_str = 'VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES'
271+ if not hasattr(libvirt_driver.libvirt, cap_str):
272+ setattr(libvirt_driver.libvirt, cap_str, True)
273+ self.addCleanup(delattr, libvirt_driver.libvirt, cap_str)
274+
275+ # Handle just the NO_SUPPORT error
276+ not_supported_exc = fakelibvirt.make_libvirtError(
277+ libvirt.libvirtError,
278+ 'this function is not supported by the connection driver:'
279+ ' virConnectBaselineCPU',
280+ error_code=libvirt.VIR_ERR_NO_SUPPORT)
281+
282+ with mock.patch.object(conn._conn, 'baselineCPU',
283+ side_effect=not_supported_exc):
284+ caps = conn.get_host_capabilities()
285+ self.assertEqual(vconfig.LibvirtConfigCaps, type(caps))
286+ self.assertNotIn('aes', [x.name for x in caps.host.cpu.features])
287+
288+ # Clear cached result so we can test again...
289+ conn._caps = None
290+
291+ # Other errors should not be caught
292+ other_exc = fakelibvirt.make_libvirtError(
293+ libvirt.libvirtError,
294+ 'other exc',
295+ error_code=libvirt.VIR_ERR_NO_DOMAIN)
296+
297+ with mock.patch.object(conn._conn, 'baselineCPU',
298+ side_effect=other_exc):
299+ self.assertRaises(libvirt.libvirtError, conn.get_host_capabilities)
300+
301 def test_lxc_get_host_capabilities_failed(self):
302 conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
303
3040
=== modified file 'debian/patches/series'
--- debian/patches/series 2014-11-10 16:31:07 +0000
+++ debian/patches/series 2015-03-19 16:31:42 +0000
@@ -1,8 +1,7 @@
1# Ubuntu specific patches below here. Note these can be dropped eventually.1# Ubuntu specific patches below here. Note these can be dropped eventually.
2block-device-mapping-config.patch2drop-oslo-utils-usage.patch
3disable-websockify-tests.patch
3fix-requirements.patch4fix-requirements.patch
4skip_ipv6_test.patch5skip_ipv6_test.patch
5arm-console-patch.patch6arm-console-patch.patch
6update-run-tests.patch7update-run-tests.patch
7libvirt-Handle-unsupported-host-capabilities.patch
8cells-json-store.patch
98
=== modified file 'debian/patches/update-run-tests.patch'
--- debian/patches/update-run-tests.patch 2014-03-05 14:00:22 +0000
+++ debian/patches/update-run-tests.patch 2015-03-19 16:31:42 +0000
@@ -1,20 +1,9 @@
1Description: Update run_tests.sh to show results and default the concurrency to 1.1Description: Update run_tests.sh to show results.
2Author: Chuck Short <zulcss@ubuntu.com>2Author: Chuck Short <zulcss@ubuntu.com>
3Forwarded: Not needed.3Forwarded: Not needed.
4diff --git a/run_tests.sh b/run_tests.sh
5index 1fecc4c..84537cb 100755
6--- a/run_tests.sh4--- a/run_tests.sh
7+++ b/run_tests.sh5+++ b/run_tests.sh
8@@ -86,7 +86,7 @@ no_pep8=06@@ -137,14 +137,7 @@
9 coverage=0
10 debug=0
11 update=0
12-concurrency=0
13+concurrency=4
14
15 LANG=en_US.UTF-8
16 LANGUAGE=en_US:en
17@@ -137,14 +137,7 @@ function run_tests {
18 ${wrapper} python setup.py egg_info7 ${wrapper} python setup.py egg_info
19 fi8 fi
20 echo "Running \`${wrapper} $TESTRTESTS\`"9 echo "Running \`${wrapper} $TESTRTESTS\`"
@@ -30,6 +19,3 @@
30 RESULT=$?19 RESULT=$?
31 set -e20 set -e
32 21
33--
341.9.0
35

Subscribers

People subscribed via source and target branches