From 89a08cb9ff32e6873eed8c9bc91156988dc85fbc Mon Sep 17 00:00:00 2001 From: "R.A. Stern" Date: Thu, 27 May 2021 15:43:36 -0400 Subject: [PATCH 1/6] Add latest CWOM identifiers Add entity actions support --- .bumpversion.cfg | 2 +- docs/source/conf.py | 4 ++-- setup.py | 6 +++--- vmtconnect/__about__.py | 4 ++-- vmtconnect/__init__.py | 21 ++++++++++++++++++--- vmtconnect/versions.py | 7 ++++++- 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index df0e725..db87d2c 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 3.5.3 +current_version = 3.6.0.dev0 commit = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z]+)(?P\d*))? serialize = diff --git a/docs/source/conf.py b/docs/source/conf.py index 50eaed6..f7dfb06 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -73,9 +73,9 @@ # built documents. # # The short X.Y version. -version = u'3.5.3' +version = u'3.6.0.dev0' # The full version, including alpha/beta/rc tags. -release = u'3.5.3' +release = u'3.6.0.dev0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.py b/setup.py index 0dc960a..8414724 100644 --- a/setup.py +++ b/setup.py @@ -9,12 +9,12 @@ here = os.path.abspath(os.path.dirname(__file__)) requires = [ 'cryptography>=3,<4', - 'ijson>=3.1.post0,<4', - 'requests>=2.24.0,<3' + 'ijson>=3.1.4,<4', + 'requests>=2.25.1,<3' ] extra_requires = { - 'jq': ['jq>=1.0.2,<2'] + 'jq': ['jq>=1.1.3,<2'] } diff --git a/vmtconnect/__about__.py b/vmtconnect/__about__.py index bcafb7b..2ede14d 100644 --- a/vmtconnect/__about__.py +++ b/vmtconnect/__about__.py @@ -13,8 +13,8 @@ __title__ = 'vmtconnect' __description__ = 'Turbonomic API Client' -__version__ = '3.5.3' +__version__ = '3.6.0.dev0' __author__ = 'R.A. Stern' __author_email__ = 'richard.stern@turbonomic.com' __license__ = 'Apache 2.0' -__copyright__ = 'Copyright 2017-2020 R.A. Stern' +__copyright__ = 'Copyright 2017-2021 R.A. Stern' diff --git a/vmtconnect/__init__.py b/vmtconnect/__init__.py index bcc2c28..cba4b3e 100644 --- a/vmtconnect/__init__.py +++ b/vmtconnect/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2017-2020 R.A. Stern +# Copyright 2017-2021 R.A. Stern # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -857,8 +857,12 @@ def version(self): def __login(self): u, p = (base64.b64decode(self.__basic_auth)).decode().split(':', maxsplit=1) - body = {'username': (None, u), 'password': (None, p)} - self.request('login', 'POST', disable_hateoas=False, content_type=None, files=body, allow_redirects=False) + self.request('login', + 'POST', + disable_hateoas=False, + content_type=None, + files={'username': (None, u), 'password': (None, p)}, + allow_redirects=False) def __use_session(self, value): if value: @@ -1411,6 +1415,17 @@ def get_entity_cluster(self, uuid, cache=False, **kwargs): if uuid == vm['uuid']: return c + def get_entity_actions(self, uuid=None, **kwargs): + """Returns a list of entity actions. + + Args: + uuid (str): Entity UUID. + + Returns: + A list containing all actions for the given the entity. + """ + return self.request(f'entities/{uuid}/actions', **kwargs) + def get_entity_groups(self, uuid, **kwargs): """Returns a list of groups the entity belongs to. diff --git a/vmtconnect/versions.py b/vmtconnect/versions.py index 0abc7ee..f36d759 100644 --- a/vmtconnect/versions.py +++ b/vmtconnect/versions.py @@ -65,6 +65,11 @@ '2.3.26': '6.4.30', '2.3.27': '6.4.31', '2.3.28': '6.4.32', - '2.3.29': '6.4.33' + '2.3.29': '6.4.33', + '2.3.30': '6.4.34', + '2.3.31': '6.4.35', + '2.3.32': '6.4.36', + '2.3.33': '6.4.37', + '2.3.34': '6.4.38' } } From b26ab5992848d0a9f9c9636cb60a7abef8eea735 Mon Sep 17 00:00:00 2001 From: "R.A. Stern" Date: Wed, 2 Jun 2021 19:07:39 -0400 Subject: [PATCH 2/6] Update copyright --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index f7dfb06..bd849b3 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -65,7 +65,7 @@ # General information about the project. project = u'vmt-connect' -copyright = u'2017-2020' +copyright = u'2017-2021' author = u'R.A. Stern' # The version info for the project you're documenting, acts as replacement for From 41547fdc6c9b53570568b1a9605e6658da1f583e Mon Sep 17 00:00:00 2001 From: "R.A. Stern" Date: Wed, 2 Jun 2021 19:07:58 -0400 Subject: [PATCH 3/6] Fix query giving unnecessary warning --- vmtconnect/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vmtconnect/__init__.py b/vmtconnect/__init__.py index cba4b3e..d92fcdc 100644 --- a/vmtconnect/__init__.py +++ b/vmtconnect/__init__.py @@ -1071,7 +1071,7 @@ def request(self, path, method='GET', query='', dto=None, **kwargs): except KeyError: pass - if isinstance(query, str): + if query and isinstance(query, str): msg = 'Query parameters should be passed in as a dictionary.' warnings.warn(msg, DeprecationWarning) From 34a07c3924aed64e893d808529d1a42f85e4d417 Mon Sep 17 00:00:00 2001 From: "R.A. Stern" Date: Mon, 14 Jun 2021 11:11:11 -0400 Subject: [PATCH 4/6] Version translation update, fix invalid ID reference, fix StringIO compatibility --- vmtconnect/__init__.py | 17 ++++++++++++++--- vmtconnect/util.py | 5 +++-- vmtconnect/versions.py | 3 ++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/vmtconnect/__init__.py b/vmtconnect/__init__.py index d92fcdc..15a4155 100644 --- a/vmtconnect/__init__.py +++ b/vmtconnect/__init__.py @@ -1176,7 +1176,7 @@ def get_cached_inventory(self, id, uuid=None, **kwargs): elif id == '__group_members': self.__inventory_cache[id]['data'] = self.request(f'groups/{uuid}/members', **kwargs) else: - self.__inventory_cache[id]['data'] = self.request(f'markets/{id}/entities', fetch_all=True, **kwargs) + self.__inventory_cache[id]['data'] = self.request(f'markets/{uuid}/entities', fetch_all=True, **kwargs) delta = datetime.timedelta(seconds=self.__inventory_cache_timeout) self.__inventory_cache[id]['expires'] = datetime.datetime.now() + delta @@ -1415,7 +1415,7 @@ def get_entity_cluster(self, uuid, cache=False, **kwargs): if uuid == vm['uuid']: return c - def get_entity_actions(self, uuid=None, **kwargs): + def get_entity_actions(self, uuid, **kwargs): """Returns a list of entity actions. Args: @@ -1526,7 +1526,7 @@ def get_groups(self, uuid=None, cache=False, **kwargs): return self.request('groups', uuid=uuid, **kwargs) - def get_group_actions(self, uuid=None, **kwargs): + def get_group_actions(self, uuid, **kwargs): """Returns a list of group actions. Args: @@ -1669,6 +1669,17 @@ def get_targets(self, uuid=None, **kwargs): """ return self.request('targets', uuid=uuid, **kwargs) + def get_target_actions(self, uuid, **kwargs): + """Returns a list actions on a target. + + Args: + uuid (str): Entity UUID. + + Returns: + A list containing all actions for entities of the given the target. + """ + return self.request(f'targets/{uuid}/actions', **kwargs) + def get_target_for_entity(self, uuid=None, name=None, type='VirtualMachine', **kwargs): """Returns a list of templates. diff --git a/vmtconnect/util.py b/vmtconnect/util.py index b7872af..6d6fa26 100644 --- a/vmtconnect/util.py +++ b/vmtconnect/util.py @@ -13,7 +13,7 @@ from collections import defaultdict from copy import deepcopy from decimal import Decimal -from io import StringIO +from io import StringIO, BytesIO import re @@ -237,7 +237,8 @@ def apply(_s, _f): out = [None] * size idx = 0 - for x in ijson.items(StringIO(source), 'item', use_float=use_float): + # to remove ijson BytesIO warning + for x in ijson.items(BytesIO(source.encode('utf-8')), 'item', use_float=use_float): if idx >= len(out): out.extend([None] * size) diff --git a/vmtconnect/versions.py b/vmtconnect/versions.py index f36d759..3432ff0 100644 --- a/vmtconnect/versions.py +++ b/vmtconnect/versions.py @@ -70,6 +70,7 @@ '2.3.31': '6.4.35', '2.3.32': '6.4.36', '2.3.33': '6.4.37', - '2.3.34': '6.4.38' + '2.3.34': '6.4.38', + '3.0.1': '8.2.1' } } From b10dcff30b8e3aa1a48a58d2646a47cb8fbb118a Mon Sep 17 00:00:00 2001 From: "R.A. Stern" Date: Mon, 14 Jun 2021 13:42:23 -0400 Subject: [PATCH 5/6] Fix broken links --- docs/source/advancedguide.rst | 8 ++++---- docs/source/index.rst | 2 +- docs/source/start.rst | 11 ++++++----- docs/source/userguide.rst | 2 +- vmtconnect/__init__.py | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/source/advancedguide.rst b/docs/source/advancedguide.rst index 853faea..015ad07 100644 --- a/docs/source/advancedguide.rst +++ b/docs/source/advancedguide.rst @@ -1,14 +1,14 @@ .. # Links -.. _API: https://greencircle.vmturbo.com/community/products/pages/documentation +.. _API: https://support-turbonomic.force.com/TurbonomicCustomerCommunity/s/documentation .. _cryptography: https://pypi.org/project/cryptography/ .. _Fernet: https://github.com/fernet/spec/blob/master/Spec.md .. _jq: https://stedolan.github.io/jq/ .. _jq python: https://pypi.org/project/jq/ .. _jq script: https://stedolan.github.io/jq/manual/ .. _Turbonomic: https://www.turbonomic.com -.. _Requests: https://requests.readthedocs.io/en/master/ -.. _proxies: https://requests.readthedocs.io/en/master/user/advanced/#proxies -.. _RFC 2732: https://tools.ietf.org/html/rfc2732 +.. _Requests: https://docs.python-requests.org/en/master/ +.. _proxies: https://docs.python-requests.org/en/master/user/advanced/#proxies +.. _RFC 2732: https://datatracker.ietf.org/doc/html/rfc2732 ============== Advanced Usage diff --git a/docs/source/index.rst b/docs/source/index.rst index 8c4110e..8af7cd3 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -2,7 +2,7 @@ sphinx-quickstart on Tue Jul 18 10:49:54 2017. .. # Links -.. _APIs: https://greencircle.vmturbo.com/community/products/pages/documentation +.. _APIs: https://support-turbonomic.force.com/TurbonomicCustomerCommunity/s/documentation .. _Turbonomic: https://www.turbonomic.com ================================== diff --git a/docs/source/start.rst b/docs/source/start.rst index ca48e50..320ae36 100644 --- a/docs/source/start.rst +++ b/docs/source/start.rst @@ -1,11 +1,11 @@ .. # Links .. _CPython: https://www.python.org/ .. _PyPi: http://pypi.org/ -.. _Requests: https://requests.readthedocs.io/en/master/ +.. _Requests: https://docs.python-requests.org/en/master/ .. _IronPython: http://http://ironpython.net/ .. _GitHub: https://github.com/turbonomic/vmt-connect .. _releases: https://github.com/turbonomic/vmt-connect/releases -.. _Apache 2.0: https://github.com/turbonomic/vmt-connect/blob/master/LICENSE +.. _Apache 2.0: https://www.apache.org/licenses/LICENSE-2.0.txt .. _Turbonomic: https://www.turbonomic.com =============== @@ -63,7 +63,7 @@ However, you may find it more useful to alias the import Source Code =========== -*vmt-connect* is now an official Turbonomic_ Open Source project. The source code +*vmt-connect* is an official Turbonomic_ Open Source project. The source code continues to be hosted on GitHub_. Individual release archives may be found `here`__. @@ -87,8 +87,9 @@ Turbonomic REST API Guides ========================== The following published user guides are available to aid in developing against -the Turbonomic API. Additional resources are availble at https://docs.turbonomic.com/. +the Turbonomic REST API. Additional resources are available on the `Turbonomic Documentation `_ website. + * `XL 8.1.0 `_ * `XL 8.0.1 `_ * `XL 7.22.2 `_ * `Unofficial User Guide `_ for 6.0. @@ -99,4 +100,4 @@ License ======= *vmt-connect* is distributed under the `Apache 2.0`_ software license, which may -also be obtained from the Apache Software Foundation, http://www.apache.org/licenses/LICENSE-2.0 +also be obtained from the Apache Software Foundation, https://www.apache.org/licenses/LICENSE-2.0.txt diff --git a/docs/source/userguide.rst b/docs/source/userguide.rst index 7c28f1a..e15b591 100644 --- a/docs/source/userguide.rst +++ b/docs/source/userguide.rst @@ -1,5 +1,5 @@ .. # Links -.. _API: https://greencircle.vmturbo.com/community/products/pages/documentation +.. _API: https://support-turbonomic.force.com/TurbonomicCustomerCommunity/s/documentation .. _Turbonomic: https://www.turbonomic.com ================ diff --git a/vmtconnect/__init__.py b/vmtconnect/__init__.py index 15a4155..cdaafa0 100644 --- a/vmtconnect/__init__.py +++ b/vmtconnect/__init__.py @@ -657,7 +657,7 @@ class Connection: Each of these override the connection global property, and will be safely ignored if the endpoint does not support, or does not require paging the results. Additionally, you may pass :py:class:`requests.Request` keyword - arguments to each call if required (e.g. `timeout `_). + arguments to each call if required (e.g. `timeout `_). Care should be taken, as some parameters will break *vmt-connect* calls if they conflict with existing headers, or alter expected results. From 69c698a626a1b7cebd6349f5f1f6ccb687ca197b Mon Sep 17 00:00:00 2001 From: "R.A. Stern" Date: Mon, 14 Jun 2021 13:48:45 -0400 Subject: [PATCH 6/6] Bump version for release --- .bumpversion.cfg | 2 +- docs/source/conf.py | 4 ++-- vmtconnect/__about__.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index db87d2c..71fc13a 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 3.6.0.dev0 +current_version = 3.6.0 commit = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z]+)(?P\d*))? serialize = diff --git a/docs/source/conf.py b/docs/source/conf.py index bd849b3..fc66279 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -73,9 +73,9 @@ # built documents. # # The short X.Y version. -version = u'3.6.0.dev0' +version = u'3.6.0' # The full version, including alpha/beta/rc tags. -release = u'3.6.0.dev0' +release = u'3.6.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/vmtconnect/__about__.py b/vmtconnect/__about__.py index 2ede14d..c8dc438 100644 --- a/vmtconnect/__about__.py +++ b/vmtconnect/__about__.py @@ -13,7 +13,7 @@ __title__ = 'vmtconnect' __description__ = 'Turbonomic API Client' -__version__ = '3.6.0.dev0' +__version__ = '3.6.0' __author__ = 'R.A. Stern' __author_email__ = 'richard.stern@turbonomic.com' __license__ = 'Apache 2.0'