Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly forwarding the "region" parameter provided as an input argument in list_cluster.py #1029

Merged
merged 1 commit into from
Jul 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dataproc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<YOUR-PROJECT-ID> --zone=us-central1-b
python list_clusters.py <YOUR-PROJECT-ID> --region=us-central1


To run create_cluster_and_submit_job, first create a GCS bucket, from the Cloud Console or with
Expand Down
17 changes: 8 additions & 9 deletions dataproc/list_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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)


Expand All @@ -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)