Skip to content

Commit 1ac31da

Browse files
committed
Resolved issue payload dict config with prism.Config.*_categories and prism.Config.*_projects
1 parent 9a1de8d commit 1ac31da

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ A log of changes by version and date.
77
:header: "Version", "Date", "Notes"
88
:widths: 10, 10, 60
99

10+
"1.1.18", "3/26/2021", "Resolved issue payload dict config with prism.Config.*_categories and prism.Config.*_projects"
1011
"1.1.17", "3/26/2021", "Resolved issue with the returned value from prism.Cluster.get"
1112
"1.1.16", "3/26/2021", "Changed version import in __init.py__ to be absolute. Modified Vm.get to allow for conditional return of both VM disks and VM nics."
1213
"1.1.15", "3/25/2021", "Fixed inconsistency between master& develop branches"

ntnx_api/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# 2) we can import it in setup.py for the same reason
44
# 3) we can import it into your module module
55

6-
__version_info__ = ('1', '1', '17')
6+
__version_info__ = ('1', '1', '18')
77
__version__ = '.'.join(__version_info__)

ntnx_api/prism.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ def get_categories(self):
164164

165165
if self.api_client.connection_type == "pc":
166166
uri = '/categories/list'
167-
payload = '{ "kind":"category", "offset": 0, "length": 2147483647 }'
167+
payload = {
168+
"kind": "category",
169+
"offset": 0,
170+
"length": 2147483647
171+
}
168172
self.categories = self.api_client.request(uri=uri, payload=payload, params=params).get(
169173
'entities')
170174

@@ -187,7 +191,11 @@ def get_category_keys(self, category):
187191

188192
if self.api_client.connection_type == "pc":
189193
uri = '/categories/{0}/list'.format(category)
190-
payload = '{ "kind":"category", "offset": 0, "length": 2147483647 }'
194+
payload = {
195+
"kind": "category",
196+
"offset": 0,
197+
"length": 2147483647
198+
}
191199
self.category_keys = self.api_client.request(uri=uri, payload=payload, params=params).get(
192200
'entities')
193201

@@ -254,7 +262,11 @@ def get_projects(self):
254262

255263
if self.api_client == "pc":
256264
uri = '/projects/list'
257-
payload = '{ "kind":"project", "offset": 0, "length": 2147483647 }'
265+
payload = {
266+
"kind": "project",
267+
"offset": 0,
268+
"length": 2147483647
269+
}
258270
self.projects = self.api_client.request(uri=uri, payload=payload, params=params).get(
259271
'entities')
260272

@@ -278,7 +290,11 @@ def get_project_usage(self, project_name):
278290

279291
if self.api_client == "pc":
280292
uri = '/vms/list'
281-
payload = '{"kind": "vm", "offset": 0, "length": 2147483647 }'
293+
payload = {
294+
"kind": "vm",
295+
"offset": 0,
296+
"length": 2147483647
297+
}
282298
vms = self.api_client.request(uri=uri, payload=payload, params=params)
283299

284300
for vm in vms:
@@ -2316,17 +2332,20 @@ def get(self, clusteruuid=None, refresh=False):
23162332

23172333
# Remove existing data for this cluster if it exists
23182334
if refresh:
2335+
logger.info('refresh selected')
23192336
if self.cluster.get(clusteruuid):
23202337
self.cluster.pop(clusteruuid)
23212338
logger.info('removing existing data from class dict cluster for cluster {0}'.format(clusteruuid))
23222339
result = self.api_client.request(uri=uri, api_version='v2.0', payload=payload, params=params)
23232340
self.cluster[clusteruuid] = result
23242341

23252342
elif not self.cluster.get(clusteruuid):
2343+
logger.info('no existing data. getting cluster data from api.')
23262344
result = self.api_client.request(uri=uri, api_version='v2.0', payload=payload, params=params)
23272345
self.cluster[clusteruuid] = result
23282346

23292347
else:
2348+
logger.info('using existing data')
23302349
result = self.cluster.get(clusteruuid)
23312350

23322351
return result

0 commit comments

Comments
 (0)