diff --git a/dataproc/README.md b/dataproc/README.md index 8cbb3f6879c0..6f0a0390e2a9 100644 --- a/dataproc/README.md +++ b/dataproc/README.md @@ -32,7 +32,7 @@ Create local credentials by running the following command and following the oaut To run list_clusters.py: - python list_clusters.py --project_id= --zone=us-central1-b + python list_clusters.py --region=us-central1 To run create_cluster_and_submit_job, first create a GCS bucket, from the Cloud Console or with diff --git a/dataproc/list_clusters.py b/dataproc/list_clusters.py index 89cf0c340fbd..14a2ba8176c3 100644 --- a/dataproc/list_clusters.py +++ b/dataproc/list_clusters.py @@ -18,15 +18,12 @@ import googleapiclient.discovery -# Currently only the "global" region is supported -REGION = 'global' - # [START list_clusters] -def list_clusters(dataproc, project): +def list_clusters(dataproc, project, region): result = dataproc.projects().regions().clusters().list( projectId=project, - region=REGION).execute() + region=region).execute() return result # [END list_clusters] @@ -39,9 +36,9 @@ def get_client(): # [END get_client] -def main(project_id, zone): +def main(project_id, region): dataproc = get_client() - result = list_clusters(dataproc, project_id) + result = list_clusters(dataproc, project_id, region) print(result) @@ -52,8 +49,10 @@ def main(project_id, zone): ) parser.add_argument( 'project_id', help='Project ID you want to access.'), + # Sets the region to "global" if it's not provided + # Note: sub-regions (e.g.: us-central1-a/b) are currently not supported parser.add_argument( - 'zone', help='Region to create clusters in') + '--region', default='global', help='Region to create clusters in') args = parser.parse_args() - main(args.project_id, args.zone) + main(args.project_id, args.region)