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) )
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 )
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)
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 ''