Exemple #1
0
 def __lock(self):
     "get build lock"
     logger.info("Acquire build lock:" + self.__buildLock)
     self.__locked = ContainerUtils.acquireGlobalLock(
         self.__buildLock, self.__lockExpire, self.__lockWait)
     if not self.__locked:
         raise Exception("Unable to acquire build lock:" + self.__buildLock)
Exemple #2
0
 def __lock(self):
     "get global lock"
     self.__locked = ContainerUtils.acquireGlobalLock(
         self.__clusterConfigDir, self.__lockExpire, self.__lockWait)
     if not self.__locked:
         raise Exception("Unable to acquire global lock:" +
                         self.__clusterConfigDir)
 def __lock(self):
     "get global lock"
     self.__locked = ContainerUtils.acquireGlobalLock(
         self.__swarmid, self.__lockExpire, self.__lockWait)
     if not self.__locked:
         raise "Unable to acquire global lock:" + self.__swarmid
 def __lock(self):
     "get build lock"
     logger.info("Acquire build lock:" + self.__buildLock)
     self.__locked = ContainerUtils.acquireGlobalLock(self.__buildLock, self.__lockExpire, self.__lockWait)
     if not self.__locked:
         raise Exception("Unable to acquire build lock:" + self.__buildLock)
    def __init__(self, additionalVariables):
        " initialize oracle database"
        
        self.__hostname = "localhost";
        try:
            self.__hostname = InetAddress.getLocalHost().getCanonicalHostName()
        except:
            type, value, traceback = sys.exc_info()
            logger.severe("Hostname error:" + `value`)
        
        additionalVariables.add(RuntimeContextVariable("ORACLE_HOSTNAME", self.__hostname, RuntimeContextVariable.ENVIRONMENT_TYPE))

        dbPassword = getVariableValue("DB_PASSWORD_ALL")
        
        if dbPassword and dbPassword.strip():
            self.__sysPassword = dbPassword
            additionalVariables.add(RuntimeContextVariable("SYS_PWD", dbPassword, RuntimeContextVariable.ENVIRONMENT_TYPE))
            additionalVariables.add(RuntimeContextVariable("DBSNMP_PWD", dbPassword, RuntimeContextVariable.ENVIRONMENT_TYPE));
            additionalVariables.add(RuntimeContextVariable("SYSMAN_PWD", dbPassword, RuntimeContextVariable.ENVIRONMENT_TYPE))
            additionalVariables.add(RuntimeContextVariable("SYSTEM_PWD", dbPassword, RuntimeContextVariable.ENVIRONMENT_TYPE));
        else:
            self.__sysPassword = getVariableValue("SYS_PWD")
            
        dbDataLocation = getVariableValue("DB_DATA_LOC")
        if dbDataLocation and os.path.isdir(dbDataLocation):
            dbName = getVariableValue("DB_NAME")
            
            dbDataDir = os.path.join(dbDataLocation, dbName)
            if os.path.isdir(dbDataDir):
                logger.info("DB Data directory already exists:" + dbDataDir + "; Setting DB_INSTALL_OPTION to INSTALL_DB_SWONLY")
                additionalVariables.add(RuntimeContextVariable( "DB_INSTALL_OPTION", "INSTALL_DB_SWONLY", RuntimeContextVariable.ENVIRONMENT_TYPE))
        

        tcpPort = getVariableValue("TCP_PORT");
        self.__serviceName = getVariableValue("DB_GLOBAL_NAME")

        sb = StringBuilder("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)")
        sb.append("(HOST=").append(self.__hostname).append(")")
        sb.append("(PORT=").append(tcpPort).append("))")
        sb.append("(CONNECT_DATA=(SERVICE_NAME=").append(self.__serviceName).append(")))")
        
        self.__oracleServiceUrl = sb.toString()
        
        logger.info("Oracle listener service URL:" + self.__oracleServiceUrl)
        
        self.__jdbcUrl = "jdbc:oracle:thin:@" + self.__hostname +":"+ tcpPort + ":" + self.__serviceName
        runtimeContext.addVariable(RuntimeContextVariable("JDBC_URL", self.__jdbcUrl, RuntimeContextVariable.STRING_TYPE, "Oracle Thin Driver JDBC Url", True, RuntimeContextVariable.NO_INCREMENT))
        
        
        oracleDriver = "oracle.jdbc.OracleDriver"
        runtimeContext.addVariable(RuntimeContextVariable("JDBC_DRIVER", oracleDriver, RuntimeContextVariable.STRING_TYPE, "Oracle Thin Driver class", True, RuntimeContextVariable.NO_INCREMENT))
        
        self.__dbControl = Boolean.parseBoolean(getVariableValue("CONFIG_DBCONTROL", "false"))
        
        if self.__dbControl:
            self.__dbCtrlPort = getVariableValue("DBCONTROL_HTTP_PORT")
            additionalVariables.add(RuntimeContextVariable( "HTTPS_PORT", self.__dbCtrlPort, RuntimeContextVariable.STRING_TYPE))
        
        oracleDir = getVariableValue("ORACLE_DIR")
        self.__markerFilePath = os.path.join(oracleDir, ".#dsoracle")
        
        self.__maintFilePath = getVariableValue("ORACLE_MAINT_FILE")
        
        dbInstallOption = getVariableValue("DB_INSTALL_OPTION")
        if dbInstallOption == "INSTALL_DB_AND_CONFIG":
            globalLockString = "OracleEnabler-" + self.__hostname
            logger.info("Requesting Global Lock with name: " + globalLockString)
            domain = proxy.getContainer().getCurrentDomain()
            options = domain.getOptions()
            maxActivationTimeOut = options.getProperty(Options.MAX_ACTIVATION_TIME_IN_SECONDS)
            lockTimeOut = Long.parseLong(maxActivationTimeOut) * 1000
            acquired = ContainerUtils.acquireGlobalLock(globalLockString, lockTimeOut , lockTimeOut)
            if acquired:
                logger.info("Acquired Global lock with name: " + globalLockString)
            else:
                logger.severe("Could not acquire Global lock with name: " + globalLockString)
                raise Exception("Could not acquire Global lock with name: " + globalLockString)
 def __lock(self):
     "get global lock"
     self.__locked = ContainerUtils.acquireGlobalLock(self.__swarmid, self.__lockExpire, self.__lockWait)
     if not self.__locked:
         raise "Unable to acquire global lock:" + self.__swarmid
 def __lock(self):
     "get global lock"
     self.__locked = ContainerUtils.acquireGlobalLock(self.__clusterConfigDir, self.__lockExpire, self.__lockWait)
     if not self.__locked:
         raise Exception("Unable to acquire global lock:" + self.__clusterConfigDir)
Exemple #8
0
    def __init__(self, additionalVariables):
        " initialize oracle database"

        self.__hostname = "localhost"
        try:
            self.__hostname = InetAddress.getLocalHost().getCanonicalHostName()
        except:
            type, value, traceback = sys.exc_info()
            logger.severe("Hostname error:" + ` value `)

        additionalVariables.add(
            RuntimeContextVariable("ORACLE_HOSTNAME", self.__hostname,
                                   RuntimeContextVariable.ENVIRONMENT_TYPE,
                                   "Oracle Hostname", True,
                                   RuntimeContextVariable.NO_INCREMENT))

        listenAddress = getVariableValue("LISTEN_ADDRESS")
        additionalVariables.add(
            RuntimeContextVariable("ORACLE_LISTEN_ADDRESS", listenAddress,
                                   RuntimeContextVariable.ENVIRONMENT_TYPE,
                                   "Oracle Listen Address", True,
                                   RuntimeContextVariable.NO_INCREMENT))

        dbPassword = getVariableValue("DB_PASSWORD_ALL")

        if dbPassword and dbPassword.strip():
            self.__sysPassword = dbPassword
            additionalVariables.add(
                RuntimeContextVariable(
                    "SYS_PWD", dbPassword,
                    RuntimeContextVariable.ENVIRONMENT_TYPE))
            additionalVariables.add(
                RuntimeContextVariable(
                    "DBSNMP_PWD", dbPassword,
                    RuntimeContextVariable.ENVIRONMENT_TYPE))
            additionalVariables.add(
                RuntimeContextVariable(
                    "SYSMAN_PWD", dbPassword,
                    RuntimeContextVariable.ENVIRONMENT_TYPE))
            additionalVariables.add(
                RuntimeContextVariable(
                    "SYSTEM_PWD", dbPassword,
                    RuntimeContextVariable.ENVIRONMENT_TYPE))
        else:
            self.__sysPassword = getVariableValue("SYS_PWD")

        dbDataLocation = getVariableValue("DB_DATA_LOC")
        if dbDataLocation and os.path.isdir(dbDataLocation):
            dbName = getVariableValue("DB_NAME")

            dbDataDir = os.path.join(dbDataLocation, dbName)
            if os.path.isdir(dbDataDir):
                logger.info("DB Data directory already exists:" + dbDataDir +
                            "; Setting DB_INSTALL_OPTION to INSTALL_DB_SWONLY")
                additionalVariables.add(
                    RuntimeContextVariable(
                        "DB_INSTALL_OPTION", "INSTALL_DB_SWONLY",
                        RuntimeContextVariable.ENVIRONMENT_TYPE))

        tcpPort = getVariableValue("TCP_PORT")
        self.__serviceName = getVariableValue("DB_GLOBAL_NAME")

        sb = StringBuilder(
            "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)")
        sb.append("(HOST=").append(self.__hostname).append(")")
        sb.append("(PORT=").append(tcpPort).append("))")
        sb.append("(CONNECT_DATA=(SERVICE_NAME=").append(
            self.__serviceName).append(")))")

        self.__oracleServiceUrl = sb.toString()

        logger.info("Oracle listener service URL:" + self.__oracleServiceUrl)

        self.__jdbcUrl = "jdbc:oracle:thin:@" + self.__hostname + ":" + tcpPort + ":" + self.__serviceName
        additionalVariables.add(
            RuntimeContextVariable("JDBC_URL", self.__jdbcUrl,
                                   RuntimeContextVariable.STRING_TYPE,
                                   "Oracle Thin Driver JDBC Url", True,
                                   RuntimeContextVariable.NO_INCREMENT))

        oracleDriver = "oracle.jdbc.OracleDriver"
        additionalVariables.add(
            RuntimeContextVariable("JDBC_DRIVER", oracleDriver,
                                   RuntimeContextVariable.STRING_TYPE,
                                   "Oracle Thin Driver class", True,
                                   RuntimeContextVariable.NO_INCREMENT))

        self.__dbControl = Boolean.parseBoolean(
            getVariableValue("CONFIG_DBCONTROL", "false"))

        if self.__dbControl:
            self.__dbCtrlPort = getVariableValue("DBCONTROL_HTTP_PORT")
            additionalVariables.add(
                RuntimeContextVariable("HTTPS_PORT", self.__dbCtrlPort,
                                       RuntimeContextVariable.STRING_TYPE))

        oracleDir = getVariableValue("ORACLE_DIR")
        self.__markerFilePath = os.path.join(oracleDir, ".#dsoracle")

        self.__maintFilePath = getVariableValue("ORACLE_MAINT_FILE")

        dbInstallOption = getVariableValue("DB_INSTALL_OPTION")
        if dbInstallOption == "INSTALL_DB_AND_CONFIG":
            globalLockString = "OracleEnabler-" + self.__hostname
            logger.info("Requesting Global Lock with name: " +
                        globalLockString)
            domain = proxy.getContainer().getCurrentDomain()
            options = domain.getOptions()
            maxActivationTimeOut = options.getProperty(
                Options.MAX_ACTIVATION_TIME_IN_SECONDS)
            lockTimeOut = Long.parseLong(maxActivationTimeOut) * 1000
            acquired = ContainerUtils.acquireGlobalLock(
                globalLockString, lockTimeOut, lockTimeOut)
            if acquired:
                logger.info("Acquired Global lock with name: " +
                            globalLockString)
            else:
                logger.severe("Could not acquire Global lock with name: " +
                              globalLockString)
                raise Exception("Could not acquire Global lock with name: " +
                                globalLockString)