本文整理匯總了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))