Ejemplo n.º 1
0
 def do_mysql(self, arg, opts=None):
     from node import MySQL
     mysql = MySQL(self.server.current_node)
     if opts.dserver:
         dest_server = None
         line = string.strip(opts.dserver)
         dbid = line
         if string.find(line, '[') != -1:
             (dbid, info) = string.split(line, '[')
             (dbid, info) = string.split(info, ':')
             dest_server = self.server.current_node.get_node(int(dbid))
         if dest_server is None:
             print 'Not find the destination :%s' % line
             return
     if opts.backup and opts.sport:
         backup_path = mysql.backup(db_name=opts.databases if opts.databases else None, port=opts.sport,
                                    no_data=True if opts.no_data else False)
         if len(backup_path) > 0:
             print "Backup databases [%s] finished -> %s:%s " % (opts.databases, mysql.server, backup_path)
             if opts.dserver:
                 trans = Transfer(mysql.server, backup_path)
                 trans.add_dest_server(dest_server)
                 trans.send('/home/databackup/')
                 print "Trans backup file finished -> %s:%s " % (dest_server, '/home/databackup/')
     if opts.merage and opts.sport and opts.dserver and opts.dport:
         #db_lists=None
         #if opts.databases:
         #db_lists=string.split(opts.databases,',')
         #else:
         #db_lists=[None]
         mysql.merage(opts.databases, sport=opts.sport, dest_server=dest_server, dport=opts.dport,
                      bk_nodata=True if opts.no_data else False)
         return
Ejemplo n.º 2
0
    def do_mysql(self, arg, opts=None):
        from node import MySQL
        mysql = MySQL(self.server.current_node)
        if opts.dserver:
            dest_server = None
            line = string.strip(opts.dserver)
            dbid = line
            if string.find(line, '[') != -1:
                (dbid, info) = string.split(line, '[')
                (dbid, info) = string.split(info, ':')
                dest_server = self.server.current_node.get_node(int(dbid))
            if dest_server is None:
                print 'Not find the destination :%s' % line
                return
        if opts.backup and opts.sport:
            backup_path = mysql.backup(
                db_name=opts.databases if opts.databases else None,
                port=opts.sport,
                no_data=True if opts.no_data else False)
            if len(backup_path) > 0:
                print "Backup databases [%s] finished -> %s:%s " % (
                    opts.databases, mysql.server, backup_path)
                if opts.dserver:
                    trans = Transfer(mysql.server, backup_path)
                    trans.add_dest_server(dest_server)
                    trans.send('/home/databackup/')
                    print "Trans backup file finished -> %s:%s " % (
                        dest_server, '/home/databackup/')
        if opts.merage and opts.sport and opts.dserver and opts.dport:

            #db_lists=None
            #if opts.databases:
            #db_lists=string.split(opts.databases,',')
            #else:
            #db_lists=[None]
            mysql.merage(opts.databases,
                         sport=opts.sport,
                         dest_server=dest_server,
                         dport=opts.dport,
                         bk_nodata=True if opts.no_data else False)
            return
Ejemplo n.º 3
0
    def do_trans(self, arg, opts=None):

        server_list = self._get_operation_list(
            self.server.current_node,
            inPiece=opts.piece if opts.piece else None,
            inCurrent=False,
            inChilds=True if opts.childs else False,
            useRecursion=True if opts.recursion else False,
            objClass=None)

        trans_task = Transfer()
        if opts.get_version:

            src_path = Transfer.get_from_lftp(self.server.current_node.root,
                                              'get-version', 'db_version/ALL/',
                                              opts.get_version)
            if src_path:
                trans_task.set_source_server(self.server.current_node.root)
                trans_task.set_source_path(src_path)
            else:
                return
        else:
            trans_task.set_source_server(self.server.current_node)
            trans_task.set_source_path(opts.target)
            #self.server.current_node,opts.target)
        if opts.who:
            line = string.strip(opts.who)
            dbid = line
            if string.find(line, '[') != -1:
                (dbid, info) = string.split(line, '[')
                (dbid, info) = string.split(info, ':')
                server_list.append(self.server.current_node.get_node(
                    int(dbid)))
        if len(server_list) > 0:
            trans_task.add_dest_server(*server_list)
            print "Servers Count:%s" % len(trans_task.dest_servers)
            trans_task.send(opts.deploy_dir if opts.deploy_dir else '/tmp')
            trans_task.clear()
Ejemplo n.º 4
0
    def do_trans(self, arg, opts=None):

        server_list = self._get_operation_list(self.server.current_node,
                                               inPiece=opts.piece if opts.piece else None,
                                               inCurrent=False,
                                               inChilds=True if opts.childs else False,
                                               useRecursion=True if opts.recursion else False,
                                               objClass=None)

        trans_task = Transfer()
        if opts.get_version:


            src_path = Transfer.get_from_lftp(self.server.current_node.root,
                                              'get-version',
                                              'db_version/ALL/',
                                              opts.get_version)
            if src_path:
                trans_task.set_source_server(self.server.current_node.root)
                trans_task.set_source_path(src_path)
            else:
                return
        else:
            trans_task.set_source_server(self.server.current_node)
            trans_task.set_source_path(opts.target)
            #self.server.current_node,opts.target)
        if opts.who:
            line = string.strip(opts.who)
            dbid = line
            if string.find(line, '[') != -1:
                (dbid, info) = string.split(line, '[')
                (dbid, info) = string.split(info, ':')
                server_list.append(self.server.current_node.get_node(int(dbid)))
        if len(server_list) > 0:
            trans_task.add_dest_server(*server_list)
            print "Servers Count:%s" % len(trans_task.dest_servers)
            trans_task.send(opts.deploy_dir if opts.deploy_dir else '/tmp')
            trans_task.clear()