Beispiel #1
0
 def _get_logbook(self, lb_uuid):
     lb_path = paths.join(self.book_path, lb_uuid)
     try:
         lb_data, _zstat = self._client.get(lb_path)
     except k_exc.NoNodeError:
         raise exc.NotFound("No logbook found with id: %s" % lb_uuid)
     else:
         lb = p_utils.unformat_logbook(lb_uuid, misc.decode_json(lb_data))
         for fd_uuid in self._client.get_children(lb_path):
             lb.add(self._get_flow_details(fd_uuid))
         return lb
 def _get_logbook(self, lb_uuid):
     lb_path = paths.join(self.book_path, lb_uuid)
     try:
         lb_data, _zstat = self._client.get(lb_path)
     except k_exc.NoNodeError:
         raise exc.NotFound("No logbook found with id: %s" % lb_uuid)
     else:
         lb = p_utils.unformat_logbook(lb_uuid,
                                       misc.decode_json(lb_data))
         for fd_uuid in self._client.get_children(lb_path):
             lb.add(self._get_flow_details(fd_uuid))
         return lb
 def _update_logbook(lb_path, lb_data, txn):
     e_lb = p_utils.unformat_logbook(lb.uuid, misc.decode_json(lb_data))
     e_lb = p_utils.logbook_merge(e_lb, lb)
     lb_data = p_utils.format_logbook(e_lb, created_at=lb.created_at)
     txn.set_data(lb_path, misc.binary_encode(jsonutils.dumps(lb_data)))
     for fd in lb:
         fd_path = paths.join(lb_path, fd.uuid)
         if not self._client.exists(fd_path):
             # NOTE(harlowja): create an entry in the logbook path
             # for the provided flow detail so that a reference exists
             # from the logbook to its flow details.
             txn.create(fd_path)
         e_fd = self._update_flow_details(fd, txn, create_missing=True)
         e_lb.add(e_fd)
     return e_lb
Beispiel #4
0
 def _update_logbook(lb_path, lb_data, txn):
     e_lb = p_utils.unformat_logbook(lb.uuid, misc.decode_json(lb_data))
     e_lb = p_utils.logbook_merge(e_lb, lb)
     lb_data = p_utils.format_logbook(e_lb, created_at=lb.created_at)
     txn.set_data(lb_path, misc.binary_encode(jsonutils.dumps(lb_data)))
     for fd in lb:
         fd_path = paths.join(lb_path, fd.uuid)
         if not self._client.exists(fd_path):
             # NOTE(harlowja): create an entry in the logbook path
             # for the provided flow detail so that a reference exists
             # from the logbook to its flow details.
             txn.create(fd_path)
         e_fd = self._update_flow_details(fd, txn, create_missing=True)
         e_lb.add(e_fd)
     return e_lb
 def _get_logbook(self, book_uuid):
     book_path = os.path.join(self._book_path, book_uuid)
     meta_path = os.path.join(book_path, 'metadata')
     try:
         meta = jsonutils.loads(self._read_from(meta_path))
     except EnvironmentError as e:
         if e.errno == errno.ENOENT:
             raise exc.NotFound("No logbook found with id: %s" % book_uuid)
         else:
             raise
     lb = p_utils.unformat_logbook(book_uuid, meta)
     fd_path = os.path.join(book_path, 'flows')
     fd_uuids = []
     try:
         fd_uuids = [f for f in os.listdir(fd_path)
                     if os.path.islink(os.path.join(fd_path, f))]
     except EnvironmentError as e:
         if e.errno != errno.ENOENT:
             raise
     for fd_uuid in fd_uuids:
         lb.add(self._get_flow_details(fd_uuid))
     return lb
Beispiel #6
0
 def _get_logbook(self, book_uuid):
     book_path = os.path.join(self._book_path, book_uuid)
     meta_path = os.path.join(book_path, 'metadata')
     try:
         meta = misc.decode_json(self._read_from(meta_path))
     except EnvironmentError as e:
         if e.errno == errno.ENOENT:
             raise exc.NotFound("No logbook found with id: %s" % book_uuid)
         else:
             raise
     lb = p_utils.unformat_logbook(book_uuid, meta)
     fd_path = os.path.join(book_path, 'flows')
     fd_uuids = []
     try:
         fd_uuids = [f for f in os.listdir(fd_path)
                     if os.path.islink(os.path.join(fd_path, f))]
     except EnvironmentError as e:
         if e.errno != errno.ENOENT:
             raise
     for fd_uuid in fd_uuids:
         lb.add(self._get_flow_details(fd_uuid))
     return lb