示例#1
0
    def _update_flow_details(self, fd, txn, create_missing=False):
        # Determine whether the desired data exists or not
        fd_path = paths.join(self.flow_path, fd.uuid)
        try:
            fd_data, _zstat = self._client.get(fd_path)
        except k_exc.NoNodeError:
            # Not-existent: create or raise exception
            if create_missing:
                txn.create(fd_path)
                e_fd = logbook.FlowDetail(name=fd.name, uuid=fd.uuid)
            else:
                raise exc.NotFound("No flow details found with id: %s"
                                   % fd.uuid)
        else:
            # Existent: read it out
            e_fd = p_utils.unformat_flow_detail(fd.uuid,
                                                misc.decode_json(fd_data))

        # Update and write it back
        e_fd = p_utils.flow_details_merge(e_fd, fd)
        fd_data = p_utils.format_flow_detail(e_fd)
        txn.set_data(fd_path, misc.binary_encode(jsonutils.dumps(fd_data)))
        for td in fd:
            td_path = paths.join(fd_path, td.uuid)
            # NOTE(harlowja): create an entry in the flow detail path
            # for the provided task detail so that a reference exists
            # from the flow detail to its task details.
            if not self._client.exists(td_path):
                txn.create(td_path)
            e_fd.add(self._update_task_details(td, txn, create_missing=True))
        return e_fd
示例#2
0
    def _update_flow_details(self, fd, txn, create_missing=False):
        # Determine whether the desired data exists or not
        fd_path = paths.join(self.flow_path, fd.uuid)
        try:
            fd_data, _zstat = self._client.get(fd_path)
        except k_exc.NoNodeError:
            # Not-existent: create or raise exception
            if create_missing:
                txn.create(fd_path)
                e_fd = logbook.FlowDetail(name=fd.name, uuid=fd.uuid)
            else:
                raise exc.NotFound("No flow details found with id: %s" %
                                   fd.uuid)
        else:
            # Existent: read it out
            e_fd = p_utils.unformat_flow_detail(fd.uuid,
                                                misc.decode_json(fd_data))

        # Update and write it back
        e_fd = p_utils.flow_details_merge(e_fd, fd)
        fd_data = p_utils.format_flow_detail(e_fd)
        txn.set_data(fd_path, misc.binary_encode(jsonutils.dumps(fd_data)))
        for td in fd:
            td_path = paths.join(fd_path, td.uuid)
            # NOTE(harlowja): create an entry in the flow detail path
            # for the provided task detail so that a reference exists
            # from the flow detail to its task details.
            if not self._client.exists(td_path):
                txn.create(td_path)
            e_fd.add(self._update_task_details(td, txn, create_missing=True))
        return e_fd
示例#3
0
    def _get_flow_details(self, fd_uuid):
        fd_path = paths.join(self.flow_path, fd_uuid)
        try:
            fd_data, _zstat = self._client.get(fd_path)
        except k_exc.NoNodeError:
            raise exc.NotFound("No flow details found with id: %s" % fd_uuid)

        fd = p_utils.unformat_flow_detail(fd_uuid, misc.decode_json(fd_data))
        for td_uuid in self._client.get_children(fd_path):
            fd.add(self._get_task_details(td_uuid))
        return fd
示例#4
0
    def _get_flow_details(self, fd_uuid):
        fd_path = paths.join(self.flow_path, fd_uuid)
        try:
            fd_data, _zstat = self._client.get(fd_path)
        except k_exc.NoNodeError:
            raise exc.NotFound("No flow details found with id: %s" % fd_uuid)

        fd = p_utils.unformat_flow_detail(fd_uuid, misc.decode_json(fd_data))
        for td_uuid in self._client.get_children(fd_path):
            fd.add(self._get_task_details(td_uuid))
        return fd
 def _get():
     fd_path = os.path.join(self._flow_path, uuid)
     meta_path = os.path.join(fd_path, 'metadata')
     meta = jsonutils.loads(self._read_from(meta_path))
     fd = p_utils.unformat_flow_detail(uuid, meta)
     td_to_load = []
     td_path = os.path.join(fd_path, 'tasks')
     try:
         td_to_load = [f for f in os.listdir(td_path)
                       if os.path.islink(os.path.join(td_path, f))]
     except EnvironmentError as e:
         if e.errno != errno.ENOENT:
             raise
     for t_uuid in td_to_load:
         fd.add(self._get_task_details(t_uuid))
     return fd
示例#6
0
 def _get():
     fd_path = os.path.join(self._flow_path, uuid)
     meta_path = os.path.join(fd_path, 'metadata')
     meta = misc.decode_json(self._read_from(meta_path))
     fd = p_utils.unformat_flow_detail(uuid, meta)
     td_to_load = []
     td_path = os.path.join(fd_path, 'tasks')
     try:
         td_to_load = [f for f in os.listdir(td_path)
                       if os.path.islink(os.path.join(td_path, f))]
     except EnvironmentError as e:
         if e.errno != errno.ENOENT:
             raise
     for t_uuid in td_to_load:
         fd.add(self._get_task_details(t_uuid))
     return fd