Merge "Raise an exception if no active VIOSes in build_tx_feed_task"

This commit is contained in:
Jenkins
2016-06-02 21:11:59 +00:00
committed by Gerrit Code Review
3 changed files with 26 additions and 2 deletions

View File

@@ -103,6 +103,22 @@ class TestVios(test.TestCase):
result = set(vios.get_physical_wwpns(self.adpt, 'fake_uuid'))
self.assertSetEqual(expected, result)
@mock.patch('nova_powervm.virt.powervm.vios.get_active_vioses')
@mock.patch('pypowervm.utils.transaction.FeedTask')
def test_build_tx_feed_task(self, mock_feed_task, mock_get_active_vioses):
mock_get_active_vioses.return_value = ['vios1', 'vios2']
mock_feed_task.return_value = 'mock_feed'
self.assertEqual('mock_feed',
vios.build_tx_feed_task(mock.MagicMock(),
mock.MagicMock()))
@mock.patch('nova_powervm.virt.powervm.vios.get_active_vioses')
def test_build_tx_feed_task_w_empty_feed(self, mock_get_active_vioses):
mock_get_active_vioses.return_value = []
self.assertRaises(
nova_pvm_exc.NoActiveViosForFeedTask, vios.build_tx_feed_task,
mock.MagicMock(), mock.MagicMock())
@mock.patch('retrying.retry')
@mock.patch('nova_powervm.virt.powervm.vios.get_active_vioses')
@mock.patch('nova_powervm.virt.powervm.vios.get_inactive_running_vioses')

View File

@@ -125,6 +125,10 @@ class ViosNotAvailable(nex.NovaException):
"I/O Servers and then restart the Nova Compute Agent.")
class NoActiveViosForFeedTask(nex.NovaException):
msg_fmt = _("There are no active Virtual I/O Servers available.")
class InvalidRebuild(nex.NovaException):
msg_fmt = _("Unable to rebuild virtual machine on new host. Error is "
"%(error)s")

View File

@@ -127,8 +127,12 @@ def build_tx_feed_task(adapter, host_uuid, name='vio_feed_mgr',
in defaults to all storage options (as this is most common
case for using a transaction manager).
"""
return pvm_tx.FeedTask(name,
get_active_vioses(adapter, host_uuid, xag=xag))
active_vio_feed = get_active_vioses(adapter, xag=xag)
if not active_vio_feed:
raise nova_pvm_exc.NoActiveViosForFeedTask()
return pvm_tx.FeedTask(name, active_vio_feed)
def validate_vios_ready(adapter, host_uuid):