示例#1
0
文件: deployr.py 项目: otype/deployr
def main():
    """
        Start the Tornado Web server
    """
    # Parse the shell arguments, first.
    parse_shell_args()

    # Check if config write has been requested. If yes, bail out afterwards.
    if args.write_config:
        check_for_config_write()

    # Load configuration
    config = deployr_config_service.load_configuration()

    # Show all configured handlers
    show_all_settings(config)

    # start the MQ consumer
    if args.mode == 'deploy':
        from app_deployr.deploy_mq_rx import start_consumer
    elif args.mode == 'balance':
        from lb_deployr.loadbalance_update_mq_rx import start_consumer
    else:
        from app_deployr.deploy_mq_rx import start_consumer

    start_consumer(broker_host=config['BROKER_HOST'],
                   broker_port=int(config['BROKER_PORT']),
                   username=config['BROKER_USER'],
                   password=config['BROKER_PASSWORD'],
                   activate_prefetch=config['BROKER_PREFETCH_COUNT'])
示例#2
0
def get_supervisor_xml_rpc_server():
    """
        Get the Supervisor XML-RPC server address
    """
    # Load configuration
    configuration = deployr_config_service.load_configuration()

    # Contact XML-RPC on given address
    xml_rpc_address = configuration['SUPERVISOR_XML_RPC_SERVER_ADDRESS']

    return xmlrpclib.Server(xml_rpc_address), xml_rpc_address
示例#3
0
def get_logger(log_level=None):
    """
        Get the logger object
    """
    # Load the global configuration from config file
    config = deployr_config_service.load_configuration()

    if log_level is None:
        # Extract the log level from the config object
        log_level = get_log_level_from_config(config['LOGGING'])

    return setup_logging(log_level)
示例#4
0
def get_logger(log_level=None):
    """
        Get the logger object
    """
    # Load the global configuration from config file
    config = deployr_config_service.load_configuration()

    if log_level is None:
        # Extract the log level from the config object
        log_level = get_log_level_from_config(config['LOGGING'])

    return setup_logging(log_level)
示例#5
0
    def __init__(self):
        """
            Initialize the EventReporter
        """
        super(EventReporter, self).__init__()

        # Load configuration
        self.config = deployr_config_service.load_configuration()
        self.env = EVENT_REPORTER_CONFIG[self.config['NAME']]
        logger.debug("EventReporter env = {}".format(self.env))
        self.url = self.env['EVENT_REPORTER_URL']
        logger.debug("EventReporter API BASE URL = {}".format(self.url))

        # Setup the Async HTTP client for calling Riak asynchronously
        self.http_client = tornado.httpclient.HTTPClient()
示例#6
0
    def __init__(self):
        """
            Initialize the EventReporter
        """
        super(EventReporter, self).__init__()

        # Load configuration
        self.config = deployr_config_service.load_configuration()
        self.env = EVENT_REPORTER_CONFIG[self.config['NAME']]
        logger.debug("EventReporter env = {}".format(self.env))
        self.url = self.env['EVENT_REPORTER_URL']
        logger.debug("EventReporter API BASE URL = {}".format(self.url))

        # Setup the Async HTTP client for calling Riak asynchronously
        self.http_client = tornado.httpclient.HTTPClient()
示例#7
0
# Logger
#
logger = logging_service.get_logger()

msg = DeployMessage(
    api_id='MANUAL_TASK_DEPLOY_API_ID',
    db_host='riak1.dev.apitrary.net',
    db_port=8098,
    genapi_version=1,
    log_level='debug',
    entities=['jedis', 'wookies', 'stormtroopers'],
    api_key='suchasecretapikeyyouwouldneverguess'
)

# Load the global configuration from config file
config = deployr_config_service.load_configuration()

def send(host, message):
    """
        Simply send the message
    """
    config['BROKER_HOST'] = host
    message_tx = BlockingMessageTx(config=config)
    message_tx.send(message=message)

# MAIN
#
#
if __name__ == '__main__':
    host = (len(sys.argv) > 1) and sys.argv[1] or '127.0.0.1'
    logger.info('Connecting to broker: {}'.format(host))
示例#8
0
 def __init__(self):
     """
         We need the configuration upon task creation
     """
     self.config = deployr_config_service.load_configuration()
示例#9
0
#
# Logger
#
logger = logging_service.get_logger()

msg = DeployMessage(api_id='MANUAL_TASK_DEPLOY_API_ID',
                    db_host='riak1.dev.apitrary.net',
                    db_port=8098,
                    genapi_version=1,
                    log_level='debug',
                    entities=['jedis', 'wookies', 'stormtroopers'],
                    api_key='suchasecretapikeyyouwouldneverguess')

# Load the global configuration from config file
config = deployr_config_service.load_configuration()


def send(host, message):
    """
        Simply send the message
    """
    config['BROKER_HOST'] = host
    message_tx = BlockingMessageTx(config=config)
    message_tx.send(message=message)


# MAIN
#
#
if __name__ == '__main__':
示例#10
0
 def __init__(self):
     """
         We need the configuration upon task creation
     """
     self.config = deployr_config_service.load_configuration()