Exemplo n.º 1
0
    def _test_get_best_config_path(self, original, expected, files_exist=()):
        def mock_isfile_f(f):
            return f in files_exist

        with mock.patch('os.path.isfile', side_effect=mock_isfile_f):
            self.assertEqual(
                expected,
                config.get_best_config_path(original)
            )
Exemplo n.º 2
0
    def _test_get_best_config_path(self, original, expected, files_exist=()):
        def mock_isfile_f(f):
            return f in files_exist

        with mock.patch('os.path.isfile', side_effect=mock_isfile_f):
            self.assertEqual(
                config.get_best_config_path(original),
                expected
            )
Exemplo n.º 3
0
    def initialize_app(self, argv):
        # Quiet logging for some request library
        logging.getLogger('requests').setLevel(logging.WARN)

        # Don't pass argv here because cfg.CONF will intercept the
        # help options and exit.
        cfg.CONF(['--config-file', config.get_best_config_path()],
                 project='astara-orchestrator')
        self.rug_ini = cfg.CONF
        return super(RugController, self).initialize_app(argv)
Exemplo n.º 4
0
def _ssh_key():
    key = config.get_best_config_path(cfg.CONF.ssh_public_key)
    if not key:
        return ''
    try:
        with open(key) as out:
            return out.read()
    except IOError:
        LOG.warning(_LW('Could not load router ssh public key from %s'), key)
        return ''
Exemplo n.º 5
0
def _ssh_key():
    key = config.get_best_config_path(cfg.CONF.ssh_public_key)
    if not key:
        return ''
    try:
        with open(key) as out:
            return out.read()
    except IOError:
        LOG.warning(_LW('Could not load router ssh public key from %s'), key)
        return ''