diff --git a/CHANGELOG.md b/CHANGELOG.md index cb694ab..f616375 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ This project uses [Semantic Versioning](https://semver.org/) - MAJOR.MINOR.PATCH # Changelog +# Saltext.Azurerm 4.0.1 (2023-08-14) + +### Fixed + +- Fix NameError for __salt__ access and a public IP KeyError (#40) + + # Saltext.Azurerm 4.0.0 (2023-08-14) ### Added diff --git a/src/saltext/azurerm/clouds/azurerm.py b/src/saltext/azurerm/clouds/azurerm.py index 503eb4f..1abc7ff 100644 --- a/src/saltext/azurerm/clouds/azurerm.py +++ b/src/saltext/azurerm/clouds/azurerm.py @@ -99,7 +99,6 @@ import salt.cache # pylint: disable=import-error import salt.config as config # pylint: disable=import-error -import salt.loader # pylint: disable=import-error import salt.utils.cloud # pylint: disable=import-error import salt.utils.files # pylint: disable=import-error import salt.utils.stringutils # pylint: disable=import-error @@ -124,6 +123,16 @@ except ImportError: pass +try: + __salt__ # pylint: disable=used-before-assignment +except NameError: + import salt.loader # pylint: disable=import-error + + __opts__ = salt.config.minion_config("/etc/salt/minion") + __utils__ = salt.loader.utils(__opts__) + __salt__ = salt.loader.minion_mods(__opts__, utils=__utils__) + + __virtualname__ = "azurerm" log = logging.getLogger(__name__) @@ -643,8 +652,9 @@ def _get_network_interface(name, resource_group): ip_config["public_ip_address"]["id"], netapi_version, "name" ) public_ip = _get_public_ip(public_ip_name, resource_group) - public_ips.append(public_ip["ip_address"]) - netiface["ip_configurations"][index]["public_ip_address"].update(public_ip) + if public_ip.get("ip_address"): + public_ips.append(public_ip["ip_address"]) + netiface["ip_configurations"][index]["public_ip_address"].update(public_ip) return netiface, public_ips, private_ips diff --git a/src/saltext/azurerm/version.py b/src/saltext/azurerm/version.py index 904285f..d750c32 100644 --- a/src/saltext/azurerm/version.py +++ b/src/saltext/azurerm/version.py @@ -1,2 +1,2 @@ # pylint: disable=missing-module-docstring -__version__ = "4.0.0" +__version__ = "4.0.1"