Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release-2.11.0'
Browse files Browse the repository at this point in the history
* release-2.11.0: (45 commits)
  Bumping version to 2.11.0
  Added release notes for v2.11.0.
  Fixed SNS' ``publish`` to behave better when sending mobile push notifications.
  Example update and PEP8 fixes
  Add unit tests to dialt0ne's VPC implementation
  rds support for vpc security groups (rebased on boto 0.10.0 master)
  Revert "Merge pull request #1683 from danielgtaylor/rds-vpc-sg"
  sort dictionary parameters by keys. add unit tests for SNS
  fix serialization of parameter of type map
  Switched SWF over to SigV4.
  Start moving get_all_instances to get_all_reservations
  Make s3put non-multipart uploads not require ListBucket access, and document that multi-part uploads require ListBucket and ListMultipartUploadParts permissions. Fixes #1642.
  Add unit tests for trim_snapshots defeault behavior and test the new monthly backups feature
  add trim_snapshots option to limit number of monthly backups
  correct start of month in trim_snapshots docstring
  Use transcoding-invariant headers when available in gs.Key
  Fixed a small typo in the SQS tutorial.
  Add unit tests for vpc_security_groups when creating RDS database instances.
  Documentation fixes
  Rename vpc_security_groups_ids -> vpc_security_groups for consistency with security_groups option; Modify behavior to allow passing in SecurityGroup instances from EC2.
  ...
  • Loading branch information
toastdriven committed Aug 29, 2013
2 parents 32761fa + 6a7e0c7 commit efa5d58
Show file tree
Hide file tree
Showing 62 changed files with 1,395 additions and 112 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
####
boto
####
boto 2.10.0
boto 2.11.0

Released: 13-August-2013
Released: 29-August-2013

.. image:: https://travis-ci.org/boto/boto.png?branch=develop
:target: https://travis-ci.org/boto/boto
Expand Down
5 changes: 2 additions & 3 deletions bin/elbadmin
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ def get(elb, name):
instances = [state.instance_id for state in instance_health]

names = {}
for r in ec2.get_all_instances(instances):
for i in r.instances:
names[i.id] = i.tags.get('Name', '')
for i in ec2.get_only_instances(instances):
names[i.id] = i.tags.get('Name', '')

name_column_width = max([4] + [len(v) for k,v in names.iteritems()]) + 2

Expand Down
2 changes: 1 addition & 1 deletion bin/instance_events
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def list(region, headers, order, completed):

ec2 = boto.connect_ec2(region=region)

reservations = ec2.get_all_instances()
reservations = ec2.get_all_reservations()

instanceinfo = {}
events = {}
Expand Down
2 changes: 1 addition & 1 deletion bin/list_instances
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def main():
print format_string % headers
print "-" * len(format_string % headers)

for r in ec2.get_all_instances(filters=filters):
for r in ec2.get_all_reservations(filters=filters):
groups = [g.name for g in r.groups]
for i in r.instances:
i.groups = ','.join(groups)
Expand Down
6 changes: 4 additions & 2 deletions bin/s3put
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ try:
multipart_capable = True
usage_flag_multipart_capable = """ [--multipart]"""
usage_string_multipart_capable = """
multipart - Upload files as multiple parts. This needs filechunkio."""
multipart - Upload files as multiple parts. This needs filechunkio.
Requires ListBucket, ListMultipartUploadParts,
ListBucketMultipartUploads and PutObject permissions."""
except ImportError as err:
multipart_capable = False
usage_flag_multipart_capable = ""
Expand Down Expand Up @@ -313,7 +315,7 @@ def main():
c = boto.connect_s3(aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key)
c.debug = debug
b = c.get_bucket(bucket_name)
b = c.get_bucket(bucket_name, validate=False)
existing_keys_to_check_against = []
files_to_check_for_upload = []

Expand Down
2 changes: 1 addition & 1 deletion boto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import urlparse
from boto.exception import InvalidUriError

__version__ = '2.10.0'
__version__ = '2.11.0'
Version = __version__ # for backware compatibility

UserAgent = 'Boto/%s (%s)' % (__version__, sys.platform)
Expand Down
41 changes: 41 additions & 0 deletions boto/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ def credential_scope(self, http_request):
parts = http_request.host.split('.')
if self.region_name is not None:
region_name = self.region_name
elif parts[1] == 'us-gov':
region_name = 'us-gov-west-1'
else:
if len(parts) == 3:
region_name = 'us-east-1'
Expand Down Expand Up @@ -510,6 +512,45 @@ def add_auth(self, req, **kwargs):
req.headers['Authorization'] = ','.join(l)


class QueryAuthHandler(AuthHandler):
"""
Provides pure query construction (no actual signing).
Mostly useful for STS' ``assume_role_with_web_identity``.
Does **NOT** escape query string values!
"""

capability = ['pure-query']

def _escape_value(self, value):
# Would normally be ``return urllib.quote(value)``.
return value

def _build_query_string(self, params):
keys = params.keys()
keys.sort(cmp=lambda x, y: cmp(x.lower(), y.lower()))
pairs = []
for key in keys:
val = boto.utils.get_utf8_value(params[key])
pairs.append(key + '=' + self._escape_value(val))
return '&'.join(pairs)

def add_auth(self, http_request, **kwargs):
headers = http_request.headers
params = http_request.params
qs = self._build_query_string(
http_request.params
)
boto.log.debug('query_string: %s' % qs)
headers['Content-Type'] = 'application/json; charset=UTF-8'
http_request.body = ''
# if this is a retried request, the qs from the previous try will
# already be there, we need to get rid of that and rebuild it
http_request.path = http_request.path.split('?')[0]
http_request.path = http_request.path + '?' + qs


class QuerySignatureHelper(HmacKeys):
"""
Helper for Query signature based Auth handler.
Expand Down
8 changes: 4 additions & 4 deletions boto/cloudformation/stack.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def __repr__(self):
class StackResourceSummary(object):
def __init__(self, connection=None):
self.connection = connection
self.last_updated_timestamp = None
self.last_updated_time = None
self.logical_resource_id = None
self.physical_resource_id = None
self.resource_status = None
Expand All @@ -306,14 +306,14 @@ def startElement(self, name, attrs, connection):
return None

def endElement(self, name, value, connection):
if name == "LastUpdatedTimestamp":
if name == "LastUpdatedTime":
try:
self.last_updated_timestamp = datetime.strptime(
self.last_updated_time = datetime.strptime(
value,
'%Y-%m-%dT%H:%M:%SZ'
)
except ValueError:
self.last_updated_timestamp = datetime.strptime(
self.last_updated_time = datetime.strptime(
value,
'%Y-%m-%dT%H:%M:%S.%fZ'
)
Expand Down
3 changes: 3 additions & 0 deletions boto/dynamodb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def regions():
return [RegionInfo(name='us-east-1',
endpoint='dynamodb.us-east-1.amazonaws.com',
connection_cls=boto.dynamodb.layer2.Layer2),
RegionInfo(name='us-gov-west-1',
endpoint='dynamodb.us-gov-west-1.amazonaws.com',
connection_cls=boto.dynamodb.layer2.Layer2),
RegionInfo(name='us-west-1',
endpoint='dynamodb.us-west-1.amazonaws.com',
connection_cls=boto.dynamodb.layer2.Layer2),
Expand Down
3 changes: 3 additions & 0 deletions boto/dynamodb2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def regions():
return [RegionInfo(name='us-east-1',
endpoint='dynamodb.us-east-1.amazonaws.com',
connection_cls=DynamoDBConnection),
RegionInfo(name='us-gov-west-1',
endpoint='dynamodb.us-gov-west-1.amazonaws.com',
connection_cls=DynamoDBConnection),
RegionInfo(name='us-west-1',
endpoint='dynamodb.us-west-1.amazonaws.com',
connection_cls=DynamoDBConnection),
Expand Down
13 changes: 6 additions & 7 deletions boto/dynamodb2/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, table_name, schema=None, throughput=None, indexes=None,
>>> conn = Table('users')
# The full, minimum-extra-calls case.
>>> from boto.dynamodb2.layer1 import DynamoDBConnection
>>> from boto import dynamodb2
>>> users = Table('users', schema=[
... HashKey('username'),
... RangeKey('date_joined', data_type=NUMBER)
Expand All @@ -69,11 +69,10 @@ def __init__(self, table_name, schema=None, throughput=None, indexes=None,
... RangeKey('date_joined')
... ]),
... ],
... connection=DynamoDBConnection(
... aws_access_key_id='key',
... aws_secret_access_key='key',
... region='us-west-2'
... ))
... connection=dynamodb2.connect_to_region('us-west-2',
... aws_access_key_id='key',
... aws_secret_access_key='key',
... ))
"""
self.table_name = table_name
Expand Down Expand Up @@ -133,7 +132,7 @@ def create(cls, table_name, schema, throughput=None, indexes=None,
Example::
>>> users = Table.create_table('users', schema=[
>>> users = Table.create('users', schema=[
... HashKey('username'),
... RangeKey('date_joined', data_type=NUMBER)
... ], throughput={
Expand Down
1 change: 1 addition & 0 deletions boto/ec2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

RegionData = {
'us-east-1': 'ec2.us-east-1.amazonaws.com',
'us-gov-west-1': 'ec2.us-gov-west-1.amazonaws.com',
'us-west-1': 'ec2.us-west-1.amazonaws.com',
'us-west-2': 'ec2.us-west-2.amazonaws.com',
'sa-east-1': 'ec2.sa-east-1.amazonaws.com',
Expand Down
1 change: 1 addition & 0 deletions boto/ec2/autoscale/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

RegionData = {
'us-east-1': 'autoscaling.us-east-1.amazonaws.com',
'us-gov-west-1': 'autoscaling.us-gov-west-1.amazonaws.com',
'us-west-1': 'autoscaling.us-west-1.amazonaws.com',
'us-west-2': 'autoscaling.us-west-2.amazonaws.com',
'sa-east-1': 'autoscaling.sa-east-1.amazonaws.com',
Expand Down
1 change: 1 addition & 0 deletions boto/ec2/cloudwatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

RegionData = {
'us-east-1': 'monitoring.us-east-1.amazonaws.com',
'us-gov-west-1': 'monitoring.us-gov-west-1.amazonaws.com',
'us-west-1': 'monitoring.us-west-1.amazonaws.com',
'us-west-2': 'monitoring.us-west-2.amazonaws.com',
'sa-east-1': 'monitoring.sa-east-1.amazonaws.com',
Expand Down
70 changes: 67 additions & 3 deletions boto/ec2/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,69 @@ def reset_image_attribute(self, image_id, attribute='launchPermission'):
# Instance methods

def get_all_instances(self, instance_ids=None, filters=None):
"""
Retrieve all the instance reservations associated with your account.
.. note::
This method's current behavior is deprecated in favor of
:meth:`get_all_reservations`. A future major release will change
:meth:`get_all_instances` to return a list of
:class:`boto.ec2.instance.Instance` objects as its name suggests.
To obtain that behavior today, use :meth:`get_only_instances`.
:type instance_ids: list
:param instance_ids: A list of strings of instance IDs
:type filters: dict
:param filters: Optional filters that can be used to limit the
results returned. Filters are provided in the form of a
dictionary consisting of filter names as the key and
filter values as the value. The set of allowable filter
names/values is dependent on the request being performed.
Check the EC2 API guide for details.
:rtype: list
:return: A list of :class:`boto.ec2.instance.Reservation`
"""
warnings.warn(('The current get_all_instances implementation will be '
'replaced with get_all_reservations.'),
PendingDeprecationWarning)
return self.get_all_reservations(instance_ids=instance_ids,
filters=filters)

def get_only_instances(self, instance_ids=None, filters=None):
# A future release should rename this method to get_all_instances
# and make get_only_instances an alias for that.
"""
Retrieve all the instances associated with your account.
:type instance_ids: list
:param instance_ids: A list of strings of instance IDs
:type filters: dict
:param filters: Optional filters that can be used to limit the
results returned. Filters are provided in the form of a
dictionary consisting of filter names as the key and
filter values as the value. The set of allowable filter
names/values is dependent on the request being performed.
Check the EC2 API guide for details.
:rtype: list
:return: A list of :class:`boto.ec2.instance.Instance`
"""
reservations = self.get_all_reservations(instance_ids=instance_ids,
filters=filters)
return [instance for reservation in reservations
for instance in reservation.instances]

def get_all_reservations(self, instance_ids=None, filters=None):
"""
Retrieve all the instance reservations associated with your account.
:type instance_ids: list
:param instance_ids: A list of strings of instance IDs
:type filters: dict
:param filters: Optional filters that can be used to limit the
results returned. Filters are provided in the form of a
Expand Down Expand Up @@ -1957,7 +2014,7 @@ def copy_snapshot(self, source_region, source_snapshot_id,
return snapshot.id

def trim_snapshots(self, hourly_backups=8, daily_backups=7,
weekly_backups=4):
weekly_backups=4, monthly_backups=True):
"""
Trim excess snapshots, based on when they were taken. More current
snapshots are retained, with the number retained decreasing as you
Expand All @@ -1975,7 +2032,7 @@ def trim_snapshots(self, hourly_backups=8, daily_backups=7,
snapshots taken in each of the last seven days, the first snapshots
taken in the last 4 weeks (counting Midnight Sunday morning as
the start of the week), and the first snapshot from the first
Sunday of each month forever.
day of each month forever.
:type hourly_backups: int
:param hourly_backups: How many recent hourly backups should be saved.
Expand All @@ -1985,6 +2042,9 @@ def trim_snapshots(self, hourly_backups=8, daily_backups=7,
:type weekly_backups: int
:param weekly_backups: How many recent weekly backups should be saved.
:type monthly_backups: int
:param monthly_backups: How many monthly backups should be saved. Use True for no limit.
"""

# This function first builds up an ordered list of target times
Expand Down Expand Up @@ -2019,10 +2079,14 @@ def trim_snapshots(self, hourly_backups=8, daily_backups=7,
target_backup_times.append(last_sunday - timedelta(weeks = week))

one_day = timedelta(days = 1)
while start_of_month > oldest_snapshot_date:
monthly_snapshots_added = 0
while (start_of_month > oldest_snapshot_date and
(monthly_backups is True or
monthly_snapshots_added < monthly_backups)):
# append the start of the month to the list of
# snapshot dates to save:
target_backup_times.append(start_of_month)
monthly_snapshots_added += 1
# there's no timedelta setting for one month, so instead:
# decrement the day by one, so we go to the final day of
# the previous month...
Expand Down
1 change: 1 addition & 0 deletions boto/ec2/elb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

RegionData = {
'us-east-1': 'elasticloadbalancing.us-east-1.amazonaws.com',
'us-gov-west-1': 'elasticloadbalancing.us-gov-west-1.amazonaws.com',
'us-west-1': 'elasticloadbalancing.us-west-1.amazonaws.com',
'us-west-2': 'elasticloadbalancing.us-west-2.amazonaws.com',
'sa-east-1': 'elasticloadbalancing.sa-east-1.amazonaws.com',
Expand Down
2 changes: 1 addition & 1 deletion boto/ec2/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def update(self, validate=False):
raise a ValueError exception if no data is
returned from EC2.
"""
rs = self.connection.get_all_instances([self.id])
rs = self.connection.get_all_reservations([self.id])
if len(rs) > 0:
r = rs[0]
for i in r.instances:
Expand Down
7 changes: 6 additions & 1 deletion boto/ec2/networkinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,18 @@ def build_list_params(self, params, prefix=''):
if ip_addr.primary is not None:
params[query_param_key_prefix + '.Primary'] = \
'true' if ip_addr.primary else 'false'
if spec.associate_public_ip_address is not None:
params[full_prefix + 'AssociatePublicIpAddress'] = \
'true' if spec.associate_public_ip_address else 'false'


class NetworkInterfaceSpecification(object):
def __init__(self, network_interface_id=None, device_index=None,
subnet_id=None, description=None, private_ip_address=None,
groups=None, delete_on_termination=None,
private_ip_addresses=None,
secondary_private_ip_address_count=None):
secondary_private_ip_address_count=None,
associate_public_ip_address=None):
self.network_interface_id = network_interface_id
self.device_index = device_index
self.subnet_id = subnet_id
Expand All @@ -247,3 +251,4 @@ def __init__(self, network_interface_id=None, device_index=None,
self.private_ip_addresses = private_ip_addresses
self.secondary_private_ip_address_count = \
secondary_private_ip_address_count
self.associate_public_ip_address = associate_public_ip_address
Loading

0 comments on commit efa5d58

Please sign in to comment.