Beispiel #1
0
def cleanup(hostname, username, password):
    if host_reachable(hostname):
        print "The host %s is reachable, will perform the cleanup!" % hostname
    else:
        print "The host %s is not reachable, could not run the cleanup!" % hostname
        return 0

    host = oda_lib.Oda_ha(hostname, username, password)
    if not host.is_dcs_or_oak():
        cmd = "perl /opt/oracle/oak/onecmd/cleanupDeploy.pl"
        result = oak_cleanup(host, cmd)
        return result
    else:
        if host.is_deployed_or_not():
            cmd = "perl /opt/oracle/oak/onecmd/cleanup.pl -griduser %s -dbuser %s" % (host.griduser(), host.racuser())
        else:
            cmd = "perl /opt/oracle/oak/onecmd/cleanup.pl"
        if host.is_ha_not():
            node2name = cf.node2_name(hostname)
            host2 = oda_lib.Oda_ha(node2name, username, password)
            result = oak_cleanup(host, cmd)
            print result
            print "Wait two minutes, and it will run cleanup on the 2nd node!"
            time.sleep(120)
            result2 = oak_cleanup(host2, cmd)
            print result2
        else:
            result = oak_cleanup(host, cmd)
            print result
Beispiel #2
0
def main(hostname, username, password, version):
    logfile_name = 'check_oda_patch_%s.log' % hostname
    fp, out, err, log = cf.logfile_name_gen_open(logfile_name)
    host = oda_lib.Oda_ha(hostname, username, password)
    dcs_patch(host, version)
    server_patch(host, version)
    time.sleep(600)
    cf.wait_until_ping(host.hostname)
    host2 = oda_lib.Oda_ha(hostname, username, password)
    dbhome_patch(host2, version)
    error = cf.logfile_close_check_error(fp, out, err, log)
    return error
Beispiel #3
0
def dcs_patch(host, version=oda_lib.Oda_ha.Current_version):
    v_loc = "ODA" + '.'.join(version.split('.')[0:4])
    remote_dir = '/tmp/'
    server_loc = '/chqin/%s/patch/' % v_loc
    scpfile(host, remote_dir, server_loc)
    unpack_all_files(host, remote_dir, server_loc)
    hostname = host.hostname
    username = host.username
    password = host.password
    if host.is_ha_not() and is_12211_or_not(host):
        node2 = cf.node2_name(hostname)
        host2 = oda_lib.Oda_ha(node2, username, password)
        scpfile(host2, remote_dir, server_loc)
        unpack_all_files(host2, remote_dir, server_loc)
    cf.extend_space_u01(host)
    print "*" * 20 + "dcsagent patch begin" + "*" * 20
    print host.describe_component()
    print host.crs_status()
    if not update_dcsagent(host, version):
        print "update dcsagent failed"
        sys.exit(0)
    time.sleep(180)
    print host.describe_component()
    print host.crs_status()
    print "*" * 20 + "dcsagent patch finish" + "*" * 20
def main(arg):
    hostname = arg['-s']
    version = arg['-v']
    password = arg['-p']
    username = arg['-u']
    vm = arg["--vm"]
    logfile_name = 'Image_firstnet_provision_patch_%s.log' % hostname
    fp, out, err, log = cf.logfile_name_gen_open(logfile_name)
    image.cleanup(hostname, username, password)
    sys.stdout.flush()
    time.sleep(300)
    print "Will image the host %s" % hostname
    sys.stdout.flush()
    image.image(hostname, version, vm)
    ips = configure_firstnet.configure_firstnet(hostname, version, vm)
    print "Finish configure firstnet, you can use the following ip to configure:"
    print ips
    sys.stdout.flush()
    if not configure_firstnet.is_dcs(hostname, version):
        print "This host is OAK stack, please continue to deploy to %s manually!" % (
            hostname, version)
        sys.stdout.flush()
    else:
        print "Will do the provision and patch to latest version!"
        sys.stdout.flush()
        host = oda_lib.Oda_ha(ips[0], "root", "welcome1")
        d_p_p.provision_patch(host)
        sys.stdout.flush()
    cf.closefile(fp, out, err)
    print "Done, please check the log %s for details!" % log
Beispiel #5
0
 def setUpClass(cls):
     hostname = raw_input("input the hostname:")
     cls.hostname = hostname
     cls.username = "******"
     cls.password = "******"
     host = oda_lib.Oda_ha(cls.hostname, cls.username, cls.password)
     cf.extend_space_u01(host)
Beispiel #6
0
def main(hostname, username, password):
    logfile_name = 'check_delete_db_dbhome_%s.log' % hostname
    fp, out, err, log = cf.logfile_name_gen_open(logfile_name)
    host = oda_lib.Oda_ha(hostname, username, password)
    delete_all_databases(host)
    delete_all_dbhomes(host)
    error = cf.logfile_close_check_error(fp, out, err, log)
    return error
Beispiel #7
0
def main(hostname, username, password):
    logfile_name = 'check_dbhome_create_delete_%s.log' % hostname
    fp, out, err, log = cf.logfile_name_gen_open(logfile_name)
    host = oda_lib.Oda_ha(hostname, username, password)
    ver = random.choice(['170814', '171017', '180116', '180417'])
    check_dbhome(host, ver)
    error = cf.logfile_close_check_error(fp, out, err, log)
    return error
Beispiel #8
0
def main(hostname, username, password):
    logfile_name = 'check_deploy_patch_%s.log' % hostname
    fp, out, err, log = cf.logfile_name_gen_open(logfile_name)
    host = oda_lib.Oda_ha(hostname, username, password)
    provision_patch(host)
    #patch_deploy(host)
    error = cf.logfile_close_check_error(fp, out, err, log)
    return error
Beispiel #9
0
def patch_deploy(host):
    if not host.is_latest_or_not():
        o_p.dcs_patch(host)
        o_p.server_patch(host)
        time.sleep(300)
        cf.wait_until_ping(host.hostname)
        host = oda_lib.Oda_ha(host.hostname, host.username, host.password)
    if not host.is_deployed_or_not():
        o_d.oda_deploy(host)
Beispiel #10
0
def main(hostname, username, password):
    logfile_name = 'check_cpucore_%s.log' % hostname
    fp, out, err, log = cf.logfile_name_gen_open(logfile_name)
    host = oda_lib.Oda_ha(hostname, username, password)
    cpucore_org = host.decribe_cpucore()[0]['cpuCores']
    positive_case(host, int(cpucore_org))
    negative_case(host)
    positive_case2(host, int(cpucore_org))
    error = cf.logfile_close_check_error(fp, out, err, log)
    return error
Beispiel #11
0
def patch_deploy(host):
    need_to_12_vesion = ['12.1.2.8', '12.1.2.8.1', '12.1.2.9', '12.1.2.10', '12.1.2.11']
    s_v = host.system_version()
    s_v = cf.trim_version(s_v)
    if s_v in need_to_12_vesion:
        o_p.dcs_patch(host, "12.1.2.12.0")
        o_p.simple_update_server(host, "12.1.2.12.0")
        time.sleep(300)
        cf.wait_until_ping(host.hostname)
        host = oda_lib.Oda_ha(host.hostname, host.username, host.password)
    if not host.is_latest_or_not():
        o_p.dcs_patch(host)
        if not o_p.update_server(host, version = oda_lib.Oda_ha.Current_version):
            print "update server failed"
            sys.exit(0)
        time.sleep(300)
        cf.wait_until_ping(host.hostname)
        host = oda_lib.Oda_ha(host.hostname, host.username, host.password)
    if not host.is_deployed_or_not():
        o_d.oda_deploy(host)
Beispiel #12
0
def provision_patch(host):
    if not host.is_deployed_or_not():
        o_d.oda_deploy(host)
    cf.extend_space_u01(host)
    create_db(host)
    if not host.is_latest_or_not():
        o_p.dcs_patch(host)
        o_p.server_patch(host)
        time.sleep(300)
        cf.wait_until_ping(host.hostname)
        host2 = oda_lib.Oda_ha(host.hostname, host.username, host.password)
        o_p.dbhome_patch(host2)
Beispiel #13
0
def main(hostname, username, password):
    logfile_name = 'check_create_dbstorage_%s.log' % hostname
    fp, out, err,log = cf.logfile_name_gen_open(logfile_name)
    #out, err = sys.stdout, sys.stderr
    #fp = open(logfile_name_stamp, 'a')
    #sys.stdout, sys.stderr = fp, fp

    host = oda_lib.Oda_ha(hostname, username, password)
    dbstorage_asm_create(host)
    dbstorage_acfs_create(host)
    error = cf.logfile_close_check_error(fp, out, err,log)
    return error
Beispiel #14
0
def main(arg):
    hostname = arg['-s']
    username = arg['-u']
    password = arg['-p']
    logfile_name = 'check_deploy_patch_%s.log' % hostname
    fp, out, err,log = cf.logfile_name_gen_open(logfile_name)
    host = oda_lib.Oda_ha(hostname, username, password)
    if arg['--pbd']:
        patch_deploy(host)
    else:
        provision_patch(host)
    error = cf.logfile_close_check_error(fp, out, err,log)
    return error
Beispiel #15
0
def main(hostname, username, password):
    logfile_name = 'check_create_database_%s.log' % hostname
    fp, out, err,log = cf.logfile_name_gen_open(logfile_name)
    #out, err = sys.stdout, sys.stderr
    #fp = open(logfile_name_stamp, 'a')
    #sys.stdout, sys.stderr = fp, fp

    host = oda_lib.Oda_ha(hostname,username,password)

    create_database_case(host)
    #delete_all_dbhomes(host)
    error = cf.logfile_close_check_error(fp, out, err,log)
    return error
Beispiel #16
0
def main(hostname, username, password):
    logfile_name = 'check_create_backupconfig_%s.log' % hostname
    fp, out, err, log = cf.logfile_name_gen_open(logfile_name)
    #out, err = sys.stdout, sys.stderr
    #fp = open(logfile_name_stamp, 'a')
    #sys.stdout, sys.stderr = fp, fp

    host = oda_lib.Oda_ha(hostname, username, password)
    #create_bkc_disk(host)
    create_bkc_oss(host)
    #create_bkc_none(host)
    error = cf.logfile_close_check_error(fp, out, err, log)
    return error
Beispiel #17
0
def provision_patch(host):
    if not host.is_deployed_or_not():
        o_d.oda_deploy(host)
    cf.extend_space_u01(host)
    create_db(host)
    need_to_12_vesion = ['12.1.2.8','12.1.2.8.1','12.1.2.9','12.1.2.10','12.1.2.11']
    s_v = host.system_version()
    s_v = cf.trim_version(s_v)
    if s_v in need_to_12_vesion:
        o_p.dcs_patch(host, "12.1.2.12.0")
        o_p.simple_update_server(host,"12.1.2.12.0")
        time.sleep(300)
        cf.wait_until_ping(host.hostname)
        host = oda_lib.Oda_ha(host.hostname, host.username, host.password)
        o_p.simple_update_dbhome(host, "12.1.2.12.0")

    if not host.is_latest_or_not():
        o_p.dcs_patch(host)
        o_p.server_patch(host)
        time.sleep(300)
        cf.wait_until_ping(host.hostname)
        host2 = oda_lib.Oda_ha(host.hostname, host.username, host.password)
        o_p.dbhome_patch(host2)
Beispiel #18
0
def main(hostname, username, password):
    logfile_name = 'check_back_recovery_%s.log' % hostname
    fp, out, err,log = cf.logfile_name_gen_open(logfile_name)
    host = oda_lib.Oda_ha(hostname, username, password)
    global dbname
    dbname = randomget_dbname(host)
    print dbname
    if dbname:
        #backup_disk(host)
        backup_oss(host)
    else:
        print "Fail to get the dbname!"
    error = cf.logfile_close_check_error(fp, out, err,log)
    return error
Beispiel #19
0
def scp_unpack_file(host):
    s_v = host.system_version()
    version = cf.trim_version(s_v)
    hostname = host.hostname
    username = host.username
    password = host.password
    v_loc = "ODA" + '.'.join(version.split('.')[0:4])
    remote_dir = '/tmp/'
    server_loc = '/chqin/%s/oda-sm/' % v_loc
    scpfile(host, server_loc, remote_dir)
    unpack_all_files(host, server_loc, remote_dir)

    if host.is_ha_not() and o_p.is_12211_or_not(host):
        node2 = o_p.node2_name(hostname)
        host2 = oda_lib.Oda_ha(node2, username, password)
        scpfile(host2, server_loc, remote_dir)
        unpack_all_files(host2, server_loc, remote_dir)
Beispiel #20
0
def db_versions(host, version):
    list = []
    if version == "170814" and host.is_x6_or_x7():
        version_f = "170814_x6"
    elif version == "170814" and not host.is_x6_or_x7():
        version_f = "170814_x7"
    else:
        version_f = version
    for i in dbclone.keys():
        if re.search(version_f, i):
            list.append(i)
    return list


if __name__ == '__main__':
    arg = docopt(__doc__)
    print arg
    hostname = arg['-s']
    username = arg['-u']
    password = arg['-p']
    host = oda_lib.Oda_ha(hostname, username, password)

    if arg['-v']:
        version = arg['-v']
        create_multiple_db(host, version)
    else:
        create_multiple_db(host)

    #main("scaoda7s005", 'root','welcome1')
Beispiel #21
0
def extend_space_u01(host):
    host.extend_u01()
    if host.is_ha_not():
        node2 = node2_name(host.hostname)
        host2 = oda_lib.Oda_ha(node2, host.username, host.password)
        host2.extend_u01()