зеркало из https://github.com/Azure/aztk.git
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:
Родитель
608a3c8408
Коммит
62c7ef2c38
|
@ -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))
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче