Beispiel #1
0
import paramiko
from sys import *
from paramiko import *
import log4erp

try:
    #    if argv[1] == "--u":
    #        print "usage: sh startlsnr.sh <Target Database IP> <Target database sid> <Target Sudo User> <Target Sudo User Password> <Refresh ID>"
    #    else:
    user = "******" + argv[2].lower()
    refresh_id = argv[5] + ".log"

    print "STARTLSNR:I: Establishing Connection on target server ( Hostname - " + argv[
        1] + " )"
    log4erp.write(
        refresh_id,
        "POST:I: Establishing Connection on target server ( Hostname - " +
        argv[1] + " )")

    client = SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.connect(argv[1], username=argv[3], password=argv[4])
    channel = client.invoke_shell()

    print "STARTLSNR:I: Connection established successfully on target server ( Hostname - " + argv[
        1] + " )"
    log4erp.write(
        refresh_id,
        "POST:I: Connection established successfully on target server ( Hostname - "
        + argv[1] + " )")

    print "STARTLSNR:I: Starting Listner on target server ( Hostname - " + argv[
Beispiel #2
0
    syspass = argv[8]
    schema = argv[9]
    location = argv[10]

    # print schema
    # #print type(schema)

    # status="su - " +  user + " -c \"echo \'SELECT USERNAME FROM DBA_USERS;\' | sqlplus system/Welcome2\" | grep -i ops"
    command = 'c:\python27\python.exe ' + location + '\wmiexec.py ' + username.strip(
    ) + ':' + password.strip(
    ) + '@' + hostname + ' "echo \'SELECT USERNAME FROM DBA_USERS;\' | sqlplus system/' + syspass + '"'
    command = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
    out, err = command.communicate()
    if command.returncode == 0:
        print "OPS:I: SELECTING USERNAME FROM DBA_USERS"
        log4erp.write(refresh_id, 'POST:I: SELECTING USERNAME FROM DBA_USERS ')
    else:
        print "OPS:F: Not able to select username from DBA_USERS"
        log4erp.write(refresh_id,
                      'POST:F: Not able to Select USERNAME from DBA_USERS ')
        status = stdout.readlines()

    #				command="sudo su - " +  user + " -c \"echo \'CREATE USER " + "\"" + userapp + "\"" + " DEFAULT TABLESPACE SYSTEM TEMPORARY TABLESPACE PSAPTEMP IDENTIFIED EXTERNALLY;\' | sqlplus / as sysdba\" > /dev/null 2>&1"
    command = 'c:\python27\python.exe ' + location + '\wmiexec.py ' + username.strip(
    ) + ':' + password.strip(
    ) + '@' + hostname + ' "echo \'CREATE USER ' + '\"' + userapp + '\"' + ' DEFAULT TABLESPACE SYSTEM TEMPORARY TABLESPACE PSAPTEMP IDENTIFIED EXTERNALLY;\' | sqlplus / as sysdba "'
    #       print command
    command = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
    out, err = command.communicate()
    if command.returncode == 0:
        print "OPS:I: Creating First User " + userapp
Beispiel #3
0
    db_sid = argv[4]
    refresh_id = argv[5] + ".log"
    schema = argv[6]
    ker_location = argv[7]
    location = argv[8]
    user = "******" + argv[4].lower()

    command = 'c:\python27\python.exe ' + location + '\wmiexec.py ' + username.strip(
    ) + ':' + password.strip(
    ) + '@' + hostname + ' "cd ' + ker_location + '; sqlplus /nolog @sapdba_role.sql ' + schema + '"'
    command = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
    out, err = command.communicate()
    if command.returncode == 0:
        print "SAPDBA:P: The SAPDBA role updation has been successful on the target server (HOSTNAME - " + hostname + ")"
        log4erp.write(
            refresh_id,
            'POST:P: The SAPDBA role updation has been successful on the target server (HOSTNAME - '
            + hostname + ')')
    else:
        print "SAPDBA:F:The SAPDBA role updation has been failed on the target server (HOSTNAME - " + hostname + ")"
        log4erp.write(
            refresh_id,
            'POST:F: The SAPDBA role updation has been failed on the target server (HOSTNAME -'
            + hostname + ')')

except Exception as e:
    if str(e) == "[Errno -2] Name or service not known":
        print "SAPDBA:F:GERR_2801:Hostname unknown"
        log4erp.write(refresh_id,
                      'POST:F: Hostname unknown [Error Code - 2801]')
    elif str(e).strip() == "list index out of range":
        print "SAPDBA:F:GERR_2802:Argument/s missing for SAPDBA script"
Beispiel #4
0
import log4erp
from log4erp import *

try:
#    if argv[1] == "--u":
#        print "usage: sh startlsnr.sh <Target Database IP> <Target database sid> <Target Sudo User> <Target Sudo User Password> <Refresh ID>"
#    else:
        hostname = argv[1]
        username = argv[3]
        password = argv[4]
        user="******" + argv[2].lower()
        refresh_id = argv[5] + ".log"
        location = argv[6]

        print "STARTLSNR:I: Starting Listner on target server ( Hostname - " + argv[1] + " )"
        log4erp.write(refresh_id,"POST:I: Establishing Connection on target server ( Hostname - " + argv[1] + " )")
		
        command = 'c:\python27\python.exe ' + location + '\wmiexec.py ' + username.strip() + ':' + password.strip() + '@' + hostname + ' "lsnrctl start"'
        command=subprocess.Popen(command,shell=True,stdout=subprocess.PIPE)
        out, err = command.communicate()
        out = ''.join(out)
        if "already been started" in out:
                print "STARTLSNR:P: Listner service was already running on the target server ( HOSTNAME - " + argv[1] + " )"
                log4erp.write(refresh_id,"POST:I: Listner service was already running on the target server ( HOSTNAME - " + argv[1] + " )")
        elif "The command completed successfully" in out:
                print "STARTLSNR:P: Listner has been started on the target server ( HOSTNAME - " + argv[1] + " )"
                log4erp.write(refresh_id,"POST:I: Listner has been started on the target server ( HOSTNAME - " + argv[1] + " )")
        else:
                print "STARTLSNR:F: The listener has not been started on the target server HOSTNAME - " + argv[1] + " )"
                log4erp.write(refresh_id,"POST: F: The listener has not been started on the target server HOSTNAME - " + argv[1] + " )")
Beispiel #5
0
        client.connect(host, username=sudo_user, password=passwd)
        channel = client.invoke_shell()

        ################################### STARTING LISTENER ########################################################

        command = 'sudo su - ' + db_user + ' -c "lsnrctl start LISTENER"'
        #        print command
        stdin, stdout, stderr = client.exec_command(command,
                                                    timeout=1000,
                                                    get_pty=True)
        status = stdout.channel.recv_exit_status()
        #       print status
        if status != 0 and status != 1:
            print "POST:F: The listener has not been started on the target Server (HOSTNAME - " + host + ")"
            log4erp.write(
                logfile,
                ":F: The listener has not been started on the target Server (HOSTNAME - "
                + host + ")")
            exit()
        else:
            print 'POST:P: The listener has been started on the target Server (HOSTNAME - ' + host + ')'
            log4erp.write(
                logfile,
                ":P: The listener has been started on the target Server (HOSTNAME - "
                + host + ')')
        channel.close()
        client.close()

except Exception as e:
    if str(e) == "[Errno -2] Name or service not known":
        print "POST:F:GERR_1301:Hostname unknown - " + host
        write(logfile,
Beispiel #6
0
        db_sid = argv[4]
	s_app_sid = argv[5]
	s_db_sid = argv[6]
        refresh_id = argv[7] + ".log"

        user = "******" + argv[4].lower()
        s_db_user= "******" + argv[6].lower()
	s_app_user = argv[5].lower() + "adm"


        client = SSHClient()
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        client.connect(hostname,username = username, password = password)
        channel = client.invoke_shell()
        print "SAPDBA:I: Connection established Successfully (Hostname -" + hostname + ")"
        log4erp.write(refresh_id,'POST:I: Connection established Successfully (Hostname -' + hostname + ')')

	command = 'sudo su - ' + user + ' -c \'echo "select username from dba_users;" | sqlplus / as sysdba\''
	print command
	stdin, stdout, stderr = client.exec_command(command, timeout=1000, get_pty=True)
	out = stdout.readlines()
	exist = out[0]
	if "does not exist" in exist:
		print "SAPDBA:F: Target Database SID entered by the user - " + db_sid + " is incorrect"
		log4erp.write(refresh_id,"POST:F: Target Database SID entered by the user - " + db_sid + " is incorrect")
		exit()
	
	myarray = np.asarray(out)
	#print myarray

	for users in myarray:
Beispiel #7
0
def check(hostname, username, password, database_sid, logfile):
    try:

        client = SSHClient()
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        client.connect(hostname, username=username, password=password)
        channel = client.invoke_shell()

        command = "ls /oracle/" + database_sid.upper() + " >&1 /dev/null"
        #       print command
        stdin, stdout, stderr = client.exec_command(command,
                                                    timeout=1000,
                                                    get_pty=True)
        status = stdout.channel.recv_exit_status()
        #       print status

        if status != 0:
            print "SAPFILE:F: Provided input for the database SID ( " + database_sid + " ) in " + hostname + " host is incorrect"
            log4erp.write(
                logfile, "POST:F: Provided input for the database SID ( " +
                database_sid + " ) in " + hostname + " host is incorrect")
            exit()

        channel.close()
        client.close()

    except Exception as e:
        if str(e) == "[Errno -2] Name or service not known":
            print "CONTROL:F:GERR_1201:Hostname unknown for Target Server (" + hostname + ")"
            write(
                logfile, 'POST:F:Hostname unknown for Target Server (' +
                hostname + ')[Error Code - 1201]')
        elif str(e) == "list index out of range":
            print "CONTROL:F:GERR_1202:Argument/s missing for the script"
        elif str(e) == "Authentication failed.":
            print "CONTROL:F:GERR_1203:Authentication failed to the Target Server (" + hostname + ")"
            write(
                logfile,
                'POST:F:Authentication failed to the Target Server (' +
                hostname + ')[Error Code - 1203]')
        elif str(e) == "[Errno 110] Connection timed out":
            print "CONTROL:F:GERR_1204:Target Host Unreachable (" + hostname + ")"
            write(
                logfile, 'POST:F:Target Host Unreachable (' + hostname +
                ') [Error Code - 1204]')
        elif "getaddrinfo failed" in str(e):
            print "CONTROL:F:GERR_1205: Please check the Target Hostname - " + hostname + " that you have provide"
            write(
                logfile, 'POST:F:Please check the Target Hostname - ' +
                hostname + ' that you have provide [Error Code - 1205]')
        elif "[Errno None] Unable to connect to port 22 on" in str(e):
            print "CONTROL:F:GERR_1206:Host Unreachable or Unable to connect to port 22"
            write(
                logfile,
                'POST:F:Host Unreachable or Unable to connect to port 22 [Error Code - 1206]'
            )
        elif "invalid decimal" in str(e):
            print "CONTROL:F:GERR_1207:Unknown Error:" + str(e)
            write(logfile,
                  'POST:F:Unknown Error:' + str(e) + '[Error Code - 1207]')
        else:
            print "CONTROL:F:" + str(e)
            write(logfile, 'POST:F:' + str(e))
Beispiel #8
0
        client = SSHClient()
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        client.connect(s_host, username=s_user, password=s_pass)
        channel = client.invoke_shell()

        cmd = 'sudo su - ' + s_dbuser + ' -c "echo \'ALTER SYSTEM ARCHIVE LOG CURRENT ; \'| sqlplus / as sysdba\"'
        #print cmd
        stdin, stdout, stderr = client.exec_command(cmd,
                                                    timeout=1000,
                                                    get_pty=True)
        out = stdout.readlines()
        #print out[11]
        if "System altered." in out[11]:
            print "UPDATING_ARCHIVE:P: Source System archive update have been completed successfully - " + s_host
            log4erp.write(
                logfile,
                "POST:P: Source System archive update have been completed successfully - "
                + s_host)
        else:
            print "UPDATING_ARCHIVE:F: Source System archive update have been Failed - " + s_host
            log4erp.write(
                logfile,
                "POST:F: Source System archive update have been Failed - " +
                s_host)

        channel.close()
        client.close()
except Exception as e:
    if str(e) == "[Errno -2] Name or service not known":
        print "UPDATING_ARCHIVE:F:GERR_1301:Source Hostname unknown - " + s_host
        write(
            logfile, 'POST:F: Source Hostname unknown - ' + s_host +
Beispiel #9
0
        password = argv[3]
        s_db_sid = argv[4]
        t_db_sid = argv[5]
        refresh_id = argv[6] + ".log"

	check(hostname,username,password,s_db_sid)

        s_user = "******" + s_db_sid.lower()
        t_user = "******" + t_db_sid.lower()

        client = SSHClient()
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        client.connect(hostname,username = username, password = password)
        channel = client.invoke_shell()
        print "CONTROL:I :Connection established Successfully with the target server (Hostname -" + hostname + ")"
        log4erp.write(refresh_id,'POST:I:Connection established Successfully with the target server (Hostname -' + hostname + ')')

        print "CONTROL:I :Updating Control File in the Source Server (Hostname -" + hostname + ")"
        log4erp.write(refresh_id,'POST:I:Updating Control File in the Source Server (Hostname -' + hostname + ')')

        command = 'sudo sed -i "s/\/oracle\/' + s_db_sid.upper() + '/\/oracle\/' + t_db_sid.upper() + '/g\" /home/' + s_user + '/control_script_' + s_db_sid.upper() + '.sql'
	print command
        stdin, stdout, stderr = client.exec_command(command, timeout=1000, get_pty=True)
	print stdout.channel.recv_exit_status()

        command = 'sudo sed -i \"s/' + s_db_sid.upper() + '/' + t_db_sid.upper() + '/g\" /home/' + s_user + '/control_script_' + s_db_sid.upper() + '.sql'
	print command
        stdin, stdout, stderr = client.exec_command(command, timeout=1000, get_pty=True)
	print stdout.channel.recv_exit_status()

        command = 'sudo sed -i \"/--/d\" /home/' + s_user + '/control_script_' + s_db_sid.upper() + '.sql'
Beispiel #10
0
        s_db_sid = argv[4]
        t_db_sid = argv[5]
        logfile = argv[6] + ".log"

        check(hostname, username, password, t_db_sid, logfile)

        s_user = "******" + s_db_sid.lower()
        t_user = "******" + t_db_sid.lower()

        client = SSHClient()
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        client.connect(hostname, username=username, password=password)
        channel = client.invoke_shell()
        print "CONTROL:I :Connection established Successfully with the target server (Hostname -" + hostname + ")"
        log4erp.write(
            logfile,
            'POST:I:Connection established Successfully with the target server (Hostname -'
            + hostname + ')')

        print "CONTROL:I :Updating Control File in the Source Server (Hostname -" + hostname + ")"
        log4erp.write(
            logfile,
            'POST:I:Updating Control File in the Source Server (Hostname -' +
            hostname + ')')

        #	command = 'sudo sed -i "s/\/oracle\/' + s_db_sid.upper() + '/\/oracle\/' + t_db_sid.upper() + '/g\" /home/' + t_user + '/scp/control_script_' + s_db_sid.upper() + '.sql'
        #        print command
        #        stdin, stdout, stderr = client.exec_command(command, timeout=1000, get_pty=True)
        #        print stdout.channel.recv_exit_status()

        ########################################################## REPLACING SOURCE DB SID WITH TARGET DB SID #################################
Beispiel #11
0
    #       print "python changeid.py <target database Host> <Target Login User Name> <Target Login User Name Password> <Target database sid> <Target Refresh ID>"
    #    else:
    hostname = argv[1]
    username = argv[2]
    password = argv[3]
    db_sid = argv[4]

    user = "******" + argv[4].lower()
    refresh_id = argv[5] + '.log'
    location = argv[6]

    #            print "CHANGEID:I: Establishing Connection on target server ( Hostname - " + hostname + " )"

    print "CHANGEID:I: Shutting down database on target server ( Hostname - " + hostname + " )"
    log4erp.write(
        refresh_id,
        "POST:I: Shutting down database on target server ( Hostname - " +
        hostname + " )")

    command = 'c:\python27\python.exe ' + location + '\wmiexec.py ' + username.strip(
    ) + ':' + password.strip(
    ) + '@' + hostname + ' "echo \'shutdown immediate\' | sqlplus / as sysdba"'
    command = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
    out, err = command.communicate()
    if command.returncode == 0:
        print "CHANGEID:P: Database Shutdown completed successfully on target server ( Hostname - " + hostname + " )"
        log4erp.write(
            refresh_id,
            "POST:P: Database Shutdown completed successfully on target server ( Hostname - "
            + hostname + " )")

    print "CHANGEID:I: Mounting database on target server ( Hostname - " + hostname + " )"
Beispiel #12
0
    else:
        dbhostname = argv[1]
        dbusername = argv[2]
        dbpassword = argv[3]
        database_sid = argv[4]
        orauser = "******" + database_sid.lower()
        refreshid = argv[5] + ".log"
	try:
        	client = SSHClient()
	        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
	        client.connect( dbhostname,username = dbusername, password = dbpassword)
	        channel = client.invoke_shell()
	except Exception as e:
		if str(e) == "[Errno -2] Name or service not known":
	        	print "TRUNCATETABLE:F:GERR_2301:Target Application Hostname unknown"
	        	log4erp.write(refreshid,'POST:F: Target Application Hostname unknown [Error Code - 2301]')
		elif str(e) == "Authentication failed.":
        		print "TRUNCATETABLE:F:GERR_2303:Authentication failed to the Target Application Host"
	        	log4erp.write(refreshid,'POST:F:Authentication failed to the Target Application Host [Error Code - 2303]')
		elif str(e) == "[Errno 110] Connection timed out":
        		print "TRUNCATETABLE:F:GERR_2304:Target Application Host Unreachable"
	        	write(refreshid,'POST:F:Target Application Host Unreachable.[Error Code - 2304]')
		elif "getaddrinfo failed" in str(e):
        		print "TRUNCATETABLE:F:GERR_2305: Please check the Application hostname that you have provide"
	        	log4erp.write(refreshid,'POST:F: Please check the Application hostname that you have provide [Error Code - 2305]')
		elif "[Errno None] Unable to connect to port 22 on" in str(e):
        		print "TRUNCATETABLE:F:GERR_2306:Target Application Host Unreachable or Unable to connect to port 22"
	        	write(refreshid,'POST:F: Target Application Host Unreachable or Unable to connect to port 22 [Error Code - 2306]')
		else:
			print "TRUNCATETABLE:F:" + str(e)
			write(refreshid,'POST:F: ' + str(e))
Beispiel #13
0
        s_appsid = argv[6].upper()
        s_dbsid = argv[7].upper()
        refresh_id = argv[8] + ".log"
        t_appuser = "******" + t_appsid + "ADM"
        dbuser = "******"
        t_dbuser = dbuser + t_dbsid

        client = SSHClient()
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        client.connect(argv[1], username=argv[2], password=argv[3])
        channel = client.invoke_shell()

        print "OPS:I: Connection established Successfully (Hostname -" + argv[
            1] + ")"
        log4erp.write(
            refresh_id,
            'POST:I: Connection established Successfully (Hostname -' +
            argv[1] + ')')

        print "OPS:I: Checking User Existence in target server (Hostname -" + argv[
            1] + ")"
        log4erp.write(
            refresh_id,
            'POST:I: Checking User Existence in target server (Hostname -' +
            argv[1] + ')')

        command = "sudo su - " + t_db_user + " -c 'exit'; echo $?"
        stdin, stdout, stderr = client.exec_command(command,
                                                    timeout=60,
                                                    get_pty=True)
        status = stdout.readline()[0].rstrip()
        #        print command
Beispiel #14
0
    t_appsid = argv[3].upper()
    t_userapp = "OPS\$" + t_appsid + "ADM"
    userdb = "OPS\$ORA"
    t_userdb = userdb + t_dbsid
    refresh_id = argv[7] + ".log"
    syspass = argv[8]

    client = SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.connect(argv[1], username=argv[5], password=argv[6])
    channel = client.invoke_shell()

    print "OPS:I: Connection established Successfully (Hostname -" + argv[
        1] + ")"
    log4erp.write(
        refresh_id, 'POST:I: Connection established Successfully (Hostname -' +
        argv[1] + ')')

    print "OPS:I: Checking User Existence in target server (Hostname -" + argv[
        1] + ")"
    log4erp.write(
        refresh_id,
        'POST:I: Checking User Existence in target server (Hostname -' +
        argv[1] + ')')

    command = 'sudo su - ' + user + ' -c \'echo "select username from dba_users;" | sqlplus / as sysdba\''
    print command
    command = "sudo su - " + user + " -c 'exit'; echo $?"
    stdin, stdout, stderr = client.exec_command(command,
                                                timeout=60,
                                                get_pty=True)
Beispiel #15
0
    #    if argv[1] == "--u":
    #        print "usage: python ctrlrun.py <Target Host> <Sudo User Name> <Sudo User Password> <database SID> <Refresh ID>"
    #    else:
    hostname = argv[1]
    username = argv[2]
    password = argv[3]
    db_sid = argv[4]
    refresh_id = argv[5] + ".log"
    t_location = argv[6]
    location = argv[7]

    user = "******" + db_sid.lower()

    print "CTRLRUN:I: Running Control file to database on target server ( Hostname - " + hostname + " )"
    log4erp.write(
        refresh_id,
        "POST:I: Running Control file to database on target server ( Hostname - "
        + hostname + " )")
    command = 'c:\python27\python.exe ' + location + '\wmiexec.py ' + username.strip(
    ) + ':' + password.strip(
    ) + '@' + hostname + ' "echo \'@' + t_location + '\control_script_' + db_sid.upper(
    ) + '.sql\' | sqlplus / as sysdba"'
    print command
    stdin, stdout, stderr = client.exec_command(command,
                                                timeout=1000,
                                                get_pty=True)
    if stdout.channel.recv_exit_status() == 0:
        print "CTRLRUN:P: The control file has been run successfully on the target server (HOSTNAME - " + hostname + ")"
        log4erp.write(
            refresh_id,
            "POST:P: The control file has been run successfully on the target server ( Hostname - "
            + hostname + " )")
Beispiel #16
0
    command = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
    out, err = command.communicate()
    out = ''.join(out)
    if "(0000)." in out:
        print "R3TRANS:P: The Database Refresh process has been completed successfully"
        log = "POST:P: The Database Refresh process has been completed successfully"
        write(refresh_id, log)
    else:
        print "R3TRANS:F: The database Refresh process has been failed"
        log = "POST:P: The Database Refresh process has been failed"
        write(refresh_id, log)

except Exception as e:
    if str(e) == "[Errno -2] Name or service not known":
        print "R3TRANS:F:GERR_2901:Hostname unknown"
        log4erp.write(refresh_id,
                      'POST:F: Hostname unknown [Error Code - 2901]')
    elif str(e).strip() == "list index out of range":
        print "R3TRANS:F:GERR_2902:Argument/s missing for r3trans script"
    elif str(e) == "Authentication failed.":
        print "R3TRANS:F:GERR_2903:Authentication failed."
        log4erp.write(refresh_id,
                      'POST:F:Authentication failed[Error Code - 2903]')
    elif str(e) == "[Errno 110] Connection timed out":
        print "R3TRANS:F:GERR_2904:Host Unreachable"
        write(refresh_id, 'POST:F:Host Unreachable.[Error Code - 2904]')
    elif "getaddrinfo failed" in str(e):
        print "R3TRANS:F:GERR_2905: Please check the hostname that you have provide"
        log4erp.write(
            refresh_id,
            'POST:F: Please check the hostname that you have provide [Error Code - 2905]'
        )
Beispiel #17
0
try:
    if argv[1] == "--u":
        print "usage: python ctrlrun.py <Target Host> <Sudo User Name> <Sudo User Password> <database SID> <Refresh ID>"
    else:
        hostname = argv[1]
        username = argv[2]
        password = argv[3]
        db_sid = argv[4]
        refresh_id = argv[5] + ".log"

        user = "******" + db_sid.lower()

        print "CTRLRUN:I: Establishing Connection on target server ( Hostname - " + hostname + " )"
        log4erp.write(
            refresh_id,
            "POST:I: Establishing Connection on target server ( Hostname - " +
            hostname + " )")
        client = SSHClient()
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        client.connect(hostname, username=username, password=password)
        channel = client.invoke_shell()
        print "CTRLRUN:I: Connection established successfully on target server ( Hostname - " + hostname + " )"
        log4erp.write(
            refresh_id,
            "POST:I: Connection established successfully on target server ( Hostname - "
            + hostname + " )")

        command = "chown " + user + ":dba /oracle/" + db_sid.upper(
        ) + "/sapreorg/control_script_" + db_sid.upper(
        ) + ".sql;chmod 777 /oracle/" + db_sid.upper(
        ) + "/sapreorg/control_script_" + db_sid.upper() + ".sql"
Beispiel #18
0
    password = argv[3]
    dbsid = argv[4]
    user_db = "ora" + dbsid.lower()
    refresh_id = argv[5] + '.log'
    location = argv[6]

    command = 'c:\python27\python.exe ' + location + '\wmiexec.py ' + username.strip(
    ) + ':' + password.strip(
    ) + '@' + hostname + ' "echo \"alter user SAPBOA identified by BOA_' + dbsid + '01;\" | sqlplus / as sysdba"'
    print command
    command = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
    out, err = command.communicate()
    if command.returncode == 0:
        print "BOA:P: The password for the user BOA has been changed successfully in the target database server (hostname - " + hostname + ")"
        log4erp.write(
            refresh_id,
            'POST:P:The password for the user BOA has been changed successfully in the target database server (Hostname -'
            + hostname + ')')
    else:
        print "BOA:F: The password for the user BOA has not been changed successfully in the target database server (hostname - " + hostname + ")"
        log4erp.write(
            refresh_id,
            'POST:F: The password for the user BOA has not been changed successfully in the target database server (Hostname -'
            + hostname + ')')

except Exception as e:
    if str(e) == "[Errno -2] Name or service not known":
        print "BOA:F:GERR_2501:Hostname unknown"
        log4erp.write(refresh_id,
                      'POST:F: Hostname unknown [Error Code - 2501]')
    elif str(e).strip() == "list index out of range":
        print "BOA:F:GERR_2502:Argument/s missing for BOA script"
Beispiel #19
0
    print app_user
    db_user = '******' + argv[9].lower()
    schema = argv[10]
    location = argv[11].strip('\\')

    command = 'c:\python27\python.exe ' + location + '\wmiexec.py ' + username.strip(
    ) + ':' + password.strip(
    ) + '@' + hostname + ' "brconnect -u system/' + sys_pass + ' -c -f chpass -o SYSTEM -p ' + new_sys_pass + '"'
    print command
    command = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
    out, err = command.communicate()
    #print out
    if command.returncode == 0:
        print 'ASSIGN:P: The password for the system user has been changed successfully in the target database server (hostname - ' + hostname + ')'
        log4erp.write(
            refresh_id,
            'POST:P:The password for the system user has been changed in the target server (Hostname -'
            + hostname + ')')
        command = 'c:\python27\python.exe ' + location + '\wmiexec.py ' + username.strip(
        ) + ':' + password.strip(
        ) + '@' + hostname + ' "brconnect -u system/' + sys_pass + ' -c -f chpass -o ' + schema + ' -p ' + new_sys_pass + '"'
        print command
        command = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
        out, err = command.communicate()
        #print out
        if command.returncode == 0:
            print 'ASSIGN:P: The password for the ' + schema[0].strip(
            ) + ' user has been changed successfully in the target database server (hostname - ' + hostname + ')'
            log4erp.write(
                refresh_id,
                'POST:P:The password for the ' + schema[0].strip() +
                ' user has been changed in the Target Server (Hostname -' +
Beispiel #20
0
        appuser = app_sid.lower() + "adm"
        dbhostname = argv[5]
        dbusername = argv[6]
        dbpassword = argv[7]
        database_sid = argv[8]
        orauser = "******" + database_sid.lower()
        refreshid = argv[9] + ".log"
	try:
        	client = SSHClient()
	        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
	        client.connect( apphostname,username = appusername, password = apppassword)
	        channel = client.invoke_shell()
	except Exception as e:
		if str(e) == "[Errno -2] Name or service not known":
	        	print "TRUNCATETABLE:F:GERR_2301:Target Application Hostname unknown"
	        	log4erp.write(refreshid,'POST:F: Target Application Hostname unknown [Error Code - 2301]')
		elif str(e) == "Authentication failed.":
        		print "TRUNCATETABLE:F:GERR_2303:Authentication failed to the Target Application Host"
	        	log4erp.write(refreshid,'POST:F:Authentication failed to the Target Application Host [Error Code - 2303]')
		elif str(e) == "[Errno 110] Connection timed out":
        		print "TRUNCATETABLE:F:GERR_2304:Target Application Host Unreachable"
	        	write(refreshid,'POST:F:Target Application Host Unreachable.[Error Code - 2304]')
		elif "getaddrinfo failed" in str(e):
        		print "TRUNCATETABLE:F:GERR_2305: Please check the Application hostname that you have provide"
	        	log4erp.write(refreshid,'POST:F: Please check the Application hostname that you have provide [Error Code - 2305]')
		elif "[Errno None] Unable to connect to port 22 on" in str(e):
        		print "TRUNCATETABLE:F:GERR_2306:Target Application Host Unreachable or Unable to connect to port 22"
	        	write(refreshid,'POST:F: Target Application Host Unreachable or Unable to connect to port 22 [Error Code - 2306]')
		else:
			print "TRUNCATETABLE:F:" + str(e)
			write(refreshid,'POST:F: ' + str(e))
Beispiel #21
0
            dbhostname = argv[1]
            dbusername = argv[2]
            dbpassword = argv[3]
            database_sid = argv[4]
            orauser = "******" + database_sid.lower()
            refreshid = argv[5] + ".log"
            schema = argv[6]
            location = argv[7]

            command = 'c:\python27\python.exe ' + location + '\wmiexec.py ' + dbusername.strip() + ':' + dbpassword.strip() + '@' + dbhostname + ' "echo \'Truncate TABLE ' + schema + '.DBSTATHORA;\' | sqlplus / as sysdba"'
            command=subprocess.Popen(command,shell=True,stdout=subprocess.PIPE)
            out, err = command.communicate()
            out = ''.join(out)
            if "Table truncated." in out:
                print "TRUNCATETABLE:P:Truncate of " +  schema + ".DBSTATHORA table has completed successfully on target database server ( Hostname - " + dbhostname + " )"
                log4erp.write(refreshid,"POST:P:Truncate of " +  schema + ".DBSTATHORA table has completed successfully on target database server ( Hostname - " + dbhostname + " )")
            else:
                print "TRUNCATETABLE:F:Truncate of " + schema + ".DBSTATHORA table has failed on target database server ( Hostname - " + dbhostname + " )"
                log4erp.write(refreshid,"POST:F:Truncate of " + schema + ".DBSTATHORA table has failed on target database server ( Hostname - " + dbhostname + " )")
            
            command = 'c:\python27\python.exe ' + location + '\wmiexec.py ' + dbusername.strip() + ':' + dbpassword.strip() + '@' + dbhostname + ' "echo \'Truncate TABLE ' + schema + '.DBSTAIHORA;\' | sqlplus / as sysdba"'
            command=subprocess.Popen(command,shell=True,stdout=subprocess.PIPE)
            out, err = command.communicate()
            out = ''.join(out)
            if "Table truncated." in out:
                print "TRUNCATETABLE:P:Truncate of " +  schema + ".DBSTAIHORA table has completed successfully on target database server ( Hostname - " + dbhostname + " )"
                log4erp.write(refreshid,"POST:P:Truncate of " +  schema + ".DBSTAIHORA table has completed successfully on target database server ( Hostname - " + dbhostname + " )")
            else:
                print "TRUNCATETABLE:F:Truncate of " + schema + ".DBSTAIHORA table has failed on target database server ( Hostname - " + dbhostname + " )"
                log4erp.write(refreshid,"POST:F:Truncate of " + schema + ".DBSTAIHORA table has failed on target database server ( Hostname - " + dbhostname + " )")
Beispiel #22
0
    if argv[1] == "--u":
        print "usage: python temptable.py <Source DB Host> <Source Sudo user> <source sudo pass> <Source DB SID> <Target DB Host> <target sudo user> <target sudo pass>  <Target Application sid> <Target DB sid> <Refersh ID> "
    else:
	s_host = argv[1]
	s_user = argv[2]
	s_pass = argv[3]
	s_dbsid = argv[4]
	t_host = argv[5]
	t_user = argv[6]
	t_pass  = argv[7]
	t_appsid = argv[8]
	t_dbsid = argv[9]
        refresh_id = argv[10] + ".log"
		
        print "TEMPTABLE:I: Establishing Connection on source server ( Hostname - " + argv[1] + " )"
        log4erp.write(refresh_id,"POST:I: Establishing Connection on source server ( Hostname - " + argv[1] + " )")
		
        client = SSHClient()
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        client.connect( argv[1],username = argv[2], password = argv[3])
        channel = client.invoke_shell()
		
        print "TEMPTABLE:I: Connection established successfully on source server ( Hostname - " + argv[1] + " )"
        log4erp.write(refresh_id,"POST:I: Connection established successfully on source server ( Hostname - " + argv[1] + " )")

        print "TEMPTABLE:I: Establishing Connection on target server ( Hostname - " + argv[5] + " )"
        log4erp.write(refresh_id,"POST:I: Establishing Connection on target server ( Hostname - " + argv[5] + " )")
		
        client1 = SSHClient()
        client1.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        client1.connect( argv[5],username = argv[6], password = argv[7])
Beispiel #23
0
        print "GLOBALNAME:P: The global name change has been successful on the target database server (HOSTNAME - " + argv[
            1] + ")"
        log = "POST:P: the global name has been changed on the target database server (HOSTNAME - " + argv[
            1] + ")"
        write(logfile, log)
    else:
        print "GLOBALNAME:F: the global name has not  been changed on the target database server (HOSTNAME - " + argv[
            1] + ")"
        log = "POST:F: the global name has not been changed on the target database server (HOSTNAME - " + argv[
            1] + ")"
        write(logfile, log)

except Exception as e:
    if str(e) == "[Errno -2] Name or service not known":
        print "GLOBALNAME:F:GERR_2701:Hostname unknown"
        log4erp.write(logfile, 'POST:F: Hostname unknown [Error Code - 2701]')
    elif str(e).strip() == "list index out of range":
        print "GLOBALNAME:F:GERR_2702:Argument/s missing for GLOBALNAME script"
    elif str(e) == "Authentication failed.":
        print "GLOBALNAME:F:GERR_2703:Authentication failed."
        log4erp.write(logfile,
                      'POST:F:Authentication failed[Error Code - 2703]')
    elif str(e) == "[Errno 110] Connection timed out":
        print "GLOBALNAME:F:GERR_2704:Host Unreachable"
        write(logfile, 'POST:F:Host Unreachable.[Error Code - 2704]')
    elif "getaddrinfo failed" in str(e):
        print "GLOBALNAME:F:GERR_2705: Please check the hostname that you have provide"
        log4erp.write(
            logfile,
            'POST:F: Please check the hostname that you have provide [Error Code - 2705]'
        )