Skip to content

Commit

Permalink
Include azure storage library in vendored_sdks (#6909)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyclam authored Dec 1, 2023
1 parent 97350f1 commit 57320b1
Show file tree
Hide file tree
Showing 151 changed files with 87,840 additions and 8,807 deletions.
12 changes: 8 additions & 4 deletions src/aosm/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
Release History
===============

1.0.0b3
++++++++
* Move azure-storage-blob dependency to vendored_sdks (on advice from Azure CLI team to avoid 'azure' namespace issues)

1.0.0b2
++++++++
* Fixed: Use default_factory when a dataclass default is hashable (Python 3.11 compatibility)

1.0.0b1
++++++++
* Initial release - beta quality
* `az aosm nfd|nsd generate-config` to generate an example config file to fill in for an NFD or NSD
* `az aosm nfd|nsd build|publish|delete` to prepare files for, publish or delete an NFD or NSD

1.0.0b2
++++++++
* Fixed: Use default_factory when a dataclass default is hashable (Python 3.11 compatibility)
37 changes: 26 additions & 11 deletions src/aosm/azext_aosm/delete/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
"""Contains class for deploying generated definitions using the Python SDK."""
from time import sleep
from typing import Optional
from knack.log import get_logger

from azure.cli.core.commands import LongRunningOperation
from azure.core.exceptions import ResourceExistsError
from azext_aosm._configuration import (
Configuration,
NFConfiguration,
Expand All @@ -15,6 +16,7 @@
)
from azext_aosm.util.management_clients import ApiClients
from azext_aosm.util.utils import input_ack
from knack.log import get_logger

logger = get_logger(__name__)

Expand Down Expand Up @@ -296,16 +298,29 @@ def delete_publisher(self) -> None:
message = f"Delete Publisher {self.config.publisher_name}"
logger.debug(message)
print(message)
try:
poller = self.api_clients.aosm_client.publishers.begin_delete(
resource_group_name=self.config.publisher_resource_group_name,
publisher_name=self.config.publisher_name,
)
LongRunningOperation(self.cli_ctx, "Deleting Publisher...")(poller)
logger.info("Deleted Publisher")
except Exception:
logger.error("Failed to delete publisher")
raise
# Occasionally nested resources that have just been deleted (e.g. artifact store) will
# still appear to exist, raising ResourceExistsError. We handle this by retrying up to
# 6 times, with a 30 second wait between each.
for attempt in range(6):
try:
poller = self.api_clients.aosm_client.publishers.begin_delete(
resource_group_name=self.config.publisher_resource_group_name,
publisher_name=self.config.publisher_name,
)
LongRunningOperation(self.cli_ctx, "Deleting Publisher...")(poller)
logger.info("Deleted Publisher")
break
except ResourceExistsError:
if attempt == 5:
logger.error("Failed to delete publisher")
raise
logger.debug(
"ResourceExistsError: This may be nested resource is not finished deleting. Wait and retry."
)
sleep(30)
except Exception:
logger.error("Failed to delete publisher")
raise

def delete_config_group_schema(self) -> None:
"""Delete the Configuration Group Schema."""
Expand Down
3 changes: 2 additions & 1 deletion src/aosm/azext_aosm/deploy/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from dataclasses import dataclass
from typing import Any, Optional, Union

from azure.storage.blob import BlobClient, BlobType
from knack.log import get_logger
from knack.util import CLIError
from oras.client import OrasClient
Expand All @@ -23,6 +22,8 @@
HelmPackageConfig,
VhdArtifactConfig,
)
from azext_aosm.vendored_sdks.azure_storagev2.blob.v2022_11_02 import (
BlobClient, BlobType)

logger = get_logger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/aosm/azext_aosm/deploy/artifact_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from typing import Any, List, Union

from azure.cli.core.azclierror import AzCLIError
from azure.storage.blob import BlobClient
from knack.log import get_logger
from oras.client import OrasClient

Expand All @@ -20,6 +19,7 @@
CredentialType,
ManifestArtifactFormat,
)
from azext_aosm.vendored_sdks.azure_storagev2.blob.v2022_11_02 import BlobClient

logger = get_logger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/aosm/azext_aosm/generate_nfd/cnf_nfd_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def search_schema(
# (This currently only supports a single type, not a list of types.
# If a list is provided, we default to string.)
array_item_schema = node.get("items", {})
if type(array_item_schema) is dict:
if isinstance(array_item_schema, dict):
param_type = array_item_schema.get("type", None)
else:
logger.debug("Array item schema is not a dict (probably a list)")
Expand Down
Loading

0 comments on commit 57320b1

Please sign in to comment.