本文整理汇总了Python中misc.Misc.format_boto3_filter方法的典型用法代码示例。如果您正苦于以下问题:Python Misc.format_boto3_filter方法的具体用法?Python Misc.format_boto3_filter怎么用?Python Misc.format_boto3_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类misc.Misc
的用法示例。
在下文中一共展示了Misc.format_boto3_filter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: report_elb
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import format_boto3_filter [as 别名]
def report_elb(self):
'''
This function is a wrapper for parsing arguments and printing for elb attribute reports
Tested
:return:
'''
logger.info("Started report generation command")
a = awsrequests(session=self.account_information['session'])
parser = argparse.ArgumentParser(description='report generation about elbs', usage='''kerrigan.py elb report_elb [<args>]]
''' + self.global_options, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="kerrigan")
parser.add_argument('--columns', action='store', default=a.service_supported_columns(service="elb"),
help="Which columns to display")
parser.add_argument('--filters', action='store', default=None,
help="The filters that should be used, example: key1:value1,key2:value2")
args = parser.parse_args(sys.argv[3:])
columns = Misc.parse_service_columns(columns=args.columns, service="elb")
if args.filters:
filters = Misc.format_boto3_filter(filters=args.filters)
else:
filters = None
result = a.information_elbs(columns=columns, filters=filters)
for res in result:
if self.account_information['logger_arguments']['table']:
res['AvailabilityZones'] = Misc.list_to_multiline_string(list=res['AvailabilityZones'])
res['SecurityGroups'] = Misc.list_to_multiline_string(list=res['SecurityGroups'])
res['Instances'] = Misc.list_to_multiline_string(list=res['Instances'])
else:
res['AvailabilityZones'] = Misc.join_list_to_string(list=res['AvailabilityZones'])
res['SecurityGroups'] = Misc.join_list_to_string(list=res['SecurityGroups'])
res['Instances'] = Misc.join_list_to_string(list=res['Instances'])
logger.output(data=result, csvvar=self.account_information['logger_arguments']['csv'],
tablevar=self.account_information['logger_arguments']['table'])
示例2: report_ami
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import format_boto3_filter [as 别名]
def report_ami(self):
'''
This function is a wrapper for parsing arguments and printing for ami attribute reports
:return:
'''
logger.info("Started report generation command")
a = awsrequests(session=self.account_information['session'])
parser = argparse.ArgumentParser(description='report generation about ami', usage='''kerrigan.py ami report_ami [<args>]]
''' + self.global_options, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="kerrigan")
parser.add_argument('--columns', action='store', default=a.service_supported_columns(service="ami").keys(),
help="Which columns to display")
parser.add_argument('--filters', action='store', default=None,
help="The filters that should be used, example: key1:value1,key2:value2")
args = parser.parse_args(sys.argv[3:])
columns = Misc.parse_service_columns(service="ami", columns=args.columns)
if args.filters:
filters = Misc.format_boto3_filter(filters=args.filters)
else:
filters = None
result = a.information_ami(columns=columns, filters=filters)
logger.output(data=result, csvvar=self.account_information['logger_arguments']['csv'],
tablevar=self.account_information['logger_arguments']['table'])
示例3: test_format_boto3_filter_multiple_values
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import format_boto3_filter [as 别名]
def test_format_boto3_filter_multiple_values(self):
filters = "tag-value:test,tag-test:test2"
should_be = [{'Name': 'tag-value', 'Values': ['test']}, {'Name': 'tag-test', 'Values': ['test2']}]
self.assertEqual(should_be, Misc.format_boto3_filter(filters=filters))
示例4: test_format_boto3_filter_invalid_filter
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import format_boto3_filter [as 别名]
def test_format_boto3_filter_invalid_filter(self):
filters = "tag:value:test"
with self.assertRaises(ValueError) as cm:
Misc.format_boto3_filter(filters=filters)
self.assertTrue('too many values to unpack' in cm.exception)
示例5: test_format_boto3_filter
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import format_boto3_filter [as 别名]
def test_format_boto3_filter(self):
filters = "tag-value:test"
should_be = [{'Name': 'tag-value', 'Values': ['test']}]
self.assertEqual(should_be, Misc.format_boto3_filter(filters=filters))