Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def ls(args):
from . import config, tweak
def collect_kv(d, path, collector):
for k, v in d.items():
if isinstance(v, (dict, tweak.Config)):
collect_kv(d[k], path + "." + k, collector)
else:
collector.append([path.lstrip(".") + "." + k, repr(v)])
collector = []
collect_kv(config, "", collector)
page_output(format_table(collector))
def ls(args):
page_output(tabulate(list_rds_clusters(), args))
def images(args):
page_output(filter_and_tabulate(resources.ec2.images.filter(Owners=["self"]), args))
def ls(args):
@lru_cache()
def instance_id_to_name(i):
return add_name(resources.ec2.Instance(i)).name
table = [{f: get_cell(i, f) for f in args.columns} for i in filter_collection(resources.ec2.volumes, args)]
if "attachments" in args.columns:
for row in table:
row["attachments"] = ", ".join(instance_id_to_name(a["InstanceId"]) for a in row["attachments"])
page_output(tabulate(table, args))
def tables(args):
page_output(tabulate(resources.dynamodb.tables.all(), args))
def key_pairs(args):
page_output(tabulate(resources.ec2.key_pairs.all(), args))
cloudwatch = resources.cloudwatch
bucket_region = bucket.LocationConstraint or "us-east-1"
if bucket_region != cloudwatch.meta.client.meta.region_name:
cloudwatch = boto3.Session(region_name=bucket_region).resource("cloudwatch")
data = get_cloudwatch_metric_stats("AWS/S3", "NumberOfObjects",
start_time=datetime.utcnow() - timedelta(days=2),
end_time=datetime.utcnow(), period=3600, BucketName=bucket.name,
StorageType="AllStorageTypes", resource=cloudwatch)
bucket.NumberOfObjects = int(data["Datapoints"][-1]["Average"]) if data["Datapoints"] else None
data = get_cloudwatch_metric_stats("AWS/S3", "BucketSizeBytes",
start_time=datetime.utcnow() - timedelta(days=2),
end_time=datetime.utcnow(), period=3600, BucketName=bucket.name,
StorageType="StandardStorage", resource=cloudwatch)
bucket.BucketSizeBytes = format_number(data["Datapoints"][-1]["Average"]) if data["Datapoints"] else None
table.append(bucket)
page_output(tabulate(table, args))
def compute_environments(args):
page_output(tabulate(paginate(clients.batch.get_paginator("describe_compute_environments")), args))