예제 #1
0
def backup_oss(host):
    oss_name = cf.generate_string(cf.string2, 8)
    print oss_name
    oss_result = host.create_objectstoreswift(oss_name)
    if not oss_result :
        return 0
    #op_oss = "-d ObjectStore -c chqin -on %s " % oss_name
    op_oss = "-d ObjectStore -c 'oda-oss' -on %s " % oss_name
    op = ['-cr -w 1','-no-cr -w 15','-cr -w 30']
    name = cf.generate_string(cf.string1, 8)
    for i in range(len(op)):
        bk_name = name + str(i)
        bk_op = '-n %s ' % bk_name + op_oss + op[i]
        if not host.create_backupconfig(bk_op):
            print "create backup config %s fail!\n" % bk_name
            return 0
        updatedb_op = "-in %s -bin %s -hbp %s" %(dbname, bk_name,bkpassword)
        if not host.update_database(updatedb_op):
            print "update db %s with backup config %s fail!\n" % (dbname, bk_name)
            return 0

        if i == 0:
            tag1 = cf.generate_string(cf.string2, 8)
            create_bk_op_n = ["-bt Longterm -in %s -k 1" % dbname, "-c TdeWallet -in %s" % dbname,
                          "-bt Regular-L0 -in %s -k 1" % dbname, "-bt ArchiveLog -in %s -t %s" % (dbname, tag1)]
            for j in range(0, len(create_bk_op_n)):
                if host.create_backup(create_bk_op_n[j]) and j != 3:
                    print "Nigtive case for backup fail! %s \n" % create_bk_op_n[j]
        host.disable_auto_backup()
        time.sleep(120)
        if not recover_test_oss(host):
            sys.exit(0)
예제 #2
0
def create_bkc_oss(host):
    oss_name = cf.generate_string(cf.string2, 8)
    print oss_name
    oss_result = host.create_objectstoreswift(oss_name)
    if not oss_result:
        return 0

    #op = "-d ObjectStore -c chqin -on %s " % oss_name
    op = "-d ObjectStore -c oda-oss -on %s " % oss_name

    for i in ['-cr ', '-no-cr ']:
        for j in ['0', '-1', '31']:
            bkname = cf.generate_string(cf.string1, 8)
            op1 = op + i + '-w %s -n %s' % (j, bkname)
            if host.create_backupconfig(op1):
                print "Nigtive case for backupconfig fail! %s \n" % op1

    for i in ['-cr ', '-no-cr ']:
        for j in ['1', '15', '30']:
            bkname = cf.generate_string(cf.string1, 8)
            op2 = op + i + '-w %s -n %s' % (j, bkname)
            if not host.create_backupconfig(op2):
                print "Create backupconfig fail! %s \n" % op2
            else:
                describe_info = host.describe_backupconfig("-in %s" % bkname)
                bkid = describe_info['id']
                if not describe_check(describe_info, 'ObjectStore', i, j):
                    print "describe backupconfig %s fail!" % bkname
                else:
                    if not delete_backupconfig(host, bkname, bkid):
                        print "delete backupconfig %s fail!\n" % bkname
예제 #3
0
def create_bk_op_oss():
    i = random.choice(range(4))
    if i == 0:
        a = "-bt Regular-L0 -in %s " % dbname
    elif i == 1:
        a = "-bt Regular-L1 -c Database -in %s" % dbname
    elif i == 2:
        tag = cf.generate_string(cf.string2,8)
        a = "-bt Longterm -in %s -k 1 -t %s" % (dbname, tag)
    elif i == 3:
        tag = cf.generate_string(cf.string2,8)
        a = "-bt Regular-L1 -in %s -t %s" % (dbname, tag)
    return a
예제 #4
0
def db_op(host, version):
    no_de_version = [
        '12.1.2.8', '12.1.2.8.1', '12.1.2.9', '12.1.2.10', '12.1.2.11',
        '12.1.2.12', '12.2.1.1'
    ]
    s_v = host.system_version()
    s_v = cf.trim_version(s_v)
    if s_v in no_de_version:
        appliance = host.describe_appliance()
        de = appliance['SysInstance']['dbEdition']
        options = ''
    else:
        de = random.choice(['EE', 'SE'])
        options = '-de %s ' % de

    version = version.split('_')[0]
    dbname = cf.generate_string(cf.string1, 8)
    password = "******"
    co = random.choice(["-co", "-no-co"])
    if host.is_ha_not():
        dbtype = random.choice(['RAC', 'RACONE', 'SI'])
    else:
        dbtype = 'SI'
    storage = random.choice(['ACFS', 'ASM'])
    pdbname = cf.generate_string(cf.string2, 20)
    cdb = random.choice(['-c -p %s' % pdbname, '-no-c'])
    db11class = random.choice(['OLTP', 'DSS'])
    db12class = random.choice(['OLTP', 'DSS', 'IMDB'])

    if de == "SE" and re.match("11.2", version):
        options += "-hm %s -n %s -v %s -r ACFS -y %s %s" % (
            password, dbname, version, dbtype, co)
    elif de == "SE" and re.match("12.", version):
        options += "-hm %s -n %s -v %s -r %s -y %s %s %s" % (
            password, dbname, version, storage, dbtype, co, cdb)
    elif de == "EE" and re.match("11.2", version):
        options += "-hm %s -n %s -v %s -cl %s -r ACFS -y %s %s" % (
            password, dbname, version, db11class, dbtype, co)
    else:
        options += "-hm %s -n %s -v %s -cl %s -r %s -y %s %s %s" % (
            password, dbname, version, db12class, storage, dbtype, co, cdb)
    return options
예제 #5
0
def dbstorage_acfs_create(host):
    size = ['-s 100 ', '-s 200 ']

    for i in size:
        dbname = cf.generate_string(cf.string1, 8)
        op = "-n %s -r ACFS %s" % (dbname, i)
        if random.choice(['True', 'False']):
            dbuniqname = cf.generate_string(cf.string2, 20)
            op += '-u %s ' % dbuniqname
        if host.is_flash():
            flash = random.choice(['-f ', '-no-f '])
            op += flash
        if not host.create_dbstorage(op):
            print "create dbstorage failed! %s" % op
        else:
            dbstorage_id = host.ssh2node("/opt/oracle/dcs/bin/odacli list-dbstorages|tail -n 1|awk '{print $1}'")
            if not check_acfs_dbstorage(host, op, dbstorage_id):
                print "describe dbstorage failed! %s" % op
            else:
                if not host.delete_dbstorage("-i %s" % dbstorage_id):
                    print "delete dbstorage failed! %s" % op
예제 #6
0
def create_bkc_none(host):
    op = "-d None "
    bkname = cf.generate_string(cf.string1, 8)
    op = op + '-n %s' % bkname
    if not host.create_backupconfig(op):
        print "Create backupconfig fail! %s \n" % op
    else:
        describe_info = host.describe_backupconfig("-in %s" % bkname)
        bkid = describe_info['id']
        if describe_info['backupDestination'] != 'NONE':
            print "describe backupconfig %s fail!" % bkname
        else:
            if not delete_backupconfig(host, bkname, bkid):
                print "delete backupconfig %s fail!\n" % bkname
예제 #7
0
def create_bkc_disk(host):
    op = "-d Disk "
    for i in ['-cr ', '-no-cr ']:
        for j in ['0', '-1', '15']:
            bkname = cf.generate_string(cf.string1, 8)
            op1 = op + i + '-w %s -n %s' % (j, bkname)
            if host.create_backupconfig(op1):
                print "Nigtive case for backupconfig fail! %s \n" % op1

    for i in ['-cr ', '-no-cr ']:
        for j in ['1', '7', '14']:
            bkname = cf.generate_string(cf.string1, 8)
            op2 = op + i + '-w %s -n %s' % (j, bkname)
            if not host.create_backupconfig(op2):
                print "Create backupconfig fail! %s \n" % op2
            else:
                describe_info = host.describe_backupconfig("-in %s" % bkname)
                bkid = describe_info['id']
                if not describe_check(describe_info, 'Disk', i, j):
                    print "describe backupconfig %s fail!" % bkname
                else:
                    if not delete_backupconfig(host, bkname, bkid):
                        print "delete backupconfig %s fail!\n" % bkname
예제 #8
0
def backup_disk(host):
    op = ['-cr -w 1','-no-cr -w 7','-cr -w 14']
    name = cf.generate_string(cf.string1, 8)
    for i in range(0,len(op)):
        bk_name = name + str(i)
        bk_op = '-d Disk '+ '-n %s ' % bk_name + op[i]
        if not host.create_backupconfig(bk_op):
            print "create backup config %s fail!\n" % bk_name
            return 0
        updatedb_op = "-in %s -bin %s" %(dbname, bk_name)
        if not host.update_database(updatedb_op):
            print "update db %s with backup config %s fail!\n" % (dbname, bk_name)
            return 0

        if i == 0:
            tag1 = cf.generate_string(cf.string2, 8)
            create_bk_op_n = ["-bt Longterm -in %s -k 1 -t test" % dbname, "-c TdeWallet -in %s" % dbname,
                          "-bt Regular-L0 -in %s -k 1" % dbname, "-bt ArchiveLog -in %s -t %s" % (dbname, tag1)]
            for j in range(0, len(create_bk_op_n)):
                if host.create_backup(create_bk_op_n[j]) and j != 3:
                    print "Nigtive case for backup fail! %s \n" % create_bk_op_n[j]
        host.disable_auto_backup()
        if not recover_test(host):
            sys.exit(0)
예제 #9
0
import time

sql_file = 'sql_check.sh'
delete_file_name = 'delete_file.sh'
backupreport = 'backupreport.br'
dbstatus = 'dbstatus_check.sh'
scn_sql = "select current_scn SCN from v\$database";
pitr_sql = "select to_char(sysdate, 'mm/dd/yyyy hh24:mi:ss')PITR from dual";
spfile_sql = "select value from v\$parameter where name ='spfile'";
control_sql = "select name from v\$controlfile";
datafile_sql = "select name from v\$datafile";
remote_dir = '/tmp'
bkpassword = "******"
#dbname = argv[1]

tag = cf.generate_string(cf.string2,8)


def randomget_dbname(host):
    cmd = "/opt/oracle/dcs/bin/odacli list-databases|grep Configured|awk '{print $2}'"
    result, error = host.ssh2node_job(cmd)
    if not error:
        dbname = random.choice(result.split())
        return dbname
    else:
        dbname = create_new_db(host)
        return dbname



def create_new_db(host):