def _get_warpgate_config(self): """Read the WarpGate config from the cell data. """ cell_config = cellconfig.CellConfig(self._tm_env.root) warpgate_cfg = cell_config.data['warpgate'] servers = warpgate_cfg.get('servers', []) principal = warpgate_cfg.get('principal', 'host') return (servers, principal)
def _get_docker_registry(tm_env): """Return the registry to use. """ # get registry address from cell_config.yml cell_config = cellconfig.CellConfig(tm_env.root) registry = cell_config.data['docker_registry'] if ':' in registry: host, _sep, port = registry.partition(':') else: host = registry port = '5000' # Ensure we have teh FQDN for the registry host. host = socket.getfqdn(host) return ':'.join([host, port])
def test_get_data(self): """Test get data from cell config file """ # pylint: disable=protected-access cell_config = cellconfig.CellConfig(self.root) self.assertEqual(cell_config.data, {'foo': 'bar'}) self.assertEqual(cell_config.version, '3.x') self.assertEqual(cell_config.partitions, []) # new data after updating with io.open(self._file, 'w') as f: yaml.dump( { 'data': { 'hello': 'world' }, 'version': '3.x' }, stream=f, ) # force lodaded data is older than file cell_config._modified = 0 self.assertEqual(cell_config.data, {'hello': 'world'})