From acea71f7254a29ba34cdac8d1e62e6aa2e51ce57 Mon Sep 17 00:00:00 2001 From: teramonagi Date: Thu, 10 Sep 2015 09:50:41 +0000 Subject: [PATCH 1/4] Added --profile option to specify names profiles --- ec2/spark_ec2.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ec2/spark_ec2.py b/ec2/spark_ec2.py index 11fd7ee0ec8d..1990007e0477 100755 --- a/ec2/spark_ec2.py +++ b/ec2/spark_ec2.py @@ -177,6 +177,9 @@ def parse_args(): parser.add_option( "-i", "--identity-file", help="SSH private key file to use for logging into instances") + parser.add_option( + "-p", "--profile", default="default", + help=" If you have multiple profiles, you can configure additional, named profiles by using this option (default: %default)") parser.add_option( "-t", "--instance-type", default="m1.large", help="Type of instance to launch (default: %default). " + @@ -1311,7 +1314,10 @@ def real_main(): sys.exit(1) try: - conn = ec2.connect_to_region(opts.region) + if opts.profile != "default": + conn = ec2.connect_to_region(opts.region, profile_name=opts.profile) + else: + conn = ec2.connect_to_region(opts.region) except Exception as e: print((e), file=stderr) sys.exit(1) From a726bc1f04ae173b3e138d620c187c3663d7ae68 Mon Sep 17 00:00:00 2001 From: teramonagi Date: Thu, 10 Sep 2015 21:15:14 +0900 Subject: [PATCH 2/4] Update spark_ec2.py Fixed indent. --- ec2/spark_ec2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ec2/spark_ec2.py b/ec2/spark_ec2.py index 1990007e0477..b54fb5a37e32 100755 --- a/ec2/spark_ec2.py +++ b/ec2/spark_ec2.py @@ -1316,7 +1316,7 @@ def real_main(): try: if opts.profile != "default": conn = ec2.connect_to_region(opts.region, profile_name=opts.profile) - else: + else: conn = ec2.connect_to_region(opts.region) except Exception as e: print((e), file=stderr) From 5b5c56fb70362d55112404fa451bef76b127fa2f Mon Sep 17 00:00:00 2001 From: teramonagi Date: Sat, 17 Oct 2015 17:11:33 +0900 Subject: [PATCH 3/4] Added aws/boto comment --- ec2/spark_ec2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ec2/spark_ec2.py b/ec2/spark_ec2.py index b54fb5a37e32..022dfa22467a 100755 --- a/ec2/spark_ec2.py +++ b/ec2/spark_ec2.py @@ -179,7 +179,7 @@ def parse_args(): help="SSH private key file to use for logging into instances") parser.add_option( "-p", "--profile", default="default", - help=" If you have multiple profiles, you can configure additional, named profiles by using this option (default: %default)") + help=" If you have multiple profiles(aws or boto config), you can configure additional, named profiles by using this option (default: %default)") parser.add_option( "-t", "--instance-type", default="m1.large", help="Type of instance to launch (default: %default). " + From 5152fa4250c8d763864d1f3ba8374cebe022785d Mon Sep 17 00:00:00 2001 From: teramonagi Date: Sun, 18 Oct 2015 09:40:09 +0900 Subject: [PATCH 4/4] Updated the default value for --profile option --- ec2/spark_ec2.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ec2/spark_ec2.py b/ec2/spark_ec2.py index 022dfa22467a..dab8265f2271 100755 --- a/ec2/spark_ec2.py +++ b/ec2/spark_ec2.py @@ -178,8 +178,8 @@ def parse_args(): "-i", "--identity-file", help="SSH private key file to use for logging into instances") parser.add_option( - "-p", "--profile", default="default", - help=" If you have multiple profiles(aws or boto config), you can configure additional, named profiles by using this option (default: %default)") + "-p", "--profile", default=None, + help=" If you have multiple profiles (aws or boto config), you can configure additional, named profiles by using this option (default: None)") parser.add_option( "-t", "--instance-type", default="m1.large", help="Type of instance to launch (default: %default). " + @@ -1314,10 +1314,10 @@ def real_main(): sys.exit(1) try: - if opts.profile != "default": - conn = ec2.connect_to_region(opts.region, profile_name=opts.profile) - else: + if opts.profile is None: conn = ec2.connect_to_region(opts.region) + else: + conn = ec2.connect_to_region(opts.region, profile_name=opts.profile) except Exception as e: print((e), file=stderr) sys.exit(1)