Get ID of a last created cluster: sort clusters

Get ID of a last created cluster: sort clusters
Due to possible order change in list_clusters,
we have to sort clusters before select "last"

Change-Id: I701405e517708ce92568d98c6b6559dcc5c052d7
This commit is contained in:
Alexey Stepanov 2016-09-14 17:27:02 +03:00
parent b5efd14683
commit 0cb33e9c22
1 changed files with 3 additions and 1 deletions

View File

@ -1108,7 +1108,9 @@ class FuelWebClient29(object):
logger.info('Get ID of a last created cluster')
clusters = self.client.list_clusters()
if len(clusters) > 0:
return clusters.pop()['id']
return sorted(
clusters, key=lambda cluster: cluster['id']
).pop()['id']
return None
@logwrap