def returnClusterStartTaskIfExists(request): persistManager = request.state.persistManager try: cluster = yield persistManager.loadCluster( request.body['cluster_name'], request.body['user_name']) if cluster.state in [cluster.TERMINATED, cluster.FAILED]: defer.returnValue(request) else: request.body['task_name'] = cluster.startTask defer_pipe.emit(request.update(response=cluster.startTask)) except persist.ClusterNotFoundError: defer.returnValue(request)
def returnClusterStartTaskIfExists(request): persistManager = request.state.persistManager try: cluster = yield persistManager.loadCluster(request.body['cluster_name'], request.body['user_name']) if cluster.state in [cluster.TERMINATED, cluster.FAILED]: defer.returnValue(request) else: request.body['task_name'] = cluster.startTask defer_pipe.emit(request.update(response=cluster.startTask)) except persist.ClusterNotFoundError: defer.returnValue(request)
def _(request): if request.body['cluster'] == 'local': defer.returnValue(request) else: clusters = yield clusters_client.listClusters({'cluster_name': request.body['cluster']}, request.body['user_name']) cluster = clusters[0] ret = yield http.performQuery(cluster['master']['public_dns'], url, func.updateDict(request.body, {'cluster': 'local'}), timeout=10, tries=3) defer_pipe.emit(request.update(response=ret))
def _(request): if request.body['cluster'] == 'local': defer.returnValue(request) else: clusters = yield clusters_client.listClusters( {'cluster_name': request.body['cluster']}, request.body['user_name']) cluster = clusters[0] ret = yield http.performQuery(cluster['master']['public_dns'], url, func.updateDict( request.body, {'cluster': 'local'}), timeout=10, tries=3) defer_pipe.emit(request.update(response=ret))
def returnClusterImportTaskIfExists(request): """Returns the task name of the import cluster operation if it exists already. """ persistManager = request.state.persistManager try: cluster = yield persistManager.loadCluster(request.body['dst_cluster'], request.body['user_name']) if cluster.state in [cluster.TERMINATED, cluster.FAILED]: defer.returnValue(request) else: # We won't really have an importTask attribute here but will # instead lump the task name under the startTask attribute request.body['task_name'] = cluster.startTask defer_pipe.emit(request.update(response=cluster.startTask)) except persist.ClusterNotFoundError: defer.returnValue(request)