salt-extensions / saltext-azurerm

Salt Extension Modules for Azure Resource Manager
Apache License 2.0
7 stars 9 forks source link

[BUG] NameError: name '__salt__' is not defined #40

Closed nicholasmhughes closed 1 year ago

nicholasmhughes commented 1 year ago

Description The cloud module seems unable to access the execution module code, as the __salt__ dunder isn't present.

[ERROR   ] Caught Exception, terminating workers
TRACE: name '__salt__' is not defined
Traceback (most recent call last):
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/cloud/__init__.py", line 56, in _call
    ret = func(*args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/cloud/__init__.py", line 2297, in create_multiprocessing
    output = cloud.create(
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/cloud/__init__.py", line 1226, in create
    output = self.clouds[func](vm_)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1232, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1247, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/saltext/azurerm/clouds/azurerm.py", line 1170, in create
    vm_request = request_instance(vm_=vm_)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/saltext/azurerm/clouds/azurerm.py", line 794, in request_instance
    iface_data, public_ips, private_ips = create_network_interface(call="action", kwargs=vm_)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/saltext/azurerm/clouds/azurerm.py", line 710, in create_network_interface
    pub_ip_data = __salt__["azurerm_network.public_ip_address_create_or_update"](
NameError: name '__salt__' is not defined

After implementing a quick workaround for the former error, the following issue was also found.

[ERROR   ] Failed to create VM saltmaster01. Configuration value 'ip_address' needs to be set
Traceback (most recent call last):
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/cloud/__init__.py", line 1226, in create
    output = self.clouds[func](vm_)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1232, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1247, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/saltext/azurerm/clouds/azurerm.py", line 1178, in create
    vm_request = request_instance(vm_=vm_)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/saltext/azurerm/clouds/azurerm.py", line 802, in request_instance
    iface_data, public_ips, private_ips = create_network_interface(call="action", kwargs=vm_)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/saltext/azurerm/clouds/azurerm.py", line 741, in create_network_interface
    return _get_network_interface(kwargs["iface_name"], kwargs["resource_group"])
  File "/opt/saltstack/salt/lib/python3.10/site-packages/saltext/azurerm/clouds/azurerm.py", line 654, in _get_network_interface
    public_ips.append(public_ip["ip_address"])
KeyError: 'ip_address'

Expected behavior Should be able to create a cloud instance with the cloud module.