def test_service_update(self): service = self._create_service({}) new_values = { 'host': 'fake_host1', 'binary': 'fake_binary1', 'topic': 'fake_topic1', 'report_count': 4, 'disabled': True } db.service_update(self.ctxt, service['id'], new_values) updated_service = db.service_get(self.ctxt, service['id']) for key, value in new_values.iteritems(): self.assertEqual(value, updated_service[key])
def _report_state(self, service): """Update the state of this service in the datastore.""" ctxt = context.get_admin_context() state_catalog = {} try: report_count = service.service_ref['report_count'] + 1 state_catalog['report_count'] = report_count service.service_ref = db.service_update(ctxt, service.service_ref['id'], state_catalog) if getattr(service, 'model_disconnected', False): service.model_disconnected = False LOG.error(_('Recovered model server connection!')) except Exception: if not getattr(service, 'model_disconnected', False): service.model_disconnected = True LOG.exception(_('model server went away'))