コード例 #1
0
def getBuildsWithCumulativeAgents(builds):
    linux_agents = _getCumulativeAgents(Const.getCoreRpmsDir())
    windows_agents = _getCumulativeAgents(Const.getCoreExesDir())
    for build in builds:
        if linux_agents:
            build.rpms = linux_agents.rpms
        if windows_agents:
            build.windows_update.sn_installer_path = windows_agents.windows_update.sn_installer_path
            build.windows_update.async_exec_path = windows_agents.windows_update.async_exec_path
    return builds
コード例 #2
0
    def performRaw(self, host):
        if Const.isOsaWinPlatform(host.platform.os):
            shell = "cmd.exe"
            cmd_switch = "/C"
        else:
            shell = "/bin/sh"
            cmd_switch = "-c"

        self.export("default_shell_name", shell, True)
        self.export("shell_cmd_switch", cmd_switch, True)
        try:
            return self.__performHCLRequest(host, self.__document)
        except uUtil.ExecFailed, e:
            # Notation "ex_type_id:'103'" in stderr it is a sign that exception OBJECT_NOT_EXIST is raised
            # (from modules/platform/u/EAR/poakernel-public/Common.edl).
            # We need to retry HCL request because the reason may be an outdated CORBA cache.
            # Cache will be invalidated in this case, so repeated request will pass
            # (modules/platform/cells/pem_client/cpp/Naming/Naming.cpp).
            deprecated_cache_error_pattern = re.compile(
                "OBJ_ADAPTER|OBJECT_NOT_EXIST|ex_type_id:'103'")
            if re.search(deprecated_cache_error_pattern, e.err):
                uLogging.debug("HCL request exec failed. Retrying...")
                return self.__performHCLRequest(host, self.__document)
            else:
                raise
コード例 #3
0
def runHCLCmd(hostId, commandText):
    uLogging.debug(commandText)
    con = uSysDB.connect()
    host = uPEM.getHost(hostId)
    commandText = commandText.replace(
        "${", '$${'
    )  #for more details see following issue https://jira.int.zone/browse/POA-109131
    rq = Request(user='******', group='root')
    rq.command(commandText,
               stdout='stdout',
               stderr='stderr',
               valid_exit_codes=[0])
    if Const.isOsaWinPlatform(host.platform.os):
        rq.export("default_shell_name", "cmd.exe", True)
        rq.export("shell_cmd_switch", "/C", True)
    else:
        rq.export("default_shell_name", "/bin/sh", True)
        rq.export("shell_cmd_switch", "-c", True)
    rqRv = None
    try:
        rqRv = rq.send(host)
    except uUtil.ExecFailed:
        rqRv = rq.performRaw(host)
    o = rqRv["stdout"]
    if o: uLogging.debug(o)
    return o
コード例 #4
0
def is_slave_upgradable(host, binfo, config):
    uLogging.debug("Checking if slave {host} is upgradable".format(host=host))
    is_windows_host = Const.isOsaWinPlatform(host.platform.os)

    if host.host_id in binfo.progress.updated_hosts:
        uLogging.debug("Skipping already updated slave: {host}".format(host=host))
        return False

    if config.skip_win and is_windows_host:
        uLogging.debug("Skipping windows host {host} because was passed option '--skip:win'".format(host=host))
        return False

    if config.skip_rpms and not is_windows_host:
        uLogging.debug("Skipping Linux (RPM) host {host} because was passed option '--skip:rpms'".format(host=host))
        return False

    if not uPEM.canProceedWithHost(host):
        uLogging.warn("Skipping unavailable slave: {host}".format(host=host))
        return False

    # platform-specific URL for agent
    agent_url = prepare_paagent_url(host.platform, binfo, config)

    if not agent_url and is_windows_host:
        uLogging.debug("Skipping windows slave {host} as we have no pa-agent distrib "
                       "for its platform ({platform})".format(host=host, platform=host.platform))
        return False

    if not agent_url and not config.need_update_paagent and not config.need_update_yum_repourl:
        uLogging.debug("Skipping slave {host} as we have no pa-agent distrib for its platform ({platform}) "
                       "and updating YUM repourl is not needed also".format(host=host, platform=host.platform))
        return False

    uLogging.debug("Slave is upgradable: {host}".format(host=host))
    return True
コード例 #5
0
def prepare_paagent_rpm_url(platform, binfo, config):
    uLogging.debug("Building pa-agent upgrade kit for platform {platform}".format(platform=platform))
    agent_rpm_path = get_paagent_rpm_path(binfo, platform)

    if not agent_rpm_path:
        uLogging.debug("Agent for platform {platform} not found".format(platform=platform))
        return None

    corerpms_path = "corerpms/{distrib}{osver}".format(distrib=Const.getDistribLinDir(), osver=platform.osver)
    rpm_in_corerpms_path = posixpath.join(corerpms_path, os.path.basename(agent_rpm_path))

    # Here we could get URL to our RPM, but we need to prepare archive because 'fetch' HCL method can not recognize
    # something except gzip/bzip/exe. Need to simplify this after improving install.cpp from pa-agent project.
    # We need 'fetch' method as the unified transport for agents.

    local_path = uPackaging.getMainMirror().localpath  # /usr/local/pem/install/tarballs
    kit_dir_name = 'linux_agent_upgrade_kit'
    upd_path = os.path.join(local_path, kit_dir_name, config.update_name)
    kit_tarball_filename = '{platform}_{build_name}.tgz'.format(platform=platform, build_name=config.update_name)
    kit_tarball_full_path = os.path.join(upd_path, kit_tarball_filename)

    if not os.path.exists(upd_path):
        os.makedirs(upd_path)

    tgz = tarfile.open(kit_tarball_full_path, "w:gz")
    tgz.debug = 1
    tgz.add(os.path.join(local_path, rpm_in_corerpms_path), PAAGENT_RPM_NAME)
    tgz.close()
    uLogging.debug("pa-agent upgrade kit for platform {platform} has been built: {kit_tarball_full_path}".format(
        platform=platform, kit_tarball_full_path=kit_tarball_full_path))
    return 'http://{comm_ip}/tarballs/{kit_dir_name}/{update_name}/{kit_tarball_filename}'.format(
        comm_ip=config.communication_ip, kit_dir_name=kit_dir_name,
        update_name=config.update_name, kit_tarball_filename=kit_tarball_filename
    )
コード例 #6
0
def installPrerequisites(source_dir):
    win_files_dir = os.path.join(source_dir, "os", Const.getDistribWinDir())
    installJDK(win_files_dir)
    installVCRedistX64(win_files_dir)
    installWinFile(win_files_dir, "vcredist-2005-x86-8.0.50727.6195.exe")
    installWinFile(win_files_dir, "sql-native-client-driver-x86-10.0.exe")
    installWinFile(win_files_dir, "sql-native-client-driver-x64-10.0.exe")
コード例 #7
0
def update_slave(task_item, config):
    is_slave_updated = None

    try:
        if Const.isOsaWinPlatform(task_item.host.platform.os):
            if task_item.paagent_dist_url:
                schedule_update_windows_slave(task_item)
                uAction.ntimes_retried(check_update_windows_slave, 8, 30)(task_item, config)
                is_slave_updated = True
        else:
            linux_update_result = update_linux_slave(task_item, config)
            check_update_linux_slave(task_item.host, linux_update_result)

            # This is a workaround: see async restart code in pa-agent RPM
            async_upgrade_finished_sec = 11
            uLogging.debug("Waiting {async_upgrade_finished_sec} sec for agent upgrade process is finished "
                           "on host {host}".format(host=task_item.host,
                                                   async_upgrade_finished_sec=async_upgrade_finished_sec))
            sleep(async_upgrade_finished_sec)
            uAction.ntimes_retried(wait_for_linux_slave, 8, 30)(task_item)
            is_slave_updated = True

    except Exception as e:
        uLogging.warn("Error happen during upgrade slave {host}, check details in log or wait for moment when "
                      "the result will be processed".format(host=task_item.host))
        uLogging.save_traceback()
        raise e

    return is_slave_updated
コード例 #8
0
def getUOSModule():
    if Const.isWindows():
        import uWindows
        uOS = uWindows
    else:
        import uLinux
        uOS = uLinux
    return uOS
コード例 #9
0
def startShell():
    shell_map = {
        Const.getWinPlatform(): ('COMSPEC', 'command.com'),
        None: ('SHELL', '/bin/sh')
    }
    shell = shell_map.get(sys.platform, shell_map.get(None))
    shell = os.environ.get(*shell)
    return os.system(shell)
コード例 #10
0
def installPOACoreBinaries(config, progress, build_rpms):
    """
    build_rpms needed just for keep the call signature
    build_rpms used in uLinux, where it's a list of new rpm's to install
    """
    win_files_dir = os.path.abspath(os.path.join(config.source_dir, "os", Const.getDistribWinDir()))
    progress.set_progress(75, "Installing POA MSI")
    logfile = os.environ['SYSTEMDRIVE'] + "\\poacore-install.log"
    uUtil.execCommand(["msiexec", "/i", os.path.join(win_files_dir, "poa-core.msi"), "/l*v",
                       logfile, "POA_INSTALL=1", "FULL_COMPUTER_NAME=" + config.hostname])
コード例 #11
0
def _deployBaseExesFiles(files):
    _, plesk_root = uPEM.getMNInfo()
    dst_path = os.path.join(plesk_root, Const.getCoreExesDir())
    if not os.path.exists(dst_path):
        uLogging.debug('Create directory: %s' % dst_path)
        os.makedirs(dst_path)
    for src_file_path in files:
        file_name = os.path.basename(src_file_path)
        dst_file_path = os.path.join(dst_path, file_name)
        uLogging.debug('Copying %s to %s' % (src_file_path, dst_file_path))
        shutil.copy2(src_file_path, dst_file_path)
コード例 #12
0
def update_install_win_sn(sn_installer_path, main_ppm_mirror_path):
    # copy PAgent.exe to PPM mirror for later use by SharedNodeRegistrator
    registrar_path = os.path.join(main_ppm_mirror_path, 'Win32Bin')
    if not os.path.exists(registrar_path):
        os.makedirs(registrar_path)
        os.chmod(registrar_path, 0775)
        if not Const.isWindows():
            import grp
            grpinfo = grp.getgrnam('pemgroup')
            os.chown(registrar_path, 0, grpinfo.gr_gid)
    if sn_installer_path:
        shutil.copy(sn_installer_path, registrar_path)
コード例 #13
0
def tuneJBoss(config):
    uLogging.debug("tuneJBoss started, scale_down: %s" % config.scale_down)
    if not Const.isWindows() and config.scale_down:
        from u import bootstrap
        jbossdir = bootstrap.getJBossDir(config.rootpath)

        uLogging.info("Tuning JBoss connection pool")
        bootstrap.execCLI(
            jbossdir, 'embed-server --server-config=%s,' % bootstrap.serverConfig + '/subsystem=datasources/data-source=pauds:write-attribute(name="max-pool-size", value="80")')
        # jboss restart required, performed after PUI deployment
    else:
        uLogging.debug("nothing done")
コード例 #14
0
def prepare_paagent_url(platform, binfo, config):

    if platform not in paagent_urls:

        if Const.isOsaWinPlatform(platform.os):
            paagent_urls[platform] = prepare_paagent_exe_url(platform, binfo, config)
        else:
            paagent_urls[platform] = prepare_paagent_rpm_url(platform, binfo, config)

        uLogging.debug("Defined pa-agent URL for platform {platform} is {url}".format(
            platform=platform, url=paagent_urls[platform]
        ))

    return paagent_urls[platform]
コード例 #15
0
def warn_precheck_for_deprecated_os():
    import uBilling
    nodes = set([1])
    nodes.update(uBilling.get_billing_platform_hosts().values())
    results = [(node_id, _precheck_for_deprecated_os(node_id))
               for node_id in nodes]
    errors = filter(lambda result: result[1], results)
    if errors:
        fail_reason = '\n'.join(map(str, errors))
        failed_nodes = [error[0] for error in errors]
        raise PrecheckFailed(
            fail_reason,
            'Upgrade Linux on nodes %s to minimal supported version: %s' %
            (failed_nodes, Const.getMinSupportedLinux()))
コード例 #16
0
def stopMN(minimal=False):
    if Const.isWindows():
        # ignore 2 error code, because in 5.4 pem cannot be stopped properly
        uUtil.readCmd(['net', 'stop', 'pem'], valid_codes=[0, 2])
        uUtil.readCmd(['net', 'stop', 'PAU'], valid_codes=[0, 1, 2])
    else:
        if not minimal:
            # pem script actually returns 1 and 123 on valid stops
            uUtil.execCommand('service pa-agent stop', [0, 1, 123])
            uUtil.execCommand('service pau stop', [0, 1, 5])

        # In some mysterious cases "service pa-agent stop" doesn't work
        uUtil.readCmdExt(['killall', '-9', 'pa-agent'])
        uUtil.readCmdExt(['killall', '-9', 'SoLoader'])
    resetPIDs()
コード例 #17
0
def check_platform_supported(machine):
    min_os_version = Const.getMinRhelVersion()
    os_requirement = "Only x86_64 RedHat/CentOS %d.%d or higher are supported" % min_os_version

    if not machine.os in ["Red Hat Enterprise Linux Server", "RHEL", "CentOS"]:
        raise Exception(("Installation on %s is not possible. " + os_requirement) % machine.os)

    osverfull = tuple(map(lambda v: int(v), machine.osverfull))

    if osverfull < min_os_version:
        osverfull_string = ".".join(machine.osverfull)
        raise Exception(("Current RedHat/CentOS version is %s. " + os_requirement) % osverfull_string)

    if "x86_64" != machine.arch:
        raise Exception(("Current os arch is %s. " + os_requirement) % machine.arch)
コード例 #18
0
def getPemDirectory():
    if not Const.isWindows():
        return "/usr/local/pem"

    def getPOAHostRegistryKey(hostname):
        baseRegPath = None
        for regPath in ["SOFTWARE\\SWsoft\\PEM", "SOFTWARE\\Wow6432Node\\SWsoft\\PEM"]:
            try:
                regkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, regPath, 0, _winreg.KEY_READ)
                baseRegPath = regPath
                break
            except WindowsError:
                pass

        if baseRegPath is None:
            raise Exception('System does not have valid Operation Automation installation.')

        foundHosts = []
        i = 0
        try:
            while True:
                foundHosts += [_winreg.EnumKey(regkey, i)]
                i += 1
        except WindowsError:
            pass
        _winreg.CloseKey(regkey)

        if not len(foundHosts):
            raise Exception('System does not have valid Operation Automation installation.')

        if hostname not in foundHosts:
            raise Exception("Detected: system hostname was changed.\nActual hostname is %s.\nExpected hostnames: %s." % (
                hostname, ', '.join(foundHosts)))

        return _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, '%s\\%s' % (baseRegPath, hostname), 0, _winreg.KEY_READ)

    regkey = getPOAHostRegistryKey(socket.getfqdn())
    try:
        pempath = _winreg.QueryValueEx(regkey, "conf_files_path")[0]
        # It returns something like this:
        #  "C:\Program Files\SWsoft\PEM\etc"
        pempath = os.path.split(pempath)[0]
        _winreg.CloseKey(regkey)

        return pempath
    except:
        _winreg.CloseKey(regkey)
        raise Exception("Failed to find PEM installation directory.")
コード例 #19
0
def execCommand(command, valid_codes=None, retries=0, command_to_log=None):
    if not command_to_log:
        command_to_log = command
    uLogging.debug("Executing command: '%s'", command_to_log)

    if valid_codes is None:
        valid_exit_codes = [0]
    else:
        valid_exit_codes = valid_codes

    stdout = None
    stderr = sp.STDOUT
    if uLogging.logfile:
        stdout = uLogging.logfile
        stderr = stdout
    use_shell = type(command) not in (tuple, list)

    while True:
        if Const.isWindows():
            cmd = sp.Popen(command,
                           stdout=stdout,
                           stderr=stderr,
                           shell=use_shell,
                           startupinfo=startup_info)
        else:
            env = os.environ.copy()
            env["LANG"] = "C"
            env["LC_CTYPE"] = "C"
            env["LD_LIBRARY_PATH"] = env.get("LD_LIBRARY_PATH",
                                             "") + ":/usr/pgsql-9.5/lib/"
            cmd = sp.Popen(command,
                           stdout=stdout,
                           stderr=stderr,
                           close_fds=True,
                           shell=use_shell,
                           env=env)
        status = cmd.wait()

        if status and status not in valid_exit_codes:
            uLogging.debug(
                "Executing command '%s' failed with status '%s', '%s' retries left"
                % (command_to_log, status, retries))
            if retries > 0:
                retries -= 1
                continue
            raise ExecFailed(command_to_log, status)

        return status
コード例 #20
0
def tuneDatabase(config):
    uLogging.debug("tuneDatabase started, scale_down: %s" % config.scale_down)
    if not Const.isWindows() and config.scale_down:
        uLogging.debug("tuning PgSQL")
        p = uPgSQL.PostgreSQLConfig()

        pg_conf = p.get_postgresql_conf()
        env = os.environ.copy()
        # 2147483648 bytes = 2 GB
        # 2 GB limit is set because 'shared_buffers' should be equal to 512 mb
        uUtil.readCmdExt(["odin-pg-tune", "-f", "--input-config=" + pg_conf, "--min-connections=128", "--output-config=" + pg_conf, "--memory=2147483648"], env = env)

        uLogging.debug("restarting PgSQL...")
        p.restart()
    else:
        uLogging.debug("nothing done")
コード例 #21
0
def prepare_request_for_repourl_updating(request, config):
    """Filling the request object with corresponding commands for updating yum repourl

    :param request - uHCL.Request() object
    :param config

    :return request
    """
    uLogging.debug("Preparing request for updating pa-central repo")
    yum_repo_url = posixpath.join(config.yum_repo_url, Const.getDistribLinDir(), "$releasever/")
    proxy = "proxy=%s" % config.yum_repo_proxy_url if config.yum_repo_proxy_url else ""
    contents = config.PA_YUM_REPO_CONF_TEMPLATE % {"url": yum_repo_url, "proxy": proxy}
    request.rm("/etc/yum.repos.d/poa.repo")  # remove old poa.repo config file
    request.mkfile(config.PA_YUM_REPO_FILE, contents, owner="root", group="root", perm="0600", overwrite=True)
    request.command("yum clean all --disablerepo=* --enablerepo=pa-central-repo")
    request.command("yum makecache --disablerepo=* --enablerepo=pa-central-repo")
    request.command("yum -q check-update", valid_exit_codes=[0, 100])
    return request
コード例 #22
0
def update_binary(pkg, rootpath):
    def do_unpack(pkg, rootpath):
        uLogging.info("Updating %s (%s)", pkg.package, pkg.tarball_location)
        arc = tarfile.open(pkg.tarball_location, 'r')
        for tarinfo in arc:
            arc.extract(tarinfo, path=rootpath)
        arc.close()

    if pkg.tarball_location is not None:
        try:
            do_unpack(pkg, rootpath)
        except IOError, e:
            if Const.isWindows() and e.errno == errno.EACCES:
                uLogging.err(
                    "Cannot unpack, file is probably locked. retrying")
                time.sleep(1)
                do_unpack(pkg, rootpath)
            else:
                raise
コード例 #23
0
def createPPMSite(config):
    progress.do("creating ppm site")
    system_root = os.environ['SystemRoot']
    appcmd = os.path.join(system_root, 'System32', 'inetsrv', 'appcmd.exe')
    source_dir = config.source_dir
    tarball_dir = os.path.join(config.rootpath.replace('/', '\\'), 'install', 'tarballs')
    if not os.path.exists(appcmd):
        uLogging.debug("IIS 6")
        out, err, status = uUtil.readCmdExt(
            [os.path.join(source_dir, 'os', Const.getDistribWinDir(), 'IISAdministrationTools', '_install.bat')])
        uLogging.debug("%s %s %s", out, err, status)
        iis_web = os.path.join(system_root, 'System32', 'iisweb.vbs')
        out, err, status = uUtil.readCmdExt(['cscript', iis_web, '/delete', site_name])
        uLogging.debug("%s %s %s", out, err, status)
        out, err, status = uUtil.readCmdExt(
            ['cscript', iis_web, '/create', tarball_dir, site_name, '/i', config.communication_ip])
        uLogging.debug("%s %s %s", out, err, status)
        out, err, status = uUtil.readCmdExt(
            ['cscript', os.path.join(system_root, 'System32', 'iisvdir.vbs'), '/create', site_name, 'tarballs',  tarball_dir])
        uLogging.debug("%s %s %s", out, err, status)
    else:
        uLogging.debug("IIS 7")
        out, err, status = uUtil.readCmdExt('%s delete site /site.name:"%s"' % (appcmd, site_name))
        uLogging.debug("%s %s %s", out, err, status)
        out, err, status = uUtil.readCmdExt(
            '%s add site "/name:%s" /bindings:"http://%s:80" "/physicalPath:%s"' % (appcmd, site_name, config.communication_ip, tarball_dir))
        uLogging.debug("%s %s %s", out, err, status)
        out, err, status = uUtil.readCmdExt(
            '%s add vdir "/app.name:%s/" "/physicalPath:%s" /path:/tarballs' % (appcmd, site_name, tarball_dir))
        uLogging.debug("%s %s %s", out, err, status)

    try:
        os.makedirs(tarball_dir)
    except:
        pass
    out, err, status = uUtil.readCmdExt(
        ["cscript", os.path.join(config.rootpath, 'install', 'tarball_storage_config.vbs'), site_name])
    uLogging.debug("%s %s %s", out, err, status)
    progress.done()

    progress.do("copying tarballs")
    os.path.walk(source_dir, uPackaging.copy_tarballs, tarball_dir)
    progress.done()
コード例 #24
0
def doMassImport(rootpath, pkglist, pkg_counter):
    command = [
        os.path.join(rootpath, "bin", "ppm_ctl"), '-q', '-b', '-E', '-f',
        os.path.join(rootpath, "etc", "pleskd.props"), 'add', 'pkgmass'
    ]
    pkglist = __filterCustomPackages(pkglist)

    if not pkglist:
        return

    command += [os.path.join(x.topdir, x.manifest_file) for x in pkglist]

    uLogging.debug("doMassImport: %s", command)

    if Const.isWindows():
        p = sp.Popen(command,
                     bufsize=1,
                     stdout=sp.PIPE,
                     stderr=sp.PIPE,
                     startupinfo=uUtil.startup_info)
    else:
        p = sp.Popen(command, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE)

    out_thread = threading.Thread(target=__assignPkgIds,
                                  args=(p.stdout, pkglist))
    out_thread.setDaemon(True)
    errlines = []
    err_thread = threading.Thread(target=__showProgress,
                                  args=(p.stderr, pkg_counter, errlines))
    err_thread.setDaemon(True)
    out_thread.start()
    err_thread.start()
    out_thread.join()
    err_thread.join()
    status = p.wait()

    if status > 0:
        raise Exception('ppm ctl exited with code %d: %s' %
                        (status, "\n".join(errlines)))
    elif status < 0:
        raise Exception('ppm ctl terminated with signal %d' % -status)
コード例 #25
0
def perform_aps2_db_upgrade(binfo):
    from poaupdater import uAction

    scripts_dirs = binfo.upgrade_instructions.aps
    if not scripts_dirs:
        uLogging.info(
            "There is no APS Database upgrade scripts. Skip upgrading.")
        return

    uAction.progress.do("updating APS database")
    con = uSysDB.connect()
    for scripts_dir in scripts_dirs:
        upgrade_aps_db(scripts_dir, con)

    if Const.isWindows():
        uAction.progress.do("dropping APS database page locking")
        performMSSQLUpgrade(con)
        uAction.progress.done()

    uAction.progress.done()
    uSysDB.close(con)
コード例 #26
0
def readCmdExt(command, input_data=None, env=None):
    uLogging.debug("Executing command: '%s'", command)
    use_shell = type(command) not in (tuple, list)
    if Const.isWindows():
        cmd = sp.Popen(command,
                       stdin=sp.PIPE,
                       stdout=sp.PIPE,
                       stderr=sp.PIPE,
                       shell=use_shell,
                       startupinfo=startup_info)
    else:
        cmd = sp.Popen(command,
                       close_fds=True,
                       stdin=sp.PIPE,
                       stdout=sp.PIPE,
                       stderr=sp.PIPE,
                       shell=use_shell,
                       env=env)

    out, err = cmd.communicate(input=input_data)
    status = cmd.returncode

    return str(out), str(err), status
コード例 #27
0
def startMN(minimal=False):
    resetPIDs()

    platform, root = getMNInfo()
    if Const.isWindows():
        stopMN()
        # To ensure waitForJBossStarted will do correct
        from u import bootstrap
        os.remove(bootstrap.getJBossDir(root) + '\\standalone\\log\\standalone.log')
        uUtil.readCmd(['net', 'start', 'PAU'])
        # Service is stated as "started" before JBoss is actually started, need to wait
        waitForJBossStarted(root)
        uUtil.readCmd(['net', 'start', 'pem'], valid_codes=[0])
    else:
        if minimal:

            env = dict()
            env.update(os.environ)
            pleskd_env = dict(
                LD_LIBRARY_PATH=str(os.path.join(root, "lib") + ":" + "/usr/pgsql-9.5/lib/"),
                SVC_CONF=str(os.path.join(root, "etc", "svc.conf")),
                PLESKD_PROPS=str(os.path.join(root, "etc", "pleskd.props"))
            )
            env.update(pleskd_env)

            progname = os.path.join(root, "sbin", "pa-agent")

            cmd = []
            cmd.append(progname)
            cmd.append("--props-file=" + os.path.join(root, "etc", "pleskd.props"))
            # LD_LIBRARY_PATH="/usr/local/pem/lib:/usr/pgsql-9.4/lib/"
            # PATH="${PATH}:/usr/local/pem/bin" /usr/local/pem/sbin/pleskd
            # --props-file /usr/local/pem/etc/pleskd.props --send-signal
            sp.Popen(cmd, env=env)
        else:
            uUtil.execCommand('service pau start', valid_codes=[0, 1])
            uUtil.execCommand('service pa-agent start')
コード例 #28
0
def init(config=None):
    global _config
    global _inited

    if config is not None:
        _config = config
    if _config is None:
        raise Exception, "config arg is mandatory when you're initializing uSysDB first time"

    if not hasattr(config, "database_type"):
        if Const.isWindows():
            _config.database_type = 'MSSQL'
        else:
            _config.database_type = 'PGSQL'
    else:
        _config.database_type = config.database_type

    if not _inited:
        setup_connection()

    global DBType
    uLogging.debug('Using database_name: %s(%s)' % (_config.database_name, DBType))
    import uDBSchema
    uDBSchema.init(DBType)
コード例 #29
0
def determinePlatform():
    pver = platform.version().split('.')
    pVerShort = ".".join(pver[:2])
    p = uBuild.Platform(Const.getOsaWinPlatform(), pVerShort, "x86_64")  # POA uses 2-numbered windows version like 5.2
    p.osverfull = pver		# leave scalar version in osver for compatibility with 5.5
    return p
コード例 #30
0
__author__ = 'imartynov'

import sys
import os
from uConst import Const

from poaupdater import uUtil, uLogging
if not Const.isWindows():
    from poaupdater import uPgSQL


def tuneDatabase(config):
    uLogging.debug("tuneDatabase started, scale_down: %s" % config.scale_down)
    if not Const.isWindows() and config.scale_down:
        uLogging.debug("tuning PgSQL")
        p = uPgSQL.PostgreSQLConfig()

        pg_conf = p.get_postgresql_conf()
        env = os.environ.copy()
        # 2147483648 bytes = 2 GB
        # 2 GB limit is set because 'shared_buffers' should be equal to 512 mb
        uUtil.readCmdExt(["odin-pg-tune", "-f", "--input-config=" + pg_conf, "--min-connections=128", "--output-config=" + pg_conf, "--memory=2147483648"], env = env)

        uLogging.debug("restarting PgSQL...")
        p.restart()
    else:
        uLogging.debug("nothing done")


def tuneJBoss(config):
    uLogging.debug("tuneJBoss started, scale_down: %s" % config.scale_down)