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

Improve visualization branch + Feature comparing #50

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
74c794c
Bring Python to 3.9 in Travis
gliptak Oct 31, 2020
1a5e53a
Merge pull request #44 from gliptak/patch-2
JohannesEbke Nov 19, 2020
5ab67b4
-boto3 update and recreate caches
kntrain Nov 23, 2020
976688e
-updated boto3
kntrain Nov 23, 2020
8c300df
Merge pull request #46 from kntrain/boto3-update-1.16.21
JohannesEbke Dec 21, 2020
67defae
-added additional show options
kntrain Jan 7, 2021
faec31c
-moved modifications in resources to filter class
kntrain Jan 7, 2021
889c555
-fixed restructuring issues
kntrain Jan 14, 2021
d7a4a21
-removed call to file-reference filter in listing
kntrain Jan 14, 2021
2f65155
recreate_caches: Only accept "Host not found" as error, also Warn if …
JohannesEbke Jan 21, 2021
6d8fcc7
Upgrade to boto3 1.16.57
JohannesEbke Jan 21, 2021
e4a37de
Add heuristic for new host prefixes and recreate caches
JohannesEbke Jan 21, 2021
173a70b
Fix up tests
JohannesEbke Jan 21, 2021
80c4c8c
Yapf
JohannesEbke Jan 21, 2021
f2d06fc
-renamed Listing -> RawListing
kntrain Jan 25, 2021
65a4788
changed fixing_filters to always apply
kntrain Jan 29, 2021
3199531
- new feature branch for visual improvements
kntrain Mar 1, 2021
a7016d5
- added html search feature
kntrain Mar 2, 2021
06537d5
- fixed changing column width
kntrain Mar 2, 2021
63df2d0
- fixed dynamically changing count number
kntrain Mar 2, 2021
1076f6b
- upgraded html style
kntrain Mar 10, 2021
b5a8b61
- added finish time to html
kntrain Mar 10, 2021
c92bb38
- added handling in case special ops are specified
kntrain Mar 10, 2021
5d120bb
- removed empty line
kntrain Mar 10, 2021
8e40189
- added unfilter options description
kntrain Mar 10, 2021
1ea97ae
Create HTML header and footer
kntrain Mar 15, 2021
a6c788f
Add comparing feature to available commands
kntrain Mar 15, 2021
9753209
Fix dependent ops and show command flags Bugs
kntrain Mar 16, 2021
5855f94
Implement compare command between 2 directories
kntrain Mar 17, 2021
ec3fa8e
Move html related code to generate-html.py
kntrain Mar 19, 2021
4c05e52
Restructure to get resource ID during query
kntrain Mar 25, 2021
aefb2a5
Remove stray comment and unfilter-list conversion
kntrain Mar 25, 2021
3d0565f
Add error-handling to JSON-file dependent function
kntrain Mar 29, 2021
dbe60a7
Adopt suggestions from errorhandle-branch
kntrain Apr 1, 2021
7e2cde7
Fix wrong do_list_files behaviour for errors
kntrain Apr 2, 2021
2055571
Add ResultListing as return Obj of acquire_listing
kntrain Apr 2, 2021
436a66c
Enhance visualization-feature
kntrain Apr 3, 2021
02b15a9
Fix comparing algorithm bug
kntrain Apr 6, 2021
5f4e644
Merge pull request #49 from kntrain/improve-errorhandle
JohannesEbke Apr 13, 2021
e7b75a4
Do minor restrcuturing in main and generate_html
kntrain Apr 15, 2021
5d92c58
Incorporate print-html into new command 'view'
kntrain Apr 18, 2021
320f99e
Incorporate html+compare option into show command
kntrain Apr 21, 2021
7b26c47
Fix html-file save location
kntrain Apr 22, 2021
e5d169f
Change creation and generating of html-content
kntrain May 17, 2021
eec28a0
Merge branch 'master' into feature_comparing
kntrain May 17, 2021
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 .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: python
python:
- "2.7"
- "3.6"
- "3.9"
install:
- pip install flake8 yapf pytest
- python setup.py install
Expand Down
101 changes: 98 additions & 3 deletions aws_list_all/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
from __future__ import print_function

import os
import sys
import webbrowser
from resource import getrlimit, setrlimit, RLIMIT_NOFILE
from argparse import ArgumentParser
from sys import exit, stderr

from .introspection import (
get_listing_operations, get_services, get_verbs, introspect_regions_for_service, recreate_caches
)
from .query import do_list_files, do_query
from .query import show_list_files, do_query, do_consecutive


def increase_limit_nofiles():
Expand Down Expand Up @@ -72,6 +74,12 @@ def main():
action='append',
help='Restrict querying to the given operation (can be specified multiple times)'
)
query.add_argument(
'-u',
'--unfilter',
action='append',
help='Exclude given default-value filter from being applied (can be specified multiple times)'
)
query.add_argument('-p', '--parallel', default=32, type=int, help='Number of request to do in parallel')
query.add_argument('-d', '--directory', default='.', help='Directory to save result listings to')
query.add_argument('-v', '--verbose', action='count', help='Print detailed info during run')
Expand All @@ -83,6 +91,17 @@ def main():
)
show.add_argument('listingfile', nargs='*', help='listing file(s) to load and print')
show.add_argument('-v', '--verbose', action='count', help='print given listing files with detailed info')
show.add_argument('-n', '--not_found', default=False, action='store_true', help='additionally print listing files of resources not found')
show.add_argument('-e', '--errors', default=False, action='store_true', help='additionally print listing files of resources where queries resulted in errors')
show.add_argument('-b', '--denied', default=False, action='store_true', help='additionally print listing files of resources with "missing permission" errors')
show.add_argument('-w', '--html', default='', help='Print and display the results in HTML-file with given name')
show.add_argument('-c', '--cmp', nargs='*', default='.', help='Compare target directory to this and display the results in HTML-file named cmp.html')
show.add_argument(
'-u',
'--unfilter',
action='append',
help='Exclude given default-value filter from being applied (can be specified multiple times)'
)

# Introspection debugging is not the main function. So we put it all into a subcommand.
introspect = subparsers.add_parser(
Expand Down Expand Up @@ -119,6 +138,45 @@ def main():
)
introspecters.add_parser('debug', description='Debug information', help='Debug information')

# Combine the features of query and show and optionally print the findings
# from query to an HTML file to be viewed in a browser
view = subparsers.add_parser(
'view', description='Print a listing to an HTML file to be viewed in a browser',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be clearer about that it is actually querying the data.

help='Create browser view of listing'
)
view.add_argument(
'-s',
'--service',
action='append',
help='Restrict querying to the given service (can be specified multiple times)'
)
view.add_argument(
'-r',
'--region',
action='append',
help='Restrict querying to the given region (can be specified multiple times)'
)
view.add_argument(
'-o',
'--operation',
action='append',
help='Restrict querying to the given operation (can be specified multiple times)'
)
view.add_argument(
'-u',
'--unfilter',
action='append',
help='Exclude given default-value filter from being applied (can be specified multiple times)'
)
view.add_argument('-p', '--parallel', default=32, type=int, help='Number of request to do in parallel')
view.add_argument('-d', '--directory', default='.', help='Directory to save result listings to')
view.add_argument('-v', '--verbose', action='count', help='Print detailed info during run')
view.add_argument('-c', '--profile', help='Use a specific .aws/credentials profile.')
view.add_argument('-n', '--not_found', default=False, action='store_true', help='additionally print listing files of resources not found')
view.add_argument('-e', '--errors', default=False, action='store_true', help='additionally print listing files of resources where queries resulted in errors')
view.add_argument('-b', '--denied', default=False, action='store_true', help='additionally print listing files of resources with "missing permission" errors')
view.add_argument('-w', '--html', default='', help='Print and display the query results inside HTML-file with given name')

# Finally, refreshing the service/region caches comes last.
caches = subparsers.add_parser(
'recreate-caches',
Expand Down Expand Up @@ -156,12 +214,24 @@ def main():
args.operation,
verbose=args.verbose or 0,
parallel=args.parallel,
selected_profile=args.profile
selected_profile=args.profile,
unfilter=args.unfilter
)
elif args.command == 'show':
orig_dir = os.getcwd()
if args.listingfile:
increase_limit_nofiles()
do_list_files(args.listingfile, verbose=args.verbose or 0)
show_list_files(
args.listingfile,
orig_dir,
args.cmp,
args.html,
verbose=args.verbose or 0,
not_found=args.not_found,
errors=args.errors,
denied=args.denied,
unfilter=args.unfilter
)
else:
show.print_help()
return 1
Expand All @@ -183,6 +253,31 @@ def main():
else:
introspect.print_help()
return 1
elif args.command == 'view':
orig_dir = os.getcwd()
if args.directory:
try:
os.makedirs(args.directory)
except OSError:
pass
os.chdir(args.directory)
increase_limit_nofiles()
services = args.service or get_services()
do_consecutive(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be expressed as a sequence of query & view.

services,
orig_dir,
args.directory,
args.html,
args.region,
args.operation,
verbose=args.verbose or 0,
parallel=args.parallel,
selected_profile=args.profile,
unfilter=args.unfilter,
not_found=args.not_found,
errors=args.errors,
denied=args.denied
)
elif args.command == 'recreate-caches':
increase_limit_nofiles()
recreate_caches(args.update_packaged_values)
Expand Down
152 changes: 152 additions & 0 deletions aws_list_all/apply_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import json
import os
import sys

from .fixing_filter import *
from .resource_filter import *

def apply_filters(listing, unfilterList, response, complete):
"""Apply filters for operations to be handled in a special way or
to remove default resources from the response"""
apply_complete = complete

if not('cloudfront' in unfilterList):
filter = CloudfrontFilter()
filter.execute(listing, response)

if not('medialive' in unfilterList):
filter = MedialiveFilter()
filter.execute(listing, response)

if not('ssmListCommands' in unfilterList):
filter = SSMListCommandsFilter()
filter.execute(listing, response)

if not('snsListSubscriptions' in unfilterList):
filter = SNSListSubscriptionsFilter()
filter.execute(listing, response)

if not('athenaWorkGroups' in unfilterList):
filter = AthenaWorkGroupsFilter()
filter.execute(listing, response)

if not('listEventBuses' in unfilterList):
filter = ListEventBusesFilter()
filter.execute(listing, response)

if not('xRayGroups' in unfilterList):
filter = XRayGroupsFilter()
filter.execute(listing, response)

if not('route53Resolver' in unfilterList):
filter = Route53ResolverFilter()
filter.execute(listing, response)

filter = CountFilter(apply_complete)
filter.execute(listing, response)
apply_complete = filter.complete

filter = QuantityFilter(apply_complete)
filter.execute(listing, response)
apply_complete = filter.complete

filter = NeutralThingFilter()
filter.execute(listing, response)

filter = BadThingFilter(apply_complete)
filter.execute(listing, response)
apply_complete = filter.complete

if not('kmsListAliases' in unfilterList):
filter = KMSListAliasesFilter()
filter.execute(listing, response)

if not('appstreamImages' in unfilterList):
filter = AppstreamImagesFilter()
filter.execute(listing, response)

if not('cloudsearch' in unfilterList):
filter = CloudsearchFilter()
filter.execute(listing, response)

if not('cloudTrail' in unfilterList):
filter = CloudTrailFilter()
filter.execute(listing, response)

if not('cloudWatch' in unfilterList):
filter = CloudWatchFilter()
filter.execute(listing, response)

if not('iamPolicies' in unfilterList):
filter = IAMPoliciesFilter()
filter.execute(listing, response)

if not('s3Owner' in unfilterList):
filter = S3OwnerFilter()
filter.execute(listing, response)

if not('ecsClustersFailure' in unfilterList):
filter = ECSClustersFailureFilter()
filter.execute(listing, response)

if not('pinpointGetApps' in unfilterList):
filter = PinpointGetAppsFilter()
filter.execute(listing, response)

if not('ssmBaselines' in unfilterList):
filter = SSMBaselinesFilter()
filter.execute(listing, response)

if not('dbSecurityGroups' in unfilterList):
filter = DBSecurityGroupsFilter()
filter.execute(listing, response)

if not('dbParameterGroups' in unfilterList):
filter = DBParameterGroupsFilter()
filter.execute(listing, response)

if not('dbClusterParameterGroups' in unfilterList):
filter = DBClusterParameterGroupsFilter()
filter.execute(listing, response)

if not('dbOptionGroups' in unfilterList):
filter = DBOptionGroupsFilter()
filter.execute(listing, response)

if not('ec2VPC' in unfilterList):
filter = EC2VPCFilter()
filter.execute(listing, response)

if not('ec2Subnets' in unfilterList):
filter = EC2SubnetsFilter()
filter.execute(listing, response)

if not('ec2SecurityGroups' in unfilterList):
filter = EC2SecurityGroupsFilter()
filter.execute(listing, response)

if not('ec2RouteTables' in unfilterList):
filter = EC2RouteTablesFilter()
filter.execute(listing, response)

if not('ec2NetworkAcls' in unfilterList):
filter = EC2NetworkAclsFilter()
filter.execute(listing, response)

if not('ec2FpgaImages' in unfilterList):
filter = EC2FpgaImagesFilter()
filter.execute(listing, response)

if not('workmailDeletedOrganizations' in unfilterList):
filter = WorkmailDeletedOrganizationsFilter()
filter.execute(listing, response)

if not('elasticacheSubnetGroups' in unfilterList):
filter = ElasticacheSubnetGroupsFilter()
filter.execute(listing, response)

filter = NextTokenFilter(apply_complete)
filter.execute(listing, response)
apply_complete = getattr(filter, 'complete')

return apply_complete
Loading