Example #1
0
 def __cluster_copy(self,
                    cluster_id,
                    source_path,
                    destination_path,
                    container_name=None,
                    internal=False,
                    get=False,
                    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_copy(container_name=container_name,
                               username='******',
                               nodes=cluster_nodes,
                               source_path=source_path,
                               destination_path=destination_path,
                               ssh_key=ssh_key.exportKey().decode('utf-8'),
                               get=get,
                               timeout=timeout))
         return output
     except (OSError, batch_error.BatchErrorException) as exc:
         raise exc
     finally:
         self.__delete_user_on_pool('aztk', pool.id, nodes)
Example #2
0
 def __cluster_copy(self, cluster_id, container_name, source_path, destination_path):
     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_copy(container_name=container_name,
                                                                       username='******',
                                                                       nodes=cluster_nodes,
                                                                       source_path=source_path,
                                                                       destination_path=destination_path,
                                                                       ssh_key=ssh_key.exportKey().decode('utf-8')))
         self.__delete_user_on_pool('aztk', pool.id, nodes)
     except (OSError, batch_error.BatchErrorException) as exc:
         raise exc
Example #3
0
def cluster_copy(
    cluster_operations,
    cluster_id,
    source_path,
    destination_path=None,
    container_name=None,
    internal=False,
    get=False,
    timeout=None,
):
    cluster = cluster_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,
             cluster_operations.get_remote_login_settings(pool.id, node.id))
            for node in nodes
        ]

    try:
        generated_username, ssh_key = cluster_operations.generate_user_on_cluster(
            pool.id, nodes)
    except BatchErrorException as e:
        raise error.AztkError(helpers.format_batch_exception(e))

    try:
        output = asyncio.get_event_loop().run_until_complete(
            ssh_lib.clus_copy(
                container_name=container_name,
                username=generated_username,
                nodes=cluster_nodes,
                source_path=source_path,
                destination_path=destination_path,
                ssh_key=ssh_key.exportKey().decode("utf-8"),
                get=get,
                timeout=timeout,
            ))
        return output
    except (OSError, BatchErrorException) as exc:
        raise exc
    finally:
        cluster_operations.delete_user_on_cluster(pool.id, nodes,
                                                  generated_username)