예제 #1
0
def do_transfer(CONF, xfer_id, state_machine):
    """
    This function does a transfer.  It will create its own DB.  This should be
    run in its own thread.
    """
    db_con = db.StaccatoDB(CONF)
    try:
        request = db_con.lookup_xfer_request_by_id(xfer_id)

        checkpointer = xfer_utils.XferCheckpointer(request, {}, db_con)
        monitor = xfer_utils.XferReadMonitor(db_con, request.id)

        src_module = utils.load_protocol_module(request.src_module_name, CONF)
        dst_module = utils.load_protocol_module(request.dst_module_name, CONF)

        dsturl_parts = urlparse.urlparse(request.dsturl)
        writer = dst_module.get_writer(dsturl_parts,
                                       request.dest_opts,
                                       checkpointer=checkpointer)

        # it is up to the reader/writer to put on the bw limits
        srcurl_parts = urlparse.urlparse(request.srcurl)
        reader = src_module.get_reader(srcurl_parts,
                                       writer,
                                       monitor,
                                       request.source_opts,
                                       request.next_ndx,
                                       request.end_ndx)

        reader.process()
    except Exception, ex:
        state_machine.event_occurred(constants.Events.EVENT_ERROR,
                                     exception=ex,
                                     conf=CONF,
                                     xfer_request=request,
                                     db=db_con)
        raise
예제 #2
0
파일: xfer.py 프로젝트: AsherBond/staccato
    def newtransfer(self, request, source_url, destination_url, owner,
                    source_options=None, destination_options=None,
                    start_offset=0, end_offset=None):

        srcurl_parts = urlparse.urlparse(source_url)
        dsturl_parts = urlparse.urlparse(destination_url)

        dstopts = {}
        srcopts = {}

        if source_options is not None:
            srcopts = source_options
        if destination_options is not None:
            dstopts = destination_options

        plugin_policy = config.get_protocol_policy(self.conf)
        src_module_name = utils.find_protocol_module_name(plugin_policy,
                                                          srcurl_parts)
        dst_module_name = utils.find_protocol_module_name(plugin_policy,
                                                          dsturl_parts)

        src_module = utils.load_protocol_module(src_module_name, self.conf)
        dst_module = utils.load_protocol_module(dst_module_name, self.conf)

        dstopts = dst_module.new_write(dsturl_parts, dstopts)
        srcopts = src_module.new_read(srcurl_parts, srcopts)

        xfer = self.db_con.get_new_xfer(owner,
                                        source_url,
                                        destination_url,
                                        src_module_name,
                                        dst_module_name,
                                        start_ndx=start_offset,
                                        end_ndx=end_offset,
                                        source_opts=srcopts,
                                        dest_opts=dstopts)
        return xfer
예제 #3
0
 def test_basic_load(self):
     proto_name = "staccato.protocols.file.FileProtocol"
     inst = utils.load_protocol_module(proto_name, {})
     self.assertTrue(isinstance(inst, file_protocol.FileProtocol))