Your message dated Tue, 15 Oct 2024 23:33:26 +0000
with message-id <[email protected]>
and subject line Bug#1052452: fixed in python-pyvmomi 8.0.3.0.1-1
has caused the Debian Bug report #1052452,
regarding python3-pyvmomi version too old, breaks ansible 7.3.0+dfsg-1
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)
--
1052452: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1052452
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: python3-pyvmomi
Version: 6.7.1-4
Severity: important
Tags: patch
Running ansible vmware_guest module in debian stable fails with this error:
AttributeError: module 'pyVmomi.VmomiSupport' has no attribute
'VmomiJSONEncoder'
Actually the vmware_guest module in stable cannot be used and version
6.7.1-6 in testing and sid is still too old, as support for JSON
encoding in vmomi is tracked in pyvmomi #732[1] and solved in
v6.7.1.2018.12 Bug Fix release.
It would be nice if python3-pyvmomi can be upgraded to a ever newer
version (now is at 8.0U1 patch 2), but I include a patch with
differences in file pyVmomi/VmomiSupport between version v6.7.1.2018.12
and v6.7.1, if you want to stay minimal (in the upstream diff there are
also many other changes in docs and examples that aren't related to this
bug). I tested it in my environment and it works for me.
-- System Information:
Debian Release: 12.1
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500,
'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 6.1.0-12-amd64 (SMP w/1 CPU thread; PREEMPT)
Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8), LANGUAGE
not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages python3-pyvmomi depends on:
ii dpkg 1.21.22
ii python3 3.11.2-1+b1
ii python3-requests 2.28.1+dfsg-1
ii python3-six 1.16.0-4
python3-pyvmomi recommends no packages.
Versions of packages python3-pyvmomi suggests:
pn python-pyvmomi-doc <none>
-- no debconf information
Best regards.
Paolo
1. https://github.com/vmware/pyvmomi/pull/732
diff --git a/pyVmomi/VmomiSupport.py b/pyVmomi/VmomiSupport.py
index 925d4a9..b3b7878 100644
--- a/pyVmomi/VmomiSupport.py
+++ b/pyVmomi/VmomiSupport.py
@@ -1,5 +1,5 @@
# VMware vSphere Python SDK
-# Copyright (c) 2008-2016 VMware, Inc. All Rights Reserved.
+# Copyright (c) 2008-2018 VMware, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ from six import PY3
from datetime import datetime
from pyVmomi import Iso8601
import base64
+import json
import threading
if PY3:
from functools import cmp_to_key
@@ -273,6 +274,131 @@ class LazyModule(object):
else:
raise AttributeError("'%s' does not exist" % self.name)
+
+class VmomiJSONEncoder(json.JSONEncoder):
+ """
+ Custom JSON encoder to encode vSphere objects.
+
+ When a ManagedObject is encoded, it gains three properties:
+ _vimid is the _moId (ex: 'vm-42')
+ _vimref is the moRef (ex: 'vim.VirtualMachine:vm-42')
+ _vimtype is the class name (ex: 'vim.VirtualMachine')
+
+ When a DataObject is encoded, it gains one property:
+ _vimtype is the class name (ex: 'vim.VirtualMachineQuestionInfo')
+
+ If the dynamicProperty and dynamicType are empty, they are optionally
+ omitted from the results of DataObjects and ManagedObjects
+
+ @example "Explode only the object passed in"
+ data = json.dumps(vm, cls=VmomiJSONEncoder)
+
+ @example "Explode specific objects"
+ data = json.dumps(vm, cls=VmomiJSONEncoder,
+ explode=[vm, vm.network[0]])
+
+ @example "Explode all virtual machines in a list and their snapshots"
+ data = json.dumps([vm1, vm2], cls=VmomiJSONEncoder,
+ explode=[templateOf('VirtualMachine'),
+ templateOf('VirtualMachineSnapshot')])
+ """
+ def __init__(self, *args, **kwargs):
+ """
+ Consumer must specify what types to explode into full content
+ and what types to leave as a ManagedObjectReference. If the
+ root object of the encoding is a ManagedObject, it will be
+ added to the explode list automatically.
+
+ A ManagedObject is only exploded once, the first time it is
+ encountered. All subsequent times it will be a moRef.
+
+ @param explode (list) A list of objects and/or types to
+ expand in the conversion process. Directly add any
+ objects to the list, or add the type of any object
+ using type(templateOf('VirtualMachine')) for example.
+
+ @param strip_dynamic (bool) Every object normally contains
+ a dynamicProperty list and a dynamicType field even if
+ the contents are [] and None respectively. These fields
+ clutter the output making it more difficult for a person
+ to read and bloat the size of the result unnecessarily.
+ This option removes them if they are the empty values above.
+ The default is False.
+ """
+ self._done = set()
+ self._first = True
+ self._explode = kwargs.pop('explode', None)
+ self._strip_dynamic = kwargs.pop('strip_dynamic', False)
+ super(VmomiJSONEncoder, self).__init__(*args, **kwargs)
+
+ def _remove_empty_dynamic_if(self, result):
+ if self._strip_dynamic:
+ if 'dynamicProperty' in result and len(result['dynamicProperty'])
== 0:
+ result.pop('dynamicProperty')
+ if 'dynamicType' in result and not result['dynamicType']:
+ result.pop('dynamicType')
+ return result
+
+ def default(self, obj): # pylint: disable=method-hidden
+ if self._first:
+ self._first = False
+ if not self._explode:
+ self._explode = []
+ if isinstance(obj, ManagedObject):
+ self._explode.append(obj)
+ if isinstance(obj, ManagedObject):
+ if self.explode(obj):
+ result = {}
+ result['_vimid'] = obj._moId
+ result['_vimref'] = '{}:{}'.format(obj.__class__.__name__,
+ obj._moId)
+ result['_vimtype'] = obj.__class__.__name__
+ for prop in obj._GetPropertyList():
+ result[prop.name] = getattr(obj, prop.name)
+ return self._remove_empty_dynamic_if(result)
+ return str(obj).strip("'") # see FormatObject below
+ if isinstance(obj, DataObject):
+ result = {k:v for k,v in obj.__dict__.items()}
+ result['_vimtype'] = obj.__class__.__name__
+ return self._remove_empty_dynamic_if(result)
+ if isinstance(obj, binary):
+ result = base64.b64encode(obj)
+ if PY3: # see FormatObject below
+ result = str(result, 'utf-8')
+ return result
+ if isinstance(obj, datetime):
+ return Iso8601.ISO8601Format(obj)
+ if isinstance(obj, UncallableManagedMethod):
+ return obj.name
+ if isinstance(obj, ManagedMethod):
+ return str(obj) # see FormatObject below
+ if isinstance(obj, type):
+ return obj.__name__
+ super(VmomiJSONEncoder, self).default(obj)
+
+ def explode(self, obj):
+ """ Determine if the object should be exploded. """
+ if obj in self._done:
+ return False
+ result = False
+ for item in self._explode:
+ if hasattr(item, '_moId'):
+ # If it has a _moId it is an instance
+ if obj._moId == item._moId:
+ result = True
+ else:
+ # If it does not have a _moId it is a template
+ if obj.__class__.__name__ == item.__name__:
+ result = True
+ if result:
+ self._done.add(obj)
+ return result
+
+
+def templateOf(typestr):
+ """ Returns a class template. """
+ return GetWsdlType(XMLNS_VMODL_BASE, typestr)
+
## Format a python VMOMI object
#
# @param val the object
@@ -1325,7 +1451,14 @@ double = type("double", (float,), {})
if PY3:
long = type("long", (int,), {})
URI = type("URI", (str,), {})
-binary = type("binary", (binary_type,), {})
+if not PY3:
+ # six defines binary_type in python2 as a string; this means the
+ # JSON encoder sees checksum properties as strings and attempts
+ # to perform utf-8 decoding on them because they contain high-bit
+ # characters.
+ binary = type("binary", (bytearray,), {})
+else:
+ binary = type("binary", (binary_type,), {})
PropertyPath = type("PropertyPath", (text_type,), {})
# _wsdlTypeMapNSs store namespaces added to _wsdlTypeMap in _SetWsdlType
--- End Message ---
--- Begin Message ---
Source: python-pyvmomi
Source-Version: 8.0.3.0.1-1
Done: Colin Watson <[email protected]>
We believe that the bug you reported is fixed in the latest version of
python-pyvmomi, which is due to be installed in the Debian FTP archive.
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Colin Watson <[email protected]> (supplier of updated python-pyvmomi package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Format: 1.8
Date: Wed, 16 Oct 2024 00:05:33 +0100
Source: python-pyvmomi
Architecture: source
Version: 8.0.3.0.1-1
Distribution: unstable
Urgency: medium
Maintainer: Debian Python Team <[email protected]>
Changed-By: Colin Watson <[email protected]>
Closes: 1025402 1052452 1052793
Changes:
python-pyvmomi (8.0.3.0.1-1) unstable; urgency=medium
.
* Team upload.
.
[ Alexandre Detiste ]
* New upstream version 8.0.3.0.1 (Closes: #1052793, #1052452, #1025402)
.
[ Colin Watson ]
* Run tests using pytest, skipping a few broken ones.
* Drop python-pyvmomi-doc binary package; upstream now points to their
website for most documentation and no longer ships it in the source
package.
* Remove some OpenStack leftovers from debian/rules.
* Use pybuild-plugin-pyproject.
* Enable autopkgtest-pkg-pybuild.
Checksums-Sha1:
a091a19170f95d7574d2cf1dfcc0967f43e3c9ca 2296 python-pyvmomi_8.0.3.0.1-1.dsc
99ffdef85dd24a8cc2df6000a04e647356ba96d9 1116169
python-pyvmomi_8.0.3.0.1.orig.tar.gz
6698c0c5405870c7a975823b9fb8f9521146a90d 3804
python-pyvmomi_8.0.3.0.1-1.debian.tar.xz
Checksums-Sha256:
e7707a8add10358e07e819ce7f6be00dacb3198de2b92ef118601c096af34f57 2296
python-pyvmomi_8.0.3.0.1-1.dsc
4ed2ff75b60612a23da6e16d7b46d8bc030a82e0f01eebdfcb8973a67c30df9a 1116169
python-pyvmomi_8.0.3.0.1.orig.tar.gz
adc2dcf0d102f121c4e58025a3eb64d7727fc6d024ea069f1e96342e43e3ac59 3804
python-pyvmomi_8.0.3.0.1-1.debian.tar.xz
Files:
1d0defa243c2d5b82ab2a0418465ff4f 2296 python optional
python-pyvmomi_8.0.3.0.1-1.dsc
552e39a033e9d7428ee1e90f37d04543 1116169 python optional
python-pyvmomi_8.0.3.0.1.orig.tar.gz
a60c4a1d85f0eea8ce73b3d2d26d82e9 3804 python optional
python-pyvmomi_8.0.3.0.1-1.debian.tar.xz
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEErApP8SYRtvzPAcEROTWH2X2GUAsFAmcO9Z8ACgkQOTWH2X2G
UAul8xAAqKBndjiDeUuXTLwMnLPkIrKiVeFRMwok1LV5HJIk2VwgHk3lPlQia4Ai
T3OVvLwUd7gBLiL2wOAUhD2oizRhzST1As2WkygdRWj8PAmd7xDmFDSi7Fb750SG
sNPMyURkY1I6O0hds7QrJBnmgQtiRXe+vbGQSwVRBQ1qAzBkBaSKmADh0L2HFOPm
6roR9mQaNT8s4inTCc3wqY7PmXzQCBmkHJlf/FZg1u9AdO5Lm+bE2z6tSvtK18LJ
98jtF9dN3Yf7pWZKUxpI38rm4/QprShu49NQl7k2322yMX7NEVnkltdYWpvetYLd
zWNjROzNm/VbNzEKqAJeMFg2eN+2unihTwd7aglXb15HWmb635cNr4mZvGpLWpai
Ykm+npAJ5eTiP9UWfgCQOgZacugLEkxBKEvim97IAOfzCXMTAXukgrCH9MY+xF3p
p2pX7xqAob5bFwMgjSYDpOyn4jM0MBGi3pcmVZ+VKpXScWeEfDvXZ3CXjlNgA9V2
KTtXG9UM0EHILQrkw6YmalVhp5Pq6WtVyzyRh0bYkmxJrIi9SLroWNxw3tp/c8WK
rSBFGlLSUmgPiPO2Fy/jm7OHmI9YUE7f9JJKoHqwwQgiNdCkhCjw7MxAY+VNoi6a
cJg38udSyzGcvat0w9v390oon3Ya1xRhfTQJ1S2fclaGO/qXy04=
=RHF7
-----END PGP SIGNATURE-----
pgpiAD_Cxqs5U.pgp
Description: PGP signature
--- End Message ---