コード例 #1
0
def _get_or_create_volume(suffix, disk_size_gb):
    volume_spec_config_key = f'volume-spec-{suffix}'
    volume_spec = _config_get(volume_spec_config_key, required=False)
    if volume_spec:
        volume_spec = yaml.load(volume_spec)
    else:
        from ckan_cloud_operator.providers.cluster import manager as cluster_manager
        volume_spec = cluster_manager.create_volume(disk_size_gb, _get_resource_labels(suffix=suffix))
        _config_set(volume_spec_config_key, yaml.dump(volume_spec, default_flow_style=False))
    return volume_spec
コード例 #2
0
def _get_or_create_volume(suffix, disk_size_gb, dry_run=False, zone=0):
    volume_spec_config_key = f'volume-spec-{suffix}'
    volume_spec = _config_get(volume_spec_config_key, required=False)
    if volume_spec:
        volume_spec = yaml.load(volume_spec)
    else:
        assert not dry_run, 'creating a new volume is not supported for dry_run'
        from ckan_cloud_operator.providers.cluster import manager as cluster_manager
        volume_spec = cluster_manager.create_volume(
            disk_size_gb, _get_resource_labels(suffix=suffix), zone=zone)
        _config_set(volume_spec_config_key,
                    yaml.dump(volume_spec, default_flow_style=False))
    if dry_run:
        print(yaml.dump(volume_spec, default_flow_style=False))
    return volume_spec
コード例 #3
0
def _get_or_create_volume(storage_suffix=None, use_existing_disk_name=None):
    disk_size_gb = _config_get('disk-size-gb',
                               required=True,
                               suffix=storage_suffix)
    volume_spec = _config_get('volume-spec',
                              required=False,
                              suffix=storage_suffix)
    if volume_spec:
        volume_spec = yaml.load(volume_spec)
    else:
        from ckan_cloud_operator.providers.cluster import manager as cluster_manager
        volume_spec = cluster_manager.create_volume(
            disk_size_gb,
            _get_resource_labels(suffix=storage_suffix),
            use_existing_disk_name=use_existing_disk_name)
        _config_set('volume-spec',
                    yaml.dump(volume_spec, default_flow_style=False),
                    suffix=storage_suffix)
    return volume_spec
コード例 #4
0
ファイル: cli.py プロジェクト: hasadna/ckan-cloud-operator
def create_volume(disk_size_gb, zone):
    label_prefix = labels_manager.get_label_prefix()
    print(
        manager.create_volume(
            disk_size_gb, {f'{label_prefix}/operator-volume-source': 'cli'},
            zone=zone))