Exemplo n.º 1
0
def main(actions=None):
    # NOTE(agordeev): get its own process group by calling setpgrp.
    # Process group is used to distribute signals to subprocesses.
    os.setpgrp()
    signal.signal(signal.SIGTERM, handle_sigterm)
    CONF(sys.argv[1:],
         project='bareon',
         version=version.version_info.release_string())

    logging.setup('bareon')
    LOG = logging.getLogger(__name__)

    try:
        if CONF.input_data:
            data = yaml.safe_load(CONF.input_data)
        else:
            with open(CONF.input_data_file) as f:
                data = yaml.safe_load(f)
        LOG.debug('Input data: %s', data)

        data_driver_class = utils.get_data_driver(CONF.data_driver)
        data_driver = data_driver_class(data)

        deploy_driver_class = utils.get_deploy_driver(CONF.deploy_driver)
        deploy_driver = deploy_driver_class(data_driver)

        if actions:
            for action in actions:
                getattr(deploy_driver, action)()
    except Exception as exc:
        handle_exception(exc)
Exemplo n.º 2
0
def main(actions=None):
    # NOTE(agordeev): get its own process group by calling setpgrp.
    # Process group is used to distribute signals to subprocesses.
    # The main application is already a process group leader,
    # then there's no need to call os.setpgrp
    if os.getpid() != os.getpgrp():
        os.setpgrp()
    signal.signal(signal.SIGTERM, handle_sigterm)

    # Setup logging and process configuration options
    logging.register_options(CONF)
    CONF.register_cli_opts(cli_opts)
    CONF(sys.argv[1:], project=PROJECT, version=version.version_info.release_string())
    logging.setup(CONF, PROJECT)

    try:
        if CONF.input_data:
            data = yaml.safe_load(CONF.input_data)
        else:
            with open(CONF.input_data_file) as f:
                data = yaml.safe_load(f)
        LOG.debug("Input data: %s", data)

        data_driver_class = utils.get_data_driver(CONF.data_driver)
        data_driver = data_driver_class(data)

        deploy_driver_class = utils.get_deploy_driver(CONF.deploy_driver)
        deploy_driver = deploy_driver_class(data_driver)

        if actions:
            for action in actions:
                getattr(deploy_driver, action)()
    except Exception as exc:
        handle_exception(exc)
Exemplo n.º 3
0
def main(actions=None):
    # NOTE(agordeev): get its own process group by calling setpgrp.
    # Process group is used to distribute signals to subprocesses.
    os.setpgrp()
    signal.signal(signal.SIGTERM, handle_sigterm)
    CONF(sys.argv[1:], project='bareon',
         version=version.version_info.release_string())

    logging.setup('bareon')
    LOG = logging.getLogger(__name__)

    try:
        if CONF.input_data:
            data = yaml.safe_load(CONF.input_data)
        else:
            with open(CONF.input_data_file) as f:
                data = yaml.safe_load(f)
        LOG.debug('Input data: %s', data)

        data_driver_class = utils.get_data_driver(CONF.data_driver)
        data_driver = data_driver_class(data)

        deploy_driver_class = utils.get_deploy_driver(CONF.deploy_driver)
        deploy_driver = deploy_driver_class(data_driver)

        if actions:
            for action in actions:
                getattr(deploy_driver, action)()
    except Exception as exc:
        handle_exception(exc)
Exemplo n.º 4
0
 def test_get_deploy_driver(self, mock_drv_manager):
     mock_drv_manager.return_value = self.drv_depl_mgr
     self.assertEqual(mock.MagicMock.__name__, utils.get_deploy_driver("fake_deploy_driver").__name__)
Exemplo n.º 5
0
 def test_get_deploy_driver(self, mock_drv_manager):
     mock_drv_manager.return_value = self.drv_depl_mgr
     self.assertEqual(
         mock.MagicMock.__name__,
         utils.get_deploy_driver('fake_deploy_driver').__name__)