repo stringlengths 7 54 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 20 28.4k | docstring stringlengths 1 46.3k | docstring_tokens listlengths 1 1.66k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value | summary stringlengths 4 350 | obf_code stringlengths 7.85k 764k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cloud-custodian/cloud-custodian | c7n/resources/vpc.py | SGPermission.expand_permissions | def expand_permissions(self, permissions):
"""Expand each list of cidr, prefix list, user id group pair
by port/protocol as an individual rule.
The console ux automatically expands them out as addition/removal is
per this expansion, the describe calls automatically group them.
"... | python | def expand_permissions(self, permissions):
"""Expand each list of cidr, prefix list, user id group pair
by port/protocol as an individual rule.
The console ux automatically expands them out as addition/removal is
per this expansion, the describe calls automatically group them.
"... | [
"def",
"expand_permissions",
"(",
"self",
",",
"permissions",
")",
":",
"for",
"p",
"in",
"permissions",
":",
"np",
"=",
"dict",
"(",
"p",
")",
"values",
"=",
"{",
"}",
"for",
"k",
"in",
"(",
"u'IpRanges'",
",",
"u'Ipv6Ranges'",
",",
"u'PrefixListIds'",
... | Expand each list of cidr, prefix list, user id group pair
by port/protocol as an individual rule.
The console ux automatically expands them out as addition/removal is
per this expansion, the describe calls automatically group them. | [
"Expand",
"each",
"list",
"of",
"cidr",
"prefix",
"list",
"user",
"id",
"group",
"pair",
"by",
"port",
"/",
"protocol",
"as",
"an",
"individual",
"rule",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/vpc.py#L1088-L1110 | train | Expand each list of cidr prefix list user id group pair
by port or protocol as an individual rule. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/reports/csvout.py | report | def report(policies, start_date, options, output_fh, raw_output_fh=None):
"""Format a policy's extant records into a report."""
regions = set([p.options.region for p in policies])
policy_names = set([p.name for p in policies])
formatter = Formatter(
policies[0].resource_manager.resource_type,
... | python | def report(policies, start_date, options, output_fh, raw_output_fh=None):
"""Format a policy's extant records into a report."""
regions = set([p.options.region for p in policies])
policy_names = set([p.name for p in policies])
formatter = Formatter(
policies[0].resource_manager.resource_type,
... | [
"def",
"report",
"(",
"policies",
",",
"start_date",
",",
"options",
",",
"output_fh",
",",
"raw_output_fh",
"=",
"None",
")",
":",
"regions",
"=",
"set",
"(",
"[",
"p",
".",
"options",
".",
"region",
"for",
"p",
"in",
"policies",
"]",
")",
"policy_nam... | Format a policy's extant records into a report. | [
"Format",
"a",
"policy",
"s",
"extant",
"records",
"into",
"a",
"report",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/reports/csvout.py#L66-L112 | train | Format a list of policies into a single report. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/reports/csvout.py | record_set | def record_set(session_factory, bucket, key_prefix, start_date, specify_hour=False):
"""Retrieve all s3 records for the given policy output url
From the given start date.
"""
s3 = local_session(session_factory).client('s3')
records = []
key_count = 0
date = start_date.strftime('%Y/%m/%d'... | python | def record_set(session_factory, bucket, key_prefix, start_date, specify_hour=False):
"""Retrieve all s3 records for the given policy output url
From the given start date.
"""
s3 = local_session(session_factory).client('s3')
records = []
key_count = 0
date = start_date.strftime('%Y/%m/%d'... | [
"def",
"record_set",
"(",
"session_factory",
",",
"bucket",
",",
"key_prefix",
",",
"start_date",
",",
"specify_hour",
"=",
"False",
")",
":",
"s3",
"=",
"local_session",
"(",
"session_factory",
")",
".",
"client",
"(",
"'s3'",
")",
"records",
"=",
"[",
"]... | Retrieve all s3 records for the given policy output url
From the given start date. | [
"Retrieve",
"all",
"s3",
"records",
"for",
"the",
"given",
"policy",
"output",
"url"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/reports/csvout.py#L238-L278 | train | Retrieve all s3 records for the given policy output url | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/reports/csvout.py | Formatter.uniq_by_id | def uniq_by_id(self, records):
"""Only the first record for each id"""
uniq = []
keys = set()
for rec in records:
rec_id = rec[self._id_field]
if rec_id not in keys:
uniq.append(rec)
keys.add(rec_id)
return uniq | python | def uniq_by_id(self, records):
"""Only the first record for each id"""
uniq = []
keys = set()
for rec in records:
rec_id = rec[self._id_field]
if rec_id not in keys:
uniq.append(rec)
keys.add(rec_id)
return uniq | [
"def",
"uniq_by_id",
"(",
"self",
",",
"records",
")",
":",
"uniq",
"=",
"[",
"]",
"keys",
"=",
"set",
"(",
")",
"for",
"rec",
"in",
"records",
":",
"rec_id",
"=",
"rec",
"[",
"self",
".",
"_id_field",
"]",
"if",
"rec_id",
"not",
"in",
"keys",
":... | Only the first record for each id | [
"Only",
"the",
"first",
"record",
"for",
"each",
"id"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/reports/csvout.py#L192-L201 | train | Only the first record for each id | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/ops/org-pr-monitor.py | run | def run(organization, hook_context, github_url, github_token,
verbose, metrics=False, since=None, assume=None, region=None):
"""scan org repo status hooks"""
logging.basicConfig(level=logging.DEBUG)
since = dateparser.parse(
since, settings={
'RETURN_AS_TIMEZONE_AWARE': True, 'T... | python | def run(organization, hook_context, github_url, github_token,
verbose, metrics=False, since=None, assume=None, region=None):
"""scan org repo status hooks"""
logging.basicConfig(level=logging.DEBUG)
since = dateparser.parse(
since, settings={
'RETURN_AS_TIMEZONE_AWARE': True, 'T... | [
"def",
"run",
"(",
"organization",
",",
"hook_context",
",",
"github_url",
",",
"github_token",
",",
"verbose",
",",
"metrics",
"=",
"False",
",",
"since",
"=",
"None",
",",
"assume",
"=",
"None",
",",
"region",
"=",
"None",
")",
":",
"logging",
".",
"... | scan org repo status hooks | [
"scan",
"org",
"repo",
"status",
"hooks"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/ops/org-pr-monitor.py#L143-L201 | train | run org repo status hooks | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/actions/notify.py | BaseNotify.expand_variables | def expand_variables(self, message):
"""expand any variables in the action to_from/cc_from fields.
"""
p = copy.deepcopy(self.data)
if 'to_from' in self.data:
to_from = self.data['to_from'].copy()
to_from['url'] = to_from['url'].format(**message)
if 'e... | python | def expand_variables(self, message):
"""expand any variables in the action to_from/cc_from fields.
"""
p = copy.deepcopy(self.data)
if 'to_from' in self.data:
to_from = self.data['to_from'].copy()
to_from['url'] = to_from['url'].format(**message)
if 'e... | [
"def",
"expand_variables",
"(",
"self",
",",
"message",
")",
":",
"p",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"data",
")",
"if",
"'to_from'",
"in",
"self",
".",
"data",
":",
"to_from",
"=",
"self",
".",
"data",
"[",
"'to_from'",
"]",
".",
... | expand any variables in the action to_from/cc_from fields. | [
"expand",
"any",
"variables",
"in",
"the",
"action",
"to_from",
"/",
"cc_from",
"fields",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/actions/notify.py#L30-L46 | train | expand any variables in the action to_from or cc_from fields. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/actions/notify.py | Notify.prepare_resources | def prepare_resources(self, resources):
"""Resources preparation for transport.
If we have sensitive or overly large resource metadata we want to
remove or additional serialization we need to perform, this
provides a mechanism.
TODO: consider alternative implementations, at min... | python | def prepare_resources(self, resources):
"""Resources preparation for transport.
If we have sensitive or overly large resource metadata we want to
remove or additional serialization we need to perform, this
provides a mechanism.
TODO: consider alternative implementations, at min... | [
"def",
"prepare_resources",
"(",
"self",
",",
"resources",
")",
":",
"handler",
"=",
"getattr",
"(",
"self",
",",
"\"prepare_%s\"",
"%",
"(",
"self",
".",
"manager",
".",
"type",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
")",
",",
"None",
")",
"if... | Resources preparation for transport.
If we have sensitive or overly large resource metadata we want to
remove or additional serialization we need to perform, this
provides a mechanism.
TODO: consider alternative implementations, at min look at adding
provider as additional disc... | [
"Resources",
"preparation",
"for",
"transport",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/actions/notify.py#L191-L208 | train | Prepare resources for transport.
. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | validate | def validate(config):
"""validate config file"""
with open(config) as fh:
content = fh.read()
try:
data = yaml.safe_load(content)
except Exception:
log.error("config file: %s is not valid yaml", config)
raise
try:
jsonschema.validate(data, CONFIG_SCHEMA)
... | python | def validate(config):
"""validate config file"""
with open(config) as fh:
content = fh.read()
try:
data = yaml.safe_load(content)
except Exception:
log.error("config file: %s is not valid yaml", config)
raise
try:
jsonschema.validate(data, CONFIG_SCHEMA)
... | [
"def",
"validate",
"(",
"config",
")",
":",
"with",
"open",
"(",
"config",
")",
"as",
"fh",
":",
"content",
"=",
"fh",
".",
"read",
"(",
")",
"try",
":",
"data",
"=",
"yaml",
".",
"safe_load",
"(",
"content",
")",
"except",
"Exception",
":",
"log",... | validate config file | [
"validate",
"config",
"file"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L124-L142 | train | validate config file | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | subscribe | def subscribe(config, accounts, region, merge, debug):
"""subscribe accounts log groups to target account log group destination"""
config = validate.callback(config)
subscription = config.get('subscription')
if subscription is None:
log.error("config file: logs subscription missing")
sy... | python | def subscribe(config, accounts, region, merge, debug):
"""subscribe accounts log groups to target account log group destination"""
config = validate.callback(config)
subscription = config.get('subscription')
if subscription is None:
log.error("config file: logs subscription missing")
sy... | [
"def",
"subscribe",
"(",
"config",
",",
"accounts",
",",
"region",
",",
"merge",
",",
"debug",
")",
":",
"config",
"=",
"validate",
".",
"callback",
"(",
"config",
")",
"subscription",
"=",
"config",
".",
"get",
"(",
"'subscription'",
")",
"if",
"subscri... | subscribe accounts log groups to target account log group destination | [
"subscribe",
"accounts",
"log",
"groups",
"to",
"target",
"account",
"log",
"group",
"destination"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L171-L251 | train | subscribe accounts log groups to target account log group destination | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | run | def run(config, start, end, accounts, region, debug):
"""run export across accounts and log groups specified in config."""
config = validate.callback(config)
destination = config.get('destination')
start = start and parse(start) or start
end = end and parse(end) or datetime.now()
executor = debu... | python | def run(config, start, end, accounts, region, debug):
"""run export across accounts and log groups specified in config."""
config = validate.callback(config)
destination = config.get('destination')
start = start and parse(start) or start
end = end and parse(end) or datetime.now()
executor = debu... | [
"def",
"run",
"(",
"config",
",",
"start",
",",
"end",
",",
"accounts",
",",
"region",
",",
"debug",
")",
":",
"config",
"=",
"validate",
".",
"callback",
"(",
"config",
")",
"destination",
"=",
"config",
".",
"get",
"(",
"'destination'",
")",
"start",... | run export across accounts and log groups specified in config. | [
"run",
"export",
"across",
"accounts",
"and",
"log",
"groups",
"specified",
"in",
"config",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L261-L281 | train | run export across accounts and log groups specified in config | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | lambdafan | def lambdafan(func):
"""simple decorator that will auto fan out async style in lambda.
outside of lambda, this will invoke synchrously.
"""
if 'AWS_LAMBDA_FUNCTION_NAME' not in os.environ:
return func
@functools.wraps(func)
def scaleout(*args, **kw):
client = boto3.client('lamb... | python | def lambdafan(func):
"""simple decorator that will auto fan out async style in lambda.
outside of lambda, this will invoke synchrously.
"""
if 'AWS_LAMBDA_FUNCTION_NAME' not in os.environ:
return func
@functools.wraps(func)
def scaleout(*args, **kw):
client = boto3.client('lamb... | [
"def",
"lambdafan",
"(",
"func",
")",
":",
"if",
"'AWS_LAMBDA_FUNCTION_NAME'",
"not",
"in",
"os",
".",
"environ",
":",
"return",
"func",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"scaleout",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
... | simple decorator that will auto fan out async style in lambda.
outside of lambda, this will invoke synchrously. | [
"simple",
"decorator",
"that",
"will",
"auto",
"fan",
"out",
"async",
"style",
"in",
"lambda",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L284-L304 | train | simple decorator that will auto fan out async style in lambda. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | filter_group_names | def filter_group_names(groups, patterns):
"""Filter log groups by shell patterns.
"""
group_names = [g['logGroupName'] for g in groups]
matched = set()
for p in patterns:
matched.update(fnmatch.filter(group_names, p))
return [g for g in groups if g['logGroupName'] in matched] | python | def filter_group_names(groups, patterns):
"""Filter log groups by shell patterns.
"""
group_names = [g['logGroupName'] for g in groups]
matched = set()
for p in patterns:
matched.update(fnmatch.filter(group_names, p))
return [g for g in groups if g['logGroupName'] in matched] | [
"def",
"filter_group_names",
"(",
"groups",
",",
"patterns",
")",
":",
"group_names",
"=",
"[",
"g",
"[",
"'logGroupName'",
"]",
"for",
"g",
"in",
"groups",
"]",
"matched",
"=",
"set",
"(",
")",
"for",
"p",
"in",
"patterns",
":",
"matched",
".",
"updat... | Filter log groups by shell patterns. | [
"Filter",
"log",
"groups",
"by",
"shell",
"patterns",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L362-L369 | train | Filter log groups by shell patterns. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | filter_creation_date | def filter_creation_date(groups, start, end):
"""Filter log groups by their creation date.
Also sets group specific value for start to the minimum
of creation date or start.
"""
results = []
for g in groups:
created = datetime.fromtimestamp(g['creationTime'] / 1000.0)
if created... | python | def filter_creation_date(groups, start, end):
"""Filter log groups by their creation date.
Also sets group specific value for start to the minimum
of creation date or start.
"""
results = []
for g in groups:
created = datetime.fromtimestamp(g['creationTime'] / 1000.0)
if created... | [
"def",
"filter_creation_date",
"(",
"groups",
",",
"start",
",",
"end",
")",
":",
"results",
"=",
"[",
"]",
"for",
"g",
"in",
"groups",
":",
"created",
"=",
"datetime",
".",
"fromtimestamp",
"(",
"g",
"[",
"'creationTime'",
"]",
"/",
"1000.0",
")",
"if... | Filter log groups by their creation date.
Also sets group specific value for start to the minimum
of creation date or start. | [
"Filter",
"log",
"groups",
"by",
"their",
"creation",
"date",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L372-L388 | train | Filter log groups by their creation date. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | filter_last_write | def filter_last_write(client, groups, start):
"""Filter log groups where the last write was before the start date.
"""
retry = get_retry(('ThrottlingException',))
def process_group(group_set):
matched = []
for g in group_set:
streams = retry(
client.describe_... | python | def filter_last_write(client, groups, start):
"""Filter log groups where the last write was before the start date.
"""
retry = get_retry(('ThrottlingException',))
def process_group(group_set):
matched = []
for g in group_set:
streams = retry(
client.describe_... | [
"def",
"filter_last_write",
"(",
"client",
",",
"groups",
",",
"start",
")",
":",
"retry",
"=",
"get_retry",
"(",
"(",
"'ThrottlingException'",
",",
")",
")",
"def",
"process_group",
"(",
"group_set",
")",
":",
"matched",
"=",
"[",
"]",
"for",
"g",
"in",... | Filter log groups where the last write was before the start date. | [
"Filter",
"log",
"groups",
"where",
"the",
"last",
"write",
"was",
"before",
"the",
"start",
"date",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L391-L430 | train | Filter log groups where the last write was before the start date. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | filter_extant_exports | def filter_extant_exports(client, bucket, prefix, days, start, end=None):
"""Filter days where the bucket already has extant export keys.
"""
end = end or datetime.now()
# days = [start + timedelta(i) for i in range((end-start).days)]
try:
tag_set = client.get_object_tagging(Bucket=bucket, K... | python | def filter_extant_exports(client, bucket, prefix, days, start, end=None):
"""Filter days where the bucket already has extant export keys.
"""
end = end or datetime.now()
# days = [start + timedelta(i) for i in range((end-start).days)]
try:
tag_set = client.get_object_tagging(Bucket=bucket, K... | [
"def",
"filter_extant_exports",
"(",
"client",
",",
"bucket",
",",
"prefix",
",",
"days",
",",
"start",
",",
"end",
"=",
"None",
")",
":",
"end",
"=",
"end",
"or",
"datetime",
".",
"now",
"(",
")",
"# days = [start + timedelta(i) for i in range((end-start).days)... | Filter days where the bucket already has extant export keys. | [
"Filter",
"days",
"where",
"the",
"bucket",
"already",
"has",
"extant",
"export",
"keys",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L433-L451 | train | Filter days where the bucket already has extant export keys. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | access | def access(config, region, accounts=()):
"""Check iam permissions for log export access in each account"""
config = validate.callback(config)
accounts_report = []
def check_access(account):
accounts_report.append(account)
session = get_session(account['role'], region)
identity =... | python | def access(config, region, accounts=()):
"""Check iam permissions for log export access in each account"""
config = validate.callback(config)
accounts_report = []
def check_access(account):
accounts_report.append(account)
session = get_session(account['role'], region)
identity =... | [
"def",
"access",
"(",
"config",
",",
"region",
",",
"accounts",
"=",
"(",
")",
")",
":",
"config",
"=",
"validate",
".",
"callback",
"(",
"config",
")",
"accounts_report",
"=",
"[",
"]",
"def",
"check_access",
"(",
"account",
")",
":",
"accounts_report",... | Check iam permissions for log export access in each account | [
"Check",
"iam",
"permissions",
"for",
"log",
"export",
"access",
"in",
"each",
"account"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L458-L492 | train | Check iam permissions for log export access in each account | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | size | def size(config, accounts=(), day=None, group=None, human=True, region=None):
"""size of exported records for a given day."""
config = validate.callback(config)
destination = config.get('destination')
client = boto3.Session().client('s3')
day = parse(day)
def export_size(client, account):
... | python | def size(config, accounts=(), day=None, group=None, human=True, region=None):
"""size of exported records for a given day."""
config = validate.callback(config)
destination = config.get('destination')
client = boto3.Session().client('s3')
day = parse(day)
def export_size(client, account):
... | [
"def",
"size",
"(",
"config",
",",
"accounts",
"=",
"(",
")",
",",
"day",
"=",
"None",
",",
"group",
"=",
"None",
",",
"human",
"=",
"True",
",",
"region",
"=",
"None",
")",
":",
"config",
"=",
"validate",
".",
"callback",
"(",
"config",
")",
"de... | size of exported records for a given day. | [
"size",
"of",
"exported",
"records",
"for",
"a",
"given",
"day",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L514-L563 | train | Returns a list of exported records for a given day. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | sync | def sync(config, group, accounts=(), dryrun=False, region=None):
"""sync last recorded export to actual
Use --dryrun to check status.
"""
config = validate.callback(config)
destination = config.get('destination')
client = boto3.Session().client('s3')
for account in config.get('accounts', (... | python | def sync(config, group, accounts=(), dryrun=False, region=None):
"""sync last recorded export to actual
Use --dryrun to check status.
"""
config = validate.callback(config)
destination = config.get('destination')
client = boto3.Session().client('s3')
for account in config.get('accounts', (... | [
"def",
"sync",
"(",
"config",
",",
"group",
",",
"accounts",
"=",
"(",
")",
",",
"dryrun",
"=",
"False",
",",
"region",
"=",
"None",
")",
":",
"config",
"=",
"validate",
".",
"callback",
"(",
"config",
")",
"destination",
"=",
"config",
".",
"get",
... | sync last recorded export to actual
Use --dryrun to check status. | [
"sync",
"last",
"recorded",
"export",
"to",
"actual"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L572-L659 | train | Sync the last recorded export to actual | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | status | def status(config, group, accounts=(), region=None):
"""report current export state status"""
config = validate.callback(config)
destination = config.get('destination')
client = boto3.Session().client('s3')
for account in config.get('accounts', ()):
if accounts and account['name'] not in ac... | python | def status(config, group, accounts=(), region=None):
"""report current export state status"""
config = validate.callback(config)
destination = config.get('destination')
client = boto3.Session().client('s3')
for account in config.get('accounts', ()):
if accounts and account['name'] not in ac... | [
"def",
"status",
"(",
"config",
",",
"group",
",",
"accounts",
"=",
"(",
")",
",",
"region",
"=",
"None",
")",
":",
"config",
"=",
"validate",
".",
"callback",
"(",
"config",
")",
"destination",
"=",
"config",
".",
"get",
"(",
"'destination'",
")",
"... | report current export state status | [
"report",
"current",
"export",
"state",
"status"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L667-L706 | train | report current export state status | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | get_exports | def get_exports(client, bucket, prefix, latest=True):
"""Find exports for a given account
"""
keys = client.list_objects_v2(
Bucket=bucket, Prefix=prefix, Delimiter='/').get('CommonPrefixes', [])
found = []
years = []
for y in keys:
part = y['Prefix'].rsplit('/', 2)[-2]
i... | python | def get_exports(client, bucket, prefix, latest=True):
"""Find exports for a given account
"""
keys = client.list_objects_v2(
Bucket=bucket, Prefix=prefix, Delimiter='/').get('CommonPrefixes', [])
found = []
years = []
for y in keys:
part = y['Prefix'].rsplit('/', 2)[-2]
i... | [
"def",
"get_exports",
"(",
"client",
",",
"bucket",
",",
"prefix",
",",
"latest",
"=",
"True",
")",
":",
"keys",
"=",
"client",
".",
"list_objects_v2",
"(",
"Bucket",
"=",
"bucket",
",",
"Prefix",
"=",
"prefix",
",",
"Delimiter",
"=",
"'/'",
")",
".",
... | Find exports for a given account | [
"Find",
"exports",
"for",
"a",
"given",
"account"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L709-L762 | train | Find exports for a given account | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | export | def export(group, bucket, prefix, start, end, role, poll_period=120,
session=None, name="", region=None):
"""export a given log group to s3"""
start = start and isinstance(start, six.string_types) and parse(start) or start
end = (end and isinstance(start, six.string_types) and
parse(en... | python | def export(group, bucket, prefix, start, end, role, poll_period=120,
session=None, name="", region=None):
"""export a given log group to s3"""
start = start and isinstance(start, six.string_types) and parse(start) or start
end = (end and isinstance(start, six.string_types) and
parse(en... | [
"def",
"export",
"(",
"group",
",",
"bucket",
",",
"prefix",
",",
"start",
",",
"end",
",",
"role",
",",
"poll_period",
"=",
"120",
",",
"session",
"=",
"None",
",",
"name",
"=",
"\"\"",
",",
"region",
"=",
"None",
")",
":",
"start",
"=",
"start",
... | export a given log group to s3 | [
"export",
"a",
"given",
"log",
"group",
"to",
"s3"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L777-L910 | train | export a given log group to s3 | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_sentry/c7n_sentry/c7nsentry.py | init | def init():
""" Lambda globals cache.
"""
global sqs, logs, config
if config is None:
with open('config.json') as fh:
config = json.load(fh)
if sqs is None:
sqs = boto3.client('sqs')
if logs is None:
logs = boto3.client('logs') | python | def init():
""" Lambda globals cache.
"""
global sqs, logs, config
if config is None:
with open('config.json') as fh:
config = json.load(fh)
if sqs is None:
sqs = boto3.client('sqs')
if logs is None:
logs = boto3.client('logs') | [
"def",
"init",
"(",
")",
":",
"global",
"sqs",
",",
"logs",
",",
"config",
"if",
"config",
"is",
"None",
":",
"with",
"open",
"(",
"'config.json'",
")",
"as",
"fh",
":",
"config",
"=",
"json",
".",
"load",
"(",
"fh",
")",
"if",
"sqs",
"is",
"None... | Lambda globals cache. | [
"Lambda",
"globals",
"cache",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_sentry/c7n_sentry/c7nsentry.py#L84-L94 | train | Lambda globals cache.
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_sentry/c7n_sentry/c7nsentry.py | process_log_event | def process_log_event(event, context):
"""Lambda Entrypoint - Log Subscriber
Format log events and relay to sentry (direct or sqs)
"""
init()
# Grab the actual error log payload
serialized = event['awslogs'].pop('data')
data = json.loads(zlib.decompress(
base64.b64decode(serialized)... | python | def process_log_event(event, context):
"""Lambda Entrypoint - Log Subscriber
Format log events and relay to sentry (direct or sqs)
"""
init()
# Grab the actual error log payload
serialized = event['awslogs'].pop('data')
data = json.loads(zlib.decompress(
base64.b64decode(serialized)... | [
"def",
"process_log_event",
"(",
"event",
",",
"context",
")",
":",
"init",
"(",
")",
"# Grab the actual error log payload",
"serialized",
"=",
"event",
"[",
"'awslogs'",
"]",
".",
"pop",
"(",
"'data'",
")",
"data",
"=",
"json",
".",
"loads",
"(",
"zlib",
... | Lambda Entrypoint - Log Subscriber
Format log events and relay to sentry (direct or sqs) | [
"Lambda",
"Entrypoint",
"-",
"Log",
"Subscriber"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_sentry/c7n_sentry/c7nsentry.py#L97-L116 | train | Process a single log event and relay it to sentry | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_sentry/c7n_sentry/c7nsentry.py | process_log_group | def process_log_group(config):
"""CLI - Replay / Index
"""
from c7n.credentials import SessionFactory
factory = SessionFactory(
config.region, config.profile, assume_role=config.role)
session = factory()
client = session.client('logs')
params = dict(logGroupName=config.log_group,
... | python | def process_log_group(config):
"""CLI - Replay / Index
"""
from c7n.credentials import SessionFactory
factory = SessionFactory(
config.region, config.profile, assume_role=config.role)
session = factory()
client = session.client('logs')
params = dict(logGroupName=config.log_group,
... | [
"def",
"process_log_group",
"(",
"config",
")",
":",
"from",
"c7n",
".",
"credentials",
"import",
"SessionFactory",
"factory",
"=",
"SessionFactory",
"(",
"config",
".",
"region",
",",
"config",
".",
"profile",
",",
"assume_role",
"=",
"config",
".",
"role",
... | CLI - Replay / Index | [
"CLI",
"-",
"Replay",
"/",
"Index"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_sentry/c7n_sentry/c7nsentry.py#L125-L169 | train | Processes the log group and sends the messages to the Sentry server. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_sentry/c7n_sentry/c7nsentry.py | parse_traceback | def parse_traceback(msg, site_path="site-packages", in_app_prefix="c7n"):
"""Extract a sentry traceback structure,
From a python formatted traceback string per python stdlib
traceback.print_exc()
"""
data = {}
lines = list(filter(None, msg.split('\n')))
data['frames'] = []
err_ctx = No... | python | def parse_traceback(msg, site_path="site-packages", in_app_prefix="c7n"):
"""Extract a sentry traceback structure,
From a python formatted traceback string per python stdlib
traceback.print_exc()
"""
data = {}
lines = list(filter(None, msg.split('\n')))
data['frames'] = []
err_ctx = No... | [
"def",
"parse_traceback",
"(",
"msg",
",",
"site_path",
"=",
"\"site-packages\"",
",",
"in_app_prefix",
"=",
"\"c7n\"",
")",
":",
"data",
"=",
"{",
"}",
"lines",
"=",
"list",
"(",
"filter",
"(",
"None",
",",
"msg",
".",
"split",
"(",
"'\\n'",
")",
")",... | Extract a sentry traceback structure,
From a python formatted traceback string per python stdlib
traceback.print_exc() | [
"Extract",
"a",
"sentry",
"traceback",
"structure"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_sentry/c7n_sentry/c7nsentry.py#L280-L319 | train | Extract a sentry traceback structure from a python formatted traceback string per python stdlib traceback. print_exc | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_sentry/c7n_sentry/c7nsentry.py | get_function | def get_function(session_factory, name, handler, runtime, role,
log_groups,
project, account_name, account_id,
sentry_dsn,
pattern="Traceback"):
"""Lambda function provisioning.
Self contained within the component, to allow for easier reuse.
... | python | def get_function(session_factory, name, handler, runtime, role,
log_groups,
project, account_name, account_id,
sentry_dsn,
pattern="Traceback"):
"""Lambda function provisioning.
Self contained within the component, to allow for easier reuse.
... | [
"def",
"get_function",
"(",
"session_factory",
",",
"name",
",",
"handler",
",",
"runtime",
",",
"role",
",",
"log_groups",
",",
"project",
",",
"account_name",
",",
"account_id",
",",
"sentry_dsn",
",",
"pattern",
"=",
"\"Traceback\"",
")",
":",
"# Lazy impor... | Lambda function provisioning.
Self contained within the component, to allow for easier reuse. | [
"Lambda",
"function",
"provisioning",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_sentry/c7n_sentry/c7nsentry.py#L322-L361 | train | Get a Lambda function provisioning. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/sandbox/zerodark/zerodark/ipdb.py | chunks | def chunks(iterable, size=50):
"""Break an iterable into lists of size"""
batch = []
for n in iterable:
batch.append(n)
if len(batch) % size == 0:
yield batch
batch = []
if batch:
yield batch | python | def chunks(iterable, size=50):
"""Break an iterable into lists of size"""
batch = []
for n in iterable:
batch.append(n)
if len(batch) % size == 0:
yield batch
batch = []
if batch:
yield batch | [
"def",
"chunks",
"(",
"iterable",
",",
"size",
"=",
"50",
")",
":",
"batch",
"=",
"[",
"]",
"for",
"n",
"in",
"iterable",
":",
"batch",
".",
"append",
"(",
"n",
")",
"if",
"len",
"(",
"batch",
")",
"%",
"size",
"==",
"0",
":",
"yield",
"batch",... | Break an iterable into lists of size | [
"Break",
"an",
"iterable",
"into",
"lists",
"of",
"size"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/zerodark/zerodark/ipdb.py#L527-L536 | train | Break an iterable into lists of size | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/sandbox/zerodark/zerodark/ipdb.py | worker_config | def worker_config(queue, s3_key, period, verbose):
"""daemon queue worker for config notifications"""
logging.basicConfig(level=(verbose and logging.DEBUG or logging.INFO))
logging.getLogger('botocore').setLevel(logging.WARNING)
logging.getLogger('s3transfer').setLevel(logging.WARNING)
queue, regio... | python | def worker_config(queue, s3_key, period, verbose):
"""daemon queue worker for config notifications"""
logging.basicConfig(level=(verbose and logging.DEBUG or logging.INFO))
logging.getLogger('botocore').setLevel(logging.WARNING)
logging.getLogger('s3transfer').setLevel(logging.WARNING)
queue, regio... | [
"def",
"worker_config",
"(",
"queue",
",",
"s3_key",
",",
"period",
",",
"verbose",
")",
":",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"(",
"verbose",
"and",
"logging",
".",
"DEBUG",
"or",
"logging",
".",
"INFO",
")",
")",
"logging",
".",
"get... | daemon queue worker for config notifications | [
"daemon",
"queue",
"worker",
"for",
"config",
"notifications"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/zerodark/zerodark/ipdb.py#L566-L587 | train | daemon worker for config notifications | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/sandbox/zerodark/zerodark/ipdb.py | list_app_resources | def list_app_resources(
app, env, resources, cmdb, start, end, tz):
"""Analyze flow log records for application and generate metrics per period"""
logging.basicConfig(level=logging.INFO)
start, end = get_dates(start, end, tz)
all_resources = []
for rtype_name in resources:
rtype = R... | python | def list_app_resources(
app, env, resources, cmdb, start, end, tz):
"""Analyze flow log records for application and generate metrics per period"""
logging.basicConfig(level=logging.INFO)
start, end = get_dates(start, end, tz)
all_resources = []
for rtype_name in resources:
rtype = R... | [
"def",
"list_app_resources",
"(",
"app",
",",
"env",
",",
"resources",
",",
"cmdb",
",",
"start",
",",
"end",
",",
"tz",
")",
":",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"INFO",
")",
"start",
",",
"end",
"=",
"get_dates",
"... | Analyze flow log records for application and generate metrics per period | [
"Analyze",
"flow",
"log",
"records",
"for",
"application",
"and",
"generate",
"metrics",
"per",
"period"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/zerodark/zerodark/ipdb.py#L617-L628 | train | Analyze flow log records for application and generate metrics per period | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/sandbox/zerodark/zerodark/ipdb.py | load_resources | def load_resources(bucket, prefix, region, account_config, accounts,
assume, start, end, resources, store, db, verbose, debug):
"""load resources into resource database."""
logging.basicConfig(level=(verbose and logging.DEBUG or logging.INFO))
logging.getLogger('botocore').setLevel(loggin... | python | def load_resources(bucket, prefix, region, account_config, accounts,
assume, start, end, resources, store, db, verbose, debug):
"""load resources into resource database."""
logging.basicConfig(level=(verbose and logging.DEBUG or logging.INFO))
logging.getLogger('botocore').setLevel(loggin... | [
"def",
"load_resources",
"(",
"bucket",
",",
"prefix",
",",
"region",
",",
"account_config",
",",
"accounts",
",",
"assume",
",",
"start",
",",
"end",
",",
"resources",
",",
"store",
",",
"db",
",",
"verbose",
",",
"debug",
")",
":",
"logging",
".",
"b... | load resources into resource database. | [
"load",
"resources",
"into",
"resource",
"database",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/zerodark/zerodark/ipdb.py#L646-L702 | train | load resources into resource database. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/registry.py | PluginRegistry.load_plugins | def load_plugins(self):
""" Load external plugins.
Custodian is intended to interact with internal and external systems
that are not suitable for embedding into the custodian code base.
"""
try:
from pkg_resources import iter_entry_points
except ImportError:
... | python | def load_plugins(self):
""" Load external plugins.
Custodian is intended to interact with internal and external systems
that are not suitable for embedding into the custodian code base.
"""
try:
from pkg_resources import iter_entry_points
except ImportError:
... | [
"def",
"load_plugins",
"(",
"self",
")",
":",
"try",
":",
"from",
"pkg_resources",
"import",
"iter_entry_points",
"except",
"ImportError",
":",
"return",
"for",
"ep",
"in",
"iter_entry_points",
"(",
"group",
"=",
"\"custodian.%s\"",
"%",
"self",
".",
"plugin_typ... | Load external plugins.
Custodian is intended to interact with internal and external systems
that are not suitable for embedding into the custodian code base. | [
"Load",
"external",
"plugins",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/registry.py#L106-L118 | train | Load external plugins. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/sqsexec.py | SQSExecutor.submit | def submit(self, func, *args, **kwargs):
"""Submit a function for serialized execution on sqs
"""
self.op_sequence += 1
self.sqs.send_message(
QueueUrl=self.map_queue,
MessageBody=utils.dumps({'args': args, 'kwargs': kwargs}),
MessageAttributes={
... | python | def submit(self, func, *args, **kwargs):
"""Submit a function for serialized execution on sqs
"""
self.op_sequence += 1
self.sqs.send_message(
QueueUrl=self.map_queue,
MessageBody=utils.dumps({'args': args, 'kwargs': kwargs}),
MessageAttributes={
... | [
"def",
"submit",
"(",
"self",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"op_sequence",
"+=",
"1",
"self",
".",
"sqs",
".",
"send_message",
"(",
"QueueUrl",
"=",
"self",
".",
"map_queue",
",",
"MessageBody",
"=",
... | Submit a function for serialized execution on sqs | [
"Submit",
"a",
"function",
"for",
"serialized",
"execution",
"on",
"sqs"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/sqsexec.py#L56-L78 | train | Submit a function for serialized execution on sqs
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/sqsexec.py | SQSExecutor.gather | def gather(self):
"""Fetch results from separate queue
"""
limit = self.op_sequence - self.op_sequence_start
results = MessageIterator(self.sqs, self.reduce_queue, limit)
for m in results:
# sequence_id from above
msg_id = int(m['MessageAttributes']['seque... | python | def gather(self):
"""Fetch results from separate queue
"""
limit = self.op_sequence - self.op_sequence_start
results = MessageIterator(self.sqs, self.reduce_queue, limit)
for m in results:
# sequence_id from above
msg_id = int(m['MessageAttributes']['seque... | [
"def",
"gather",
"(",
"self",
")",
":",
"limit",
"=",
"self",
".",
"op_sequence",
"-",
"self",
".",
"op_sequence_start",
"results",
"=",
"MessageIterator",
"(",
"self",
".",
"sqs",
",",
"self",
".",
"reduce_queue",
",",
"limit",
")",
"for",
"m",
"in",
... | Fetch results from separate queue | [
"Fetch",
"results",
"from",
"separate",
"queue"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/sqsexec.py#L80-L95 | train | Gather the results from the queue and set them as result of the next concurrent process. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/resources/ecs.py | ecs_tag_normalize | def ecs_tag_normalize(resources):
"""normalize tag format on ecs resources to match common aws format."""
for r in resources:
if 'tags' in r:
r['Tags'] = [{'Key': t['key'], 'Value': t['value']} for t in r['tags']]
r.pop('tags') | python | def ecs_tag_normalize(resources):
"""normalize tag format on ecs resources to match common aws format."""
for r in resources:
if 'tags' in r:
r['Tags'] = [{'Key': t['key'], 'Value': t['value']} for t in r['tags']]
r.pop('tags') | [
"def",
"ecs_tag_normalize",
"(",
"resources",
")",
":",
"for",
"r",
"in",
"resources",
":",
"if",
"'tags'",
"in",
"r",
":",
"r",
"[",
"'Tags'",
"]",
"=",
"[",
"{",
"'Key'",
":",
"t",
"[",
"'key'",
"]",
",",
"'Value'",
":",
"t",
"[",
"'value'",
"]... | normalize tag format on ecs resources to match common aws format. | [
"normalize",
"tag",
"format",
"on",
"ecs",
"resources",
"to",
"match",
"common",
"aws",
"format",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/ecs.py#L28-L33 | train | normalize tag format on ecs resources to match common aws format | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/resources/ecs.py | ECSClusterResourceDescribeSource.get_resources | def get_resources(self, ids, cache=True):
"""Retrieve ecs resources for serverless policies or related resources
Requires arns in new format.
https://docs.aws.amazon.com/AmazonECS/latest/userguide/ecs-resource-ids.html
"""
cluster_resources = {}
for i in ids:
... | python | def get_resources(self, ids, cache=True):
"""Retrieve ecs resources for serverless policies or related resources
Requires arns in new format.
https://docs.aws.amazon.com/AmazonECS/latest/userguide/ecs-resource-ids.html
"""
cluster_resources = {}
for i in ids:
... | [
"def",
"get_resources",
"(",
"self",
",",
"ids",
",",
"cache",
"=",
"True",
")",
":",
"cluster_resources",
"=",
"{",
"}",
"for",
"i",
"in",
"ids",
":",
"_",
",",
"ident",
"=",
"i",
".",
"rsplit",
"(",
"':'",
",",
"1",
")",
"parts",
"=",
"ident",
... | Retrieve ecs resources for serverless policies or related resources
Requires arns in new format.
https://docs.aws.amazon.com/AmazonECS/latest/userguide/ecs-resource-ids.html | [
"Retrieve",
"ecs",
"resources",
"for",
"serverless",
"policies",
"or",
"related",
"resources"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/ecs.py#L97-L116 | train | Retrieve ecs resources for serverless policies or related resources | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/policy.py | PolicyCollection.resource_types | def resource_types(self):
"""resource types used by the collection."""
rtypes = set()
for p in self.policies:
rtypes.add(p.resource_type)
return rtypes | python | def resource_types(self):
"""resource types used by the collection."""
rtypes = set()
for p in self.policies:
rtypes.add(p.resource_type)
return rtypes | [
"def",
"resource_types",
"(",
"self",
")",
":",
"rtypes",
"=",
"set",
"(",
")",
"for",
"p",
"in",
"self",
".",
"policies",
":",
"rtypes",
".",
"add",
"(",
"p",
".",
"resource_type",
")",
"return",
"rtypes"
] | resource types used by the collection. | [
"resource",
"types",
"used",
"by",
"the",
"collection",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/policy.py#L118-L123 | train | resource types used by the collection. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/policy.py | PolicyExecutionMode.get_metrics | def get_metrics(self, start, end, period):
"""Retrieve any associated metrics for the policy."""
values = {}
default_dimensions = {
'Policy': self.policy.name, 'ResType': self.policy.resource_type,
'Scope': 'Policy'}
metrics = list(self.POLICY_METRICS)
#... | python | def get_metrics(self, start, end, period):
"""Retrieve any associated metrics for the policy."""
values = {}
default_dimensions = {
'Policy': self.policy.name, 'ResType': self.policy.resource_type,
'Scope': 'Policy'}
metrics = list(self.POLICY_METRICS)
#... | [
"def",
"get_metrics",
"(",
"self",
",",
"start",
",",
"end",
",",
"period",
")",
":",
"values",
"=",
"{",
"}",
"default_dimensions",
"=",
"{",
"'Policy'",
":",
"self",
".",
"policy",
".",
"name",
",",
"'ResType'",
":",
"self",
".",
"policy",
".",
"re... | Retrieve any associated metrics for the policy. | [
"Retrieve",
"any",
"associated",
"metrics",
"for",
"the",
"policy",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/policy.py#L153-L190 | train | Retrieve any associated metrics for the policy. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/policy.py | LambdaMode.run | def run(self, event, lambda_context):
"""Run policy in push mode against given event.
Lambda automatically generates cloud watch logs, and metrics
for us, albeit with some deficienies, metrics no longer count
against valid resources matches, but against execution.
If metrics ex... | python | def run(self, event, lambda_context):
"""Run policy in push mode against given event.
Lambda automatically generates cloud watch logs, and metrics
for us, albeit with some deficienies, metrics no longer count
against valid resources matches, but against execution.
If metrics ex... | [
"def",
"run",
"(",
"self",
",",
"event",
",",
"lambda_context",
")",
":",
"from",
"c7n",
".",
"actions",
"import",
"EventAction",
"mode",
"=",
"self",
".",
"policy",
".",
"data",
".",
"get",
"(",
"'mode'",
",",
"{",
"}",
")",
"if",
"not",
"bool",
"... | Run policy in push mode against given event.
Lambda automatically generates cloud watch logs, and metrics
for us, albeit with some deficienies, metrics no longer count
against valid resources matches, but against execution.
If metrics execution option is enabled, custodian will generat... | [
"Run",
"policy",
"in",
"push",
"mode",
"against",
"given",
"event",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/policy.py#L426-L481 | train | Run policy in push mode against given event. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/policy.py | Policy.get_variables | def get_variables(self, variables=None):
"""Get runtime variables for policy interpolation.
Runtime variables are merged with the passed in variables
if any.
"""
# Global policy variable expansion, we have to carry forward on
# various filter/action local vocabularies. W... | python | def get_variables(self, variables=None):
"""Get runtime variables for policy interpolation.
Runtime variables are merged with the passed in variables
if any.
"""
# Global policy variable expansion, we have to carry forward on
# various filter/action local vocabularies. W... | [
"def",
"get_variables",
"(",
"self",
",",
"variables",
"=",
"None",
")",
":",
"# Global policy variable expansion, we have to carry forward on",
"# various filter/action local vocabularies. Where possible defer",
"# by using a format string.",
"#",
"# See https://github.com/capitalone/cl... | Get runtime variables for policy interpolation.
Runtime variables are merged with the passed in variables
if any. | [
"Get",
"runtime",
"variables",
"for",
"policy",
"interpolation",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/policy.py#L836-L880 | train | Get runtime variables for policy interpolation. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/policy.py | Policy.expand_variables | def expand_variables(self, variables):
"""Expand variables in policy data.
Updates the policy data in-place.
"""
# format string values returns a copy
updated = utils.format_string_values(self.data, **variables)
# Several keys should only be expanded at runtime, perserv... | python | def expand_variables(self, variables):
"""Expand variables in policy data.
Updates the policy data in-place.
"""
# format string values returns a copy
updated = utils.format_string_values(self.data, **variables)
# Several keys should only be expanded at runtime, perserv... | [
"def",
"expand_variables",
"(",
"self",
",",
"variables",
")",
":",
"# format string values returns a copy",
"updated",
"=",
"utils",
".",
"format_string_values",
"(",
"self",
".",
"data",
",",
"*",
"*",
"variables",
")",
"# Several keys should only be expanded at runti... | Expand variables in policy data.
Updates the policy data in-place. | [
"Expand",
"variables",
"in",
"policy",
"data",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/policy.py#L882-L906 | train | Expand variables in the policy data. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/policy.py | Policy.get_permissions | def get_permissions(self):
"""get permissions needed by this policy"""
permissions = set()
permissions.update(self.resource_manager.get_permissions())
for f in self.resource_manager.filters:
permissions.update(f.get_permissions())
for a in self.resource_manager.action... | python | def get_permissions(self):
"""get permissions needed by this policy"""
permissions = set()
permissions.update(self.resource_manager.get_permissions())
for f in self.resource_manager.filters:
permissions.update(f.get_permissions())
for a in self.resource_manager.action... | [
"def",
"get_permissions",
"(",
"self",
")",
":",
"permissions",
"=",
"set",
"(",
")",
"permissions",
".",
"update",
"(",
"self",
".",
"resource_manager",
".",
"get_permissions",
"(",
")",
")",
"for",
"f",
"in",
"self",
".",
"resource_manager",
".",
"filter... | get permissions needed by this policy | [
"get",
"permissions",
"needed",
"by",
"this",
"policy"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/policy.py#L930-L938 | train | get permissions needed by this policy | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/resources/ebs.py | ErrorHandler.extract_bad_snapshot | def extract_bad_snapshot(e):
"""Handle various client side errors when describing snapshots"""
msg = e.response['Error']['Message']
error = e.response['Error']['Code']
e_snap_id = None
if error == 'InvalidSnapshot.NotFound':
e_snap_id = msg[msg.find("'") + 1:msg.rfind... | python | def extract_bad_snapshot(e):
"""Handle various client side errors when describing snapshots"""
msg = e.response['Error']['Message']
error = e.response['Error']['Code']
e_snap_id = None
if error == 'InvalidSnapshot.NotFound':
e_snap_id = msg[msg.find("'") + 1:msg.rfind... | [
"def",
"extract_bad_snapshot",
"(",
"e",
")",
":",
"msg",
"=",
"e",
".",
"response",
"[",
"'Error'",
"]",
"[",
"'Message'",
"]",
"error",
"=",
"e",
".",
"response",
"[",
"'Error'",
"]",
"[",
"'Code'",
"]",
"e_snap_id",
"=",
"None",
"if",
"error",
"==... | Handle various client side errors when describing snapshots | [
"Handle",
"various",
"client",
"side",
"errors",
"when",
"describing",
"snapshots"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/ebs.py#L116-L127 | train | Handle various client side errors when describing snapshots | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/credentials.py | assumed_session | def assumed_session(role_arn, session_name, session=None, region=None, external_id=None):
"""STS Role assume a boto3.Session
With automatic credential renewal.
Args:
role_arn: iam role arn to assume
session_name: client session identifier
session: an optional extant session, note session... | python | def assumed_session(role_arn, session_name, session=None, region=None, external_id=None):
"""STS Role assume a boto3.Session
With automatic credential renewal.
Args:
role_arn: iam role arn to assume
session_name: client session identifier
session: an optional extant session, note session... | [
"def",
"assumed_session",
"(",
"role_arn",
",",
"session_name",
",",
"session",
"=",
"None",
",",
"region",
"=",
"None",
",",
"external_id",
"=",
"None",
")",
":",
"if",
"session",
"is",
"None",
":",
"session",
"=",
"Session",
"(",
")",
"retry",
"=",
"... | STS Role assume a boto3.Session
With automatic credential renewal.
Args:
role_arn: iam role arn to assume
session_name: client session identifier
session: an optional extant session, note session is captured
in a function closure for renewing the sts assumed role.
:return: a boto3... | [
"STS",
"Role",
"assume",
"a",
"boto3",
".",
"Session"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/credentials.py#L73-L125 | train | This function returns a boto3. Session object with the credentials for the given role and session. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/filters/offhours.py | Time.process_resource_schedule | def process_resource_schedule(self, i, value, time_type):
"""Does the resource tag schedule and policy match the current time."""
rid = i[self.id_key]
# this is to normalize trailing semicolons which when done allows
# dateutil.parser.parse to process: value='off=(m-f,1);' properly.
... | python | def process_resource_schedule(self, i, value, time_type):
"""Does the resource tag schedule and policy match the current time."""
rid = i[self.id_key]
# this is to normalize trailing semicolons which when done allows
# dateutil.parser.parse to process: value='off=(m-f,1);' properly.
... | [
"def",
"process_resource_schedule",
"(",
"self",
",",
"i",
",",
"value",
",",
"time_type",
")",
":",
"rid",
"=",
"i",
"[",
"self",
".",
"id_key",
"]",
"# this is to normalize trailing semicolons which when done allows",
"# dateutil.parser.parse to process: value='off=(m-f,1... | Does the resource tag schedule and policy match the current time. | [
"Does",
"the",
"resource",
"tag",
"schedule",
"and",
"policy",
"match",
"the",
"current",
"time",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/offhours.py#L398-L438 | train | Does the resource tag schedule and policy match the current time? | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/filters/offhours.py | Time.get_tag_value | def get_tag_value(self, i):
"""Get the resource's tag value specifying its schedule."""
# Look for the tag, Normalize tag key and tag value
found = False
for t in i.get('Tags', ()):
if t['Key'].lower() == self.tag_key:
found = t['Value']
break
... | python | def get_tag_value(self, i):
"""Get the resource's tag value specifying its schedule."""
# Look for the tag, Normalize tag key and tag value
found = False
for t in i.get('Tags', ()):
if t['Key'].lower() == self.tag_key:
found = t['Value']
break
... | [
"def",
"get_tag_value",
"(",
"self",
",",
"i",
")",
":",
"# Look for the tag, Normalize tag key and tag value",
"found",
"=",
"False",
"for",
"t",
"in",
"i",
".",
"get",
"(",
"'Tags'",
",",
"(",
")",
")",
":",
"if",
"t",
"[",
"'Key'",
"]",
".",
"lower",
... | Get the resource's tag value specifying its schedule. | [
"Get",
"the",
"resource",
"s",
"tag",
"value",
"specifying",
"its",
"schedule",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/offhours.py#L448-L463 | train | Get the resource s tag value specifying its schedule. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/filters/offhours.py | ScheduleParser.raw_data | def raw_data(tag_value):
"""convert the tag to a dictionary, taking values as is
This method name and purpose are opaque... and not true.
"""
data = {}
pieces = []
for p in tag_value.split(' '):
pieces.extend(p.split(';'))
# parse components
... | python | def raw_data(tag_value):
"""convert the tag to a dictionary, taking values as is
This method name and purpose are opaque... and not true.
"""
data = {}
pieces = []
for p in tag_value.split(' '):
pieces.extend(p.split(';'))
# parse components
... | [
"def",
"raw_data",
"(",
"tag_value",
")",
":",
"data",
"=",
"{",
"}",
"pieces",
"=",
"[",
"]",
"for",
"p",
"in",
"tag_value",
".",
"split",
"(",
"' '",
")",
":",
"pieces",
".",
"extend",
"(",
"p",
".",
"split",
"(",
"';'",
")",
")",
"# parse comp... | convert the tag to a dictionary, taking values as is
This method name and purpose are opaque... and not true. | [
"convert",
"the",
"tag",
"to",
"a",
"dictionary",
"taking",
"values",
"as",
"is"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/offhours.py#L577-L594 | train | convert the tag value to a dictionary taking values as is
This method name and purpose are opaque... and not true. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/filters/offhours.py | ScheduleParser.keys_are_valid | def keys_are_valid(self, tag_value):
"""test that provided tag keys are valid"""
for key in ScheduleParser.raw_data(tag_value):
if key not in ('on', 'off', 'tz'):
return False
return True | python | def keys_are_valid(self, tag_value):
"""test that provided tag keys are valid"""
for key in ScheduleParser.raw_data(tag_value):
if key not in ('on', 'off', 'tz'):
return False
return True | [
"def",
"keys_are_valid",
"(",
"self",
",",
"tag_value",
")",
":",
"for",
"key",
"in",
"ScheduleParser",
".",
"raw_data",
"(",
"tag_value",
")",
":",
"if",
"key",
"not",
"in",
"(",
"'on'",
",",
"'off'",
",",
"'tz'",
")",
":",
"return",
"False",
"return"... | test that provided tag keys are valid | [
"test",
"that",
"provided",
"tag",
"keys",
"are",
"valid"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/offhours.py#L596-L601 | train | test that provided tag keys are valid | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/ops/mugc.py | resources_gc_prefix | def resources_gc_prefix(options, policy_config, policy_collection):
"""Garbage collect old custodian policies based on prefix.
We attempt to introspect to find the event sources for a policy
but without the old configuration this is implicit.
"""
# Classify policies by region
policy_regions = ... | python | def resources_gc_prefix(options, policy_config, policy_collection):
"""Garbage collect old custodian policies based on prefix.
We attempt to introspect to find the event sources for a policy
but without the old configuration this is implicit.
"""
# Classify policies by region
policy_regions = ... | [
"def",
"resources_gc_prefix",
"(",
"options",
",",
"policy_config",
",",
"policy_collection",
")",
":",
"# Classify policies by region",
"policy_regions",
"=",
"{",
"}",
"for",
"p",
"in",
"policy_collection",
":",
"if",
"p",
".",
"execution_mode",
"==",
"'poll'",
... | Garbage collect old custodian policies based on prefix.
We attempt to introspect to find the event sources for a policy
but without the old configuration this is implicit. | [
"Garbage",
"collect",
"old",
"custodian",
"policies",
"based",
"on",
"prefix",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/ops/mugc.py#L113-L129 | train | Garbage collect old custodian policies based on prefix. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/worker.py | get_session | def get_session(account_info):
"""Get a boto3 sesssion potentially cross account sts assumed
assumed sessions are automatically refreshed.
"""
s = getattr(CONN_CACHE, '%s-session' % account_info['name'], None)
if s is not None:
return s
if account_info.get('role'):
s = assumed_s... | python | def get_session(account_info):
"""Get a boto3 sesssion potentially cross account sts assumed
assumed sessions are automatically refreshed.
"""
s = getattr(CONN_CACHE, '%s-session' % account_info['name'], None)
if s is not None:
return s
if account_info.get('role'):
s = assumed_s... | [
"def",
"get_session",
"(",
"account_info",
")",
":",
"s",
"=",
"getattr",
"(",
"CONN_CACHE",
",",
"'%s-session'",
"%",
"account_info",
"[",
"'name'",
"]",
",",
"None",
")",
"if",
"s",
"is",
"not",
"None",
":",
"return",
"s",
"if",
"account_info",
".",
... | Get a boto3 sesssion potentially cross account sts assumed
assumed sessions are automatically refreshed. | [
"Get",
"a",
"boto3",
"sesssion",
"potentially",
"cross",
"account",
"sts",
"assumed"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/worker.py#L136-L149 | train | Get a boto3 session potentially cross account sts | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/worker.py | bulk_invoke | def bulk_invoke(func, args, nargs):
"""Bulk invoke a function via queues
Uses internal implementation details of rq.
"""
# for comparison, simplest thing that works
# for i in nargs:
# argv = list(args)
# argv.append(i)
# func.delay(*argv)
# some variances between cpy and ... | python | def bulk_invoke(func, args, nargs):
"""Bulk invoke a function via queues
Uses internal implementation details of rq.
"""
# for comparison, simplest thing that works
# for i in nargs:
# argv = list(args)
# argv.append(i)
# func.delay(*argv)
# some variances between cpy and ... | [
"def",
"bulk_invoke",
"(",
"func",
",",
"args",
",",
"nargs",
")",
":",
"# for comparison, simplest thing that works",
"# for i in nargs:",
"# argv = list(args)",
"# argv.append(i)",
"# func.delay(*argv)",
"# some variances between cpy and pypy, sniff detect",
"for",
"clos... | Bulk invoke a function via queues
Uses internal implementation details of rq. | [
"Bulk",
"invoke",
"a",
"function",
"via",
"queues"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/worker.py#L160-L193 | train | Bulk invoke a function via queues
ridge Uses internal implementation details of rq.
ridge | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/worker.py | bucket_ops | def bucket_ops(bid, api=""):
"""Context manager for dealing with s3 errors in one place
bid: bucket_id in form of account_name:bucket_name
"""
try:
yield 42
except ClientError as e:
code = e.response['Error']['Code']
log.info(
"bucket error bucket:%s error:%s",
... | python | def bucket_ops(bid, api=""):
"""Context manager for dealing with s3 errors in one place
bid: bucket_id in form of account_name:bucket_name
"""
try:
yield 42
except ClientError as e:
code = e.response['Error']['Code']
log.info(
"bucket error bucket:%s error:%s",
... | [
"def",
"bucket_ops",
"(",
"bid",
",",
"api",
"=",
"\"\"",
")",
":",
"try",
":",
"yield",
"42",
"except",
"ClientError",
"as",
"e",
":",
"code",
"=",
"e",
".",
"response",
"[",
"'Error'",
"]",
"[",
"'Code'",
"]",
"log",
".",
"info",
"(",
"\"bucket e... | Context manager for dealing with s3 errors in one place
bid: bucket_id in form of account_name:bucket_name | [
"Context",
"manager",
"for",
"dealing",
"with",
"s3",
"errors",
"in",
"one",
"place"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/worker.py#L197-L225 | train | Context manager for dealing with s3 errors in one place | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/worker.py | page_strip | def page_strip(page, versioned):
"""Remove bits in content results to minimize memory utilization.
TODO: evolve this to a key filter on metadata, like date
"""
# page strip filtering should be conditional
page.pop('ResponseMetadata', None)
contents_key = versioned and 'Versions' or 'Contents'
... | python | def page_strip(page, versioned):
"""Remove bits in content results to minimize memory utilization.
TODO: evolve this to a key filter on metadata, like date
"""
# page strip filtering should be conditional
page.pop('ResponseMetadata', None)
contents_key = versioned and 'Versions' or 'Contents'
... | [
"def",
"page_strip",
"(",
"page",
",",
"versioned",
")",
":",
"# page strip filtering should be conditional",
"page",
".",
"pop",
"(",
"'ResponseMetadata'",
",",
"None",
")",
"contents_key",
"=",
"versioned",
"and",
"'Versions'",
"or",
"'Contents'",
"contents",
"=",... | Remove bits in content results to minimize memory utilization.
TODO: evolve this to a key filter on metadata, like date | [
"Remove",
"bits",
"in",
"content",
"results",
"to",
"minimize",
"memory",
"utilization",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/worker.py#L228-L262 | train | Remove bits in content results to minimize memory utilization. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/worker.py | process_account | def process_account(account_info):
"""Scan all buckets in an account and schedule processing"""
log = logging.getLogger('salactus.bucket-iterator')
log.info("processing account %s", account_info)
session = get_session(account_info)
client = session.client('s3', config=s3config)
buckets = client.... | python | def process_account(account_info):
"""Scan all buckets in an account and schedule processing"""
log = logging.getLogger('salactus.bucket-iterator')
log.info("processing account %s", account_info)
session = get_session(account_info)
client = session.client('s3', config=s3config)
buckets = client.... | [
"def",
"process_account",
"(",
"account_info",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"'salactus.bucket-iterator'",
")",
"log",
".",
"info",
"(",
"\"processing account %s\"",
",",
"account_info",
")",
"session",
"=",
"get_session",
"(",
"account_i... | Scan all buckets in an account and schedule processing | [
"Scan",
"all",
"buckets",
"in",
"an",
"account",
"and",
"schedule",
"processing"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/worker.py#L287-L314 | train | Scan all buckets in an account and schedule processing | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/worker.py | process_bucket_set | def process_bucket_set(account_info, buckets):
"""Process a collection of buckets.
For each bucket fetch location, versioning and size and
then kickoff processing strategy based on size.
"""
region_clients = {}
log = logging.getLogger('salactus.bucket-set')
log.info("processing account %s",... | python | def process_bucket_set(account_info, buckets):
"""Process a collection of buckets.
For each bucket fetch location, versioning and size and
then kickoff processing strategy based on size.
"""
region_clients = {}
log = logging.getLogger('salactus.bucket-set')
log.info("processing account %s",... | [
"def",
"process_bucket_set",
"(",
"account_info",
",",
"buckets",
")",
":",
"region_clients",
"=",
"{",
"}",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"'salactus.bucket-set'",
")",
"log",
".",
"info",
"(",
"\"processing account %s\"",
",",
"account_info",
")... | Process a collection of buckets.
For each bucket fetch location, versioning and size and
then kickoff processing strategy based on size. | [
"Process",
"a",
"collection",
"of",
"buckets",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/worker.py#L318-L385 | train | Process a collection of buckets. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/worker.py | dispatch_object_source | def dispatch_object_source(client, account_info, bid, bucket_info):
"""Select and dispatch an object source for a bucket.
Choices are bucket partition, inventory, or direct pagination.
"""
if (account_info.get('inventory') and
bucket_info['keycount'] >
account_info['inventory'].get... | python | def dispatch_object_source(client, account_info, bid, bucket_info):
"""Select and dispatch an object source for a bucket.
Choices are bucket partition, inventory, or direct pagination.
"""
if (account_info.get('inventory') and
bucket_info['keycount'] >
account_info['inventory'].get... | [
"def",
"dispatch_object_source",
"(",
"client",
",",
"account_info",
",",
"bid",
",",
"bucket_info",
")",
":",
"if",
"(",
"account_info",
".",
"get",
"(",
"'inventory'",
")",
"and",
"bucket_info",
"[",
"'keycount'",
"]",
">",
"account_info",
"[",
"'inventory'"... | Select and dispatch an object source for a bucket.
Choices are bucket partition, inventory, or direct pagination. | [
"Select",
"and",
"dispatch",
"an",
"object",
"source",
"for",
"a",
"bucket",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/worker.py#L388-L410 | train | Select and dispatch an object source for a bucket. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/worker.py | get_keys_charset | def get_keys_charset(keys, bid):
""" Use set of keys as selector for character superset
Note this isn't optimal, its probabilistic on the keyset char population.
"""
# use the keys found to sample possible chars
chars = set()
for k in keys:
chars.update(k[:4])
remainder = chars
... | python | def get_keys_charset(keys, bid):
""" Use set of keys as selector for character superset
Note this isn't optimal, its probabilistic on the keyset char population.
"""
# use the keys found to sample possible chars
chars = set()
for k in keys:
chars.update(k[:4])
remainder = chars
... | [
"def",
"get_keys_charset",
"(",
"keys",
",",
"bid",
")",
":",
"# use the keys found to sample possible chars",
"chars",
"=",
"set",
"(",
")",
"for",
"k",
"in",
"keys",
":",
"chars",
".",
"update",
"(",
"k",
"[",
":",
"4",
"]",
")",
"remainder",
"=",
"cha... | Use set of keys as selector for character superset
Note this isn't optimal, its probabilistic on the keyset char population. | [
"Use",
"set",
"of",
"keys",
"as",
"selector",
"for",
"character",
"superset"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/worker.py#L507-L544 | train | Use set of keys as selector for character superset of a keyset. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/worker.py | detect_partition_strategy | def detect_partition_strategy(bid, delimiters=('/', '-'), prefix=''):
"""Try to detect the best partitioning strategy for a large bucket
Consider nested buckets with common prefixes, and flat buckets.
"""
account, bucket = bid.split(":", 1)
region = connection.hget('bucket-regions', bid)
versio... | python | def detect_partition_strategy(bid, delimiters=('/', '-'), prefix=''):
"""Try to detect the best partitioning strategy for a large bucket
Consider nested buckets with common prefixes, and flat buckets.
"""
account, bucket = bid.split(":", 1)
region = connection.hget('bucket-regions', bid)
versio... | [
"def",
"detect_partition_strategy",
"(",
"bid",
",",
"delimiters",
"=",
"(",
"'/'",
",",
"'-'",
")",
",",
"prefix",
"=",
"''",
")",
":",
"account",
",",
"bucket",
"=",
"bid",
".",
"split",
"(",
"\":\"",
",",
"1",
")",
"region",
"=",
"connection",
"."... | Try to detect the best partitioning strategy for a large bucket
Consider nested buckets with common prefixes, and flat buckets. | [
"Try",
"to",
"detect",
"the",
"best",
"partitioning",
"strategy",
"for",
"a",
"large",
"bucket"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/worker.py#L547-L608 | train | Detect the partition strategy for a large bucket. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/worker.py | process_bucket_partitions | def process_bucket_partitions(
bid, prefix_set=('',), partition='/', strategy=None, limit=4):
"""Split up a bucket keyspace into smaller sets for parallel iteration.
"""
if strategy is None:
return detect_partition_strategy(bid)
account, bucket = bid.split(':', 1)
region = connectio... | python | def process_bucket_partitions(
bid, prefix_set=('',), partition='/', strategy=None, limit=4):
"""Split up a bucket keyspace into smaller sets for parallel iteration.
"""
if strategy is None:
return detect_partition_strategy(bid)
account, bucket = bid.split(':', 1)
region = connectio... | [
"def",
"process_bucket_partitions",
"(",
"bid",
",",
"prefix_set",
"=",
"(",
"''",
",",
")",
",",
"partition",
"=",
"'/'",
",",
"strategy",
"=",
"None",
",",
"limit",
"=",
"4",
")",
":",
"if",
"strategy",
"is",
"None",
":",
"return",
"detect_partition_st... | Split up a bucket keyspace into smaller sets for parallel iteration. | [
"Split",
"up",
"a",
"bucket",
"keyspace",
"into",
"smaller",
"sets",
"for",
"parallel",
"iteration",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/worker.py#L613-L703 | train | Process a set of partitions for a given bucket. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/worker.py | process_bucket_inventory | def process_bucket_inventory(bid, inventory_bucket, inventory_prefix):
"""Load last inventory dump and feed as key source.
"""
log.info("Loading bucket %s keys from inventory s3://%s/%s",
bid, inventory_bucket, inventory_prefix)
account, bucket = bid.split(':', 1)
region = connection.hg... | python | def process_bucket_inventory(bid, inventory_bucket, inventory_prefix):
"""Load last inventory dump and feed as key source.
"""
log.info("Loading bucket %s keys from inventory s3://%s/%s",
bid, inventory_bucket, inventory_prefix)
account, bucket = bid.split(':', 1)
region = connection.hg... | [
"def",
"process_bucket_inventory",
"(",
"bid",
",",
"inventory_bucket",
",",
"inventory_prefix",
")",
":",
"log",
".",
"info",
"(",
"\"Loading bucket %s keys from inventory s3://%s/%s\"",
",",
"bid",
",",
"inventory_bucket",
",",
"inventory_prefix",
")",
"account",
",",... | Load last inventory dump and feed as key source. | [
"Load",
"last",
"inventory",
"dump",
"and",
"feed",
"as",
"key",
"source",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/worker.py#L708-L735 | train | Load last inventory dump and feed as key source. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/worker.py | process_bucket_iterator | def process_bucket_iterator(bid, prefix="", delimiter="", **continuation):
"""Bucket pagination
"""
log.info("Iterating keys bucket %s prefix %s delimiter %s",
bid, prefix, delimiter)
account, bucket = bid.split(':', 1)
region = connection.hget('bucket-regions', bid)
versioned = bo... | python | def process_bucket_iterator(bid, prefix="", delimiter="", **continuation):
"""Bucket pagination
"""
log.info("Iterating keys bucket %s prefix %s delimiter %s",
bid, prefix, delimiter)
account, bucket = bid.split(':', 1)
region = connection.hget('bucket-regions', bid)
versioned = bo... | [
"def",
"process_bucket_iterator",
"(",
"bid",
",",
"prefix",
"=",
"\"\"",
",",
"delimiter",
"=",
"\"\"",
",",
"*",
"*",
"continuation",
")",
":",
"log",
".",
"info",
"(",
"\"Iterating keys bucket %s prefix %s delimiter %s\"",
",",
"bid",
",",
"prefix",
",",
"d... | Bucket pagination | [
"Bucket",
"pagination"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/worker.py#L740-L785 | train | Process a single bucket iterator. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/tags.py | universal_retry | def universal_retry(method, ResourceARNList, **kw):
"""Retry support for resourcegroup tagging apis.
The resource group tagging api typically returns a 200 status code
with embedded resource specific errors. To enable resource specific
retry on throttles, we extract those, perform backoff w/ jitter and... | python | def universal_retry(method, ResourceARNList, **kw):
"""Retry support for resourcegroup tagging apis.
The resource group tagging api typically returns a 200 status code
with embedded resource specific errors. To enable resource specific
retry on throttles, we extract those, perform backoff w/ jitter and... | [
"def",
"universal_retry",
"(",
"method",
",",
"ResourceARNList",
",",
"*",
"*",
"kw",
")",
":",
"max_attempts",
"=",
"6",
"for",
"idx",
",",
"delay",
"in",
"enumerate",
"(",
"utils",
".",
"backoff_delays",
"(",
"1.5",
",",
"2",
"**",
"8",
",",
"jitter"... | Retry support for resourcegroup tagging apis.
The resource group tagging api typically returns a 200 status code
with embedded resource specific errors. To enable resource specific
retry on throttles, we extract those, perform backoff w/ jitter and
continue. Other errors are immediately raised.
We... | [
"Retry",
"support",
"for",
"resourcegroup",
"tagging",
"apis",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/tags.py#L1094-L1134 | train | Universal retry support for resourcegroup tagging apis. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/tags.py | coalesce_copy_user_tags | def coalesce_copy_user_tags(resource, copy_tags, user_tags):
"""
Returns a list of tags from resource and user supplied in
the format: [{'Key': 'key', 'Value': 'value'}]
Due to drift on implementation on copy-tags/tags used throughout
the code base, the following options are supported:
cop... | python | def coalesce_copy_user_tags(resource, copy_tags, user_tags):
"""
Returns a list of tags from resource and user supplied in
the format: [{'Key': 'key', 'Value': 'value'}]
Due to drift on implementation on copy-tags/tags used throughout
the code base, the following options are supported:
cop... | [
"def",
"coalesce_copy_user_tags",
"(",
"resource",
",",
"copy_tags",
",",
"user_tags",
")",
":",
"assert",
"isinstance",
"(",
"copy_tags",
",",
"bool",
")",
"or",
"isinstance",
"(",
"copy_tags",
",",
"list",
")",
"assert",
"isinstance",
"(",
"user_tags",
",",
... | Returns a list of tags from resource and user supplied in
the format: [{'Key': 'key', 'Value': 'value'}]
Due to drift on implementation on copy-tags/tags used throughout
the code base, the following options are supported:
copy_tags (Tags to copy from the resource):
- list of str, e.g. ['... | [
"Returns",
"a",
"list",
"of",
"tags",
"from",
"resource",
"and",
"user",
"supplied",
"in",
"the",
"format",
":",
"[",
"{",
"Key",
":",
"key",
"Value",
":",
"value",
"}",
"]"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/tags.py#L1137-L1185 | train | Coalesce the tags from a resource and user supplied tags. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/tags.py | RenameTag.process_rename | def process_rename(self, client, tag_value, resource_set):
"""
Move source tag value to destination tag value
- Collect value from old tag
- Delete old tag
- Create new tag & assign stored value
"""
self.log.info("Renaming tag on %s instances" % (len(resource_set... | python | def process_rename(self, client, tag_value, resource_set):
"""
Move source tag value to destination tag value
- Collect value from old tag
- Delete old tag
- Create new tag & assign stored value
"""
self.log.info("Renaming tag on %s instances" % (len(resource_set... | [
"def",
"process_rename",
"(",
"self",
",",
"client",
",",
"tag_value",
",",
"resource_set",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Renaming tag on %s instances\"",
"%",
"(",
"len",
"(",
"resource_set",
")",
")",
")",
"old_key",
"=",
"self",
"."... | Move source tag value to destination tag value
- Collect value from old tag
- Delete old tag
- Create new tag & assign stored value | [
"Move",
"source",
"tag",
"value",
"to",
"destination",
"tag",
"value"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/tags.py#L515-L540 | train | Process a rename request. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/tags.py | NormalizeTag.process_transform | def process_transform(self, tag_value, resource_set):
"""
Transform tag value
- Collect value from tag
- Transform Tag value
- Assign new value for key
"""
self.log.info("Transforming tag value on %s instances" % (
len(resource_set)))
key = se... | python | def process_transform(self, tag_value, resource_set):
"""
Transform tag value
- Collect value from tag
- Transform Tag value
- Assign new value for key
"""
self.log.info("Transforming tag value on %s instances" % (
len(resource_set)))
key = se... | [
"def",
"process_transform",
"(",
"self",
",",
"tag_value",
",",
"resource_set",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Transforming tag value on %s instances\"",
"%",
"(",
"len",
"(",
"resource_set",
")",
")",
")",
"key",
"=",
"self",
".",
"data"... | Transform tag value
- Collect value from tag
- Transform Tag value
- Assign new value for key | [
"Transform",
"tag",
"value"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/tags.py#L758-L776 | train | Process the transform tag value for the resource set | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/tags.py | CopyRelatedResourceTag.get_resource_tag_map | def get_resource_tag_map(self, r_type, ids):
"""
Returns a mapping of {resource_id: {tagkey: tagvalue}}
"""
manager = self.manager.get_resource_manager(r_type)
r_id = manager.resource_type.id
# TODO only fetch resource with the given ids.
return {
r[r_... | python | def get_resource_tag_map(self, r_type, ids):
"""
Returns a mapping of {resource_id: {tagkey: tagvalue}}
"""
manager = self.manager.get_resource_manager(r_type)
r_id = manager.resource_type.id
# TODO only fetch resource with the given ids.
return {
r[r_... | [
"def",
"get_resource_tag_map",
"(",
"self",
",",
"r_type",
",",
"ids",
")",
":",
"manager",
"=",
"self",
".",
"manager",
".",
"get_resource_manager",
"(",
"r_type",
")",
"r_id",
"=",
"manager",
".",
"resource_type",
".",
"id",
"# TODO only fetch resource with th... | Returns a mapping of {resource_id: {tagkey: tagvalue}} | [
"Returns",
"a",
"mapping",
"of",
"{",
"resource_id",
":",
"{",
"tagkey",
":",
"tagvalue",
"}}"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/tags.py#L1071-L1081 | train | Returns a mapping of resource_id to tagkey - > tagvalue | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/resources/asg.py | LaunchInfo.get_launch_configs | def get_launch_configs(self, asgs):
"""Return a mapping of launch configs for the given set of asgs"""
config_names = set()
for a in asgs:
if 'LaunchConfigurationName' not in a:
continue
config_names.add(a['LaunchConfigurationName'])
if not config_... | python | def get_launch_configs(self, asgs):
"""Return a mapping of launch configs for the given set of asgs"""
config_names = set()
for a in asgs:
if 'LaunchConfigurationName' not in a:
continue
config_names.add(a['LaunchConfigurationName'])
if not config_... | [
"def",
"get_launch_configs",
"(",
"self",
",",
"asgs",
")",
":",
"config_names",
"=",
"set",
"(",
")",
"for",
"a",
"in",
"asgs",
":",
"if",
"'LaunchConfigurationName'",
"not",
"in",
"a",
":",
"continue",
"config_names",
".",
"add",
"(",
"a",
"[",
"'Launc... | Return a mapping of launch configs for the given set of asgs | [
"Return",
"a",
"mapping",
"of",
"launch",
"configs",
"for",
"the",
"given",
"set",
"of",
"asgs"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/asg.py#L103-L119 | train | Return a mapping of launch configs for the given set of asgs | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | c7n/resources/appelb.py | DescribeAppElb.get_resources | def get_resources(self, ids, cache=True):
"""Support server side filtering on arns or names
"""
if ids[0].startswith('arn:'):
params = {'LoadBalancerArns': ids}
else:
params = {'Names': ids}
return self.query.filter(self.manager, **params) | python | def get_resources(self, ids, cache=True):
"""Support server side filtering on arns or names
"""
if ids[0].startswith('arn:'):
params = {'LoadBalancerArns': ids}
else:
params = {'Names': ids}
return self.query.filter(self.manager, **params) | [
"def",
"get_resources",
"(",
"self",
",",
"ids",
",",
"cache",
"=",
"True",
")",
":",
"if",
"ids",
"[",
"0",
"]",
".",
"startswith",
"(",
"'arn:'",
")",
":",
"params",
"=",
"{",
"'LoadBalancerArns'",
":",
"ids",
"}",
"else",
":",
"params",
"=",
"{"... | Support server side filtering on arns or names | [
"Support",
"server",
"side",
"filtering",
"on",
"arns",
"or",
"names"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/resources/appelb.py#L81-L88 | train | Support server side filtering on arns or names | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/cli.py | validate | def validate(config):
"""Validate a configuration file."""
with open(config) as fh:
data = utils.yaml_load(fh.read())
jsonschema.validate(data, CONFIG_SCHEMA) | python | def validate(config):
"""Validate a configuration file."""
with open(config) as fh:
data = utils.yaml_load(fh.read())
jsonschema.validate(data, CONFIG_SCHEMA) | [
"def",
"validate",
"(",
"config",
")",
":",
"with",
"open",
"(",
"config",
")",
"as",
"fh",
":",
"data",
"=",
"utils",
".",
"yaml_load",
"(",
"fh",
".",
"read",
"(",
")",
")",
"jsonschema",
".",
"validate",
"(",
"data",
",",
"CONFIG_SCHEMA",
")"
] | Validate a configuration file. | [
"Validate",
"a",
"configuration",
"file",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/cli.py#L168-L172 | train | Validate a configuration file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/cli.py | run | def run(config, tag, bucket, account, not_bucket, not_account, debug, region):
"""Run across a set of accounts and buckets."""
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s: %(name)s:%(levelname)s %(message)s")
logging.getLogger('botocore').setLevel(level=logging.WARNING)
... | python | def run(config, tag, bucket, account, not_bucket, not_account, debug, region):
"""Run across a set of accounts and buckets."""
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s: %(name)s:%(levelname)s %(message)s")
logging.getLogger('botocore').setLevel(level=logging.WARNING)
... | [
"def",
"run",
"(",
"config",
",",
"tag",
",",
"bucket",
",",
"account",
",",
"not_bucket",
",",
"not_account",
",",
"debug",
",",
"region",
")",
":",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"INFO",
",",
"format",
"=",
"\"%(asc... | Run across a set of accounts and buckets. | [
"Run",
"across",
"a",
"set",
"of",
"accounts",
"and",
"buckets",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/cli.py#L190-L238 | train | Run across a set of accounts and buckets. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/cli.py | reset | def reset(c7n_async=None):
"""Delete all persistent cluster state.
"""
click.echo('Delete db? Are you Sure? [yn] ', nl=False)
c = click.getchar()
click.echo()
if c == 'y':
click.echo('Wiping database')
worker.connection.flushdb()
elif c == 'n':
click.echo('Abort!')
... | python | def reset(c7n_async=None):
"""Delete all persistent cluster state.
"""
click.echo('Delete db? Are you Sure? [yn] ', nl=False)
c = click.getchar()
click.echo()
if c == 'y':
click.echo('Wiping database')
worker.connection.flushdb()
elif c == 'n':
click.echo('Abort!')
... | [
"def",
"reset",
"(",
"c7n_async",
"=",
"None",
")",
":",
"click",
".",
"echo",
"(",
"'Delete db? Are you Sure? [yn] '",
",",
"nl",
"=",
"False",
")",
"c",
"=",
"click",
".",
"getchar",
"(",
")",
"click",
".",
"echo",
"(",
")",
"if",
"c",
"==",
"'y'",... | Delete all persistent cluster state. | [
"Delete",
"all",
"persistent",
"cluster",
"state",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/cli.py#L253-L265 | train | Delete all persistent cluster state. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/cli.py | workers | def workers():
"""Show information on salactus workers. (slow)"""
counter = Counter()
for w in Worker.all(connection=worker.connection):
for q in w.queues:
counter[q.name] += 1
import pprint
pprint.pprint(dict(counter)) | python | def workers():
"""Show information on salactus workers. (slow)"""
counter = Counter()
for w in Worker.all(connection=worker.connection):
for q in w.queues:
counter[q.name] += 1
import pprint
pprint.pprint(dict(counter)) | [
"def",
"workers",
"(",
")",
":",
"counter",
"=",
"Counter",
"(",
")",
"for",
"w",
"in",
"Worker",
".",
"all",
"(",
"connection",
"=",
"worker",
".",
"connection",
")",
":",
"for",
"q",
"in",
"w",
".",
"queues",
":",
"counter",
"[",
"q",
".",
"nam... | Show information on salactus workers. (slow) | [
"Show",
"information",
"on",
"salactus",
"workers",
".",
"(",
"slow",
")"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/cli.py#L269-L276 | train | Show information on salactus workers. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/cli.py | accounts | def accounts(dbpath, output, format, account,
config=None, tag=None, tagprefix=None, region=(),
not_region=(), not_bucket=None):
"""Report on stats by account"""
d = db.db(dbpath)
accounts = d.accounts()
formatter = (
format == 'csv' and format_accounts_csv or format_ac... | python | def accounts(dbpath, output, format, account,
config=None, tag=None, tagprefix=None, region=(),
not_region=(), not_bucket=None):
"""Report on stats by account"""
d = db.db(dbpath)
accounts = d.accounts()
formatter = (
format == 'csv' and format_accounts_csv or format_ac... | [
"def",
"accounts",
"(",
"dbpath",
",",
"output",
",",
"format",
",",
"account",
",",
"config",
"=",
"None",
",",
"tag",
"=",
"None",
",",
"tagprefix",
"=",
"None",
",",
"region",
"=",
"(",
")",
",",
"not_region",
"=",
"(",
")",
",",
"not_bucket",
"... | Report on stats by account | [
"Report",
"on",
"stats",
"by",
"account"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/cli.py#L335-L382 | train | Report on stats by account | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/cli.py | buckets | def buckets(bucket=None, account=None, matched=False, kdenied=False,
errors=False, dbpath=None, size=None, denied=False,
format=None, incomplete=False, oversize=False, region=(),
not_region=(), inventory=None, output=None, config=None, sort=None,
tagprefix=None, not_bucke... | python | def buckets(bucket=None, account=None, matched=False, kdenied=False,
errors=False, dbpath=None, size=None, denied=False,
format=None, incomplete=False, oversize=False, region=(),
not_region=(), inventory=None, output=None, config=None, sort=None,
tagprefix=None, not_bucke... | [
"def",
"buckets",
"(",
"bucket",
"=",
"None",
",",
"account",
"=",
"None",
",",
"matched",
"=",
"False",
",",
"kdenied",
"=",
"False",
",",
"errors",
"=",
"False",
",",
"dbpath",
"=",
"None",
",",
"size",
"=",
"None",
",",
"denied",
"=",
"False",
"... | Report on stats by bucket | [
"Report",
"on",
"stats",
"by",
"bucket"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/cli.py#L470-L528 | train | Report on stats by bucket | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/cli.py | watch | def watch(limit):
"""watch scan rates across the cluster"""
period = 5.0
prev = db.db()
prev_totals = None
while True:
click.clear()
time.sleep(period)
cur = db.db()
cur.data['gkrate'] = {}
progress = []
prev_buckets = {b.bucket_id: b for b in prev.bu... | python | def watch(limit):
"""watch scan rates across the cluster"""
period = 5.0
prev = db.db()
prev_totals = None
while True:
click.clear()
time.sleep(period)
cur = db.db()
cur.data['gkrate'] = {}
progress = []
prev_buckets = {b.bucket_id: b for b in prev.bu... | [
"def",
"watch",
"(",
"limit",
")",
":",
"period",
"=",
"5.0",
"prev",
"=",
"db",
".",
"db",
"(",
")",
"prev_totals",
"=",
"None",
"while",
"True",
":",
"click",
".",
"clear",
"(",
")",
"time",
".",
"sleep",
"(",
"period",
")",
"cur",
"=",
"db",
... | watch scan rates across the cluster | [
"watch",
"scan",
"rates",
"across",
"the",
"cluster"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/cli.py#L533-L582 | train | watch scan rates across the cluster | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/cli.py | inspect_partitions | def inspect_partitions(bucket):
"""Discover the partitions on a bucket via introspection.
For large buckets which lack s3 inventories, salactus will attempt
to process objects in parallel on the bucket by breaking the bucket
into a separate keyspace partitions. It does this with a heurestic
that at... | python | def inspect_partitions(bucket):
"""Discover the partitions on a bucket via introspection.
For large buckets which lack s3 inventories, salactus will attempt
to process objects in parallel on the bucket by breaking the bucket
into a separate keyspace partitions. It does this with a heurestic
that at... | [
"def",
"inspect_partitions",
"(",
"bucket",
")",
":",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"INFO",
",",
"format",
"=",
"\"%(asctime)s: %(name)s:%(levelname)s %(message)s\"",
")",
"logging",
".",
"getLogger",
"(",
"'botocore'",
")",
"."... | Discover the partitions on a bucket via introspection.
For large buckets which lack s3 inventories, salactus will attempt
to process objects in parallel on the bucket by breaking the bucket
into a separate keyspace partitions. It does this with a heurestic
that attempts to sample the keyspace and deter... | [
"Discover",
"the",
"partitions",
"on",
"a",
"bucket",
"via",
"introspection",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/cli.py#L587-L641 | train | This command provides a simple interface to discover the partitions on a given bucket. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/cli.py | inspect_bucket | def inspect_bucket(bucket):
"""Show all information known on a bucket."""
state = db.db()
found = None
for b in state.buckets():
if b.name == bucket:
found = b
if not found:
click.echo("no bucket named: %s" % bucket)
return
click.echo("Bucket: %s" % found.nam... | python | def inspect_bucket(bucket):
"""Show all information known on a bucket."""
state = db.db()
found = None
for b in state.buckets():
if b.name == bucket:
found = b
if not found:
click.echo("no bucket named: %s" % bucket)
return
click.echo("Bucket: %s" % found.nam... | [
"def",
"inspect_bucket",
"(",
"bucket",
")",
":",
"state",
"=",
"db",
".",
"db",
"(",
")",
"found",
"=",
"None",
"for",
"b",
"in",
"state",
".",
"buckets",
"(",
")",
":",
"if",
"b",
".",
"name",
"==",
"bucket",
":",
"found",
"=",
"b",
"if",
"no... | Show all information known on a bucket. | [
"Show",
"all",
"information",
"known",
"on",
"a",
"bucket",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/cli.py#L646-L675 | train | Show all information known on a bucket. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/cli.py | inspect_queue | def inspect_queue(queue, state, limit, bucket):
"""Show contents of a queue."""
if not HAVE_BIN_LIBS:
click.echo("missing required binary libs (lz4, msgpack)")
return
conn = worker.connection
def job_row(j):
if isinstance(j.args[0], basestring):
account, bucket = j.... | python | def inspect_queue(queue, state, limit, bucket):
"""Show contents of a queue."""
if not HAVE_BIN_LIBS:
click.echo("missing required binary libs (lz4, msgpack)")
return
conn = worker.connection
def job_row(j):
if isinstance(j.args[0], basestring):
account, bucket = j.... | [
"def",
"inspect_queue",
"(",
"queue",
",",
"state",
",",
"limit",
",",
"bucket",
")",
":",
"if",
"not",
"HAVE_BIN_LIBS",
":",
"click",
".",
"echo",
"(",
"\"missing required binary libs (lz4, msgpack)\"",
")",
"return",
"conn",
"=",
"worker",
".",
"connection",
... | Show contents of a queue. | [
"Show",
"contents",
"of",
"a",
"queue",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/cli.py#L685-L745 | train | Show contents of a queue. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/cli.py | queues | def queues():
"""Report on progress by queues."""
conn = worker.connection
failure_q = None
def _repr(q):
return "running:%d pending:%d finished:%d" % (
StartedJobRegistry(q.name, conn).count,
q.count,
FinishedJobRegistry(q.name, conn).count)
for q in Que... | python | def queues():
"""Report on progress by queues."""
conn = worker.connection
failure_q = None
def _repr(q):
return "running:%d pending:%d finished:%d" % (
StartedJobRegistry(q.name, conn).count,
q.count,
FinishedJobRegistry(q.name, conn).count)
for q in Que... | [
"def",
"queues",
"(",
")",
":",
"conn",
"=",
"worker",
".",
"connection",
"failure_q",
"=",
"None",
"def",
"_repr",
"(",
"q",
")",
":",
"return",
"\"running:%d pending:%d finished:%d\"",
"%",
"(",
"StartedJobRegistry",
"(",
"q",
".",
"name",
",",
"conn",
"... | Report on progress by queues. | [
"Report",
"on",
"progress",
"by",
"queues",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/cli.py#L749-L766 | train | Report on progress by queues. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_salactus/c7n_salactus/cli.py | failures | def failures():
"""Show any unexpected failures"""
if not HAVE_BIN_LIBS:
click.echo("missing required binary libs (lz4, msgpack)")
return
q = Queue('failed', connection=worker.connection)
for i in q.get_job_ids():
j = q.job_class.fetch(i, connection=q.connection)
click.e... | python | def failures():
"""Show any unexpected failures"""
if not HAVE_BIN_LIBS:
click.echo("missing required binary libs (lz4, msgpack)")
return
q = Queue('failed', connection=worker.connection)
for i in q.get_job_ids():
j = q.job_class.fetch(i, connection=q.connection)
click.e... | [
"def",
"failures",
"(",
")",
":",
"if",
"not",
"HAVE_BIN_LIBS",
":",
"click",
".",
"echo",
"(",
"\"missing required binary libs (lz4, msgpack)\"",
")",
"return",
"q",
"=",
"Queue",
"(",
"'failed'",
",",
"connection",
"=",
"worker",
".",
"connection",
")",
"for... | Show any unexpected failures | [
"Show",
"any",
"unexpected",
"failures"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_salactus/c7n_salactus/cli.py#L770-L782 | train | Show any unexpected failures | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_org/scripts/azuresubs.py | main | def main(output):
"""
Generate a c7n-org subscriptions config file
"""
client = SubscriptionClient(Session().get_credentials())
subs = [sub.serialize(True) for sub in client.subscriptions.list()]
results = []
for sub in subs:
sub_info = {
'subscription_id': sub['subscrip... | python | def main(output):
"""
Generate a c7n-org subscriptions config file
"""
client = SubscriptionClient(Session().get_credentials())
subs = [sub.serialize(True) for sub in client.subscriptions.list()]
results = []
for sub in subs:
sub_info = {
'subscription_id': sub['subscrip... | [
"def",
"main",
"(",
"output",
")",
":",
"client",
"=",
"SubscriptionClient",
"(",
"Session",
"(",
")",
".",
"get_credentials",
"(",
")",
")",
"subs",
"=",
"[",
"sub",
".",
"serialize",
"(",
"True",
")",
"for",
"sub",
"in",
"client",
".",
"subscriptions... | Generate a c7n-org subscriptions config file | [
"Generate",
"a",
"c7n",
"-",
"org",
"subscriptions",
"config",
"file"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_org/scripts/azuresubs.py#L27-L46 | train | Generate a c7n - org subscriptions config file | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_azure/c7n_azure/utils.py | custodian_azure_send_override | def custodian_azure_send_override(self, request, headers=None, content=None, **kwargs):
""" Overrides ServiceClient.send() function to implement retries & log headers
"""
retries = 0
max_retries = 3
while retries < max_retries:
response = self.orig_send(request, headers, content, **kwargs)
... | python | def custodian_azure_send_override(self, request, headers=None, content=None, **kwargs):
""" Overrides ServiceClient.send() function to implement retries & log headers
"""
retries = 0
max_retries = 3
while retries < max_retries:
response = self.orig_send(request, headers, content, **kwargs)
... | [
"def",
"custodian_azure_send_override",
"(",
"self",
",",
"request",
",",
"headers",
"=",
"None",
",",
"content",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"retries",
"=",
"0",
"max_retries",
"=",
"3",
"while",
"retries",
"<",
"max_retries",
":",
"... | Overrides ServiceClient.send() function to implement retries & log headers | [
"Overrides",
"ServiceClient",
".",
"send",
"()",
"function",
"to",
"implement",
"retries",
"&",
"log",
"headers"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/utils.py#L111-L143 | train | Override send function to implement retries & log headers
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_azure/c7n_azure/utils.py | GraphHelper.get_principal_dictionary | def get_principal_dictionary(graph_client, object_ids, raise_on_graph_call_error=False):
"""Retrieves Azure AD Objects for corresponding object ids passed.
:param graph_client: A client for Microsoft Graph.
:param object_ids: The object ids to retrieve Azure AD objects for.
:param raise_... | python | def get_principal_dictionary(graph_client, object_ids, raise_on_graph_call_error=False):
"""Retrieves Azure AD Objects for corresponding object ids passed.
:param graph_client: A client for Microsoft Graph.
:param object_ids: The object ids to retrieve Azure AD objects for.
:param raise_... | [
"def",
"get_principal_dictionary",
"(",
"graph_client",
",",
"object_ids",
",",
"raise_on_graph_call_error",
"=",
"False",
")",
":",
"if",
"not",
"object_ids",
":",
"return",
"{",
"}",
"object_params",
"=",
"GetObjectsParameters",
"(",
"include_directory_object_referenc... | Retrieves Azure AD Objects for corresponding object ids passed.
:param graph_client: A client for Microsoft Graph.
:param object_ids: The object ids to retrieve Azure AD objects for.
:param raise_on_graph_call_error: A boolean indicate whether an error should be
raised if the underlying ... | [
"Retrieves",
"Azure",
"AD",
"Objects",
"for",
"corresponding",
"object",
"ids",
"passed",
".",
":",
"param",
"graph_client",
":",
"A",
"client",
"for",
"Microsoft",
"Graph",
".",
":",
"param",
"object_ids",
":",
"The",
"object",
"ids",
"to",
"retrieve",
"Azu... | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/utils.py#L200-L237 | train | Retrieves the principal dictionary for the given object ids. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_azure/c7n_azure/utils.py | GraphHelper.get_principal_name | def get_principal_name(graph_object):
"""Attempts to resolve a principal name.
:param graph_object: the Azure AD Graph Object
:return: The resolved value or an empty string if unsuccessful.
"""
if hasattr(graph_object, 'user_principal_name'):
return graph_object.user_... | python | def get_principal_name(graph_object):
"""Attempts to resolve a principal name.
:param graph_object: the Azure AD Graph Object
:return: The resolved value or an empty string if unsuccessful.
"""
if hasattr(graph_object, 'user_principal_name'):
return graph_object.user_... | [
"def",
"get_principal_name",
"(",
"graph_object",
")",
":",
"if",
"hasattr",
"(",
"graph_object",
",",
"'user_principal_name'",
")",
":",
"return",
"graph_object",
".",
"user_principal_name",
"elif",
"hasattr",
"(",
"graph_object",
",",
"'service_principal_names'",
")... | Attempts to resolve a principal name.
:param graph_object: the Azure AD Graph Object
:return: The resolved value or an empty string if unsuccessful. | [
"Attempts",
"to",
"resolve",
"a",
"principal",
"name",
".",
":",
"param",
"graph_object",
":",
"the",
"Azure",
"AD",
"Graph",
"Object",
":",
"return",
":",
"The",
"resolved",
"value",
"or",
"an",
"empty",
"string",
"if",
"unsuccessful",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/utils.py#L240-L251 | train | Attempts to resolve a principal name. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_azure/c7n_azure/utils.py | PortsRangeHelper._get_port_range | def _get_port_range(range_str):
""" Given a string with a port or port range: '80', '80-120'
Returns tuple with range start and end ports: (80, 80), (80, 120)
"""
if range_str == '*':
return PortsRangeHelper.PortsRange(start=0, end=65535)
s = range_str.split('-')... | python | def _get_port_range(range_str):
""" Given a string with a port or port range: '80', '80-120'
Returns tuple with range start and end ports: (80, 80), (80, 120)
"""
if range_str == '*':
return PortsRangeHelper.PortsRange(start=0, end=65535)
s = range_str.split('-')... | [
"def",
"_get_port_range",
"(",
"range_str",
")",
":",
"if",
"range_str",
"==",
"'*'",
":",
"return",
"PortsRangeHelper",
".",
"PortsRange",
"(",
"start",
"=",
"0",
",",
"end",
"=",
"65535",
")",
"s",
"=",
"range_str",
".",
"split",
"(",
"'-'",
")",
"if... | Given a string with a port or port range: '80', '80-120'
Returns tuple with range start and end ports: (80, 80), (80, 120) | [
"Given",
"a",
"string",
"with",
"a",
"port",
"or",
"port",
"range",
":",
"80",
"80",
"-",
"120",
"Returns",
"tuple",
"with",
"range",
"start",
"and",
"end",
"ports",
":",
"(",
"80",
"80",
")",
"(",
"80",
"120",
")"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/utils.py#L259-L270 | train | Returns a tuple with start and end ports | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_azure/c7n_azure/utils.py | PortsRangeHelper._get_rule_port_ranges | def _get_rule_port_ranges(rule):
""" Extracts ports ranges from the NSG rule object
Returns an array of PortsRange tuples
"""
properties = rule['properties']
if 'destinationPortRange' in properties:
return [PortsRangeHelper._get_port_range(properties['destinationP... | python | def _get_rule_port_ranges(rule):
""" Extracts ports ranges from the NSG rule object
Returns an array of PortsRange tuples
"""
properties = rule['properties']
if 'destinationPortRange' in properties:
return [PortsRangeHelper._get_port_range(properties['destinationP... | [
"def",
"_get_rule_port_ranges",
"(",
"rule",
")",
":",
"properties",
"=",
"rule",
"[",
"'properties'",
"]",
"if",
"'destinationPortRange'",
"in",
"properties",
":",
"return",
"[",
"PortsRangeHelper",
".",
"_get_port_range",
"(",
"properties",
"[",
"'destinationPortR... | Extracts ports ranges from the NSG rule object
Returns an array of PortsRange tuples | [
"Extracts",
"ports",
"ranges",
"from",
"the",
"NSG",
"rule",
"object",
"Returns",
"an",
"array",
"of",
"PortsRange",
"tuples"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/utils.py#L280-L289 | train | Extracts the ports ranges from the NSG rule object
Returns an array of PortsRange tuples | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_azure/c7n_azure/utils.py | PortsRangeHelper._port_ranges_to_set | def _port_ranges_to_set(ranges):
""" Converts array of port ranges to the set of integers
Example: [(10-12), (20,20)] -> {10, 11, 12, 20}
"""
return set([i for r in ranges for i in range(r.start, r.end + 1)]) | python | def _port_ranges_to_set(ranges):
""" Converts array of port ranges to the set of integers
Example: [(10-12), (20,20)] -> {10, 11, 12, 20}
"""
return set([i for r in ranges for i in range(r.start, r.end + 1)]) | [
"def",
"_port_ranges_to_set",
"(",
"ranges",
")",
":",
"return",
"set",
"(",
"[",
"i",
"for",
"r",
"in",
"ranges",
"for",
"i",
"in",
"range",
"(",
"r",
".",
"start",
",",
"r",
".",
"end",
"+",
"1",
")",
"]",
")"
] | Converts array of port ranges to the set of integers
Example: [(10-12), (20,20)] -> {10, 11, 12, 20} | [
"Converts",
"array",
"of",
"port",
"ranges",
"to",
"the",
"set",
"of",
"integers",
"Example",
":",
"[",
"(",
"10",
"-",
"12",
")",
"(",
"20",
"20",
")",
"]",
"-",
">",
"{",
"10",
"11",
"12",
"20",
"}"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/utils.py#L292-L296 | train | Converts an array of port ranges to a set of integers
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_azure/c7n_azure/utils.py | PortsRangeHelper.validate_ports_string | def validate_ports_string(ports):
""" Validate that provided string has proper port numbers:
1. port number < 65535
2. range start < range end
"""
pattern = re.compile('^\\d+(-\\d+)?(,\\d+(-\\d+)?)*$')
if pattern.match(ports) is None:
return False
... | python | def validate_ports_string(ports):
""" Validate that provided string has proper port numbers:
1. port number < 65535
2. range start < range end
"""
pattern = re.compile('^\\d+(-\\d+)?(,\\d+(-\\d+)?)*$')
if pattern.match(ports) is None:
return False
... | [
"def",
"validate_ports_string",
"(",
"ports",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"'^\\\\d+(-\\\\d+)?(,\\\\d+(-\\\\d+)?)*$'",
")",
"if",
"pattern",
".",
"match",
"(",
"ports",
")",
"is",
"None",
":",
"return",
"False",
"ranges",
"=",
"PortsRan... | Validate that provided string has proper port numbers:
1. port number < 65535
2. range start < range end | [
"Validate",
"that",
"provided",
"string",
"has",
"proper",
"port",
"numbers",
":",
"1",
".",
"port",
"number",
"<",
"65535",
"2",
".",
"range",
"start",
"<",
"range",
"end"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/utils.py#L299-L312 | train | Validate that the string has proper port numbers | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_azure/c7n_azure/utils.py | PortsRangeHelper.get_ports_strings_from_list | def get_ports_strings_from_list(data):
""" Transform a list of port numbers to the list of strings with port ranges
Example: [10, 12, 13, 14, 15] -> ['10', '12-15']
"""
if len(data) == 0:
return []
# Transform diff_ports list to the ranges list
first = 0
... | python | def get_ports_strings_from_list(data):
""" Transform a list of port numbers to the list of strings with port ranges
Example: [10, 12, 13, 14, 15] -> ['10', '12-15']
"""
if len(data) == 0:
return []
# Transform diff_ports list to the ranges list
first = 0
... | [
"def",
"get_ports_strings_from_list",
"(",
"data",
")",
":",
"if",
"len",
"(",
"data",
")",
"==",
"0",
":",
"return",
"[",
"]",
"# Transform diff_ports list to the ranges list",
"first",
"=",
"0",
"result",
"=",
"[",
"]",
"for",
"it",
"in",
"range",
"(",
"... | Transform a list of port numbers to the list of strings with port ranges
Example: [10, 12, 13, 14, 15] -> ['10', '12-15'] | [
"Transform",
"a",
"list",
"of",
"port",
"numbers",
"to",
"the",
"list",
"of",
"strings",
"with",
"port",
"ranges",
"Example",
":",
"[",
"10",
"12",
"13",
"14",
"15",
"]",
"-",
">",
"[",
"10",
"12",
"-",
"15",
"]"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/utils.py#L330-L349 | train | Transform a list of port numbers to the list of strings with port ranges
Example : 10 12 - 13 14 - 15 | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_azure/c7n_azure/utils.py | PortsRangeHelper.build_ports_dict | def build_ports_dict(nsg, direction_key, ip_protocol):
""" Build entire ports array filled with True (Allow), False (Deny) and None(default - Deny)
based on the provided Network Security Group object, direction and protocol.
"""
rules = nsg['properties']['securityRules']
rule... | python | def build_ports_dict(nsg, direction_key, ip_protocol):
""" Build entire ports array filled with True (Allow), False (Deny) and None(default - Deny)
based on the provided Network Security Group object, direction and protocol.
"""
rules = nsg['properties']['securityRules']
rule... | [
"def",
"build_ports_dict",
"(",
"nsg",
",",
"direction_key",
",",
"ip_protocol",
")",
":",
"rules",
"=",
"nsg",
"[",
"'properties'",
"]",
"[",
"'securityRules'",
"]",
"rules",
"=",
"sorted",
"(",
"rules",
",",
"key",
"=",
"lambda",
"k",
":",
"k",
"[",
... | Build entire ports array filled with True (Allow), False (Deny) and None(default - Deny)
based on the provided Network Security Group object, direction and protocol. | [
"Build",
"entire",
"ports",
"array",
"filled",
"with",
"True",
"(",
"Allow",
")",
"False",
"(",
"Deny",
")",
"and",
"None",
"(",
"default",
"-",
"Deny",
")",
"based",
"on",
"the",
"provided",
"Network",
"Security",
"Group",
"object",
"direction",
"and",
... | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/utils.py#L352-L380 | train | Builds a dictionary of ports based on the provided Network Security Group object direction and protocol. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_gcp/c7n_gcp/actions/cscc.py | PostFinding.get_name | def get_name(self, r):
"""Given an arbitrary resource attempt to resolve back to a qualified name."""
namer = ResourceNameAdapters[self.manager.resource_type.service]
return namer(r) | python | def get_name(self, r):
"""Given an arbitrary resource attempt to resolve back to a qualified name."""
namer = ResourceNameAdapters[self.manager.resource_type.service]
return namer(r) | [
"def",
"get_name",
"(",
"self",
",",
"r",
")",
":",
"namer",
"=",
"ResourceNameAdapters",
"[",
"self",
".",
"manager",
".",
"resource_type",
".",
"service",
"]",
"return",
"namer",
"(",
"r",
")"
] | Given an arbitrary resource attempt to resolve back to a qualified name. | [
"Given",
"an",
"arbitrary",
"resource",
"attempt",
"to",
"resolve",
"back",
"to",
"a",
"qualified",
"name",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_gcp/c7n_gcp/actions/cscc.py#L137-L140 | train | Given an arbitrary resource attempt to resolve back to a qualified name. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/dev/license-headers.py | update_headers | def update_headers(src_tree):
"""Main."""
print("src tree", src_tree)
for root, dirs, files in os.walk(src_tree):
py_files = fnmatch.filter(files, "*.py")
for f in py_files:
print("checking", f)
p = os.path.join(root, f)
with open(p) as fh:
... | python | def update_headers(src_tree):
"""Main."""
print("src tree", src_tree)
for root, dirs, files in os.walk(src_tree):
py_files = fnmatch.filter(files, "*.py")
for f in py_files:
print("checking", f)
p = os.path.join(root, f)
with open(p) as fh:
... | [
"def",
"update_headers",
"(",
"src_tree",
")",
":",
"print",
"(",
"\"src tree\"",
",",
"src_tree",
")",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"src_tree",
")",
":",
"py_files",
"=",
"fnmatch",
".",
"filter",
"(",
"files... | Main. | [
"Main",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/dev/license-headers.py#L45-L60 | train | Update the license headers for all the modules in src_tree. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py | list_locks | def list_locks(account_id, resource_type=None, resource_id=None):
"""Show extant locks and unlocks.
"""
locks = Client(BASE_URL, account_id).list_locks().json()
for r in locks:
if 'LockDate' in r:
r['LockDate'] = datetime.fromtimestamp(r['LockDate'])
if 'RevisionDate' in r:
... | python | def list_locks(account_id, resource_type=None, resource_id=None):
"""Show extant locks and unlocks.
"""
locks = Client(BASE_URL, account_id).list_locks().json()
for r in locks:
if 'LockDate' in r:
r['LockDate'] = datetime.fromtimestamp(r['LockDate'])
if 'RevisionDate' in r:
... | [
"def",
"list_locks",
"(",
"account_id",
",",
"resource_type",
"=",
"None",
",",
"resource_id",
"=",
"None",
")",
":",
"locks",
"=",
"Client",
"(",
"BASE_URL",
",",
"account_id",
")",
".",
"list_locks",
"(",
")",
".",
"json",
"(",
")",
"for",
"r",
"in",... | Show extant locks and unlocks. | [
"Show",
"extant",
"locks",
"and",
"unlocks",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py#L38-L52 | train | Show extant locks and unlocks. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py | lock_status | def lock_status(account_id, resource_id, parent_id):
"""Show extant locks' status
"""
return output(
Client(BASE_URL, account_id).lock_status(resource_id, parent_id)) | python | def lock_status(account_id, resource_id, parent_id):
"""Show extant locks' status
"""
return output(
Client(BASE_URL, account_id).lock_status(resource_id, parent_id)) | [
"def",
"lock_status",
"(",
"account_id",
",",
"resource_id",
",",
"parent_id",
")",
":",
"return",
"output",
"(",
"Client",
"(",
"BASE_URL",
",",
"account_id",
")",
".",
"lock_status",
"(",
"resource_id",
",",
"parent_id",
")",
")"
] | Show extant locks' status | [
"Show",
"extant",
"locks",
"status"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py#L67-L71 | train | Show extant locks status | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py | lock | def lock(account_id, resource_id, region):
"""Lock a resource
"""
return output(
Client(BASE_URL, account_id).lock(resource_id, region)) | python | def lock(account_id, resource_id, region):
"""Lock a resource
"""
return output(
Client(BASE_URL, account_id).lock(resource_id, region)) | [
"def",
"lock",
"(",
"account_id",
",",
"resource_id",
",",
"region",
")",
":",
"return",
"output",
"(",
"Client",
"(",
"BASE_URL",
",",
"account_id",
")",
".",
"lock",
"(",
"resource_id",
",",
"region",
")",
")"
] | Lock a resource | [
"Lock",
"a",
"resource"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py#L78-L82 | train | Lock a resource in a given account | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/sandbox/c7n_sphere11/c7n_sphere11/client.py | Client.list_locks | def list_locks(self, account_id=None):
"""Get extant locks for the given account.
"""
account_id = self.get_account_id(account_id)
return self.http.get(
"%s/%s/locks" % (self.endpoint, account_id),
auth=self.get_api_auth()) | python | def list_locks(self, account_id=None):
"""Get extant locks for the given account.
"""
account_id = self.get_account_id(account_id)
return self.http.get(
"%s/%s/locks" % (self.endpoint, account_id),
auth=self.get_api_auth()) | [
"def",
"list_locks",
"(",
"self",
",",
"account_id",
"=",
"None",
")",
":",
"account_id",
"=",
"self",
".",
"get_account_id",
"(",
"account_id",
")",
"return",
"self",
".",
"http",
".",
"get",
"(",
"\"%s/%s/locks\"",
"%",
"(",
"self",
".",
"endpoint",
",... | Get extant locks for the given account. | [
"Get",
"extant",
"locks",
"for",
"the",
"given",
"account",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/client.py#L41-L47 | train | Get extant locks for the given account. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/sandbox/c7n_sphere11/c7n_sphere11/client.py | Client.lock_status | def lock_status(self, resource_id, parent_id=None, account_id=None):
"""Get the lock status for a given resource.
for security groups, parent id is their vpc.
"""
account_id = self.get_account_id(account_id)
params = parent_id and {'parent_id': parent_id} or None
return ... | python | def lock_status(self, resource_id, parent_id=None, account_id=None):
"""Get the lock status for a given resource.
for security groups, parent id is their vpc.
"""
account_id = self.get_account_id(account_id)
params = parent_id and {'parent_id': parent_id} or None
return ... | [
"def",
"lock_status",
"(",
"self",
",",
"resource_id",
",",
"parent_id",
"=",
"None",
",",
"account_id",
"=",
"None",
")",
":",
"account_id",
"=",
"self",
".",
"get_account_id",
"(",
"account_id",
")",
"params",
"=",
"parent_id",
"and",
"{",
"'parent_id'",
... | Get the lock status for a given resource.
for security groups, parent id is their vpc. | [
"Get",
"the",
"lock",
"status",
"for",
"a",
"given",
"resource",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/client.py#L49-L58 | train | Get the lock status for a given resource. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/sandbox/c7n_sphere11/c7n_sphere11/client.py | Client.lock | def lock(self, resource_id, region, account_id=None):
"""Lock a given resource
"""
account_id = self.get_account_id(account_id)
return self.http.post(
"%s/%s/locks/%s/lock" % (self.endpoint, account_id, resource_id),
json={'region': region},
auth=self.... | python | def lock(self, resource_id, region, account_id=None):
"""Lock a given resource
"""
account_id = self.get_account_id(account_id)
return self.http.post(
"%s/%s/locks/%s/lock" % (self.endpoint, account_id, resource_id),
json={'region': region},
auth=self.... | [
"def",
"lock",
"(",
"self",
",",
"resource_id",
",",
"region",
",",
"account_id",
"=",
"None",
")",
":",
"account_id",
"=",
"self",
".",
"get_account_id",
"(",
"account_id",
")",
"return",
"self",
".",
"http",
".",
"post",
"(",
"\"%s/%s/locks/%s/lock\"",
"... | Lock a given resource | [
"Lock",
"a",
"given",
"resource"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/client.py#L60-L67 | train | Lock a given resource in a given region. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_org/c7n_org/cli.py | report | def report(config, output, use, output_dir, accounts,
field, no_default_fields, tags, region, debug, verbose,
policy, policy_tags, format, resource, cache_path):
"""report on a cross account policy execution."""
accounts_config, custodian_config, executor = init(
config, use, debug... | python | def report(config, output, use, output_dir, accounts,
field, no_default_fields, tags, region, debug, verbose,
policy, policy_tags, format, resource, cache_path):
"""report on a cross account policy execution."""
accounts_config, custodian_config, executor = init(
config, use, debug... | [
"def",
"report",
"(",
"config",
",",
"output",
",",
"use",
",",
"output_dir",
",",
"accounts",
",",
"field",
",",
"no_default_fields",
",",
"tags",
",",
"region",
",",
"debug",
",",
"verbose",
",",
"policy",
",",
"policy_tags",
",",
"format",
",",
"resou... | report on a cross account policy execution. | [
"report",
"on",
"a",
"cross",
"account",
"policy",
"execution",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_org/c7n_org/cli.py#L322-L386 | train | report on a cross account policy execution. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_org/c7n_org/cli.py | run_script | def run_script(config, output_dir, accounts, tags, region, echo, serial, script_args):
"""run an aws script across accounts"""
# TODO count up on success / error / error list by account
accounts_config, custodian_config, executor = init(
config, None, serial, True, accounts, tags, (), ())
if ec... | python | def run_script(config, output_dir, accounts, tags, region, echo, serial, script_args):
"""run an aws script across accounts"""
# TODO count up on success / error / error list by account
accounts_config, custodian_config, executor = init(
config, None, serial, True, accounts, tags, (), ())
if ec... | [
"def",
"run_script",
"(",
"config",
",",
"output_dir",
",",
"accounts",
",",
"tags",
",",
"region",
",",
"echo",
",",
"serial",
",",
"script_args",
")",
":",
"# TODO count up on success / error / error list by account",
"accounts_config",
",",
"custodian_config",
",",... | run an aws script across accounts | [
"run",
"an",
"aws",
"script",
"across",
"accounts"
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_org/c7n_org/cli.py#L434-L472 | train | run an aws script across accounts | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
cloud-custodian/cloud-custodian | tools/c7n_org/c7n_org/cli.py | run_account | def run_account(account, region, policies_config, output_path,
cache_period, cache_path, metrics, dryrun, debug):
"""Execute a set of policies on an account.
"""
logging.getLogger('custodian.output').setLevel(logging.ERROR + 1)
CONN_CACHE.session = None
CONN_CACHE.time = None
# ... | python | def run_account(account, region, policies_config, output_path,
cache_period, cache_path, metrics, dryrun, debug):
"""Execute a set of policies on an account.
"""
logging.getLogger('custodian.output').setLevel(logging.ERROR + 1)
CONN_CACHE.session = None
CONN_CACHE.time = None
# ... | [
"def",
"run_account",
"(",
"account",
",",
"region",
",",
"policies_config",
",",
"output_path",
",",
"cache_period",
",",
"cache_path",
",",
"metrics",
",",
"dryrun",
",",
"debug",
")",
":",
"logging",
".",
"getLogger",
"(",
"'custodian.output'",
")",
".",
... | Execute a set of policies on an account. | [
"Execute",
"a",
"set",
"of",
"policies",
"on",
"an",
"account",
"."
] | 52ef732eb3d7bc939d1579faf519314814695c08 | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_org/c7n_org/cli.py#L492-L570 | train | Execute a set of policies on an account. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.