def __cluster_run(self, cluster_id, command, internal, container_name=None, timeout=None): pool, nodes = self.__get_pool_details(cluster_id) nodes = [node for node in nodes] if internal: cluster_nodes = [(node, models.RemoteLogin(ip_address=node.ip_address, port="22")) for node in nodes] else: cluster_nodes = [ (node, self.__get_remote_login_settings(pool.id, node.id)) for node in nodes ] try: ssh_key = self.__create_user_on_pool('aztk', pool.id, nodes) output = asyncio.get_event_loop().run_until_complete( ssh_lib.clus_exec_command( command, 'aztk', cluster_nodes, ssh_key=ssh_key.exportKey().decode('utf-8'), container_name=container_name, timeout=timeout)) return output except OSError as exc: raise exc finally: self.__delete_user_on_pool('aztk', pool.id, nodes)
def __cluster_run(self, cluster_id, container_name, command): pool, nodes = self.__get_pool_details(cluster_id) nodes = [node for node in nodes] cluster_nodes = [self.__get_remote_login_settings(pool.id, node.id) for node in nodes] try: ssh_key = self.__create_user_on_pool('aztk', pool.id, nodes) asyncio.get_event_loop().run_until_complete(ssh_lib.clus_exec_command(command, container_name, 'aztk', cluster_nodes, ssh_key=ssh_key.exportKey().decode('utf-8'))) except OSError as exc: raise exc finally: self.__delete_user_on_pool('aztk', pool.id, nodes)
def cluster_run(base_operations, cluster_id, command, internal, container_name=None, timeout=None): cluster = base_operations.get(cluster_id) pool, nodes = cluster.pool, list(cluster.nodes) if internal: cluster_nodes = [(node, models.RemoteLogin(ip_address=node.ip_address, port="22")) for node in nodes] else: cluster_nodes = [ (node, base_operations.get_remote_login_settings(pool.id, node.id)) for node in nodes ] try: generated_username, ssh_key = base_operations.generate_user_on_cluster( pool.id, nodes) except batch_error.BatchErrorException as e: raise error.AztkError(helpers.format_batch_exception(e)) try: output = asyncio.get_event_loop().run_until_complete( ssh_lib.clus_exec_command( command, generated_username, cluster_nodes, ssh_key=ssh_key.exportKey().decode("utf-8"), container_name=container_name, timeout=timeout, )) return output except OSError as exc: raise exc finally: base_operations.delete_user_on_cluster(pool.id, nodes, generated_username)