本文整理汇总了Python中misc.Misc.parse_service_columns方法的典型用法代码示例。如果您正苦于以下问题:Python Misc.parse_service_columns方法的具体用法?Python Misc.parse_service_columns怎么用?Python Misc.parse_service_columns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类misc.Misc
的用法示例。
在下文中一共展示了Misc.parse_service_columns方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: report_elb
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import parse_service_columns [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_apigateway
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import parse_service_columns [as 别名]
def report_apigateway(self):
'''
This function is a wrapper for parsing arguments and printing for apigateway attribute reports
:return:
'''
logger.info("Started report generation command")
a = awsrequests(session=self.account_information['session'])
parser = argparse.ArgumentParser(description='report generation about apigateway', usage='''kerrigan.py apigateway report_apigateway [<args>]]
''' + self.global_options, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="kerrigan")
parser.add_argument('--columns', action='store', default=a.service_supported_columns(service="sg").keys(),
help="Which columns to display")
args = parser.parse_args(sys.argv[3:])
columns = Misc.parse_service_columns(service="apigateway", columns=args.columns)
result = a.information_apigateway(columns=columns)
logger.output(data=result, csvvar=self.account_information['logger_arguments']['csv'],
tablevar=self.account_information['logger_arguments']['table'])
示例3: report_ami
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import parse_service_columns [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'])
示例4: test_parse_service_columns_with_services_elb
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import parse_service_columns [as 别名]
def test_parse_service_columns_with_services_elb(self):
columns = ""
keys = Misc.get_supported_columns(service="elb").keys()
self.assertListEqual(keys, Misc.parse_service_columns(service="elb",columns=columns))
示例5: test_parse_service_columns_with_services_cloudformation
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import parse_service_columns [as 别名]
def test_parse_service_columns_with_services_cloudformation(self):
columns = ""
keys = Misc.get_supported_columns(service="cloudformation").keys()
self.assertListEqual(keys, Misc.parse_service_columns(service="cloudformation",columns=columns))
示例6: test_parse_service_columns_all_column
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import parse_service_columns [as 别名]
def test_parse_service_columns_all_column(self):
keys = Misc.ec2_columns.keys()
columns = ",".join(keys)
self.assertListEqual(keys, Misc.parse_service_columns(service="ec2",columns=columns))
示例7: test_parse_service_columns_2_column
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import parse_service_columns [as 别名]
def test_parse_service_columns_2_column(self):
columns = "id,vpc_id,notexist"
keys = ["id", "vpc_id"]
self.assertListEqual(keys, Misc.parse_service_columns(service="ec2",columns=columns))
示例8: test_parse_service_columns_empty
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import parse_service_columns [as 别名]
def test_parse_service_columns_empty(self):
columns = ""
keys = Misc.ec2_columns.keys()
self.assertListEqual(keys, Misc.parse_service_columns(service="ec2",columns=columns))