def perform_profile_operations(self, namespace):
'''
Handle the profile operations
'''
awsconfig = aws_config.AwsConfig()
profiles = awsconfig.get_profiles()
profile_summary = {}
for profile in profiles:
profile_summary[profile] = {}
profile_summary[profile]['access_key_id'] = \
awsconfig.get_aws_access_key_id(profile)
profile_summary[profile]['secret_access_key'] = \
awsconfig.get_aws_secret_access_key(profile)
if namespace.output == "json":
pprinter = pprint.PrettyPrinter()
pprinter.pprint(profile_summary)
else:
# Setup table.
header = ["Profile Name", "Access Key ID", "Secret Access Key"]
table = prettytable.PrettyTable(header)
for profile in profile_summary.keys():
row = [profile,
profile_summary[profile]['access_key_id'],
profile_summary[profile]['secret_access_key']]
table.add_row(row)
print table
评论列表
文章目录