def test_assigned_hosting_devices_monitored_from_start_retry(self): agent = cfg_agent.CiscoCfgAgentWithStateReport(HOSTNAME, self.conf) fake_hds = [{'id': 'fake_id1'}, {'id': 'fake_id2'}] results = [exceptions.MessagingException(), exceptions.MessagingException(), fake_hds] with mock.patch.object(agent.devmgr_rpc, 'get_hosting_devices_for_agent', side_effect=results), \ mock.patch.object(agent, '_dev_status') as ds_mock: agent.after_start() ds_mock.backlog_hosting_devices.assert_called_once_with(fake_hds)
def _prepare(cls, base, exchange=_marker, topic=_marker, namespace=_marker, version=_marker, server=_marker, fanout=_marker, timeout=_marker, version_cap=_marker, retry=_marker): """Prepare a method invocation context. See RPCClient.prepare().""" if version is not None and version is not cls._marker: # quick sanity check to make sure parsable version numbers are used try: utils.version_is_compatible(version, version) except (IndexError, ValueError): raise exceptions.MessagingException( "Version must contain a major and minor integer. Got %s" % version) kwargs = dict( exchange=exchange, topic=topic, namespace=namespace, version=version, server=server, fanout=fanout) kwargs = dict([(k, v) for k, v in kwargs.items() if v is not cls._marker]) target = base.target(**kwargs) if timeout is cls._marker: timeout = base.timeout if retry is cls._marker: retry = base.retry if version_cap is cls._marker: version_cap = base.version_cap return _CallContext(base.transport, target, base.serializer, timeout, version_cap, retry)
def _check_version(cls, version): if version is not cls._marker: # quick sanity check to make sure parsable version numbers are used try: utils.version_is_compatible(version, version) except (IndexError, ValueError): raise exceptions.MessagingException( "Version must contain a major and minor integer. Got %s" % version)
def test_notify_about_instance_failed_to_send(self, mock_error): instance = mock.Mock(owner='owner', uuid='fake_uuid', user_id='fake_user') type(instance).name = mock.PropertyMock(return_value='fake_name') mock_notifier = mock.Mock() side_effect = oslo_exc.MessagingException('foo') mock_notifier.info.side_effect = side_effect self.notifier.oslo_notifier = mock_notifier self.notifier.notify_about_instance(instance) mock_error.assert_called_once_with( "Oslo notifier failed because of: %s", side_effect)