Skip to content

Commit

Permalink
Add missing exception
Browse files Browse the repository at this point in the history
Change Idd49b0c70caedfcd42420ffa2ac926a6087d406e added support for
discovery of PMEM devices by the libvirt driver. Some error handling
code in this was expected to raise a 'GetPMEMNamespacesFailed'
exception, however, a typo meant the exception was actually called
'GetPMEMNamespaceFailed' (singular). This exception was later removed in
change I6fd027fb51823b8a8a24ed7b864a2191c4e8e8c0 because it had no
references.

Re-introduce the exception, this time with the correct name, and add
some unit tests to prevent us regressing.

Change-Id: I3b597a46314a1b29a952fc0f7a9c4537341e37b8
Signed-off-by: Stephen Finucane <[email protected]>
Closes-Bug: #1904446
(cherry picked from commit 160ed6f)
  • Loading branch information
stephenfin committed Nov 19, 2020
1 parent a806b1d commit 82d415d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nova/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -2281,6 +2281,10 @@ class PMEMNamespaceConfigInvalid(NovaException):
"please check your conf file. ")


class GetPMEMNamespacesFailed(NovaException):
msg_fmt = _("Get PMEM namespaces on host failed: %(reason)s.")


class VPMEMCleanupFailed(NovaException):
msg_fmt = _("Failed to clean up the vpmem backend device %(dev)s: "
"%(error)s")
Expand Down
9 changes: 9 additions & 0 deletions nova/tests/unit/virt/libvirt/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -27549,6 +27549,15 @@ def test_vpmems_duplicated_config(self, mock_get):
self.assertRaises(exception.PMEMNamespaceConfigInvalid,
drvr._discover_vpmems, vpmem_conf)

@mock.patch('nova.privsep.libvirt.get_pmem_namespaces')
def test_get_vpmems_on_host__exception(self, mock_get_ns):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
mock_get_ns.side_effect = Exception('foo')

self.assertRaises(
exception.GetPMEMNamespacesFailed,
drvr._get_vpmems_on_host)

@mock.patch('nova.virt.hardware.get_vpmems')
def test_get_ordered_vpmems(self, mock_labels):
# get orgered vpmems based on flavor extra_specs
Expand Down

0 comments on commit 82d415d

Please sign in to comment.