Skip to content

Commit

Permalink
updated to boto 1.9b-4 (from Debian Sid)
Browse files Browse the repository at this point in the history
- removed ._<filename>.py binary files
- removed packaging files
  • Loading branch information
alonswartz committed Aug 10, 2010
1 parent b723dd7 commit fe2be48
Show file tree
Hide file tree
Showing 91 changed files with 917 additions and 1,159 deletions.
5 changes: 2 additions & 3 deletions bin/list_instances
Expand Up @@ -2,9 +2,8 @@
import boto
ec2 = boto.connect_ec2()

print "%-15s %-15s %-30s %s" % ("ID", 'Zone', "Groups", "Hostname")
print "-"*105
print "%-20s %-30s %s" % ("ID", "Groups", "Hostname")
for r in ec2.get_all_instances():
groups = [g.id for g in r.groups]
for i in r.instances:
print "%-15s %-15s %-30s %s" % (i.id, i.placement, ','.join(groups), i.public_dns_name)
print "%-20s %-30s %s" % (i.id, ','.join(groups), i.public_dns_name)
12 changes: 5 additions & 7 deletions bin/sdbadmin
Expand Up @@ -25,7 +25,6 @@
VERSION = "%prog version 1.0"
import boto
import time
from boto import sdb

def choice_input(options, default=None, title=None):
"""
Expand Down Expand Up @@ -74,13 +73,13 @@ def load_db(domain, file):
"""
domain.from_xml(file)

def create_db(domain_name, region_name):
def create_db(domain_name):
"""Create a new DB
:param domain: Name of the domain to create
:type domain: str
"""
sdb = boto.sdb.connect_to_region(region_name)
sdb = boto.connect_sdb()
return sdb.create_domain(domain_name)

if __name__ == "__main__":
Expand All @@ -97,15 +96,14 @@ if __name__ == "__main__":
parser.add_option("-a", "--all-domains", help="Operate on all domains", action="store_true", default=False, dest="all_domains")
parser.add_option("-d", "--domain", help="Do functions on domain (may be more then one)", action="append", dest="domains")
parser.add_option("-f", "--file", help="Input/Output file we're operating on", dest="file_name")
parser.add_option("-r", "--region", help="Region (e.g. us-east-1[default] or eu-west-1)", default="us-east-1", dest="region_name")

(options, args) = parser.parse_args()

if options.create:
for domain_name in options.domains:
create_db(domain_name, options.region_name)
create_db(*args)
exit()

sdb = boto.sdb.connect_to_region(options.region_name)
sdb = boto.connect_sdb()
if options.list:
for db in sdb.get_all_domains():
print db
Expand Down
14 changes: 0 additions & 14 deletions boto/__init__.py
Expand Up @@ -224,20 +224,6 @@ def connect_rds(aws_access_key_id=None, aws_secret_access_key=None, **kwargs):
from boto.rds import RDSConnection
return RDSConnection(aws_access_key_id, aws_secret_access_key, **kwargs)

def connect_emr(aws_access_key_id=None, aws_secret_access_key=None, **kwargs):
"""
:type aws_access_key_id: string
:param aws_access_key_id: Your AWS Access Key ID
:type aws_secret_access_key: string
:param aws_secret_access_key: Your AWS Secret Access Key
:rtype: :class:`boto.emr.EmrConnection`
:return: A connection to Elastic mapreduce
"""
from boto.emr import EmrConnection
return EmrConnection(aws_access_key_id, aws_secret_access_key, **kwargs)

def check_extensions(module_name, module_path):
"""
This function checks for extensions to boto modules. It should be called in the
Expand Down
5 changes: 2 additions & 3 deletions boto/cloudfront/__init__.py
Expand Up @@ -23,12 +23,11 @@
import xml.sax
import base64
import time
import boto.utils
from boto.connection import AWSAuthConnection
from boto import handler
from boto.cloudfront.distribution import Distribution, DistributionSummary, DistributionConfig
from boto.cloudfront.distribution import StreamingDistribution, StreamingDistributionSummary, StreamingDistributionConfig
from boto.cloudfront.distribution import *
from boto.cloudfront.identity import OriginAccessIdentity
from boto.cloudfront.identity import OriginAccessIdentitySummary
from boto.cloudfront.identity import OriginAccessIdentityConfig
from boto.resultset import ResultSet
from boto.cloudfront.exception import CloudFrontServerError
Expand Down
4 changes: 2 additions & 2 deletions boto/cloudfront/distribution.py
Expand Up @@ -22,7 +22,7 @@
import uuid
from boto.cloudfront.identity import OriginAccessIdentity
from boto.cloudfront.object import Object, StreamingObject
from boto.cloudfront.signers import ActiveTrustedSigners, TrustedSigners
from boto.cloudfront.signers import Signer, ActiveTrustedSigners, TrustedSigners
from boto.cloudfront.logging import LoggingInfo
from boto.s3.acl import ACL

Expand Down Expand Up @@ -69,7 +69,7 @@ def to_xml(self):
s += '</Enabled>\n'
if self.origin_access_identity:
val = self.get_oai_value()
s += '<OriginAccessIdentity>%s</OriginAccessIdentity>\n' % val
s += '<OriginAccessIdentifier>%s</OriginAccessIdentifier>\n' % val
if self.trusted_signers:
s += '<TrustedSigners>\n'
for signer in self.trusted_signers:
Expand Down
28 changes: 2 additions & 26 deletions boto/cloudfront/identity.py
Expand Up @@ -50,7 +50,7 @@ def endElement(self, name, value, connection):
setattr(self, name, value)

def update(self, comment=None):
new_config = OriginAccessIdentityConfig(self.connection,
new_config = OriginAccessIdentifyConfig(self.connection,
self.config.caller_reference,
self.config.comment)
if comment != None:
Expand All @@ -62,7 +62,7 @@ def delete(self):
return self.connection.delete_distribution(self.id, self.etag)

def uri(self):
return 'origin-access-identity/cloudfront/%s' % self.id
return 'origin-access-identity/cloudfront/%s' % id

class OriginAccessIdentityConfig:

Expand Down Expand Up @@ -94,29 +94,5 @@ def endElement(self, name, value, connection):
else:
setattr(self, name, value)

class OriginAccessIdentitySummary:

def __init__(self, connection=None, id='',
s3_user_id='', comment=''):
self.connection = connection
self.id = id
self.s3_user_id = s3_user_id
self.comment = comment
self.etag = None

def startElement(self, name, attrs, connection):
return None

def endElement(self, name, value, connection):
if name == 'Id':
self.id = value
elif name == 'S3CanonicalUserId':
self.s3_user_id = value
elif name == 'Comment':
self.comment = value
else:
setattr(self, name, value)

def get_origin_access_identity(self):
return self.connection.get_origin_access_identity_info(self.id)

13 changes: 6 additions & 7 deletions boto/connection.py
Expand Up @@ -50,7 +50,7 @@
import xml.sax
import Queue
import boto
from boto.exception import BotoClientError, BotoServerError
from boto.exception import AWSConnectionError, BotoClientError, BotoServerError
from boto.resultset import ResultSet
import boto.utils
from boto import config, UserAgent, handler
Expand Down Expand Up @@ -477,12 +477,11 @@ def close(self):

boto.log.debug('closing all HTTP connections')
self.connection = None # compat field
if hasattr(self, '_cache') and isinstance(self._cache, dict):
hosts = list(self._cache.keys())
for host in hosts:
conn = self._cache[host]
conn.close()
del self._cache[host]
hosts = list(self._cache.keys())
for host in hosts:
conn = self._cache[host]
conn.close()
del self._cache[host]

class AWSQueryConnection(AWSAuthConnection):

Expand Down
30 changes: 15 additions & 15 deletions boto/contrib/ymlmessage.py
Expand Up @@ -29,24 +29,24 @@
import yaml

class YAMLMessage(Message):
"""
The YAMLMessage class provides a YAML compatible message. Encoding and
decoding are handled automaticaly.
"""
The YAMLMessage class provides a YAML compatible message. Encoding and
decoding are handled automaticaly.
Access this message data like such:
Access this message data like such:
m.data = [ 1, 2, 3]
m.data[0] # Returns 1
m.data = [ 1, 2, 3]
m.data[0] # Returns 1
This depends on the PyYAML package
"""
This depends on the PyYAML package
"""

def __init__(self, queue=None, body='', xml_attrs=None):
self.data = None
Message.__init__(self, queue, body)
def __init__(self, queue=None, body='', xml_attrs=None):
self.data = None
Message.__init__(self, queue, body)

def set_body(self, body):
self.data = yaml.load(body)
def set_body(self, body):
self.data = yaml.load(body)

def get_body(self):
return yaml.dump(self.data)
def get_body(self):
return yaml.dump(self.data)
13 changes: 3 additions & 10 deletions boto/ec2/address.py
@@ -1,4 +1,4 @@
# Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/
# Copyright (c) 2006-2008 Mitch Garnaat http://garnaat.org/
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
Expand Down Expand Up @@ -44,15 +44,8 @@ def endElement(self, name, value, connection):
else:
setattr(self, name, value)

def release(self):
return self.connection.release_address(self.public_ip)
def delete(self):
return self.connection.delete_address(self.public_ip)

delete = release

def associate(self, instance_id):
return self.connection.associate_address(instance_id, self.public_ip)

def disassociate(self):
return self.connection.disassociate_address(self.public_ip)


3 changes: 3 additions & 0 deletions boto/ec2/autoscale/__init__.py
Expand Up @@ -25,7 +25,10 @@
"""

import boto
from boto import config
from boto.connection import AWSQueryConnection
from boto.resultset import ResultSet
from boto.ec2.regioninfo import RegionInfo
from boto.ec2.autoscale.request import Request
from boto.ec2.autoscale.trigger import Trigger
from boto.ec2.autoscale.launchconfig import LaunchConfiguration
Expand Down
1 change: 1 addition & 0 deletions boto/ec2/autoscale/group.py
Expand Up @@ -21,6 +21,7 @@

import weakref

from boto.ec2.zone import Zone
from boto.ec2.elb.listelement import ListElement
from boto.resultset import ResultSet
from boto.ec2.autoscale.trigger import Trigger
Expand Down
12 changes: 5 additions & 7 deletions boto/ec2/autoscale/instance.py
Expand Up @@ -43,11 +43,9 @@ def endElement(self, name, value, connection):
else:
setattr(self, name, value)

# BUG: self.get_object is not defined
# BUG: Request is not defined
# def terminate(self):
# """ Terminate this instance. """
# params = {'LaunchConfigurationName' : self.instance_id}
# return self.get_object('DeleteLaunchConfiguration', params,
# Request)
def terminate(self):
""" Terminate this instance. """
params = {'LaunchConfigurationName' : self.instance_id}
return self.get_object('DeleteLaunchConfiguration', params,
Request)

31 changes: 11 additions & 20 deletions boto/ec2/blockdevicemapping.py
Expand Up @@ -20,11 +20,10 @@
# IN THE SOFTWARE.
#

class BlockDeviceType(object):
class EBSBlockDeviceType(object):

def __init__(self, connection=None):
self.connection = connection
self.ephemeral_name = None
self.volume_id = None
self.snapshot_id = None
self.status = None
Expand All @@ -38,8 +37,6 @@ def startElement(self, name, attrs, connection):
def endElement(self, name, value, connection):
if name =='volumeId':
self.volume_id = value
elif name == 'virtualName':
self.ephemeral_name = value
elif name =='snapshotId':
self.snapshot_id = value
elif name == 'volumeSize':
Expand All @@ -56,9 +53,6 @@ def endElement(self, name, value, connection):
else:
setattr(self, name, value)

# for backwards compatibility
EBSBlockDeviceType = BlockDeviceType

class BlockDeviceMapping(dict):

def __init__(self, connection=None):
Expand All @@ -69,7 +63,7 @@ def __init__(self, connection=None):

def startElement(self, name, attrs, connection):
if name == 'ebs':
self.current_value = BlockDeviceType(self)
self.current_value = EBSBlockDeviceType(self)
return self.current_value

def endElement(self, name, value, connection):
Expand All @@ -81,18 +75,15 @@ def endElement(self, name, value, connection):
def build_list_params(self, params, prefix=''):
i = 1
for dev_name in self:
pre = '%sBlockDeviceMapping.%d' % (prefix, i)
pre = '%sBlockDeviceMapping.%d' % (pre, i)
params['%s.DeviceName' % pre] = dev_name
block_dev = self[dev_name]
if block_dev.ephemeral_name:
params['%s.VirtualName' % pre] = block_dev.ephemeral_name
ebs = self[dev_name]
if ebs.snapshot_id:
params['%s.Ebs.SnapshotId' % pre] = ebs.snapshot_id
if ebs.size:
params['%s.Ebs.VolumeSize' % pre] = ebs.size
if ebs.delete_on_termination:
params['%s.Ebs.DeleteOnTermination' % pre] = 'true'
else:
if block_dev.snapshot_id:
params['%s.Ebs.SnapshotId' % pre] = block_dev.snapshot_id
if block_dev.size:
params['%s.Ebs.VolumeSize' % pre] = block_dev.size
if block_dev.delete_on_termination:
params['%s.Ebs.DeleteOnTermination' % pre] = 'true'
else:
params['%s.Ebs.DeleteOnTermination' % pre] = 'false'
params['%s.Ebs.DeleteOnTermination' % pre] = 'false'
i += 1
2 changes: 1 addition & 1 deletion boto/ec2/buyreservation.py
Expand Up @@ -20,7 +20,7 @@
# IN THE SOFTWARE.

import boto.ec2
from boto.sdb.db.property import StringProperty, IntegerProperty
from boto.sdb.db.property import *
from boto.manage import propget

InstanceTypes = ['m1.small', 'm1.large', 'm1.xlarge', 'c1.medium', 'c1.xlarge']
Expand Down
17 changes: 5 additions & 12 deletions boto/ec2/cloudwatch/__init__.py
Expand Up @@ -140,6 +140,7 @@
from boto.ec2.cloudwatch.metric import Metric
from boto.ec2.cloudwatch.datapoint import Datapoint
import boto
import datetime

class CloudWatchConnection(AWSQueryConnection):

Expand Down Expand Up @@ -193,21 +194,13 @@ def get_metric_statistics(self, period, start_time, end_time, measure_name,
self.build_list_params(params, statistics, 'Statistics.member.%d')
return self.get_list('GetMetricStatistics', params, [('member', Datapoint)])

def list_metrics(self, next_token=None):
def list_metrics(self):
"""
Returns a list of the valid metrics for which there is recorded data available.
:type next_token: string
:param next_token: A maximum of 500 metrics will be returned at one time.
If more results are available, the ResultSet returned
will contain a non-Null next_token attribute. Passing
that token as a parameter to list_metrics will retrieve
the next page of metrics.
"""
params = {}
if next_token:
params['NextToken'] = next_token
return self.get_list('ListMetrics', params, [('member', Metric)])
response = self.make_request('ListMetrics')
body = response.read()
return self.get_list('ListMetrics', None, [('member', Metric)])



0 comments on commit fe2be48

Please sign in to comment.