How to use the peeringdb.config.convert_old function in peeringdb

To help you get started, we’ve selected a few peeringdb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github peeringdb / peeringdb-py / tests / test_config.py View on Github external
'peeringdb': {
            'url': 'https://test.peeringdb.com/api',
            'timeout': 10,
        }
    }
    assert config.detect_old(old_part)
    # empty case
    assert not config.detect_old({})

    # Test conversion
    conv_data = config.convert_old(old_data)
    assert config.CLIENT_SCHEMA.validate(conv_data)
    assert not config.detect_old(conv_data)
    assert conv_data == new_data

    conv_part = config.convert_old(old_part)
    assert config.CLIENT_SCHEMA.validate(conv_part)
github peeringdb / peeringdb-py / tests / test_config.py View on Github external
# Test detection
    assert config.detect_old(old_data)
    assert not config.detect_old(new_data)
    # Try partial data
    old_part = {
        'peeringdb': {
            'url': 'https://test.peeringdb.com/api',
            'timeout': 10,
        }
    }
    assert config.detect_old(old_part)
    # empty case
    assert not config.detect_old({})

    # Test conversion
    conv_data = config.convert_old(old_data)
    assert config.CLIENT_SCHEMA.validate(conv_data)
    assert not config.detect_old(conv_data)
    assert conv_data == new_data

    conv_part = config.convert_old(old_part)
    assert config.CLIENT_SCHEMA.validate(conv_part)
github peeringdb / peeringdb-py / peeringdb / cli.py View on Github external
def check_load_config(config_dir):
    convert = False
    loaded = config.read_config(config_dir) or {}

    if config.detect_old(loaded):
        print(
            "Found config file with pre-0.7 schema; backing up and converting to new format"
        )
        convert = True
        cfg = config.convert_old(loaded)
    else:
        cfg = config.default_config()
        config.recursive_update(cfg, loaded)

    if convert:
        config.write_config(cfg, config_dir, backup_existing=True)
    return cfg