[BUG] vsphere.update_dvportgroup fails with `AttributeError: 'bool' object has no attribute 'RetrieveContent'`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
vsphere.update_dvportgroup fails with AttributeError: 'bool' object has no attribute 'RetrieveContent'
Setup
/srv/salt/test.sls:
saltmod_vsphere_dvportgroup_VL1313-HV-MGMT:
module.run:
{% if salt['vsphere.list_dvportgroups'](dvs='DATA', portgroup_names=['VL1313-HV-MGMT']) %}
- vsphere.update_dvportgroup:
- portgroup: VL1313-HV-MGMT
{% else %}
- vsphere.create_dvportgroup:
- portgroup_name: VL1313-HV-MGMT
{% endif %}
- dvs: DATA
- portgroup_dict:
name: VL1313-HV-MGMT
type: earlyBinding
vlan_id: 1313
description: |
THIS OBJECT IS MANAGED BY SALT - DO NOT MODIFY
Any changes to this object may be overwritten automatically and without warning.
DPG for VLAN 1313 - HV-MGMT - Hypervisor Management
Steps to Reproduce the behavior
If the DPG doesn't exist at first, it will be created normally:
salt minion state.apply test
minion:
----------
ID: saltmod_vsphere_dvportgroup_VL1313-HV-MGMT
Function: module.run
Result: True
Comment: vsphere.create_dvportgroup: True
Started: 06:16:10.933694
Duration: 1259.483 ms
Changes:
----------
vsphere.create_dvportgroup:
True
Summary for minion
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
Total run time: 1.259 s
However, if you run the state file again (the DPG now exists):
salt minion state.apply test
minion:
----------
ID: saltmod_vsphere_dvportgroup_VL1313-HV-MGMT
Function: module.run
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/salt/state.py", line 2180, in call
*cdata["args"], **cdata["kwargs"]
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
return self.loader.run(run_func, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1201, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
return callable(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1216, in _run_as
return _func_or_method(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1249, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/utils/decorators/__init__.py", line 742, in _decorate
return self._call_function(kwargs)
File "/usr/lib/python3.6/site-packages/salt/utils/decorators/__init__.py", line 355, in _call_function
return self._function(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/states/module.py", line 425, in run
_func, returner=kwargs.get("returner"), func_args=kwargs.get(func)
File "/usr/lib/python3.6/site-packages/salt/states/module.py", line 470, in _call_function
mret = salt.utils.functools.call_function(__salt__[name], *func_args, **func_kwargs)
File "/usr/lib/python3.6/site-packages/salt/utils/functools.py", line 150, in call_function
return salt_function(*function_args, **function_kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
return self.loader.run(run_func, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1201, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
return callable(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1216, in _run_as
return _func_or_method(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/modules/vsphere.py", line 372, in __supports_proxies_
return fn(*args, **salt.utils.args.clean_kwargs(**kwargs))
File "/usr/lib/python3.6/site-packages/salt/modules/vsphere.py", line 457, in _gets_service_instance_via_proxy_
ret = fn(*args, **salt.utils.args.clean_kwargs(**kwargs))
File "/usr/lib/python3.6/site-packages/salt/modules/vsphere.py", line 5397, in update_dvportgroup
dc_ref = salt.utils.vmware.get_datacenter(service_instance, datacenter)
File "/usr/lib/python3.6/site-packages/salt/utils/vmware.py", line 1951, in get_datacenter
items = get_datacenters(service_instance, datacenter_names=[datacenter_name])
File "/usr/lib/python3.6/site-packages/salt/utils/vmware.py", line 1934, in get_datacenters
service_instance, vim.Datacenter, property_list=["name"]
File "/usr/lib/python3.6/site-packages/salt/utils/vmware.py", line 1083, in get_mors_with_properties
content = get_content(*content_args, **content_kwargs)
File "/usr/lib/python3.6/site-packages/salt/utils/vmware.py", line 908, in get_content
container_ref = get_root_folder(service_instance)
File "/usr/lib/python3.6/site-packages/salt/utils/vmware.py", line 856, in get_root_folder
return service_instance.RetrieveContent().rootFolder
AttributeError: 'bool' object has no attribute 'RetrieveContent'
Started: 06:16:18.820735
Duration: 23.903 ms
Changes:
Summary for minion
------------
Succeeded: 0
Failed: 1
------------
Total states run: 1
Total run time: 23.903 ms
ERROR: Minions returned with non-zero exit code
Expected behavior
The DPG should be updated
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Salt Version:
Salt: 3004.1
Dependency Versions:
cffi: 1.11.5
cherrypy: unknown
dateutil: 2.6.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 2.10.1
libgit2: 0.26.8
M2Crypto: 0.35.2
Mako: Not Installed
msgpack: 0.6.2
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: 2.14
pycrypto: Not Installed
pycryptodome: Not Installed
pygit2: 0.26.4
Python: 3.6.8 (default, Nov 17 2021, 16:10:06)
python-gnupg: Not Installed
PyYAML: 3.12
PyZMQ: 19.0.0
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: almalinux 8.5 Arctic Sphynx
locale: UTF-8
machine: x86_64
release: 4.18.0-348.20.1.el8_5.x86_64
system: Linux
version: AlmaLinux 8.5 Arctic Sphynx
Additional context
esxcluster proxy minion against vSphere 7.0.3. pyVmomi 7.0.3
Relates to #62064
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in salt/modules/vsphere.py at update_dvportgroup and trace the service instance into salt/utils/vmware.py, especially get_datacenter, get_datacenters, get_mors_with_properties, get_content, and get_root_folder. Reproduce the second state.apply run against an existing DPG and inspect why the proxy path supplies a boolean instead of a service instance. Done means an existing DPG can be updated successfully through the reported esxcluster proxy setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100