Exemple #1
0
 def is_latest_or_not(self):
     s_v = self.system_version()
     a = cf.trim_version(s_v)
     b = cf.trim_version(Oda_ha.Current_version)
     if a == b:
         return 1
     else:
         return 0
Exemple #2
0
def update_server(host, version):
    flag = 1
    s_v = host.system_version()
    s_v = cf.trim_version(s_v)
    if s_v in [
            '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'
    ]:
        op_lite = ['-v %s' % version]
    else:
        op_lite = [
            '-v %s' % version,
            '-v % s -l' % version,
            '-v %s -n 0' % version
        ]
    op1 = random.choice(op_lite)
    if not host.is_ha_not():
        if not host.update_server(op1):
            flag = 0
            print "update server fail! %s" % op1
    else:
        if random.choice([True, False]):
            if not host.update_server("-v %s" % version):
                flag = 0
                print "update server with '-v' fail!"
        else:
            if not host.update_server("-v %s -n 1" % version):
                flag = 0
                print "update server with '-v -n 1' fail!"
            if not host.update_server("-v %s -n 0" % version):
                flag = 0
                print "update server with '-v -n 0' fail!"
    return flag
Exemple #3
0
def check_dbhome(*a):
    host = a[0]
    if len(a) == 1:
        s_v = host.system_version()
        s_v = cf.trim_version(s_v)
        version = c_m_d.d_version[s_v]
        print version
    else:
        version = a[1]
    version_list = c_m_d.db_versions(host, version)
    if len(version_list) == 0:
        sys.exit(1)
    print version_list
    for i in version_list:
        if not c_m_d.is_clone_exists_or_not(host, i):
            c_m_d.scp_unpack_clone_file(host, i)
        v = i.split('_')[0]
        if not host.create_dbhome("-de SE -v %s" % v):
            print "create SE dbhome with version %s failed!" % v
        else:
            dbhomeid = get_dbhomeid(host)
            if not delete_dbhome(host, dbhomeid):
                print "delete dbhome failed %s" % dbhomeid

        if not host.create_dbhome("-de EE -v %s" % v):
            print "create EE dbhome with version %s failed!" % v
        else:
            dbhomeid = get_dbhomeid(host)
            if not delete_dbhome(host, dbhomeid):
                print "delete dbhome failed %s" % dbhomeid
Exemple #4
0
def update_server_precheck(host, version):
    """prechecks"""
    flag = 1
    s_v = host.system_version()
    s_v = cf.trim_version(s_v)
    if s_v in [
            '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'
    ]:
        op_pre = ['-v %s -p' % version]
    else:
        op_pre = [
            '-v %s -p' % version,
            '-v %s -p -l' % version,
            '-v %s -p -n 0' % version
        ]
    for i in op_pre:
        if not host.update_server(i):
            flag = 0
            print "update server precheck fail! %s" % i

    if host.is_ha_not():
        op_pre_ha = '-v %s -p -n 1' % version
        if not host.update_server(op_pre_ha):
            flag = 0
            print "update server precheck fail! %s" % op_pre_ha
    return flag
Exemple #5
0
def oda_deploy(*a):
    host = a[0]
    s_v = host.system_version()
    version = cf.trim_version(s_v)
    scp_unpack_file(host)
    if o_p.is_12211_or_not(host):
        time.sleep(20)
        patch(host)
    if version == "12.1.2.8.1":
        updatedcsimage(host)

    if len(a) == 2:
        json = a[1]
    else:
        a = json_string(host)
        json = json_file(a)
    if not json:
        print "Json file could not be found!"
        sys.exit(0)
    else:
        remote_file = os.path.join("/tmp", os.path.basename(json))
        host.scp2node(json,remote_file)
        if not host.create_appliance("-r %s" % remote_file):
            print "create appliance failed!"
            sys.exit(0)
Exemple #6
0
def get_version(host):
    s_v = host.system_version()
    s_v = cf.trim_version(s_v)
    bp_version = c_m_d.d_version[s_v]
    db_version = ['12.2.0.1.%s' % bp_version,'12.1.0.2.%s' % bp_version,'11.2.0.4.%s' % bp_version]
    for i in db_version:
        if not c_m_d.is_clone_exists_or_not(host, i):
            c_m_d.scp_unpack_clone_file(host, i)
    return db_version
Exemple #7
0
def no_deploy(host):
    s_v = host.system_version()
    version = cf.trim_version(s_v)
    scp_unpack_file(host)
    if o_p.is_12211_or_not(host):
        time.sleep(20)
        patch(host)
    if version == "12.1.2.8.1":
        updatedcsimage(host)
Exemple #8
0
def json_string(host):
    s_v = host.system_version()
    version = cf.trim_version(s_v)
    hostname = host.hostname
    if not host.is_bonding_or_not():
        a = "nobond_" + hostname + "*" + version
    else:
        a = hostname + "*" + version
    print a
    return a
def scp_unpack_pb(host):
    p_v = host.Current_version
    v = cf.trim_version(p_v)
    loc = "/chqin/ODA%s/OAKPB/" % v
    for i in os.listdir(loc):
        scp_file = os.path.join(loc, i)
        remote_file = os.path.join(remote_dir, i)
        host.scp2node(scp_file, remote_file)
        cmd = "/opt/oracle/oak/bin/oakcli unpack -package %s" % remote_file
        result = host.ssh2node(cmd)
        if re.search('successful', result, re.IGNORECASE):
            host.ssh2node('rm -rf %s' % remote_file)
Exemple #10
0
def getiso(hostname, version, vmflag):
    flag = 0
    ver = cf.trim_version(version)
    loc = "/chqin/ODA%s/" % ver
    oliteIso1 = "singlenode_*iso";
    oliteIso2 = "odalite-os-image*iso";
    odaIso1 = "multinode_*iso";
    odaIso2 = "OAKFactoryImage*iso";
    vmiso = "OakOvm_*.iso"

    if vmflag:
        cmd = 'ls %s' %(loc + vmiso)
        out, err = cf.exc_cmd_new(cmd)
        if err:
            print "Could not find the iso: %s" % (loc + vmiso)
            return flag
        else:
            print out
            return out.strip()

    if len(host_d[hostname]["ilom"]) == 2:
        cmd = 'ls %s' %(loc + odaIso1)
        out, err = cf.exc_cmd_new(cmd)
        if err:
            cmd1 = 'ls %s' %(loc + odaIso2)
            out, err = cf.exc_cmd_new(cmd1)
            if err:
                print "Could not find the iso: %s" % (loc + odaIso2)
                return flag
            else:
                print out
                return out.strip()
        else:
            print out
            return out.strip()

    if len(host_d[hostname]["ilom"]) == 1:
        cmd = 'ls %s' %(loc + oliteIso1)
        out, err = cf.exc_cmd_new(cmd)
        if err:
            cmd1 = 'ls %s' %(loc + oliteIso2)
            out, err = cf.exc_cmd_new(cmd1)
            if err:
                print "Could not find the iso: %s" % (loc + oliteIso2)
                return flag
            else:
                print out
                return out.strip()
        else:
            print out
            return out.strip()
Exemple #11
0
def scp_unpack_clone_file(host, version):
    clonefile = dbclone[version]
    a = clonefile.split('-')[2]
    b = cf.trim_version(a)
    c = 'ODA' + b
    d = "/chqin/%s/oda-sm/%s" % (c, clonefile)
    if os.path.exists(d):
        remote_file = os.path.join("/tmp", os.path.basename(d))
        host.scp2node(d, remote_file)
        if host.update_repository("-f %s" % remote_file):
            host.ssh2node("rm -rf %s" % remote_file)

    else:
        print "there is no clone file %s" % version
        sys.exit(0)
Exemple #12
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)
Exemple #13
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
Exemple #14
0
def create_multiple_db(*a):
    host = a[0]
    if len(a) == 1:
        s_v = host.system_version()
        s_v = cf.trim_version(s_v)
        version = d_version[s_v]
        print version
    else:
        version = a[1]
    version_list = db_versions(host, version)
    if len(version_list) == 0:
        sys.exit(1)
    print version_list
    for i in version_list:
        if not is_clone_exists_or_not(host, i):
            scp_unpack_clone_file(host, i)
        for j in range(3):
            op = db_op(host, i)
            if not host.create_database(op):
                print "database creation fail! %s" % op
Exemple #15
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)
Exemple #16
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)
Exemple #17
0
 def system_version(self):
     cmd = "rpm -qa|grep oak"
     result = self.ssh2node(cmd)
     b = re.search('oak-(\S+)_L', result).group(1)
     c = cf.trim_version(b)
     return c