Bug: only show clusters created with aztk in list (#200)

* only show clusters created with aztk in list

* check the full metadata key value pair and cleanup code
This commit is contained in:
Jacob Freck 2017-11-02 12:48:29 -07:00 коммит произвёл GitHub
Родитель 608a3c8408
Коммит 62c7ef2c38
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -116,13 +116,18 @@ class Client:
nodes = self.batch_client.compute_node.list(pool_id=cluster_id)
return pool, nodes
def __list_clusters(self):
def __list_clusters(self, software_metadata_key):
"""
List all the cluster on your account.
"""
pools = self.batch_client.pool.list()
return [pool for pool in pools]
software_metadata = (constants.AZTK_SOFTWARE_METADATA_KEY, software_metadata_key)
aztk_pools = []
for pool in [pool for pool in pools if pool.metadata]:
if software_metadata in [(metadata.name, metadata.value) for metadata in pool.metadata]:
aztk_pools.append(pool)
return aztk_pools
def __create_user(self, pool_id: str, node_id: str, username: str, password: str = None, ssh_key: str = None) -> str:
"""

Просмотреть файл

@ -1,5 +1,6 @@
from typing import List
import azure.batch.models.batch_error as batch_error
import aztk_sdk
from aztk_sdk import error
from aztk_sdk.client import Client as BaseClient
from aztk_sdk.spark import models
@ -61,7 +62,7 @@ class Client(BaseClient):
def list_clusters(self):
try:
return [models.Cluster(pool) for pool in self.__list_clusters()]
return [models.Cluster(pool) for pool in self.__list_clusters(aztk_sdk.models.Software.spark)]
except batch_error.BatchErrorException as e:
raise error.AztkError(helpers.format_batch_exception(e))