(self, *args)
Attach table(s) to local node.
Attach table(s) to local node.
Attach table ( s ) to local node .
def cmd_add_table(self, *args):
        """Attach table(s) to local node."""

        self.load_local_info()

        src_db = self.get_provider_db()
        if not self.is_root():
            src_curs = src_db.cursor()
            src_tbls = self.fetch_set_tables(src_curs)
            src_db.commit()

        dst_db = self.get_database('db')
        dst_curs = dst_db.cursor()
        dst_tbls = self.fetch_set_tables(dst_curs)
        if self.is_root():
            src_tbls = dst_tbls
        else:
            self.sync_table_list(dst_curs, src_tbls, dst_tbls)
        dst_db.commit()

        needs_tbl = self.handler_needs_table()
        args = self.expand_arg_list(dst_db, 'r', False, args, needs_tbl)

        # pick proper create flags
        if self.options.create_full:
            create_flags = skytools.T_ALL
        elif self.options.create:
            create_flags = skytools.T_TABLE | skytools.T_PKEY
        else:
            create_flags = 0

        # search for usable copy node if requested & needed
        if (self.options.find_copy_node and create_flags != 0
                and needs_tbl and not self.is_root()):
            src_name, src_loc, _ = find_copy_source(self, self.queue_name, args, None, self.provider_location)
            self.options.copy_node = src_name
            self.close_database('provider_db')
            src_db = self.get_provider_db()
            src_curs = src_db.cursor()
            src_tbls = self.fetch_set_tables(src_curs)
            src_db.commit()

        # dont check for exist/not here (root handling)
        if not self.is_root() and not self.options.expect_sync and not self.options.find_copy_node:
            problems = False
            for tbl in args:
                tbl = skytools.fq_name(tbl)
                if (tbl in src_tbls) and not src_tbls[tbl]['local']:
                    if self.options.skip_non_existing:
                        self.log.warning("Table %s does not exist on provider", tbl)
                    else:
                        self.log.error("Table %s does not exist on provider, need to switch to different provider", tbl)
                        problems = True
            if problems:
                self.log.error("Problems, canceling operation")
                sys.exit(1)

        # sanity check
        if self.options.dest_table and len(args) > 1:
            self.log.error("--dest-table can be given only for single table")
            sys.exit(1)

        # seems ok
        for tbl in args:
            self.add_table(src_db, dst_db, tbl, create_flags, src_tbls)

        # wait
        if self.options.wait_sync:
            self.wait_for_sync(dst_db)
def cmd_add_table ( self , * args ) : self . load_local_info ( ) src_db = self . get_provider_db ( ) if not self . is_root ( ) : src_curs = src_db . cursor ( ) src_tbls = self . fetch_set_tables ( src_curs ) src_db . commit ( ) dst_db = self . get_database ( 'db' ) dst_curs = dst_db . cursor ( ) dst_tbls = self . fetch_set_tables ( dst_curs ) if self . is_root ( ) : src_tbls = dst_tbls else : self . sync_table_list ( dst_curs , src_tbls , dst_tbls ) dst_db . commit ( ) needs_tbl = self . handler_needs_table ( ) args = self . expand_arg_list ( dst_db , 'r' , False , args , needs_tbl ) # pick proper create flags if self . options . create_full : create_flags = skytools . T_ALL elif self . options . create : create_flags = skytools . T_TABLE | skytools . T_PKEY else : create_flags = 0 # search for usable copy node if requested & needed if ( self . options . find_copy_node and create_flags != 0 and needs_tbl and not self . is_root ( ) ) : src_name , src_loc , _ = find_copy_source ( self , self . queue_name , args , None , self . provider_location ) self . options . copy_node = src_name self . close_database ( 'provider_db' ) src_db = self . get_provider_db ( ) src_curs = src_db . cursor ( ) src_tbls = self . fetch_set_tables ( src_curs ) src_db . commit ( ) # dont check for exist/not here (root handling) if not self . is_root ( ) and not self . options . expect_sync and not self . options . find_copy_node : problems = False for tbl in args : tbl = skytools . fq_name ( tbl ) if ( tbl in src_tbls ) and not src_tbls [ tbl ] [ 'local' ] : if self . options . skip_non_existing : self . log . warning ( "Table %s does not exist on provider" , tbl ) else : self . log . error ( "Table %s does not exist on provider, need to switch to different provider" , tbl ) problems = True if problems : self . log . error ( "Problems, canceling operation" ) sys . exit ( 1 ) # sanity check if self . options . dest_table and len ( args ) > 1 : self . log . error ( "--dest-table can be given only for single table" ) sys . exit ( 1 ) # seems ok for tbl in args : self . add_table ( src_db , dst_db , tbl , create_flags , src_tbls ) # wait if self . options . wait_sync : self . wait_for_sync ( dst_db )