diff --git a/Dockerfile b/Dockerfile index 1be33ef..2008cda 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10-slim +FROM python:3.11-slim RUN mkdir /operator WORKDIR /operator diff --git a/README.md b/README.md index 9a440c6..b407bcc 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/hybridcloud/backends/azureblob.py b/hybridcloud/backends/azureblob.py index b9e23e7..816793d 100644 --- a/hybridcloud/backends/azureblob.py +++ b/hybridcloud/backends/azureblob.py @@ -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) @@ -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: @@ -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")