Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5ad215f

Browse files
author
ddraganov
committed
Add the pyVmomi version in the user-agent request header
This change adds a project wide variable to hold the current pyVmomi version - version_info. Based of https://docs.python.org/3/library/sys.html#sys.version_info Another variable holds a text version of version_info and extends the User-Agent header - version_info_str.
1 parent 4bc1f52 commit 5ad215f

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

pyVmomi/SoapAdapter.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# **********************************************************
2-
# Copyright (c) 2005-2023 VMware, Inc.
2+
# Copyright (c) 2005-2024 VMware, Inc. All rights reserved.
33
# **********************************************************
44

55
import base64
@@ -35,6 +35,7 @@
3535
IsChildVersion, ManagedMethod, UnknownManagedMethod, ManagedObject,
3636
Object, PropertyPath, Type, binary, versionIdMap, versionMap)
3737
from .Security import VerifyCertThumbprint
38+
from . import version_info_str
3839
from . import _legacyThumbprintException
3940
if _legacyThumbprintException:
4041
from .Security import ThumbprintMismatchException # noqa: F401
@@ -1518,8 +1519,12 @@ def InvokeMethod(self, mo, info, args, outerStub=None):
15181519
'Content-Type':
15191520
'text/xml; charset={0}'.format(XML_ENCODING),
15201521
'User-Agent':
1521-
'pyvmomi Python/{0} ({1}; {2}; {3})'.format(
1522-
PYTHON_VERSION, OS_NAME, OS_VERSION, OS_ARCH)
1522+
'pyvmomi {0} Python/{1} ({2}; {3}; {4})'.format(
1523+
version_info_str,
1524+
PYTHON_VERSION,
1525+
OS_NAME,
1526+
OS_VERSION,
1527+
OS_ARCH)
15231528
}
15241529
if self._customHeaders:
15251530
headers.update(self._customHeaders)

pyVmomi/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
# **********************************************************
2-
# Copyright (c) 2005-2023 VMware, Inc.
2+
# Copyright (c) 2005-2024 VMware, Inc.
33
# **********************************************************
44

55
import sys
66
import importlib
77

8+
version_info = (
9+
8,
10+
0,
11+
2,
12+
0,
13+
1,
14+
)
15+
16+
version_info_str = ".".join(str(v) for v in version_info)
17+
818
if sys.version_info < (2, 7, 9):
919
sys.stderr.write("pyVmomi requires Python 2.7.9 or newer")
1020
sys.exit(1)

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import os
1717

1818
from setuptools import setup
19+
from pyVmomi import version_info_str
1920

2021

2122
def read(fname):
@@ -30,7 +31,7 @@ def read(fname):
3031

3132
setup(
3233
name='pyvmomi',
33-
version='8.0.2.0.1',
34+
version=version_info_str,
3435
description='VMware vSphere Python SDK',
3536
# NOTE: pypi prefers the use of RST to render docs
3637
long_description=read('README.rst'),

0 commit comments

Comments
 (0)