Ejemplo n.º 1
0
def create_boot_properties(configData, full_path): 

    """
    Create boot.properties files for instances
    """       
    if managed_key in configData:
        jsonDataArray = configData[managed_key]
    else:
        logging.error(managed_key + " config data missing from json. will not install")
        return

    if common_key in configData:
        commonData = configData[common_key]
    else:
        logging.error(common_key + " config data missing from json. will not install")
        return    

    commonRequiredFields = ['middlewareHome', 'installOwner', 'installGroup', 'wl_domain']
    commerce_setup_helper.check_required_fields(commonData, commonRequiredFields)    

    INSTALL_DIR = commonData['middlewareHome']
    INSTALL_OWNER = commonData['installOwner']
    INSTALL_GROUP = commonData['installGroup']
    WL_DOMAIN_NAME = commonData['wl_domain']
    WL_ADMIN_USER = commonData['wl_adminUser']
    WL_ADMIN_PW = commonData['wl_adminPassword']
    
    SERVER_PATH = INSTALL_DIR + '/user_projects/domains/' + WL_DOMAIN_NAME + '/servers/'
    
    logging.info("Checking boot.properties setup")
    
    for jsonData in jsonDataArray:
        
        requiredFields = ['managedServerName', 'managedServerHost']
        commerce_setup_helper.check_required_fields(jsonData, requiredFields)
    
        WL_SERVER_NAME = jsonData['managedServerName']
        WL_SERVER_HOST = jsonData['managedServerHost']
        
        # try to get the fqdn
        FQDN = socket.getfqdn()
        if (FQDN is not None):
            HOSTNAME = FQDN.split(".")[0]
            if (FQDN == WL_SERVER_HOST or HOSTNAME == WL_SERVER_HOST):
                # make sure the base servers path exists
                if(os.path.exists(SERVER_PATH)):
                    # create the instance and security dir to write to boot file to
                    outpath = SERVER_PATH + WL_SERVER_NAME + "/security/"
                    commerce_setup_helper.mkdir_with_perms(outpath, INSTALL_OWNER, INSTALL_GROUP)
                    outfile = outpath + 'boot.properties'
                    outdata = open(outfile, 'w')
                    outdata.write('username='******'password=' + WL_ADMIN_PW + "\n")
                    outdata.close()
                    # change the owner of boot.properties. should have been created by root
                    commerce_setup_helper.change_file_owner(outfile, INSTALL_OWNER, INSTALL_GROUP)
                    
                logging.info("Created boot.properties for " + WL_SERVER_NAME)
        else:
            logging.error("Cannot determine hostname. Cannot create boot.properties")
def install_weblogic(configData, full_path): 
    
    if json_key in configData:
        jsonData = configData[json_key]
    else:
        logging.error(json_key + " config data missing from json. will not install")
        return False

    logging.info("installing " + service_name)
    
    binary_path = full_path + "/binaries/wls-12.1.2"
    response_files_path = full_path + "/responseFiles/wls-12.1.2"
    install_exec = "wls_121200.jar"
    full_exec_path = binary_path + "/" + install_exec
    
    if not os.path.exists(full_exec_path):
        logging.error("Binary " + full_exec_path + " does not exist - will not install")
        return False
                    
                    
    requiredFields = ['middlewareHome', 'installOwner', 'installGroup', 'oraInventoryDir']
    commerce_setup_helper.check_required_fields(jsonData, requiredFields)

    INSTALL_DIR = jsonData['middlewareHome']
    INSTALL_OWNER = jsonData['installOwner']
    INSTALL_GROUP = jsonData['installGroup']
    ORACLE_INVENTORY_DIR = jsonData['oraInventoryDir']
    ORA_INST = "/etc/oraInst.loc"
    
    oraInst_replacements = {'ORACLE_INVENTORY_DIR':ORACLE_INVENTORY_DIR, 'ORACLE_INVENTORY_GROUP':INSTALL_GROUP}
    
    # if oraInst.loc doesn't already exist, we need to make one
    if not os.path.isfile(ORA_INST):
        commerce_setup_helper.substitute_file_fields(response_files_path + '/oraInst.loc.master', response_files_path + '/oraInst.loc', oraInst_replacements)
        shutil.copyfile(response_files_path + "/oraInst.loc" , ORA_INST)
        commerce_setup_helper.change_file_owner(ORA_INST, INSTALL_OWNER, INSTALL_GROUP)
        os.chmod(ORA_INST, 0664) 
        
    wl_replacements = {'INSTALL_DIR':INSTALL_DIR}
    commerce_setup_helper.substitute_file_fields(response_files_path + '/install.rsp.master', response_files_path + '/install.rsp', wl_replacements)
    
    # make the install tree with correct owner if needed
    commerce_setup_helper.mkdir_with_perms(INSTALL_DIR, INSTALL_OWNER, INSTALL_GROUP)
        
    # install wl
    if (platform.system() == 'SunOS'):
        installCommand = "\"" + "java -d64 -jar "
    else:
        installCommand = "\"" + "java -jar "
    installCommand = installCommand + full_exec_path + " -silent -invPtrLoc " + ORA_INST + " -responseFile " + response_files_path + "/install.rsp -logfile wlinstall.log" + "\""
    commerce_setup_helper.exec_as_user(INSTALL_OWNER, installCommand)
    
    commerce_setup_helper.add_to_bashrc(INSTALL_OWNER, "##################### \n")
    commerce_setup_helper.add_to_bashrc(INSTALL_OWNER, "#WebLogic Settings \n")
    commerce_setup_helper.add_to_bashrc(INSTALL_OWNER, "##################### \n")
    commerce_setup_helper.add_to_bashrc(INSTALL_OWNER, "export MW_HOME=" + INSTALL_DIR + "\n\n")
    
    JAVA_RAND = ""
    # if linux/Solaris, change random, This is faster in some implementations.
    if (platform.system() == "SunOS"):
        JAVA_RAND = "-Djava.security.egd=file:///dev/urandom"
    else:
        JAVA_RAND = "-Djava.security.egd=file:/dev/./urandom"
            
    commerce_setup_helper.add_to_bashrc(INSTALL_OWNER, 'export CONFIG_JVM_ARGS=\"' + JAVA_RAND + ' \" \n')
    commerce_setup_helper.add_to_bashrc(INSTALL_OWNER, 'export JAVA_OPTIONS=\"' + JAVA_RAND + ' \" \n')    
    
    # install patches if any were listed
    patch_weblogic(configData, full_path)
Ejemplo n.º 3
0
def install_otd(configData, full_path):

    if json_key in configData:
        jsonData = configData[json_key]
    else:
        print json_key + " config data missing from json. will not install"
        return False

    print "installing " + service_name

    if (platform.system() == "SunOS"):
        binary_path = full_path + "/binaries/OTD11.1.1.9/solaris"
    else:
        binary_path = full_path + "/binaries/OTD11.1.1.9"

    install_exec = "/Disk1/runInstaller"

    response_files_path = full_path + "/responseFiles/OTD11"

    full_exec_path = binary_path + install_exec

    if not os.path.exists(full_exec_path):
        print "Binary " + full_exec_path + " does not exist - will not install"
        return False

    requiredFields = [
        'instanceHome', 'installDir', 'adminUser', 'installOwner',
        'adminPassword', 'oraInventoryDir'
    ]
    commerce_setup_helper.check_required_fields(jsonData, requiredFields)

    INSTALL_OWNER = jsonData['installOwner']
    INSTANCE_HOME = jsonData['instanceHome']
    INSTALL_DIR = jsonData['installDir']
    ORACLE_INVENTORY_DIR = jsonData['oraInventoryDir']
    ORACLE_INVENTORY_GROUP = jsonData['oraInventoryGroup']
    ADMIN_USER = jsonData['adminUser']
    ADMIN_PASSWORD = jsonData['adminPassword']
    OTD_ADMIN_BOOT = jsonData['otd_startAdmin_onBoot']
    ORA_INST = "/etc/oraInst.loc"
    OTD_INSTANCE_NAME = "admin-server"

    oraInst_replacements = {
        'ORACLE_INVENTORY_DIR': ORACLE_INVENTORY_DIR,
        'ORACLE_INVENTORY_GROUP': ORACLE_INVENTORY_GROUP
    }
    otdPassword_replacements = {'TADM_ADMINPASSWORD': ADMIN_PASSWORD}

    # if oraInst.loc doesn't already exist, we need to make one
    if not os.path.isfile(ORA_INST):
        commerce_setup_helper.substitute_file_fields(
            response_files_path + '/oraInst.loc.master',
            response_files_path + '/oraInst.loc', oraInst_replacements)
        shutil.copyfile(response_files_path + "/oraInst.loc", ORA_INST)
        commerce_setup_helper.change_file_owner(ORA_INST, INSTALL_OWNER,
                                                ORACLE_INVENTORY_GROUP)
        os.chmod(ORA_INST, 0664)

    # make the install tree with correct owner if needed
    commerce_setup_helper.mkdir_with_perms(INSTALL_DIR, INSTALL_OWNER,
                                           ORACLE_INVENTORY_GROUP)

    # exec the install command
    installCommand = "\"" + binary_path + "/Disk1/runInstaller -silent -waitforcompletion -invPtrLoc /etc/oraInst.loc ORACLE_HOME=" + INSTALL_DIR + " SKIP_SOFTWARE_UPDATES=true\""
    commerce_setup_helper.exec_as_user(INSTALL_OWNER, installCommand)

    # setup password file
    commerce_setup_helper.substitute_file_fields(
        response_files_path + '/otdPassword.pwd.master',
        response_files_path + '/otdPassword.pwd', otdPassword_replacements)

    # exec base admin server creation
    configCommand = "\"" + INSTALL_DIR + "/bin/tadm configure-server --user="******" --instance-home=" + INSTANCE_HOME + " --password-file=" + response_files_path + "/otdPassword.pwd\""
    commerce_setup_helper.exec_as_user(INSTALL_OWNER, configCommand)

    if (platform.system() == 'SunOS'):
        startStopPath = "/startStopScripts/solaris/bootScripts/"
    else:
        startStopPath = "/startStopScripts/bootScripts/"

    # copy start/stop script
    otdScript_replacements = {
        'OTD_PROCESS_OWNER': INSTALL_OWNER,
        'OTD_INSTANCE_HOME': INSTANCE_HOME,
        'OTD_INSTANCE_NAME': OTD_INSTANCE_NAME
    }
    commerce_setup_helper.copy_start_script(
        OTD_ADMIN_BOOT, full_path + startStopPath + 'OTDAdmin.master',
        otdScript_replacements)

    # fire up the otd admin server
    startCmd = "/etc/init.d/OTDAdmin"
    commerce_setup_helper.exec_cmd(startCmd + " start")

    commerce_setup_helper.add_to_bashrc(
        INSTALL_OWNER,
        "# echo " + service_name + " start/stop script: " + startCmd + "\n\n")
Ejemplo n.º 4
0
def install_weblogic(configData, full_path):

    if json_key in configData:
        jsonData = configData[json_key]
    else:
        print json_key + " config data missing from json. will not install"
        return

    print "installing " + service_name

    binary_path = full_path + "/binaries/wls-12.1.3"
    response_files_path = full_path + "/responseFiles/wls-12.1.3"
    install_exec = "fmw_12.1.3.0.0_wls.jar"
    full_exec_path = binary_path + "/" + install_exec

    if not os.path.exists(full_exec_path):
        print "Binary " + full_exec_path + " does not exist - will not install"
        return False

    requiredFields = [
        'middlewareHome', 'installOwner', 'installGroup', 'oraInventoryDir'
    ]
    commerce_setup_helper.check_required_fields(jsonData, requiredFields)

    INSTALL_DIR = jsonData['middlewareHome']
    INSTALL_OWNER = jsonData['installOwner']
    INSTALL_GROUP = jsonData['installGroup']
    ORACLE_INVENTORY_DIR = jsonData['oraInventoryDir']
    ORA_INST = "/etc/oraInst.loc"

    oraInst_replacements = {
        'ORACLE_INVENTORY_DIR': ORACLE_INVENTORY_DIR,
        'ORACLE_INVENTORY_GROUP': INSTALL_GROUP
    }

    # if oraInst.loc doesn't already exist, we need to make one
    if not os.path.isfile(ORA_INST):
        commerce_setup_helper.substitute_file_fields(
            response_files_path + '/oraInst.loc.master',
            response_files_path + '/oraInst.loc', oraInst_replacements)
        shutil.copyfile(response_files_path + "/oraInst.loc", ORA_INST)
        commerce_setup_helper.change_file_owner(ORA_INST, INSTALL_OWNER,
                                                INSTALL_GROUP)
        os.chmod(ORA_INST, 0664)

    wl_replacements = {'INSTALL_DIR': INSTALL_DIR}
    commerce_setup_helper.substitute_file_fields(
        response_files_path + '/install.rsp.master',
        response_files_path + '/install.rsp', wl_replacements)

    # make the install tree with correct owner if needed
    commerce_setup_helper.mkdir_with_perms(INSTALL_DIR, INSTALL_OWNER,
                                           INSTALL_GROUP)

    # install wl
    if (platform.system() == 'SunOS'):
        installCommand = "\"" + "java -d64 -jar "
    else:
        installCommand = "\"" + "java -jar "
    installCommand = installCommand + full_exec_path + " -silent -invPtrLoc " + ORA_INST + " -responseFile " + response_files_path + "/install.rsp -logfile wlinstall.log" + "\""
    commerce_setup_helper.exec_as_user(INSTALL_OWNER, installCommand)

    commerce_setup_helper.add_to_bashrc(INSTALL_OWNER,
                                        "##################### \n")
    commerce_setup_helper.add_to_bashrc(INSTALL_OWNER, "#WebLogic Settings \n")
    commerce_setup_helper.add_to_bashrc(INSTALL_OWNER,
                                        "##################### \n")
    commerce_setup_helper.add_to_bashrc(
        INSTALL_OWNER, "export MW_HOME=" + INSTALL_DIR + "\n\n")

    # install patches if any were listed
    patch_weblogic(configData, full_path)