Skip to content

Commit e0d2942

Browse files
gioiabJon Wayne Parrott
authored and
Jon Wayne Parrott
committed
Properly forwarding the "region" parameter provided as an input argument. (#1029)
1 parent 86e9288 commit e0d2942

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

dataproc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Create local credentials by running the following command and following the oaut
3232

3333
To run list_clusters.py:
3434

35-
python list_clusters.py --project_id=<YOUR-PROJECT-ID> --zone=us-central1-b
35+
python list_clusters.py <YOUR-PROJECT-ID> --region=us-central1
3636

3737

3838
To run create_cluster_and_submit_job, first create a GCS bucket, from the Cloud Console or with

dataproc/list_clusters.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@
1818

1919
import googleapiclient.discovery
2020

21-
# Currently only the "global" region is supported
22-
REGION = 'global'
23-
2421

2522
# [START list_clusters]
26-
def list_clusters(dataproc, project):
23+
def list_clusters(dataproc, project, region):
2724
result = dataproc.projects().regions().clusters().list(
2825
projectId=project,
29-
region=REGION).execute()
26+
region=region).execute()
3027
return result
3128
# [END list_clusters]
3229

@@ -39,9 +36,9 @@ def get_client():
3936
# [END get_client]
4037

4138

42-
def main(project_id, zone):
39+
def main(project_id, region):
4340
dataproc = get_client()
44-
result = list_clusters(dataproc, project_id)
41+
result = list_clusters(dataproc, project_id, region)
4542
print(result)
4643

4744

@@ -52,8 +49,10 @@ def main(project_id, zone):
5249
)
5350
parser.add_argument(
5451
'project_id', help='Project ID you want to access.'),
52+
# Sets the region to "global" if it's not provided
53+
# Note: sub-regions (e.g.: us-central1-a/b) are currently not supported
5554
parser.add_argument(
56-
'zone', help='Region to create clusters in')
55+
'--region', default='global', help='Region to create clusters in')
5756

5857
args = parser.parse_args()
59-
main(args.project_id, args.zone)
58+
main(args.project_id, args.region)

0 commit comments

Comments
 (0)