def report_state(self): """Update the state of this service in the datastore.""" ctxt = context.get_admin_context() zone = FLAGS.node_availability_zone state_catalog = {} try: try: service_ref = db.service_get(ctxt, self.service_id) except exception.NotFound: logging.debug(_('The service database object disappeared, ' 'Recreating it.')) self._create_service_ref(ctxt) service_ref = db.service_get(ctxt, self.service_id) state_catalog['report_count'] = service_ref['report_count'] + 1 if zone != service_ref['availability_zone']: state_catalog['availability_zone'] = zone db.service_update(ctxt, self.service_id, state_catalog) # TODO(termie): make this pattern be more elegant. if getattr(self, 'model_disconnected', False): self.model_disconnected = False logging.error(_('Recovered model server connection!')) # TODO(vish): this should probably only catch connection errors except Exception: # pylint: disable=W0702 if not getattr(self, 'model_disconnected', False): self.model_disconnected = True logging.exception(_('model server went away'))
def update(self, req, id, body): context = req.environ["engine.context"] name = body["service"].get("disabled") db.service_update(context, id, body["service"]) return exc.HTTPAccepted()
def update(self, req, id, body): context = req.environ['engine.context'] name = body['service'].get('disabled') db.service_update(context, id, body['service']) return exc.HTTPAccepted()