def test_configure_logging(self): from botocross import configure_logging self.assertTrue(0 == len(log.handlers)) self.assertEquals(getattr(logging, 'NOTSET'), log.getEffectiveLevel()) configure_logging(log, 'DEBUG') self.assertEquals(type(log.handlers[0]), logging.StreamHandler) self.assertEquals(10, log.getEffectiveLevel())
def test_configure_logging(self): from botocross import configure_logging self.assertTrue(0 == len(log.handlers)) self.assertEquals(getattr(logging, "NOTSET"), log.getEffectiveLevel()) configure_logging(log, "DEBUG") self.assertEquals(type(log.handlers[0]), logging.StreamHandler) self.assertEquals(10, log.getEffectiveLevel())
import botocross as bc import logging import os # configure command line argument parsing parser = argparse.ArgumentParser( description='Upload a file to a S3 bucket in all/some available S3 regions', parents=[bc.build_region_parser(), bc.build_common_parser()]) parser.add_argument("bucket", help="A bucket name (will get region suffix)") parser.add_argument("file", help="A local file (e.g. ./test.txt)") args = parser.parse_args() # process common command line arguments log = logging.getLogger('botocross') bc.configure_logging(log, args.log_level) credentials = bc.parse_credentials(args) locations = bc.filter_regions_s3(class_iterator(Location), args.region) # execute business logic log.info("Uploading to S3 buckets named '" + args.bucket + "':") file = open(args.file, 'r') filePath, fileName = os.path.split(file.name) log.debug(filePath) log.debug(fileName) s3 = boto.connect_s3(**credentials) for location in locations: region = RegionMap[location]
import argparse import boto import boto.ec2 import botocross as bc import logging # configure command line argument parsing parser = argparse.ArgumentParser( description="Describe EBS snapshots in all/some available EC2 regions", parents=[bc.build_region_parser(), bc.build_filter_parser("EBS snapshots"), bc.build_common_parser()], ) args = parser.parse_args() # process common command line arguments log = logging.getLogger("botocross") bc.configure_logging(log, args.log_level) credentials = bc.parse_credentials(args) regions = bc.filter_regions(boto.ec2.regions(), args.region) filter = bc.build_filter(args.filter, args.exclude) log.info(args.resource_ids) # execute business logic log.info("Describing EBS snapshots:") for region in regions: try: ec2 = boto.connect_ec2(region=region, **credentials) snapshots = ec2.get_all_snapshots(snapshot_ids=args.resource_ids, owner="self", filters=filter["filters"]) if filter["excludes"]: exclusions = ec2.get_all_snapshots(owner="self", filters=filter["excludes"]) snapshots = bc.filter_list_by_attribute(snapshots, exclusions, "id")
#!/usr/bin/env python """ This is the StackFormation build script based on Fabric (http://fabfile.org/). """ import boto import boto.cloudformation import botocross as bc from fabric.api import local, task import logging import nose import os import stackformation as sfn log = logging.getLogger('fabric') bc.configure_logging(log, 'INFO') @task(default=True) def test(args=None): """ Run all tests. Specify string argument ``args`` for additional args to ``nosetests``. """ test_unit(args) test_integration(args) @task def test_integration(args=None): """ Run all integration tests.