def _get_task_details(self, td_uuid):
     td_path = paths.join(self.task_path, td_uuid)
     try:
         td_data, _zstat = self._client.get(td_path)
     except k_exc.NoNodeError:
         raise exc.NotFound("No task details found with id: %s" % td_uuid)
     else:
         return p_utils.unformat_task_detail(td_uuid,
                                             misc.decode_json(td_data))
Example #2
0
 def _get_task_details(self, td_uuid):
     td_path = paths.join(self.task_path, td_uuid)
     try:
         td_data, _zstat = self._client.get(td_path)
     except k_exc.NoNodeError:
         raise exc.NotFound("No task details found with id: %s" % td_uuid)
     else:
         return p_utils.unformat_task_detail(td_uuid,
                                             misc.decode_json(td_data))
    def _update_task_details(self, td, txn, create_missing=False):
        # Determine whether the desired data exists or not.
        td_path = paths.join(self.task_path, td.uuid)
        try:
            td_data, _zstat = self._client.get(td_path)
        except k_exc.NoNodeError:
            # Not-existent: create or raise exception.
            if create_missing:
                txn.create(td_path)
                e_td = logbook.TaskDetail(name=td.name, uuid=td.uuid)
            else:
                raise exc.NotFound("No task details found with id: %s"
                                   % td.uuid)
        else:
            # Existent: read it out.
            e_td = p_utils.unformat_task_detail(td.uuid,
                                                misc.decode_json(td_data))

        # Update and write it back
        e_td = p_utils.task_details_merge(e_td, td)
        td_data = p_utils.format_task_detail(e_td)
        txn.set_data(td_path, misc.binary_encode(jsonutils.dumps(td_data)))
        return e_td
Example #4
0
    def _update_task_details(self, td, txn, create_missing=False):
        # Determine whether the desired data exists or not.
        td_path = paths.join(self.task_path, td.uuid)
        try:
            td_data, _zstat = self._client.get(td_path)
        except k_exc.NoNodeError:
            # Not-existent: create or raise exception.
            if create_missing:
                txn.create(td_path)
                e_td = logbook.TaskDetail(name=td.name, uuid=td.uuid)
            else:
                raise exc.NotFound("No task details found with id: %s" %
                                   td.uuid)
        else:
            # Existent: read it out.
            e_td = p_utils.unformat_task_detail(td.uuid,
                                                misc.decode_json(td_data))

        # Update and write it back
        e_td = p_utils.task_details_merge(e_td, td)
        td_data = p_utils.format_task_detail(e_td)
        txn.set_data(td_path, misc.binary_encode(jsonutils.dumps(td_data)))
        return e_td
 def _get():
     td_path = os.path.join(self._task_path, uuid)
     td_data = jsonutils.loads(self._read_from(td_path))
     return p_utils.unformat_task_detail(uuid, td_data)
Example #6
0
 def _get():
     td_path = os.path.join(self._task_path, uuid)
     td_data = misc.decode_json(self._read_from(td_path))
     return p_utils.unformat_task_detail(uuid, td_data)