Ejemplo n.º 1
0
    def newInstance(self, spool):
        """Returns a new instance.

        This instance does not have any files assigned.

        """
        from xbe.xbed.config.xen import InstanceConfig
        from xbe.util.uuid import uuid

        self.mtx.acquire()
        try:
            instance_name = "xbe-%s" % uuid()
            icfg = InstanceConfig(instance_name)
            
            try:
                inst = Instance(icfg, spool, self)
            except:
                log.error(format_exception())
                raise
            
            # remember the instance in our db
            self.instances[inst.uuid()] = inst
        finally:
            self.mtx.release()
        return inst
Ejemplo n.º 2
0
    def begin(self):
	"""Begin a new transaction."""
	if self.transaction:
	    raise RuntimeError("currently only one active transaction is supported!")
	self.transaction = uuid()
	f = Frame("BEGIN")
	f.header["transaction"] = self.transaction
	self.sendFrame(f)
Ejemplo n.º 3
0
    def new(self, ticket_id):
        """Returns a new task."""
        from xbe.util.uuid import uuid
        self.mtx.acquire()

        task = Task(ticket_id, uuid(), self)

        self.tasks[task.id()] = task
        self.mtx.release()

        self.notify( (task, "newTask") )
        return task
Ejemplo n.º 4
0
    def __cache_helper(self, uri, type, **meta_info):
        uid = uuid()
        dst = self.__buildFileName(uid)

        # the following sequence does the following:
        #     - use a DataStager to retrieve the uri (returns 'dst' path)
        #     - after that, compute a hash value for the dst (returns (path, hash) tuple)
        #     - transform 'dst' into a local file uri (returns (uri, hash))
        #     - insert into the DB
        # the function returns a Deferred which fires the 'uuid' of the entry
        return self.__retrieveFile(uri, dst)\
               .addCallback(self.__cb_computeHash)\
               .addCallback(lambda ph: ("file://"+ph[0], ph[1]))\
               .addCallback(self.__cb_insertEntry, uid, type, **meta_info)\
               .addCallback(lambda _: uid)\
               .addErrback(self.__cb_cleanUpFileOnError, dst)
Ejemplo n.º 5
0
	def __init__(self):
	    StompClient.__init__(self)
	    self.client_id = uuid()
Ejemplo n.º 6
0
 def setUp(self):
     self.testDir = os.path.join("/tmp", uuid())
Ejemplo n.º 7
0
 def new(self):
     _id = uuid.uuid()
     ticket = Ticket(uuid.uuid())
     self.__tickets[ticket.id()] = ticket
     return ticket