Exemplo n.º 1
0
def create_task(func, args, func_name, return_type, label, session):
    """Creates a new Task and registers it with the XendTaskManager.

    @param func: callable object XMLRPC method
    @type func: callable object
    @param args: tuple or list of arguments
    @type args: tuple or list
    @param func_name: XMLRPC method name, so we can estimate the progress
    @type func_name: string
    
    @return: Task UUID
    @rtype: string.
    """
    task_uuid = uuid.gen_regularUuid()
    try:
        tasks_lock.acquire()
        task = XendTask(task_uuid, func, args, func_name, return_type, label,
                        '', session)
        tasks[task_uuid] = task
    finally:
        tasks_lock.release()

    task.start()

    return task_uuid
Exemplo n.º 2
0
    def login_unconditionally(self, username):
        """Returns a session UUID if valid.

        @rtype: string
        @return: Session UUID
        """
#        file_object = open('/home/lt/ver', 'w')
#        file_object.write('in uncondition')
#        file_object.close()
        new_session = uuid.gen_regularUuid()
        self.sessions[new_session] = (username, time.time())
        return new_session
Exemplo n.º 3
0
    def create_phy(self, name):
        """
        Called when a new bridge is found on xend start
        """
        # Create new uuids
        uuid = genuuid.gen_regularUuid()

        # Create instance
        record = {
                'name_label':       name,
                'name_description': '',
                'other_config':     {},
                'default_gateway':  '',
                'default_netmask':  '',
                'managed':          False,
            }
        network = XendNetwork(record, uuid)

        return uuid
Exemplo n.º 4
0
    def create(self, record):
        """
        Called from API, to create a new network
        """
        # Create new uuids
        uuid = genuuid.gen_regularUuid()

        # Create instance (do this first, to check record)
        network = XendNetwork(record, uuid)

        # Check network doesn't already exist
        name_label = network.name_label
        if bridge_exists(name_label):
            del network
            raise UniqueNameError(name_label, "network")

        # Create the bridge
        Ovsctl.bridge_create(network.name_label)

        XendNode.instance().save_networks()

        return uuid