Skip to content

Commit 762e8d3

Browse files
Surya Vadan Adivikolanusdiao
authored andcommitted
EMR: Bug fixes:Fixed describe-cluster to support pagination.
1 parent f1eb9b2 commit 762e8d3

4 files changed

Lines changed: 16 additions & 66 deletions

File tree

awscli/customizations/emr/createdefaultroles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _get_regex_match_from_endpoint_host(endpoint_host):
9595

9696
class CreateDefaultRoles(BasicCommand):
9797
NAME = "create-default-roles"
98-
DESCRIPTION = ('Creates the default IAM roles ' +
98+
DESCRIPTION = ('Creates the default IAM role ' +
9999
EC2_ROLE_NAME + ' which can be used when'
100100
' creating the cluster using the create-cluster command.')
101101
ARG_TABLE = [

awscli/customizations/emr/describecluster.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ def _call(self, operation_object, parameters, parsed_globals):
7474
if http_response.status_code == 200:
7575
response_data = page[1]
7676
keys = response_data.keys()
77-
if keys is not None and len(keys) > 0:
78-
key = keys[0]
77+
key = self.get_key_of_result(keys)
78+
if key is not None:
7979
result += response_data.get(key)
80+
8081
if key is not None:
8182
return {key: result}
8283
else:
@@ -86,6 +87,12 @@ def _call(self, operation_object, parameters, parsed_globals):
8687
**parameters)
8788
return response_data
8889

90+
def get_key_of_result(self, keys):
91+
# Return the first key that is not "Marker"
92+
for key in keys:
93+
if key != "Marker":
94+
return key
95+
8996
def construct_result(
9097
self, describe_cluster_result, list_instance_groups_result,
9198
list_bootstrap_actions_result):
Lines changed: 5 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
**1. To create the default IAM roles for EMR and EC2**
1+
**1. To create the default IAM role for EC2**
22

33
- Command::
44

55
aws emr create-default-roles
66

77
- Output::
88

9-
If both the roles already exist then the command returns nothing.
9+
If the role already exists then the command returns nothing.
1010

11-
If only one of the roles does not exist, the command returns the
12-
created 'Role' and the 'RolePolicy'.
13-
14-
If neither of the roles exist then the output will be:
11+
If the role does not exist then the output will be:
1512

1613
[
1714
{
@@ -50,65 +47,11 @@
5047
}
5148
]
5249
},
53-
"RoleId": "AROAJDKUOAL65X57SBWFK",
50+
"RoleId": "AROLORKUOAL65X57SBWFK",
5451
"CreateDate": "2014-05-07T00:02:06.154Z",
5552
"RoleName": "EMR_EC2_DefaultRole",
5653
"Path": "/",
5754
"Arn": "arn:aws:iam::176430881729:role/EMR_EC2_DefaultRole"
5855
}
59-
},
60-
{
61-
"RolePolicy": {
62-
"Version": "2012-10-17",
63-
"Statement": [
64-
{
65-
"Action": [
66-
"ec2:AuthorizeSecurityGroupIngress",
67-
"ec2:CancelSpotInstanceRequests",
68-
"ec2:CreateSecurityGroup",
69-
"ec2:CreateTags",
70-
"ec2:Describe*",
71-
"ec2:DeleteTags",
72-
"ec2:ModifyImageAttribute",
73-
"ec2:ModifyInstanceAttribute",
74-
"ec2:RequestSpotInstances",
75-
"ec2:RunInstances",
76-
"ec2:TerminateInstances",
77-
"iam:PassRole",
78-
"iam:ListRolePolicies",
79-
"iam:GetRole",
80-
"iam:GetRolePolicy",
81-
"iam:ListInstanceProfiles",
82-
"s3:Get*",
83-
"s3:List*",
84-
"s3:CreateBucket",
85-
"sdb:BatchPutAttributes",
86-
"sdb:Select"
87-
],
88-
"Resource": "*",
89-
"Effect": "Allow"
90-
}
91-
]
92-
},
93-
"Role": {
94-
"AssumeRolePolicyDocument": {
95-
"Version": "2008-10-17",
96-
"Statement": [
97-
{
98-
"Action": "sts:AssumeRole",
99-
"Sid": "",
100-
"Effect": "Allow",
101-
"Principal": {
102-
"Service": "elasticmapreduce.amazonaws.com"
103-
}
104-
}
105-
]
106-
},
107-
"RoleId": "AROAJ46UH7B2XLI3RQAS4",
108-
"CreateDate": "2014-05-07T00:02:08.724Z",
109-
"RoleName": "EMR_DefaultRole",
110-
"Path": "/",
111-
"Arn": "arn:aws:iam::176430881729:role/EMR_DefaultRole"
112-
}
11356
}
114-
]
57+
]

tests/unit/customizations/emr/test_emr_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class TestEMRutils(object):
2020

2121
def test_which_with_existing_command(self):
22-
pythonPath = which('python')
22+
pythonPath = which('python') or which('python.exe')
2323
assert_not_equal(pythonPath, None)
2424

2525
def test_which_with_non_existing_command(self):

0 commit comments

Comments
 (0)