Exemplo n.º 1
0
 def __init__(self, query, dbname):
     self.dbname = dbname
     self.query = query
     self.result = 1
     self.completed = False
     self.halt = False
     Command.__init__(self, 'on unlock', 'on unlock', ctxt=None, remoteHost=None)
Exemplo n.º 2
0
 def __init__(self, out_file, ans_file, gp_ignore = True, ignore_header = True, ignore_plans = False, match_sub = []):
     cmd_str = 'gpdiff.pl -U 10 -w -B -I NOTICE:'
     if ignore_header:
         cmd_str += ' -I GP_IGNORE -gpd_ignore_headers'
     elif gp_ignore:
         cmd_str += ' -I GP_IGNORE'
     cmd_str += ' -gpd_init %s/global_init_file' % (os.path.abspath( os.path.dirname( __file__ ) ))
     if ignore_plans:
         cmd_str += ' -gpd_ignore_plans'
     if match_sub:
         cmd_str += ' -gpd_init '
         cmd_str += ' -gpd_init '.join(match_sub)
     cmd_str += ' %s %s' % (out_file, ans_file)
     Command.__init__(self, 'run gpdiff', cmd_str)
Exemplo n.º 3
0
    def __init__(self, sql_file = None, sql_cmd = None, dbname = None, username = None, password = None,
                 PGOPTIONS = None, psql_options = None, host = None, port = None, out_file = None, 
                 output_to_file=True):

        
        if dbname == None:
            dbname_option = ""
        else:
            dbname_option = "-d %s" % (dbname)
        if username == None:
            username_option = ""
        else:
            username_option = "-U %s" % (username)
        if PGOPTIONS == None:
            PGOPTIONS = ""
        else:
            PGOPTIONS = "PGOPTIONS='%s'" % PGOPTIONS
        if psql_options == None:
            psql_cmd_options = ""
        else:
            psql_cmd_options = psql_options
        if host == None:
            hostname_option = ""
        else:
            hostname_option = "-h %s" % (host)
        if port == None:
            port_option = ""
        else:
            port_option = "-p %s" % (port)

        if sql_file is not None:
            assert os.path.exists(sql_file)
            if out_file == None:
                out_file = sql_file.replace('.sql', '.out')
            if out_file[-2:] == '.t':
                out_file = out_file[:-2]

            cmd_str = '%s psql %s %s %s %s %s -a -f %s' \
                % (PGOPTIONS, psql_cmd_options, dbname_option, username_option, 
                        hostname_option, port_option, sql_file)

            if output_to_file:
                cmd_str = "%s &> %s" % (cmd_str, out_file)
        else:
            assert sql_cmd is not None
            cmd_str = "%s psql %s %s %s %s %s -a -c \"%s\"" \
                      % (PGOPTIONS,psql_cmd_options,dbname_option,username_option,hostname_option,
                         port_option,sql_cmd)
        Command.__init__(self, 'run sql test', cmd_str)
Exemplo n.º 4
0
    def __init__(self, sql_file = None, parallel=1, dbname = None, username = None, password = None,
            PGOPTIONS = None, host = None, port = None, out_file = None, output_to_file=True):

        if dbname == None:
            dbname_option = "-d %s" % os.environ.get("PGDATABASE", os.environ["USER"])
        else:
            dbname_option = "-d %s" % (dbname)
        if username == None:
            username_option = ""
        else:
            username_option = "-U %s" % (username)
        if PGOPTIONS == None:
            PGOPTIONS = ""
        else:
            PGOPTIONS = "PGOPTIONS='%s'" % PGOPTIONS
        if host == None:
            hostname_option = ""
        else:
            hostname_option = "-h %s" % (host)
        if port == None:
            port_option = "-p %s" % os.environ.get("PGPORT", 5432)
        else:
            port_option = "-p %s" % (port)

        assert os.path.exists(sql_file)
        if out_file == None:
            out_file = sql_file.replace('.sql', '.out')
        if out_file[-2:] == '.t':
            out_file = out_file[:-2]

        cmd_str = '%s gptorment.pl -connect="%s %s %s %s" -parallel=%s -sqlfile %s' \
            % (PGOPTIONS, dbname_option, username_option, hostname_option, port_option, parallel, sql_file)

        if output_to_file:
            cmd_str = "%s &> %s" % (cmd_str, out_file)
        Command.__init__(self, 'run sql test', cmd_str)
Exemplo n.º 5
0
 def __init__(self, cmd = None):
         Command.__init__(self, 'running schema related command', cmd)
Exemplo n.º 6
0
 def __init__(self, mdd=None):
     if not mdd:
         mdd = os.getenv('MASTER_DATA_DIRECTORY')
     cmd_str = "export MASTER_DATA_DIRECTORY=%s; echo -e \"y\\ny\\n\" | gpdeletesystem -d %s" % (mdd, mdd)
     Command.__init__(self, 'run gpdeletesystem', cmd_str)
Exemplo n.º 7
0
 def __init__(self, gphome, hosts):
     self.hostfile = '/tmp/gpseginstall_hosts'
     self.gphome = gphome
     self.hosts = hosts
     cmd_str = "gpseginstall -f %s -u %s" %(self.hostfile, getpass.getuser())
     Command.__init__(self, 'run gpseginstall', cmd_str)
Exemplo n.º 8
0
	def __init__(self, cmd = None):
	        Command.__init__(self, 'Running fault command', cmd)
Exemplo n.º 9
0
 def __init__(self, standby_host, mdd=None):
     if not mdd:
         mdd = os.getenv('MASTER_DATA_DIRECTORY')
     cmd_str = 'export MASTER_DATA_DIRECTORY=%s; gpinitstandby -a -s  %s' % (mdd, standby_host)
     Command.__init__(self, 'run gpinitstandby', cmd_str)
Exemplo n.º 10
0
    def __init__(self, sql_file = None, sql_cmd = None, out_file = None, output_to_file = True, 
                 dbname = None,host = None, port = None, username = None, password = None,
                 PGOPTIONS = None, flags = '-a', isODBC = None,
                 timeout = 900, background = False):

        PSQL.propagate_env_map = {}

        if not dbname:
            dbname_option = ""
        else:
            dbname_option = "-d %s" % (dbname)

        if not username:
            username_option = ""
        else:
            username_option = "-U %s" % (username)

        if password:
            PSQL.propagate_env_map = {'PGPASSWORD': password}

        if not PGOPTIONS:
            PGOPTIONS = ""
        else:
            PGOPTIONS = "PGOPTIONS='%s'" % PGOPTIONS

        if not host:
            hostname_option = ""
        else:
            hostname_option = "-h %s" % (host)

        if not port:
            port_option = ""
        else:
            port_option = "-p %s" % (port)

        if sql_file:
            if not os.path.exists(sql_file):
                raise PSQLException('SQL file %s does not exist. ' %sql_file)

            cmd_str = '%s psql --pset pager=off %s %s %s %s %s -f %s' \
                % (PGOPTIONS, dbname_option, username_option, hostname_option, port_option,
                   flags, sql_file)

            if not out_file:
                out_file = sql_file.replace('.sql', '.out')
        
            if output_to_file:
                cmd_str = "%s &> %s 2>&1" % (cmd_str, out_file)
        else:
            assert sql_cmd is not None
            cmd_str = "%s psql --pset pager=off %s %s %s %s %s -c \"%s\"" \
                      % (PGOPTIONS,dbname_option,username_option,hostname_option,
                         port_option, flags, sql_cmd)

            if output_to_file and out_file:
                cmd_str = "%s &> %s 2>&1" % (cmd_str, out_file)
                
        if background:
            cmd_str = "%s &" %cmd_str

        Command.__init__(self, 'run sql', cmd_str)
Exemplo n.º 11
0
 def __init__(self, cmd=None):
     Command.__init__(self, 'Running fault command', cmd)
Exemplo n.º 12
0
 def __init__(self, mdd=None):
     if not mdd:
         mdd = os.getenv('MASTER_DATA_DIRECTORY')
     cmd_str = "export MASTER_DATA_DIRECTORY=%s; echo -e \"y\\ny\\n\" | gpdeletesystem -d %s" % (mdd, mdd)
     Command.__init__(self, 'run gpdeletesystem', cmd_str)
Exemplo n.º 13
0
 def __init__(self, standby_host, mdd=None):
     if not mdd:
         mdd = os.getenv('MASTER_DATA_DIRECTORY')
     cmd_str = 'export MASTER_DATA_DIRECTORY=%s; gpinitstandby -a -s  %s' % (mdd, standby_host)
     Command.__init__(self, 'run gpinitstandby', cmd_str)
Exemplo n.º 14
0
 def __init__(self, config_file):
     cmd_str = 'gpinitsystem -a -c  %s' % (config_file)
     Command.__init__(self, 'run gpinitsystem', cmd_str)
Exemplo n.º 15
0
 def __init__(self,name,filename, directory,ctxt=LOCAL,remoteHost=None):
     gphome = os.getenv("GPHOME", None)
     if not gphome:
         raise Exception('GPHOME environment variable not set.')
     cmdStr = "%s -d %s %s" % (os.path.normpath(gphome + '/lib/python/figleaf/figleaf2html'), directory, filename)        
     Command.__init__(self,name,cmdStr,ctxt,remoteHost)
Exemplo n.º 16
0
 def __init__(self, config_file):
     cmd_str = 'gpinitsystem -a -c  %s' % (config_file)
     Command.__init__(self, 'run gpinitsystem', cmd_str)
Exemplo n.º 17
0
    def __init__(
        self,
        sql_file=None,
        sql_cmd=None,
        out_file=None,
        output_to_file=True,
        dbname=None,
        host=None,
        port=None,
        username=None,
        password=None,
        PGOPTIONS=None,
        flags="-a",
        isODBC=None,
        timeout=900,
        background=False,
    ):

        PSQL.propagate_env_map = {}

        if not dbname:
            dbname_option = ""
        else:
            dbname_option = "-d %s" % (dbname)

        if not username:
            username_option = ""
        else:
            username_option = "-U %s" % (username)

        if password:
            PSQL.propagate_env_map = {"PGPASSWORD": password}

        if not PGOPTIONS:
            PGOPTIONS = ""
        else:
            PGOPTIONS = "PGOPTIONS='%s'" % PGOPTIONS

        if not host:
            hostname_option = ""
        else:
            hostname_option = "-h %s" % (host)

        if not port:
            port_option = ""
        else:
            port_option = "-p %s" % (port)

        if sql_file:
            if not os.path.exists(sql_file):
                raise PSQLException("SQL file %s does not exist. " % sql_file)

            cmd_str = "%s psql --pset pager=off %s %s %s %s %s -f %s" % (
                PGOPTIONS,
                dbname_option,
                username_option,
                hostname_option,
                port_option,
                flags,
                sql_file,
            )

            if not out_file:
                out_file = sql_file.replace(".sql", ".out")

            if output_to_file:
                cmd_str = "%s &> %s 2>&1" % (cmd_str, out_file)
        else:
            assert sql_cmd is not None
            cmd_str = '%s psql --pset pager=off %s %s %s %s %s -c "%s"' % (
                PGOPTIONS,
                dbname_option,
                username_option,
                hostname_option,
                port_option,
                flags,
                sql_cmd,
            )

            if output_to_file and out_file:
                cmd_str = "%s &> %s 2>&1" % (cmd_str, out_file)

        if background:
            cmd_str = "%s &" % cmd_str

        Command.__init__(self, "run sql", cmd_str)
Exemplo n.º 18
0
 def __init__(self, gphome, hosts):
     self.hostfile = '/tmp/gpseginstall_hosts'
     self.gphome = gphome
     self.hosts = hosts
     cmd_str = "gpseginstall -f %s -u %s" %(self.hostfile, getpass.getuser())
     Command.__init__(self, 'run gpseginstall', cmd_str)