Beispiel #1
0
 def test_update_device_list_unsupported(self):
     rpcapi = agent_rpc.PluginApi(topics.PLUGIN)
     ctxt = oslo_context.RequestContext('fake_user', 'fake_project')
     devices_up = ['fake_device1', 'fake_device2']
     devices_down = ['fake_device3', 'fake_device4']
     expected_ret_val = {
         'devices_up': ['fake_device2'],
         'failed_devices_up': ['fake_device1'],
         'devices_down': [{
             'device': 'fake_device3',
             'exists': True
         }],
         'failed_devices_down': ['fake_device4']
     }
     rpcapi.update_device_up = mock.Mock(
         side_effect=[Exception('fake_device1 fails'), None])
     rpcapi.update_device_down = mock.Mock(
         side_effect=[{
             'device': 'fake_device3',
             'exists': True
         },
                      Exception('fake_device4 fails')])
     with mock.patch.object(rpcapi.client, 'call'),\
             mock.patch.object(rpcapi.client, 'prepare') as prepare_mock:
         prepare_mock.side_effect = oslo_messaging.UnsupportedVersion(
             'test')
         res = rpcapi.update_device_list(ctxt, devices_up, devices_down,
                                         'fake_agent_id', 'fake_host')
         self.assertEqual(expected_ret_val, res)
Beispiel #2
0
 def test_devices_details_list_unsupported(self):
     agent = rpc.PluginApi('fake_topic')
     ctxt = oslo_context.RequestContext('fake_user', 'fake_project')
     expect_val_get_device_details = 'foo'
     expect_val = [expect_val_get_device_details]
     with mock.patch.object(agent.client, 'call') as mock_call, \
             mock.patch.object(agent.client, 'prepare') as mock_prepare:
         mock_prepare.return_value = agent.client
         mock_call.side_effect = [oslo_messaging.UnsupportedVersion('1.2'),
                                 expect_val_get_device_details]
         func_obj = getattr(agent, 'get_devices_details_list')
         actual_val = func_obj(ctxt, ['fake_device'], 'fake_agent_id')
     self.assertEqual(actual_val, expect_val)
Beispiel #3
0
 def test_get_devices_details_list_and_failed_devices_unsupported(self):
     rpcapi = agent_rpc.PluginApi(topics.PLUGIN)
     ctxt = oslo_context.RequestContext('fake_user', 'fake_project')
     devices = ['fake_device1', 'fake_device2']
     dev2_details = {'device': 'fake_device2', 'network_id': 'net_id',
                     'port_id': 'port_id', 'admin_state_up': True}
     expected_ret_val = {'devices': [dev2_details],
                         'failed_devices': ['fake_device1']}
     rpcapi.get_device_details = mock.Mock(
         side_effect=[Exception('fake_device1 fails'), dev2_details])
     with mock.patch.object(rpcapi.client, 'call'),\
             mock.patch.object(rpcapi.client, 'prepare') as prepare_mock:
         prepare_mock.side_effect = oslo_messaging.UnsupportedVersion(
             'test')
         res = rpcapi.get_devices_details_list_and_failed_devices(
             ctxt, devices, 'fake_agent_id', 'fake_host')
         self.assertEqual(expected_ret_val, res)