def exists(self): """ check that db exists """ logging.debug("verifying that db '%s' exists" % (basedefs.DB_NAME)) # Making sure postgresql service is up - only on local installation if utils.localHost(DB_HOST): postgresql = utils.Service("postgresql") postgresql.conditionalStart() try: # We want to make check that we can connect to basedefs.DB_NAME DB logging.debug("making sure postgresql service is up") utils.retry(utils.checkIfDbIsUp, tries=5, timeout=15, sleep=3) except: # If we're here, it means something is wrong, either there is a real db error # or the db is not installed, let's check logging.debug("checking if db is already installed..") out, rc = utils.execRemoteSqlCommand(DB_ADMIN, DB_HOST, DB_PORT, basedefs.DB_NAME, "select 1") if rc != 0: if utils.verifyStringFormat( out, ".*FATAL:\s*database\s*\"%s\"\s*does not exist" % (PREFIX)): # This means that the db is not installed, so we return false return False return True
def exists(self): """ check that db exists """ logging.debug("verifying that db '%s' exists" % (basedefs.DB_NAME)) # Making sure postgresql service is up - only on local installation if utils.localHost(DB_HOST): postgresql = utils.Service("postgresql") postgresql.conditionalStart() try: # We want to make check that we can connect to basedefs.DB_NAME DB logging.debug("making sure postgresql service is up") utils.retry(utils.checkIfDbIsUp, tries=5, timeout=15, sleep=3) except: # If we're here, it means something is wrong, either there is a real db error # or the db is not installed, let's check logging.debug("checking if db is already installed..") out, rc = utils.execRemoteSqlCommand(DB_ADMIN, DB_HOST, DB_PORT, basedefs.DB_NAME, "select 1") if rc != 0: if utils.verifyStringFormat(out,".*FATAL:\s*database\s*\"%s\"\s*does not exist" % (PREFIX)): # This means that the db is not installed, so we return false return False return True
def exists(self): """ check if db exists """ logging.debug("verifying is db exists") # Making sure postgresql service is up postgresql = utils.Service("postgresql") postgresql.conditionalStart() try: # We want to make check if postgresql service is up logging.debug("making sure postgresql service is up") utils.retry(utils.checkIfRhevmDbIsUp, tries=5, timeout=15, sleep=3) except: # If we're here, it means something is wrong, either there is a real db error # or the db is not installed, let's check logging.debug("checking if db is already installed..") (out, rc) = utils.execSqlCommand(basedefs.DB_ADMIN, basedefs.DB_NAME, "select 1") if (rc != 0): if utils.verifyStringFormat(out,".*FATAL:\s*database\s*\"%s\"\s*does not exist" % (PREFIX)): # This means that the db is not installed, so we return false return False return True
def exists(self): """ check that db exists """ logging.debug("verifying that db '%s' exists" % (basedefs.DB_NAME)) # Checking whether pgpass file exists. If not, # we cannot cleanup DB, so return False. if not os.path.exists(basedefs.DB_PASS_FILE): logging.info(MSG_ERR_CANT_FIND_PGPASS_FILE) return False # Making sure postgresql service is up - only on local installation if utils.localHost(DB_HOST): postgresql = utils.Service("postgresql") postgresql.conditionalStart() try: # We want to make check that we can connect to basedefs.DB_NAME DB logging.debug("Checking that DB '%s' exists", basedefs.DB_NAME) utils.retry(utils.checkIfDbIsUp, tries=5, timeout=15, sleep=3) except: # If we're here, it means something is wrong, either there is a real db error # or the db is not installed, let's check logging.debug("checking if db is already installed..") out, rc = utils.execRemoteSqlCommand(DB_ADMIN, DB_HOST, DB_PORT, basedefs.DB_NAME, "select 1") if rc != 0: if utils.verifyStringFormat(out,".*FATAL:\s*database\s*\"%s\"\s*does not exist" % (PREFIX)): # This means that the db is not installed, so we return false return False else: raise Exception(MSG_ERROR_CONNECT_DB) return True
def restartPostgresql(): """ restart the postgresql service """ logging.debug("Restarting the postgresql service") postgresql = utils.Service("postgresql") postgresql.stop(True) postgresql.start(True) # We want to make sure the postgres service is up utils.retry(utils.checkIfRhevmDbIsUp, tries=10, timeout=30, sleep=3)
def exists(self): """ check that db exists """ logging.debug("verifying that db '%s' exists" % (basedefs.DB_NAME)) # Checking whether pgpass file exists. If not, # we cannot cleanup DB, so return False. if not os.path.exists(basedefs.DB_PASS_FILE): logging.info(MSG_ERR_CANT_FIND_PGPASS_FILE) return False # Making sure postgresql service is up - only on local installation if utils.localHost(DB_HOST): postgresql = utils.Service("postgresql") postgresql.conditionalStart() try: # We want to make check that we can connect to basedefs.DB_NAME DB logging.debug("Checking that DB '%s' exists", basedefs.DB_NAME) utils.retry(utils.checkIfDbIsUp, tries=5, timeout=15, sleep=3) except: # If we're here, it means something is wrong, either there is a real db error # or the db is not installed, let's check logging.debug("checking if db is already installed..") out, rc = utils.execRemoteSqlCommand( userName=DB_ADMIN, dbHost=DB_HOST, dbPort=DB_PORT, dbName=basedefs.DB_NAME, sqlQuery="select 1", ) if rc != 0: if utils.verifyStringFormat( out, ".*FATAL:\s*database\s*\"%s\"\s*does not exist" % (PREFIX)): # This means that the db is not installed, so we return false return False else: raise Exception(MSG_ERROR_CONNECT_DB) return True
def waitForHostUp(): utils.retry(isHostUp, tries=20, timeout=150, sleep=5)
def waitForJbossUp(): """ Wait for Jboss to start """ utils.retry(isHealthPageUp, tries=25, timeout=15, sleep=5)