Beispiel #1
0
def advanced_storage(configData, full_path):

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

    for jsonData in jsonArray:

        requiredFields = ['device', 'mountPoint', 'mountOwner', 'mountGroup']
        commerce_setup_helper.check_required_fields(jsonData, requiredFields)
        DEVICE = jsonData['device']
        MOUNT_POINT = jsonData['mountPoint']
        MOUNT_OWNER = jsonData['mountOwner']
        MOUNT_GROUP = jsonData['mountGroup']

        FSTAB_ENTRY = DEVICE + "  " + MOUNT_POINT + "  ext4  defaults  0 0 \n"

        print "creating and mounting storage on device " + DEVICE + " at " + MOUNT_POINT + " \n"

        createCmd = "mkfs -t ext4 " + DEVICE
        mountCmd = "mount " + DEVICE + " " + MOUNT_POINT + " -t ext4"
        mountOwnerCmd = "chown " + MOUNT_OWNER + ":" + MOUNT_GROUP + " " + MOUNT_POINT

        if not (os.path.exists(MOUNT_POINT)):
            os.mkdir(MOUNT_POINT, 0755)

        commerce_setup_helper.exec_cmd(createCmd)
        commerce_setup_helper.exec_cmd(mountCmd)
        commerce_setup_helper.exec_cmd(mountOwnerCmd)

        with open("/etc/fstab", "a") as myfile:
            myfile.write(FSTAB_ENTRY)
        myfile.close()
Beispiel #2
0
def mount_storage(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
                
    logging.info("creating and mounting storage")
    
    requiredFields = ['mountPoint', 'mountOwner', 'mountGroup']
    commerce_setup_helper.check_required_fields(jsonData, requiredFields)
    MOUNT_POINT = jsonData['mountPoint']
    MOUNT_OWNER = jsonData['mountOwner']
    MOUNT_GROUP = jsonData['mountGroup']
    
    FSTAB_ENTRY = "/dev/xvdb        " + MOUNT_POINT + "            ext4    defaults    0 0 \n"
    
    createCmd = "mkfs -t ext4 /dev/xvdb"
    mountCmd = "mount /dev/xvdb " + MOUNT_POINT
    mountOwnerCmd = "chown " + MOUNT_OWNER + ":" + MOUNT_GROUP + " " + MOUNT_POINT
    
    if not (os.path.exists(MOUNT_POINT)):
        os.mkdir(MOUNT_POINT, 0755)    
    
    commerce_setup_helper.exec_cmd(createCmd)
    commerce_setup_helper.exec_cmd(mountCmd)
    commerce_setup_helper.exec_cmd(mountOwnerCmd)

    with open("/etc/fstab", "a") as myfile:
        myfile.write(FSTAB_ENTRY)
    myfile.close()    
      
    
    
                
Beispiel #3
0
def install_cas(configData, full_path):

    endecaData = configData[json_key]
    requiredFields = ['installOwner', 'installGroup']
    commerce_setup_helper.check_required_fields(endecaData, requiredFields)
    INSTALL_OWNER = endecaData['installOwner']
    INSTALL_GROUP = endecaData['installGroup']
    if service_key in endecaData:
        jsonData = endecaData[service_key]
        requiredFields = [
            'endecaRoot', 'casPort', 'casShutdownPort', 'casHostname'
        ]
        commerce_setup_helper.check_required_fields(jsonData, requiredFields)
    else:
        print service_name + " config data missing from json. will not install"
        return

    print "installing " + service_name

    if (platform.system() == "SunOS"):
        binary_path = full_path + "/binaries/endeca11.1/solaris"
        install_exec = "/CAS_Install/OCcas11.1.0-Solaris.sh"
    else:
        binary_path = full_path + "/binaries/endeca11.1"
        install_exec = "/CAS_Install/OCcas11.1.0-Linux64.sh"

    response_files_path = full_path + "/responseFiles/endeca11.1"

    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

    if jsonData is not None:

        ENDECA_ROOT = jsonData['endecaRoot']
        CAS_PORT = jsonData['casPort']
        CAS_SHUTDOWN_PORT = jsonData['casShutdownPort']
        CAS_HOSTNAME = jsonData['casHostname']
        START_ON_BOOT = jsonData['start_onBoot']
        # make the install tree with correct owner if needed
        commerce_setup_helper.mkdir_with_perms(ENDECA_ROOT, INSTALL_OWNER,
                                               INSTALL_GROUP)

        # data field to replace in our silent installer file
        field_replacements = {
            'ENDECA_ROOT': ENDECA_ROOT,
            'CAS_PORT': CAS_PORT,
            'CAS_SHUTDOWN_PORT': CAS_SHUTDOWN_PORT,
            'CAS_HOST': CAS_HOSTNAME
        }

        commerce_setup_helper.substitute_file_fields(
            response_files_path + '/cas_silent.txt.master',
            response_files_path + '/cas_silent.txt', field_replacements)

        installCommand = "\"" + full_exec_path + " --silent --target " + ENDECA_ROOT + \
        " --endeca_tools_root " + ENDECA_ROOT + "/endeca/ToolsAndFrameworks/11.1.0 --endeca_tools_conf " + ENDECA_ROOT + "/endeca/ToolsAndFrameworks/11.1.0/server/workspace < " + \
        response_files_path + "/cas_silent.txt \""
        commerce_setup_helper.exec_as_user(INSTALL_OWNER, installCommand)

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

        # copy start/stop script
        ENDECA_HOME = ENDECA_ROOT + "/endeca"
        MDEX_SETUP = ENDECA_HOME + "/MDEX/6.5.1/mdex_setup_sh.ini"
        PLATFORM_SETUP = ENDECA_HOME + "/PlatformServices/workspace/setup/installer_sh.ini"
        script_replacements = {
            'ENDECA_PROCESS_OWNER': INSTALL_OWNER,
            'ENDECA_INSTALL_ROOT': ENDECA_HOME,
            "MDEX_SETUP": MDEX_SETUP,
            "PLATFORM_SETUP": PLATFORM_SETUP
        }
        commerce_setup_helper.copy_start_script(
            START_ON_BOOT, full_path + startStopPath + 'endecaCAS.master',
            script_replacements)

        # restart other services before cas
        platformCmd = "/etc/init.d/platformServices"
        toolsCmd = "/etc/init.d/toolsAndFramework"
        commerce_setup_helper.exec_cmd(toolsCmd + " stop")
        commerce_setup_helper.exec_cmd(platformCmd + " restart")
        commerce_setup_helper.exec_cmd(toolsCmd + " start")
        # start cas
        startCmd = "/etc/init.d/endecaCAS"
        commerce_setup_helper.exec_cmd(startCmd + " start")

        commerce_setup_helper.add_to_bashrc(
            INSTALL_OWNER, "# echo Endeca " + service_name +
            " start/stop script: " + startCmd + "\n")
Beispiel #4
0
def install_oracle(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

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

    response_files_path = full_path + "/responseFiles/oracle12c"

    install_exec = "/database/runInstaller"
    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 = [
        'oracleBase', 'installOwner', 'installGroup', 'installHost',
        'oraInventoryDir', 'oracleHome', 'oracleSID', 'pdbName', 'adminPW',
        'dbStorageLoc'
    ]
    commerce_setup_helper.check_required_fields(jsonData, requiredFields)

    ORACLE_BASE = jsonData['oracleBase']
    INSTALL_OWNER = jsonData['installOwner']
    INSTALL_GROUP = jsonData['installGroup']
    INSTALL_HOST = jsonData['installHost']
    ORACLE_INVENTORY_DIR = jsonData['oraInventoryDir']
    ORACLE_HOME = jsonData['oracleHome']
    ORACLE_SID = jsonData['oracleSID']
    PDB_NAME = jsonData['pdbName']
    ORACLE_PW = jsonData['adminPW']
    DB_FILE_DIR = jsonData['dbStorageLoc']
    ORACLE_BOOT = jsonData['db_onBoot']

    oracle_replacements = {
        'BASE_DIR': ORACLE_BASE,
        'IGROUP': INSTALL_GROUP,
        'INSTALL_HOST': INSTALL_HOST,
        'INVENTORY_DIR': ORACLE_INVENTORY_DIR,
        'PRODUCT_HOME': ORACLE_HOME,
        'GLOBAL_DBNAME': ORACLE_SID,
        'PDB_NAME': PDB_NAME,
        'ORA_PW': ORACLE_PW,
        'DB_FILE_DIR': DB_FILE_DIR,
    }

    commerce_setup_helper.substitute_file_fields(
        response_files_path + '/db.rsp.master',
        response_files_path + '/db.rsp', oracle_replacements)
    commerce_setup_helper.substitute_file_fields(
        response_files_path + '/dbca.rsp.master',
        response_files_path + '/dbca.rsp', oracle_replacements)

    # make the install trees with correct owner if needed
    commerce_setup_helper.mkdir_with_perms(ORACLE_BASE, INSTALL_OWNER,
                                           INSTALL_GROUP)
    commerce_setup_helper.mkdir_with_perms(ORACLE_INVENTORY_DIR, INSTALL_OWNER,
                                           INSTALL_GROUP)
    commerce_setup_helper.mkdir_with_perms(ORACLE_HOME, INSTALL_OWNER,
                                           INSTALL_GROUP)
    commerce_setup_helper.mkdir_with_perms(DB_FILE_DIR, INSTALL_OWNER,
                                           INSTALL_GROUP)

    # install db
    installCommand = "\"" + full_exec_path + " -silent -waitforcompletion -responseFile " + response_files_path + "/db.rsp" + "\""
    commerce_setup_helper.exec_as_user(INSTALL_OWNER, installCommand)

    invCmd = ORACLE_INVENTORY_DIR + "/orainstRoot.sh"
    commerce_setup_helper.exec_cmd(invCmd)

    rootCmd = ORACLE_HOME + "/root.sh"
    commerce_setup_helper.exec_cmd(rootCmd)

    postInstallCmd = "\"" + ORACLE_HOME + "/cfgtoollogs/configToolAllCommands RESPONSE_FILE=" + response_files_path + "/db.rsp" + "\""
    commerce_setup_helper.exec_as_user(INSTALL_OWNER, postInstallCmd)

    commerce_setup_helper.add_to_bashrc(INSTALL_OWNER,
                                        "##################### \n")
    commerce_setup_helper.add_to_bashrc(INSTALL_OWNER, "#Oracle Settings \n")
    commerce_setup_helper.add_to_bashrc(INSTALL_OWNER,
                                        "##################### \n")
    commerce_setup_helper.add_to_bashrc(
        INSTALL_OWNER, "export ORACLE_HOME=" + ORACLE_HOME + "\n")
    commerce_setup_helper.add_to_bashrc(
        INSTALL_OWNER, "export ORACLE_SID=" + ORACLE_SID + "\n")
    commerce_setup_helper.add_to_bashrc(
        INSTALL_OWNER, "export PATH=$PATH:" + ORACLE_HOME + "/bin \n")

    # copy start/stop script
    script_replacements = {
        'ORACLE_HOME': ORACLE_HOME,
        'ORACLE_PROCESS_OWNER': INSTALL_OWNER
    }
    commerce_setup_helper.copy_start_script(
        ORACLE_BOOT,
        full_path + '/startStopScripts/bootScripts/oracleDatabase.master',
        script_replacements)
    # commerce_setup_helper.copy_start_script(ORACLE_BOOT, full_path + '/startStopScripts/bootScripts/oracleDBconsole.master', script_replacements)

    commerce_setup_helper.add_to_bashrc(
        INSTALL_OWNER, "# echo " + service_name +
        " start/stop script: /etc/init.d/oracleDatabase \n")
    # not used for 12c install - using em express instead
    # commerce_setup_helper.add_to_bashrc(INSTALL_OWNER, "# echo database console start/stop script: /etc/init.d/oracleDBconsole \n\n")

    install_listener(INSTALL_OWNER, ORACLE_HOME, response_files_path)

    install_sampledb(INSTALL_OWNER, ORACLE_HOME, response_files_path)

    if (platform.system() == "SunOS"):
        oratab_file = "/var/opt/oracle/oratab"
    else:
        oratab_file = "/etc/oratab"

    # set our DB to autostart in the future
    line_to_replace = ORACLE_SID + ":" + ORACLE_HOME + ":" "N"
    replace_with = ORACLE_SID + ":" + ORACLE_HOME + ":" "Y"

    for line in fileinput.input(oratab_file, inplace=True):
        print line.rstrip().replace(line_to_replace, replace_with)
Beispiel #5
0
def create_wl_domain(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

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

    response_files_path = full_path + "/responseFiles/wls-12.2.1"
                    
    logging.info("Creating " + service_name)               
     
    commonRequiredFields = ['middlewareHome', 'installOwner', 'wl_domain', 'wl_adminHttpPort', 'wl_adminHttpsPort', 'wl_adminPassword']
    commerce_setup_helper.check_required_fields(commonData, commonRequiredFields)
    
    requiredFields = ['wl_startAdmin_onBoot', 'wl_startNodemgr_onBoot']
    commerce_setup_helper.check_required_fields(jsonData, requiredFields)    

    INSTALL_DIR = commonData['middlewareHome']
    INSTALL_OWNER = commonData['installOwner']
    WL_DOMAIN_NAME = commonData['wl_domain']
    WL_ADMIN_HTTP_PORT = commonData['wl_adminHttpPort']
    WL_ADMIN_HTTPS_PORT = commonData['wl_adminHttpsPort']
    WL_ADMIN_PW = commonData['wl_adminPassword']
    WL_ADMIN_BOOT = jsonData['wl_startAdmin_onBoot']
    WL_NODE_BOOT = jsonData['wl_startNodemgr_onBoot']

    WL_MACHINES = add_machines(configData, full_path)
    WL_MANAGED_SERVERS = add_managed_servers(configData, full_path)

    wlst_path = INSTALL_DIR + "/oracle_common/common/bin/wlst.sh"
    
    if not os.path.exists(wlst_path):
        logging.error("Binary " + wlst_path + " does not exist - will not install")
        return False   
        
    wl_replacements = {'INSTALL_DIR':INSTALL_DIR, 'WL_DOMAIN_NAME':WL_DOMAIN_NAME, 'WL_ADMIN_HTTP_PORT':WL_ADMIN_HTTP_PORT, 'WL_ADMIN_HTTPS_PORT':WL_ADMIN_HTTPS_PORT, 'WL_ADMIN_PW':WL_ADMIN_PW, 'WL_MANAGED_SERVERS':WL_MANAGED_SERVERS, 'WL_MACHINES':WL_MACHINES}
    commerce_setup_helper.substitute_file_fields(response_files_path + '/basicWLSDomain.py.master', response_files_path + '/basicWLSDomain.py', wl_replacements)

    domainCmd = "\""
    
    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"
        
    # create wl domain CONFIG_JVM_ARGS
    domainCmd += "export CONFIG_JVM_ARGS='" + JAVA_RAND + "'; "
    domainCmd += wlst_path + " " + response_files_path + "/basicWLSDomain.py " + "\""
    commerce_setup_helper.exec_as_user(INSTALL_OWNER, domainCmd)  
   
    if (platform.system() == 'SunOS'):
        startStopPath = "/startStopScripts/solaris/bootScripts/"
    else:
        startStopPath = "/startStopScripts/bootScripts/"
   
    # copy start/stop script
    WL_DOMAIN_HOME = INSTALL_DIR + '/user_projects/domains/' + WL_DOMAIN_NAME
    wlScript_replacements = {'WL_DOMAIN_HOME':WL_DOMAIN_HOME, "WL_PROCESS_OWNER":INSTALL_OWNER}
    commerce_setup_helper.copy_start_script(WL_ADMIN_BOOT, full_path + startStopPath + 'weblogicAdmin.master', wlScript_replacements)
    commerce_setup_helper.copy_start_script(WL_NODE_BOOT, full_path + startStopPath + 'weblogicNodemgr.master', wlScript_replacements)
    
    # pack the domain for managed servers
    weblogic_packer.pack_domain(configData, full_path)
    
    # fire up the admin server and nodemgr 
    startWLCmd = "/etc/init.d/weblogicAdmin"
    commerce_setup_helper.exec_cmd(startWLCmd + " start")
    startNodeCmd = "/etc/init.d/weblogicNodemgr"
    commerce_setup_helper.exec_cmd(startNodeCmd + " start")
    
    # give admin server time to finish starting
    sleepTime = 60
    time.sleep(sleepTime)
    
    commerce_setup_helper.add_to_bashrc(INSTALL_OWNER, "# echo 'WebLogic Admin start/stop script: '" + startWLCmd + "\n")    
    commerce_setup_helper.add_to_bashrc(INSTALL_OWNER, "# echo 'WebLogic NodeManager start/stop script: '" + startNodeCmd + "\n")   
def install_toolsAndFramework(configData, full_path):

    endecaData = configData[json_key]
    requiredFields = ['installOwner', 'installGroup']
    commerce_setup_helper.check_required_fields(endecaData, requiredFields)
    INSTALL_OWNER = endecaData['installOwner']
    INSTALL_GROUP = endecaData['installGroup']
    if 'toolsAndFramework' in endecaData:
        jsonData = endecaData['toolsAndFramework']
        requiredFields = ['endecaRoot']
        commerce_setup_helper.check_required_fields(jsonData, requiredFields)
    else:
        logging.error(service_name +
                      " config data missing from json. will not install")
        return

    logging.info("installing " + service_name)

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

    install_exec = "/ToolsAndFrameworkInstall/Disk1/install/silent_install.sh"

    response_files_path = full_path + "/responseFiles/endeca11.3"

    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

    if jsonData is not None:
        ENDECA_ROOT = jsonData['endecaRoot']
        START_ON_BOOT = jsonData['start_onBoot']
        # make the install tree with correct owner if needed
        commerce_setup_helper.mkdir_with_perms(ENDECA_ROOT, INSTALL_OWNER,
                                               INSTALL_GROUP)

        # data field to replace in our silent installer file
        field_replacements = {
            'ENDECA_ROOT': ENDECA_ROOT,
            'ENDECA_GROUP': INSTALL_GROUP
        }

        commerce_setup_helper.substitute_file_fields(
            response_files_path + '/tools_response.rsp.master',
            response_files_path + '/tools_response.rsp', field_replacements)

        installCommand = "\"" + full_exec_path + " " + \
        response_files_path + "/tools_response.rsp ToolsAndFrameworks " + \
        ENDECA_ROOT + "/endeca/ToolsAndFrameworks "

        if 'oraInventoryDir' in jsonData:
            installCommand = installCommand + jsonData['oraInventoryDir']

        commerce_setup_helper.exec_as_user(INSTALL_OWNER,
                                           installCommand + "\"")

        # copy start/stop script
        ENDECA_HOME = ENDECA_ROOT + "/endeca"
        MDEX_SETUP = ENDECA_HOME + "/MDEX/11.3.0/mdex_setup_sh.ini"
        PLATFORM_SETUP = ENDECA_HOME + "/PlatformServices/workspace/setup/installer_sh.ini"
        script_replacements = {
            'ENDECA_PROCESS_OWNER': INSTALL_OWNER,
            'ENDECA_INSTALL_ROOT': ENDECA_HOME,
            "MDEX_SETUP": MDEX_SETUP,
            "PLATFORM_SETUP": PLATFORM_SETUP,
            "INSTALL_VERSION": endeca_version
        }
        commerce_setup_helper.copy_start_script(
            START_ON_BOOT, full_path +
            '/startStopScripts/bootScripts/toolsAndFramework.master',
            script_replacements)

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

        commerce_setup_helper.add_to_bashrc(
            INSTALL_OWNER, "# echo Endeca " + service_name +
            " start/stop script: " + startCmd + "\n")
def install_platformServices(configData, full_path):

    endecaData = configData[json_key]
    requiredFields = ['installOwner', 'installGroup']
    commerce_setup_helper.check_required_fields(endecaData, requiredFields)
    INSTALL_OWNER = endecaData['installOwner']
    INSTALL_GROUP = endecaData['installGroup']
    if 'platformServices' in endecaData:
        jsonData = endecaData['platformServices']
        requiredFields = [
            'endecaRoot', 'eacPort', 'eacShutdownPort', 'mdexRoot'
        ]
        commerce_setup_helper.check_required_fields(jsonData, requiredFields)
    else:
        logging.error(service_name +
                      " config data missing from json. will not install")
        return

    logging.info("installing " + service_name)

    if (platform.system() == "SunOS"):
        binary_path = full_path + "/binaries/endeca11.3/solaris"
        install_exec = "/Platform_Install/OCplatformservices11.3.0-Solaris.bin"
    else:
        binary_path = full_path + "/binaries/endeca11.3"
        install_exec = "/Platform_Install/OCplatformservices11.3.0-Linux64.bin"

    response_files_path = full_path + "/responseFiles/endeca11.3"

    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

    if jsonData is not None:
        ENDECA_ROOT = jsonData['endecaRoot']
        MDEX_ROOT = jsonData['mdexRoot']
        EAC_PORT = jsonData['eacPort']
        EAC_SHUTDOWN_PORT = jsonData['eacShutdownPort']
        START_ON_BOOT = jsonData['start_onBoot']
        # make the install tree with correct owner if needed
        commerce_setup_helper.mkdir_with_perms(ENDECA_ROOT, INSTALL_OWNER,
                                               INSTALL_GROUP)

        # data field to replace in our silent installer file
        field_replacements = {
            'INSTALLATION_DIR': ENDECA_ROOT,
            'MDEX_INST_ROOT': MDEX_ROOT,
            'EAC_PORT': EAC_PORT,
            'EAC_SHUTDOWN_PORT': EAC_SHUTDOWN_PORT
        }

        commerce_setup_helper.substitute_file_fields(
            response_files_path + '/platform_response.rsp.master',
            response_files_path + '/platform_response.rsp', field_replacements)

        installCommand = "\"" + full_exec_path + " -i silent -f " + response_files_path + '/platform_response.rsp' + "\""
        commerce_setup_helper.exec_as_user(INSTALL_OWNER, installCommand)

        # add bashrc entries
        commerce_setup_helper.add_to_bashrc(
            INSTALL_OWNER, "source " + ENDECA_ROOT +
            "/endeca/PlatformServices/workspace/setup/installer_sh.ini \n")

        # copy start/stop script
        ENDECA_HOME = ENDECA_ROOT + "/endeca"
        MDEX_SETUP = MDEX_ROOT + "/mdex_setup_sh.ini"
        PLATFORM_SETUP = ENDECA_HOME + "/PlatformServices/workspace/setup/installer_sh.ini"
        script_replacements = {
            'ENDECA_PROCESS_OWNER': INSTALL_OWNER,
            'ENDECA_INSTALL_ROOT': ENDECA_HOME,
            "MDEX_SETUP": MDEX_SETUP,
            "PLATFORM_SETUP": PLATFORM_SETUP,
            "INSTALL_VERSION": endeca_version
        }
        commerce_setup_helper.copy_start_script(
            START_ON_BOOT, full_path +
            '/startStopScripts/bootScripts/platformServices.master',
            script_replacements)

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

        commerce_setup_helper.add_to_bashrc(
            INSTALL_OWNER, "# echo Endeca " + service_name +
            " start/stop script: " + startCmd + "\n")
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")
def unpack_domain(configData, full_path):
    """
    Get domain template and unpack it for a new managed server setup
    """
    if json_key in configData:
        jsonData = configData[json_key]
    else:
        print json_key + " config data missing from json. will not install"
        return

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

    print "Unpacking... " + service_name

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

    requiredFields = ['wl_startNodemgr_onBoot']
    commerce_setup_helper.check_required_fields(jsonData, requiredFields)

    INSTALL_DIR = commonData['middlewareHome']
    INSTALL_OWNER = commonData['installOwner']
    INSTALL_GROUP = commonData['installGroup']
    WL_DOMAIN_NAME = commonData['wl_domain']
    WL_ADMIN_HOST = commonData['wl_adminHost']
    WL_NODE_BOOT = jsonData['wl_startNodemgr_onBoot']

    WL_DOMAIN_HOME = INSTALL_DIR + '/user_projects/domains/' + WL_DOMAIN_NAME
    DOMAIN_TEMPLATE_NAME = WL_DOMAIN_NAME + '-template.jar'
    DOMAIN_TEMPLATE_PATH = INSTALL_DIR + '/user_projects/domains/' + DOMAIN_TEMPLATE_NAME

    if not os.path.isfile(DOMAIN_TEMPLATE_PATH):
        print "domain template not found. Try to get it"
        # make the install tree with correct owner if needed
        commerce_setup_helper.mkdir_with_perms(WL_DOMAIN_HOME, INSTALL_OWNER,
                                               INSTALL_GROUP)
        retrieve_domain_template(DOMAIN_TEMPLATE_NAME, DOMAIN_TEMPLATE_PATH,
                                 WL_ADMIN_HOST)

    unpackCmd = "\"" + INSTALL_DIR + "/wlserver/common/bin/unpack.sh -domain=" + WL_DOMAIN_HOME + " -template=" + WL_DOMAIN_HOME + "-template.jar\""
    commerce_setup_helper.exec_as_user(INSTALL_OWNER, unpackCmd)

    # copy start/stop script
    WL_DOMAIN_HOME = INSTALL_DIR + '/user_projects/domains/' + WL_DOMAIN_NAME

    if (platform.system() == 'SunOS'):
        startStopPath = "/startStopScripts/solaris/bootScripts/"
    else:
        startStopPath = "/startStopScripts/bootScripts/"
    # copy start/stop script
    WL_DOMAIN_HOME = INSTALL_DIR + '/user_projects/domains/' + WL_DOMAIN_NAME
    wlScript_replacements = {
        'WL_DOMAIN_HOME': WL_DOMAIN_HOME,
        "WL_PROCESS_OWNER": INSTALL_OWNER
    }
    commerce_setup_helper.copy_start_script(
        WL_NODE_BOOT, full_path + startStopPath + 'weblogicNodemgr.master',
        wlScript_replacements)

    # fire up the nodemgr
    startNodeCmd = "/etc/init.d/weblogicNodemgr"
    commerce_setup_helper.exec_cmd(startNodeCmd + " start")
Beispiel #10
0
def clone_oracle(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
    logging.info("installing " + service_name)

    INSTALL_OWNER = jsonData['installOwner']
    ORACLE_HOME = jsonData['oracleHome']
    ORIG_HOST = jsonData['originalHost']
    NEW_HOST = jsonData['newHost']
    ORACLE_SID = jsonData['oracleSID']
    UPDATE_DB_CONSOLE = jsonData['updateDBConsole']

    db_script = "/etc/init.d/oracleDatabase"
    db_console_script = "/etc/init.d/oracleDBconsole"
    stop_db_cmd = db_script + " stop"
    stop_db_console_cmd = db_console_script + " stop"
    start_db_cmd = db_script + " start"
    start_db_console_cmd = db_console_script + " start"

    tns_path = ORACLE_HOME + "/network/admin/tnsnames.ora"
    lsnr_path = ORACLE_HOME + "/network/admin/listener.ora"

    if not os.path.exists(tns_path):
        logging.error("tnsnames.ora not found at " + tns_path +
                      " - will not proceed")
        return False

    # stop db
    commerce_setup_helper.exec_cmd(stop_db_cmd)

    # stop console
    commerce_setup_helper.exec_cmd(stop_db_console_cmd)

    tns_replacements = {}
    lsnr_replacements = {}

    if (ORIG_HOST and NEW_HOST):
        tns_replacements[ORIG_HOST] = NEW_HOST
        lsnr_replacements[ORIG_HOST] = NEW_HOST

    # update tnsnames
    if tns_replacements:
        if not os.path.exists(tns_path):
            logging.warn("tnsnames.ora not found at " + tns_path +
                         " - cannot modify")
        else:
            # backup tnsnames
            timestr = time.strftime("%Y%m%d-%H%M%S")
            installCommand = "\"" + "cp " + tns_path + " " + tns_path + "." + timestr + "\""
            commerce_setup_helper.exec_as_user(INSTALL_OWNER, installCommand)
            commerce_setup_helper.substitute_file_fields(
                tns_path, tns_path, tns_replacements)

    # update listener
    if lsnr_replacements:
        if not os.path.exists(lsnr_path):
            logging.warn("listener.ora not found at " + lsnr_path +
                         " - cannot modify")
        else:
            # backup listener
            timestr = time.strftime("%Y%m%d-%H%M%S")
            installCommand = "\"" + "cp " + lsnr_path + " " + lsnr_path + "." + timestr + "\""
            commerce_setup_helper.exec_as_user(INSTALL_OWNER, installCommand)
            commerce_setup_helper.substitute_file_fields(
                lsnr_path, lsnr_path, tns_replacements)

    # update db name
    orig_db_name = ORACLE_HOME + "/" + ORIG_HOST + "_" + ORACLE_SID
    new_db_name = ORACLE_HOME + "/" + NEW_HOST + "_" + ORACLE_SID
    if not os.path.exists(orig_db_name):
        logging.error("db path not found at " + orig_db_name +
                      " - cannot modify")
    else:
        mv_cmd = "\"" + "mv " + orig_db_name + " " + new_db_name + "\""
        commerce_setup_helper.exec_as_user(INSTALL_OWNER, mv_cmd)

    # update db console
    if (UPDATE_DB_CONSOLE == "true"):
        PORT = jsonData['lsnrPort']
        ORACLE_PW = jsonData['adminPW']
        orig_db_console = ORACLE_HOME + "/oc4j/j2ee/OC4J_DBConsole_" + ORIG_HOST + "_" + ORACLE_SID
        new_db_console = ORACLE_HOME + "/oc4j/j2ee/OC4J_DBConsole_" + NEW_HOST + "_" + ORACLE_SID
        if not os.path.exists(orig_db_console):
            logging.warn("db console not found at " + orig_db_console +
                         " - cannot modify")
        else:
            mv_cmd = "\"" + "mv " + orig_db_console + " " + new_db_console + "\""
            commerce_setup_helper.exec_as_user(INSTALL_OWNER, mv_cmd)

            # db must be running for emca to exec. make sure
            # start db
            commerce_setup_helper.exec_cmd(start_db_cmd)

            emca_params = "-SID " + ORACLE_SID + " -PORT " + PORT + " -SYS_PWD " + ORACLE_PW + " -SYSMAN_PWD " + ORACLE_PW + " -DBSNMP_PWD " + ORACLE_PW
            drop_repo_cmd = "\"" + ORACLE_HOME + "/bin/emca -deconfig dbcontrol db -repos drop -silent " + emca_params + "\""
            create_repo_cmd = "\"" + ORACLE_HOME + "/bin/emca -config dbcontrol db -repos create -silent " + emca_params + "\""
            commerce_setup_helper.exec_as_user(INSTALL_OWNER, drop_repo_cmd)
            commerce_setup_helper.exec_as_user(INSTALL_OWNER, create_repo_cmd)

    # stop db
    commerce_setup_helper.exec_cmd(stop_db_cmd)

    # stop console
    commerce_setup_helper.exec_cmd(stop_db_console_cmd)

    # start db
    commerce_setup_helper.exec_cmd(start_db_cmd)

    if (UPDATE_DB_CONSOLE == "true"):
        # start dbconsole
        commerce_setup_helper.exec_cmd(start_db_console_cmd)
Beispiel #11
0
def create_managed_scripts(configData, full_path):
    """
    Create start/stop scripts for managed servers
    """
    if json_key in configData:
        jsonDataArray = configData[json_key]
    else:
        logging.error(json_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

    logging.info("Updating... " + service_name)

    commonRequiredFields = [
        'middlewareHome', 'installOwner', 'installGroup', 'wl_domain',
        'wl_adminHost', 'wl_adminHttpPort'
    ]
    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_HOST = commonData['wl_adminHost']
    WL_ADMIN_HTTP_PORT = commonData['wl_adminHttpPort']

    WL_DOMAIN_HOME = INSTALL_DIR + '/user_projects/domains/' + WL_DOMAIN_NAME
    ADMIN_URL = WL_ADMIN_HOST + ":" + WL_ADMIN_HTTP_PORT

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

    for jsonData in jsonDataArray:

        requiredFields = [
            'managedServerName', 'managedServerHost', 'wl_startManaged_onBoot'
        ]
        commerce_setup_helper.check_required_fields(jsonData, requiredFields)

        WL_SERVER_NAME = jsonData['managedServerName']
        WL_SERVER_HOST = jsonData['managedServerHost']
        WL_SERVER_BOOT = jsonData['wl_startManaged_onBoot']

        # copy start/stop script
        WL_DOMAIN_HOME = INSTALL_DIR + '/user_projects/domains/' + WL_DOMAIN_NAME
        wlScript_replacements = {
            'WL_DOMAIN_HOME': WL_DOMAIN_HOME,
            "WL_PROCESS_OWNER": INSTALL_OWNER,
            "INSTANCE_NAME": WL_SERVER_NAME,
            "ADMIN_URL": ADMIN_URL
        }

        # 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):
                SCRIPT_NAME = 'weblogicManaged-' + WL_SERVER_NAME
                logging.info('Generating startup script for server ' +
                             WL_SERVER_NAME)
                commerce_setup_helper.copy_start_script(
                    WL_SERVER_BOOT,
                    full_path + startStopPath + 'weblogicManaged.master',
                    wlScript_replacements, SCRIPT_NAME)

                # make the path to the log dir, or first server start will fail with scripts
                logging.info('Generating log dir for server ' + WL_SERVER_NAME)
                SERVER_LOG_PATH = WL_DOMAIN_HOME + '/servers/' + WL_SERVER_NAME + '/logs'
                commerce_setup_helper.mkdir_with_perms(SERVER_LOG_PATH,
                                                       INSTALL_OWNER,
                                                       INSTALL_GROUP)

                # fire up the instance
                logging.info('Starting up instance ' + WL_SERVER_NAME)
                startCmd = "/etc/init.d/" + SCRIPT_NAME
                commerce_setup_helper.exec_cmd(startCmd + " start")

        else:
            logging.error(
                "Cannot determine hostname. Cannot create startup script")