This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Iterates over all the keys in a bucket and totals the bytes used | |
# NOTE: if you have a lot of keys, this could take a LONG time. | |
import boto | |
def bucket_du(bucket_name): | |
s3 = boto.connect_s3() | |
bucket = s3.lookup(bucket_name) | |
total_bytes = 0 | |
for key in bucket: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EUCA_KEY_DIR=$(dirname $(readlink -f ${BASH_SOURCE})) | |
export S3_URL=http://173.205.188.130:8773/services/Walrus | |
export EC2_URL=http://173.205.188.130:8773/services/Eucalyptus | |
export EC2_PRIVATE_KEY=${EUCA_KEY_DIR}/euca2-garnaat-e5ec560d-pk.pem | |
export EC2_CERT=${EUCA_KEY_DIR}/euca2-garnaat-e5ec560d-cert.pem | |
export EC2_JVM_ARGS=-Djavax.net.ssl.trustStore=${EUCA_KEY_DIR}/jssecacerts | |
export EUCALYPTUS_CERT=${EUCA_KEY_DIR}/cloud-cert.pem | |
export EC2_ACCESS_KEY='999999999999999999999999999999999999' | |
export EC2_SECRET_KEY='00000000000000000000000000000000000000' | |
# This is a bogus value; Eucalyptus does not need this but client tools do. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Credentials] | |
... | |
euca_access_key_id=999999999999999999999999999999999999 | |
euca_secret_access_key=00000000000000000000000000000000000000 | |
... | |
[Boto] | |
... | |
eucalyptus_host =173.205.188.130 | |
walrus_host = 173.205.188.130 | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python | |
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) | |
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import boto | |
>>> euca = boto.connect_euca() | |
>>> euca.get_all_images() | |
[Image:emi-DFEA10FF, Image:emi-DF0A1104, Image:emi-0CC81777, Image:emi-DF5F1113, Image:emi-DF0B1106, Image:emi-E9E51553, | |
... | |
Image:emi-169215C7, Image:emi-622216BC, Image:emi-E4C11567, Image:emi-B153146A, Image:emi-81BC1332] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import boto | |
>>> ec2 = boto.connect_ec2() | |
>>> stats = ec2.get_all_instance_status() | |
>>> stats | |
[InstanceStatus:i-67c81e0c] | |
>>> stat = stats[0] | |
>>> stat | |
InstanceStatus:i-67c81e0c | |
>>> stat.id | |
u'i-67c81e0c' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will cause full debug output to go to the console | |
>>> import boto | |
>>> boto.set_stream_logger('foo') | |
>>> ec2 = boto.connect_ec2(debug=2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto | |
elb = boto.connect_elb() | |
ec2 = boto.connect_ec2() | |
load_balancers = elb.get_all_load_balancers() | |
# | |
# The InstanceInfo object in the LoadBalancer object contains only a small subset | |
# of information about the Instance. To get the full set of information, you have |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import boto | |
>>> c = boto.connect_ec2() | |
>>> reservations = c.get_all_instances() | |
>>> reservations | |
[Reservation:r-b73716d6] | |
>>> instance = reservations[0].instances[0] | |
>>> instance | |
Instance:i-366c4354 | |
>>> instance.tags | |
{} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto | |
s3 = boto.connect_s3() | |
bucket = s3.lookup('mybucket') | |
key = bucket.lookup('mykey') | |
# Copy the key onto itself, preserving the ACL but changing the content-type | |
key.copy(key.bucket, key.name, preserve_acl=True, metadata={'Content-Type': 'text/plain'}) | |
key = bucket.lookup('mykey') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
""" | |
import multiprocessing | |
import boto | |
import os | |
import sys | |
import datetime | |
import logging | |
import Queue |