Toggle navigation
Toggle navigation
This project
Loading...
Sign in
서승완
/
kappa
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Mitch Garnaat
2015-06-22 08:52:12 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bbc712edb4582f0cd427b4b322754995db928502
bbc712ed
1 parent
c2bb94b8
Handle paginated results for roles. Fixes #17.
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
kappa/policy.py
kappa/role.py
kappa/policy.py
View file @
bbc712e
...
...
@@ -52,7 +52,7 @@ class Policy(object):
return
self
.
_arn
def
_find_all_policies
(
self
):
# boto3 does not currently do pagination
for ListPolicies
# boto3 does not currently do pagination
# so we have to do it ourselves
policies
=
[]
try
:
...
...
kappa/role.py
View file @
bbc712e
...
...
@@ -59,15 +59,26 @@ class Role(object):
LOG
.
debug
(
'Unable to find ARN for role:
%
s'
,
self
.
name
)
return
self
.
_arn
def
exists
(
self
):
def
_find_all_roles
(
self
):
# boto3 does not currently do pagination
# so we have to do it ourselves
roles
=
[]
try
:
response
=
self
.
_iam_svc
.
list_roles
(
PathPrefix
=
self
.
Path
)
LOG
.
debug
(
response
)
for
role
in
response
[
'Roles'
]:
if
role
[
'RoleName'
]
==
self
.
name
:
return
role
response
=
self
.
_iam_svc
.
list_roles
()
roles
+=
response
[
'Roles'
]
while
response
[
'IsTruncated'
]:
LOG
.
debug
(
'getting another page of roles'
)
response
=
self
.
_iam_svc
.
list_roles
(
Marker
=
response
[
'Marker'
])
roles
+=
response
[
'Roles'
]
except
Exception
:
LOG
.
exception
(
'Error listing roles'
)
return
roles
def
exists
(
self
):
for
role
in
self
.
_find_all_roles
():
if
role
[
'RoleName'
]
==
self
.
name
:
return
role
return
None
def
create
(
self
):
...
...
Please
register
or
login
to post a comment