Exemplo n.º 1
0
def resolve_ambari_config():
  try:
    config = AmbariConfig.config
    if os.path.exists(configFile):
      config.read(configFile)
      AmbariConfig.setConfig(config)
    else:
      raise Exception("No config found, use default")

  except Exception, err:
    logger.warn(err)
Exemplo n.º 2
0
Arquivo: main.py Projeto: sreev/ambari
    file(pidfile, 'w').write(pid)


  logger.setLevel(logging.INFO)
  formatter = logging.Formatter("%(asctime)s %(filename)s:%(lineno)d - %(message)s")
  rotateLog = logging.handlers.RotatingFileHandler(logfile, "a", 10000000, 10)
  rotateLog.setFormatter(formatter)
  logger.addHandler(rotateLog)
  credential = None

  # Check for ambari configuration file.
  try:
    config = AmbariConfig.config
    if(os.path.exists('/etc/ambari/ambari.ini')):
      config.read('/etc/ambari/ambari.ini')
      AmbariConfig.setConfig(config)
    else:
      raise Exception("No config found, use default")
  except Exception, err:
    logger.warn(err)

  killstaleprocesses()
  logger.info("Connecting to controller at: "+config.get('controller', 'url'))

  # Launch Controller communication
  controller = Controller(config) 
  controller.start()
  controller.run()
  logger.info("finished")
    
if __name__ == "__main__":
Exemplo n.º 3
0
from PingPortListener import PingPortListener
import hostname
from DataCleaner import DataCleaner
import socket
from ambari_commons import OSConst, OSCheck
from ambari_commons.shell import shellRunner
from ambari_commons import shell
import HeartbeatHandlers
from HeartbeatHandlers import bind_signal_handlers
from ambari_commons.constants import AMBARI_SUDO_BINARY

logger = logging.getLogger()

formatstr = "%(levelname)s %(asctime)s %(filename)s:%(lineno)d - %(message)s"
agentPid = os.getpid()
config = AmbariConfig.AmbariConfig()
configFile = config.getConfigFile()
two_way_ssl_property = config.TWO_WAY_SSL_PROPERTY


def setup_logging(verbose):
    formatter = logging.Formatter(formatstr)
    rotateLog = logging.handlers.RotatingFileHandler(
        AmbariConfig.AmbariConfig.getLogFile(), "a", 10000000, 25)
    rotateLog.setFormatter(formatter)
    logger.addHandler(rotateLog)

    if verbose:
        logging.basicConfig(format=formatstr,
                            level=logging.DEBUG,
                            filename=AmbariConfig.AmbariConfig.getLogFile())