Skip to content

Commit

Permalink
Allow configuration of hierarchical namespace for azureblob
Browse files Browse the repository at this point in the history
  • Loading branch information
swoehrl-mw committed Jan 26, 2024
1 parent 98b567b commit 69d0541
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-slim
FROM python:3.11-slim

RUN mkdir /operator
WORKDIR /operator
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ backends: # Configuration for the different backends. Required fields are only
tags: {} # Extra tags to add to the storage account resource in Azure. variables {namespace} and {name} can be used, optional
kind: StorageV2 # Kind to use for the storage accounts, optional
access_tier: Hot # Access tier for the storage accounts, can be Hot or Cold, optional
hns_enabled: false # Enable hierarchical namespace (only during bucket creation), optional
sku:
name: "Standard_LRS" # Name of the SKU to use for the storage accounts. If this is set, the settings of classes are ignored
classes: # List of size classes the user can select from, optional
lrs: # Name of the class, required
name: "Standard_LRS" # Name of the SKU in Azure, required
hns_enabled: false # Enable hierarchical namespace (only during bucket creation), optional
grs:
name: "Standard_GRS"
default_class: lrs # Name of the class to use as default if the user-provided one is invalid or not available, required if classes should be usable
Expand Down
24 changes: 21 additions & 3 deletions hybridcloud/backends/azureblob.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,14 @@ def bucket_exists(self, namespace, name):
def create_or_update_bucket(self, namespace, name, spec):
bucket_name = _calc_name(namespace, name)
sku = _determine_sku(spec.get("size", {}))
class_options = _class_options(spec.get("size", {}))
public_access = field_from_spec(spec, "network.publicAccess", default=_backend_config("parameters.network.public_access", default=False))
network_rules = self._map_network_rules(spec, public_access)
tags = _calc_tags(namespace, name)
sftp_enabled = field_from_spec(spec, "sftp.enabled", default=_backend_config("parameters.sftp.enabled",
default=False))
backup_enabled = field_from_spec(spec, "backup.enabled", default=_backend_config("parameters.backup.enabled", default=False))
hns_enabled = sftp_enabled or class_options.get("hns_enabled", _backend_config("hns_enabled", default=False))

try:
storage_account = self._storage_client.storage_accounts.get_properties(self._resource_group, bucket_name)
Expand All @@ -137,8 +139,8 @@ def create_or_update_bucket(self, namespace, name, spec):
allow_shared_key_access=True,
is_sftp_enabled=sftp_enabled,
# needed to enable sftp
is_hns_enabled=sftp_enabled,
is_local_user_enabled=sftp_enabled
is_hns_enabled=hns_enabled,
is_local_user_enabled=sftp_enabled,
)
self._storage_client.storage_accounts.begin_create(self._resource_group, bucket_name, parameters=parameters).result()
else:
Expand Down Expand Up @@ -508,9 +510,25 @@ def _determine_sku(size_spec):
return Sku(name=classes[size_class]["name"])
if default_class in classes:
return Sku(name=classes[default_class]["name"])

raise Exception(f"Default class '{default_class}' not found in classes.")


def _class_options(size_spec):
size_class = size_spec.get("class")
default_class = _backend_config("default_class")
classes = _backend_config("classes", default=[])

if not size_class and not default_class:
return {}
if size_class and size_class in classes:
return classes[size_class]
if default_class in classes:
return classes[default_class]

raise Exception(f"Default class '{default_class}' not found in classes.")


def _determine_backup_policy(backup_spec):
classes = _backend_config("backup.classes")
backup_class = backup_spec.get("class")
Expand Down

0 comments on commit 69d0541

Please sign in to comment.