You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2011/06/05 10:37:04 UTC
svn commit: r1132068 [5/8] - in /incubator/mesos/trunk: ec2/
third_party/boto-1.9b/ third_party/boto-1.9b/bin/
third_party/boto-1.9b/boto.egg-info/ third_party/boto-1.9b/boto/
third_party/boto-1.9b/boto/cloudfront/ third_party/boto-1.9b/boto/contrib/
t...
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/__init__.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/__init__.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/__init__.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/__init__.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/__init__.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/__init__.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/__init__.py Sun Jun 5 08:36:52 2011
@@ -14,65 +14,88 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
-import xml.sax
-import base64
-import time
-import boto
import boto.utils
import urllib
from boto.connection import AWSQueryConnection
-from boto import handler
-from boto.resultset import ResultSet
from boto.rds.dbinstance import DBInstance
from boto.rds.dbsecuritygroup import DBSecurityGroup
from boto.rds.parametergroup import ParameterGroup
from boto.rds.dbsnapshot import DBSnapshot
from boto.rds.event import Event
+from boto.rds.regioninfo import RDSRegionInfo
+
+def regions():
+ """
+ Get all available regions for the RDS service.
+
+ :rtype: list
+ :return: A list of :class:`boto.rds.regioninfo.RDSRegionInfo`
+ """
+ return [RDSRegionInfo(name='us-east-1',
+ endpoint='rds.amazonaws.com'),
+ RDSRegionInfo(name='eu-west-1',
+ endpoint='eu-west-1.rds.amazonaws.com'),
+ RDSRegionInfo(name='us-west-1',
+ endpoint='us-west-1.rds.amazonaws.com'),
+ RDSRegionInfo(name='ap-southeast-1',
+ endpoint='ap-southeast-1.rds.amazonaws.com')
+ ]
+
+def connect_to_region(region_name):
+ for region in regions():
+ if region.name == region_name:
+ return region.connect()
+ return None
#boto.set_stream_logger('rds')
class RDSConnection(AWSQueryConnection):
- DefaultHost = 'rds.amazonaws.com'
+ DefaultRegionName = 'us-east-1'
+ DefaultRegionEndpoint = 'rds.amazonaws.com'
APIVersion = '2009-10-16'
SignatureVersion = '2'
def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
is_secure=True, port=None, proxy=None, proxy_port=None,
- proxy_user=None, proxy_pass=None, host=DefaultHost, debug=0,
- https_connection_factory=None, path='/'):
+ proxy_user=None, proxy_pass=None, debug=0,
+ https_connection_factory=None, region=None, path='/'):
+ if not region:
+ region = RDSRegionInfo(self, self.DefaultRegionName,
+ self.DefaultRegionEndpoint)
+ self.region = region
AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_key,
is_secure, port, proxy, proxy_port, proxy_user,
- proxy_pass, self.DefaultHost, debug,
+ proxy_pass, self.region.endpoint, debug,
https_connection_factory, path)
# DB Instance methods
-
+
def get_all_dbinstances(self, instance_id=None, max_records=None,
marker=None):
"""
Retrieve all the DBInstances in your account.
-
+
:type instance_id: str
:param instance_id: DB Instance identifier. If supplied, only information
this instance will be returned. Otherwise, info
about all DB Instances will be returned.
-
+
:type max_records: int
:param max_records: The maximum number of records to be returned.
If more results are available, a MoreToken will
be returned in the response that can be used to
retrieve additional records. Default is 100.
-
+
:type marker: str
- :param marker: The marker provided by a previous request.
-
+ :param marker: The marker provided by a previous request.
+
:rtype: list
:return: A list of :class:`boto.rds.dbinstance.DBInstance`
"""
@@ -91,7 +114,8 @@ class RDSConnection(AWSQueryConnection):
security_groups=None, availability_zone=None,
preferred_maintenance_window=None,
backup_retention_period=None,
- preferred_backup_window=None):
+ preferred_backup_window=None,
+ multi_az=False):
"""
Create a new DBInstance.
@@ -112,7 +136,7 @@ class RDSConnection(AWSQueryConnection):
db.m2.2xlarge | db.m2.4xlarge
:type engine: str
-. :param engine: Name of database engine. Must be MySQL5.1 for now.
+ :param engine: Name of database engine. Must be MySQL5.1 for now.
:type master_username: str
:param master_username: Name of master user for the DBInstance.
@@ -135,11 +159,11 @@ class RDSConnection(AWSQueryConnection):
:param param_group: Name of DBParameterGroup to associate with
this DBInstance. If no groups are specified
no parameter groups will be used.
-
+
:type security_groups: list of str or list of DBSecurityGroup objects
:param security_groups: List of names of DBSecurityGroup to authorize on
this DBInstance.
-
+
:type availability_zone: str
:param availability_zone: Name of the availability zone to place
DBInstance into.
@@ -159,7 +183,11 @@ class RDSConnection(AWSQueryConnection):
automated backups are created (if
enabled). Must be in h24:mi-hh24:mi
format (UTC).
-
+
+ :type multi_az: bool
+ :param multi_az: If True, specifies the DB Instance will be
+ deployed in multiple availability zones.
+
:rtype: :class:`boto.rds.dbinstance.DBInstance`
:return: The new db instance.
"""
@@ -191,14 +219,18 @@ class RDSConnection(AWSQueryConnection):
params['BackupRetentionPeriod'] = backup_retention_period
if preferred_backup_window:
params['PreferredBackupWindow'] = preferred_backup_window
-
+ if multi_az:
+ params['MultiAZ'] = 'true'
+
return self.get_object('CreateDBInstance', params, DBInstance)
-
+
def modify_dbinstance(self, id, param_group=None, security_groups=None,
preferred_maintenance_window=None,
master_password=None, allocated_storage=None,
+ instance_class=None,
backup_retention_period=None,
preferred_backup_window=None,
+ multi_az=False,
apply_immediately=False):
"""
Modify an existing DBInstance.
@@ -209,12 +241,12 @@ class RDSConnection(AWSQueryConnection):
:type security_groups: list of str or list of DBSecurityGroup objects
:param security_groups: List of names of DBSecurityGroup to authorize on
this DBInstance.
-
+
:type preferred_maintenance_window: str
:param preferred_maintenance_window: The weekly time range (in UTC) during
which maintenance can occur.
Default is Sun:05:00-Sun:09:00
-
+
:type master_password: str
:param master_password: Password of master user for the DBInstance.
Must be 4-15 alphanumeric characters.
@@ -222,7 +254,7 @@ class RDSConnection(AWSQueryConnection):
:type allocated_storage: int
:param allocated_storage: The new allocated storage size, in GBs.
Valid values are [5-1024]
-
+
:type instance_class: str
:param instance_class: The compute and memory capacity of the DBInstance.
Changes will be applied at next maintenance
@@ -246,7 +278,11 @@ class RDSConnection(AWSQueryConnection):
automated backups are created (if
enabled). Must be in h24:mi-hh24:mi
format (UTC).
-
+
+ :type multi_az: bool
+ :param multi_az: If True, specifies the DB Instance will be
+ deployed in multiple availability zones.
+
:rtype: :class:`boto.rds.dbinstance.DBInstance`
:return: The modified db instance.
"""
@@ -267,15 +303,19 @@ class RDSConnection(AWSQueryConnection):
params['MasterUserPassword'] = master_password
if allocated_storage:
params['AllocatedStorage'] = allocated_storage
+ if instance_class:
+ params['DBInstanceClass'] = instance_class
if backup_retention_period:
params['BackupRetentionPeriod'] = backup_retention_period
if preferred_backup_window:
params['PreferredBackupWindow'] = preferred_backup_window
+ if multi_az:
+ params['MultiAZ'] = 'true'
if apply_immediately:
params['ApplyImmediately'] = 'true'
-
+
return self.get_object('ModifyDBInstance', params, DBInstance)
-
+
def delete_dbinstance(self, id, skip_final_snapshot=False,
final_snapshot_id=''):
"""
@@ -305,27 +345,41 @@ class RDSConnection(AWSQueryConnection):
params['SkipFinalSnapshot'] = 'false'
params['FinalDBSnapshotIdentifier'] = final_snapshot_id
return self.get_object('DeleteDBInstance', params, DBInstance)
-
+
+
+ def reboot_dbinstance(self, id):
+ """
+ Reboot DBInstance.
+
+ :type id: str
+ :param id: Unique identifier of the instance.
+
+ :rtype: :class:`boto.rds.dbinstance.DBInstance`
+ :return: The rebooting db instance.
+ """
+ params = {'DBInstanceIdentifier' : id}
+ return self.get_object('RebootDBInstance', params, DBInstance)
+
# DBParameterGroup methods
-
+
def get_all_dbparameter_groups(self, groupname=None, max_records=None,
marker=None):
"""
Get all parameter groups associated with your account in a region.
-
+
:type groupname: str
:param groupname: The name of the DBParameter group to retrieve.
If not provided, all DBParameter groups will be returned.
-
+
:type max_records: int
:param max_records: The maximum number of records to be returned.
If more results are available, a MoreToken will
be returned in the response that can be used to
retrieve additional records. Default is 100.
-
+
:type marker: str
- :param marker: The marker provided by a previous request.
-
+ :param marker: The marker provided by a previous request.
+
:rtype: list
:return: A list of :class:`boto.ec2.parametergroup.ParameterGroup`
"""
@@ -343,7 +397,7 @@ class RDSConnection(AWSQueryConnection):
max_records=None, marker=None):
"""
Get all parameters associated with a ParameterGroup
-
+
:type groupname: str
:param groupname: The name of the DBParameter group to retrieve.
@@ -351,16 +405,16 @@ class RDSConnection(AWSQueryConnection):
:param source: Specifies which parameters to return.
If not specified, all parameters will be returned.
Valid values are: user|system|engine-default
-
+
:type max_records: int
:param max_records: The maximum number of records to be returned.
If more results are available, a MoreToken will
be returned in the response that can be used to
retrieve additional records. Default is 100.
-
+
:type marker: str
- :param marker: The marker provided by a previous request.
-
+ :param marker: The marker provided by a previous request.
+
:rtype: :class:`boto.ec2.parametergroup.ParameterGroup`
:return: The ParameterGroup
"""
@@ -378,16 +432,16 @@ class RDSConnection(AWSQueryConnection):
def create_parameter_group(self, name, engine='MySQL5.1', description=''):
"""
Create a new dbparameter group for your account.
-
+
:type name: string
:param name: The name of the new dbparameter group
-
+
:type engine: str
:param engine: Name of database engine. Must be MySQL5.1 for now.
:type description: string
:param description: The description of the new security group
-
+
:rtype: :class:`boto.rds.dbsecuritygroup.DBSecurityGroup`
:return: The newly created DBSecurityGroup
"""
@@ -399,10 +453,10 @@ class RDSConnection(AWSQueryConnection):
def modify_parameter_group(self, name, parameters=None):
"""
Modify a parameter group for your account.
-
+
:type name: string
:param name: The name of the new parameter group
-
+
:type parameters: list of :class:`boto.rds.parametergroup.Parameter`
:param parameters: The new parameters
@@ -419,7 +473,7 @@ class RDSConnection(AWSQueryConnection):
"""
Resets some or all of the parameters of a ParameterGroup to the
default value
-
+
:type key_name: string
:param key_name: The name of the ParameterGroup to reset
@@ -440,7 +494,7 @@ class RDSConnection(AWSQueryConnection):
def delete_parameter_group(self, name):
"""
Delete a DBSecurityGroup from your account.
-
+
:type key_name: string
:param key_name: The name of the DBSecurityGroup to delete
"""
@@ -448,25 +502,25 @@ class RDSConnection(AWSQueryConnection):
return self.get_status('DeleteDBParameterGroup', params)
# DBSecurityGroup methods
-
+
def get_all_dbsecurity_groups(self, groupname=None, max_records=None,
marker=None):
"""
Get all security groups associated with your account in a region.
-
+
:type groupnames: list
:param groupnames: A list of the names of security groups to retrieve.
If not provided, all security groups will be returned.
-
+
:type max_records: int
:param max_records: The maximum number of records to be returned.
If more results are available, a MoreToken will
be returned in the response that can be used to
retrieve additional records. Default is 100.
-
+
:type marker: str
- :param marker: The marker provided by a previous request.
-
+ :param marker: The marker provided by a previous request.
+
:rtype: list
:return: A list of :class:`boto.rds.dbsecuritygroup.DBSecurityGroup`
"""
@@ -485,13 +539,13 @@ class RDSConnection(AWSQueryConnection):
Create a new security group for your account.
This will create the security group within the region you
are currently connected to.
-
+
:type name: string
:param name: The name of the new security group
-
+
:type description: string
:param description: The description of the new security group
-
+
:rtype: :class:`boto.rds.dbsecuritygroup.DBSecurityGroup`
:return: The newly created DBSecurityGroup
"""
@@ -506,7 +560,7 @@ class RDSConnection(AWSQueryConnection):
def delete_dbsecurity_group(self, name):
"""
Delete a DBSecurityGroup from your account.
-
+
:type key_name: string
:param key_name: The name of the DBSecurityGroup to delete
"""
@@ -520,19 +574,19 @@ class RDSConnection(AWSQueryConnection):
Add a new rule to an existing security group.
You need to pass in either src_security_group_name and
src_security_group_owner_id OR a CIDR block but not both.
-
+
:type group_name: string
:param group_name: The name of the security group you are adding
the rule to.
-
+
:type ec2_security_group_name: string
- :param ec2_security_group_name: The name of the EC2 security group you are
+ :param ec2_security_group_name: The name of the EC2 security group you are
granting access to.
-
+
:type ec2_security_group_owner_id: string
:param ec2_security_group_owner_id: The ID of the owner of the EC2 security
group you are granting access to.
-
+
:type cidr_ip: string
:param cidr_ip: The CIDR block you are providing access to.
See http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
@@ -555,19 +609,19 @@ class RDSConnection(AWSQueryConnection):
Remove an existing rule from an existing security group.
You need to pass in either ec2_security_group_name and
ec2_security_group_owner_id OR a CIDR block.
-
+
:type group_name: string
:param group_name: The name of the security group you are removing
the rule from.
-
+
:type ec2_security_group_name: string
- :param ec2_security_group_name: The name of the EC2 security group you are
+ :param ec2_security_group_name: The name of the EC2 security group you are
granting access to.
-
+
:type ec2_security_group_owner_id: string
:param ec2_security_group_owner_id: The ID of the owner of the EC2 security
group you are granting access to.
-
+
:type cidr_ip: string
:param cidr_ip: The CIDR block you are providing access to.
See http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
@@ -585,31 +639,31 @@ class RDSConnection(AWSQueryConnection):
return self.get_object('RevokeDBSecurityGroupIngress', params, DBSecurityGroup)
# DBSnapshot methods
-
+
def get_all_dbsnapshots(self, snapshot_id=None, instance_id=None,
max_records=None, marker=None):
"""
- Get information about DB Snapshots.
-
+ Get information about DB Snapshots.
+
:type snapshot_id: str
:param snapshot_id: The unique identifier of an RDS snapshot.
If not provided, all RDS snapshots will be returned.
-
+
:type instance_id: str
:param instance_id: The identifier of a DBInstance. If provided,
only the DBSnapshots related to that instance will
be returned.
If not provided, all RDS snapshots will be returned.
-
+
:type max_records: int
:param max_records: The maximum number of records to be returned.
If more results are available, a MoreToken will
be returned in the response that can be used to
retrieve additional records. Default is 100.
-
+
:type marker: str
- :param marker: The marker provided by a previous request.
-
+ :param marker: The marker provided by a previous request.
+
:rtype: list
:return: A list of :class:`boto.rds.dbsnapshot.DBSnapshot`
"""
@@ -623,19 +677,19 @@ class RDSConnection(AWSQueryConnection):
if marker:
params['Marker'] = marker
return self.get_list('DescribeDBSnapshots', params,
- [('DBSnapshots', DBSnapshot)])
+ [('DBSnapshot', DBSnapshot)])
def create_dbsnapshot(self, snapshot_id, dbinstance_id):
"""
Create a new DB snapshot.
-
+
:type snapshot_id: string
:param snapshot_id: The identifier for the DBSnapshot
-
+
:type dbinstance_id: string
:param dbinstance_id: The source identifier for the RDS instance from
which the snapshot is created.
-
+
:rtype: :class:`boto.rds.dbsnapshot.DBSnapshot`
:return: The newly created DBSnapshot
"""
@@ -646,7 +700,7 @@ class RDSConnection(AWSQueryConnection):
def delete_dbsnapshot(self, identifier):
"""
Delete a DBSnapshot
-
+
:type identifier: string
:param identifier: The identifier of the DBSnapshot to delete
"""
@@ -656,17 +710,17 @@ class RDSConnection(AWSQueryConnection):
def restore_dbinstance_from_dbsnapshot(self, identifier, instance_id,
instance_class, port=None,
availability_zone=None):
-
+
"""
Create a new DBInstance from a DB snapshot.
-
+
:type identifier: string
:param identifier: The identifier for the DBSnapshot
-
+
:type instance_id: string
:param instance_id: The source identifier for the RDS instance from
which the snapshot is created.
-
+
:type instance_class: str
:param instance_class: The compute and memory capacity of the DBInstance.
Valid values are:
@@ -701,13 +755,13 @@ class RDSConnection(AWSQueryConnection):
dbinstance_class=None,
port=None,
availability_zone=None):
-
+
"""
Create a new DBInstance from a point in time.
-
+
:type source_instance_id: string
:param source_instance_id: The identifier for the source DBInstance.
-
+
:type target_instance_id: string
:param target_instance_id: The identifier of the new DBInstance.
@@ -718,7 +772,7 @@ class RDSConnection(AWSQueryConnection):
:type restore_time: datetime
:param restore_time: The date and time to restore from. Only
used if use_latest is False.
-
+
:type instance_class: str
:param instance_class: The compute and memory capacity of the DBInstance.
Valid values are:
@@ -742,8 +796,8 @@ class RDSConnection(AWSQueryConnection):
params['UseLatestRestorableTime'] = 'true'
elif restore_time:
params['RestoreTime'] = restore_time.isoformat()
- if instance_class:
- params['DBInstanceClass'] = instance_class
+ if dbinstance_class:
+ params['DBInstanceClass'] = dbinstance_class
if port:
params['Port'] = port
if availability_zone:
@@ -759,7 +813,7 @@ class RDSConnection(AWSQueryConnection):
"""
Get information about events related to your DBInstances,
DBSecurityGroups and DBParameterGroups.
-
+
:type source_identifier: str
:param source_identifier: If supplied, the events returned will be
limited to those that apply to the identified
@@ -778,21 +832,21 @@ class RDSConnection(AWSQueryConnection):
:param start_time: The beginning of the time interval for events.
If not supplied, all available events will
be returned.
-
+
:type end_time: datetime
:param end_time: The ending of the time interval for events.
If not supplied, all available events will
be returned.
-
+
:type max_records: int
:param max_records: The maximum number of records to be returned.
If more results are available, a MoreToken will
be returned in the response that can be used to
retrieve additional records. Default is 100.
-
+
:type marker: str
- :param marker: The marker provided by a previous request.
-
+ :param marker: The marker provided by a previous request.
+
:rtype: list
:return: A list of class:`boto.rds.event.Event`
"""
@@ -810,4 +864,4 @@ class RDSConnection(AWSQueryConnection):
params['Marker'] = marker
return self.get_list('DescribeEvents', params, [('Event', Event)])
-
+
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/dbinstance.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/dbinstance.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/dbinstance.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/dbinstance.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/dbinstance.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/dbinstance.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/dbinstance.py Sun Jun 5 08:36:52 2011
@@ -44,6 +44,7 @@ class DBInstance(object):
self.preferred_backup_window = None
self.preferred_maintenance_window = None
self.latest_restorable_time = None
+ self.multi_az = False
self._in_endpoint = False
self._port = None
self._address = None
@@ -98,6 +99,9 @@ class DBInstance(object):
self.preferred_maintenance_window = value
elif name == 'PreferredBackupWindow':
self.preferred_backup_window = value
+ elif name == 'MultiAZ':
+ if value.lower() == 'true':
+ self.multi_az = True
else:
setattr(self, name, value)
@@ -113,6 +117,15 @@ class DBInstance(object):
"""
return self.connection.create_dbsnapshot(snapshot_id, self.id)
+ def reboot(self):
+ """
+ Reboot this DBInstance
+
+ :rtype: :class:`boto.rds.dbsnapshot.DBSnapshot`
+ :return: The newly created DBSnapshot
+ """
+ return self.connection.reboot_dbinstance(self.id)
+
def stop(self, skip_final_snapshot, final_snapshot_id):
"""
Delete this DBInstance.
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/dbsecuritygroup.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/dbsecuritygroup.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/dbsecuritygroup.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/dbsecuritygroup.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/dbsecuritygroup.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/dbsecuritygroup.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/dbsecuritygroup.py Sun Jun 5 08:36:52 2011
@@ -74,7 +74,7 @@ class DBSecurityGroup(object):
@type cidr_ip: string
@param cidr_ip: A valid CIDR IP range to authorize
- @type ec2_group: :class:`boto.ec2.securitygroup.SecurityGroup>`b
+ @type ec2_group: :class:`boto.ec2.securitygroup.SecurityGroup>`
@rtype: bool
@return: True if successful.
@@ -99,7 +99,7 @@ class DBSecurityGroup(object):
@type cidr_ip: string
@param cidr_ip: A valid CIDR IP range to authorize
- @type ec2_group: :class:`boto.ec2.securitygroup.SecurityGroup>`b
+ @type ec2_group: :class:`boto.ec2.securitygroup.SecurityGroup>`
@rtype: bool
@return: True if successful.
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/dbsnapshot.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/dbsnapshot.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/dbsnapshot.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/dbsnapshot.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/dbsnapshot.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
(empty)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/event.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/event.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/event.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/event.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/event.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
(empty)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/parametergroup.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/parametergroup.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/parametergroup.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/parametergroup.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/rds/parametergroup.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
(empty)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/regioninfo.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/s3/__init__.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/regioninfo.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/regioninfo.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/s3/__init__.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/s3/__init__.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/rds/regioninfo.py Sun Jun 5 08:36:52 2011
@@ -1,4 +1,6 @@
-# Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/
+# Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/
+# Copyright (c) 2010, Eucalyptus Systems, Inc.
+# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
@@ -20,12 +22,11 @@
# IN THE SOFTWARE.
#
-import boto
+from boto.regioninfo import RegionInfo
-boto.check_extensions(__name__, __path__)
+class RDSRegionInfo(RegionInfo):
-from connection import S3Connection as Connection
-from key import Key
-from bucket import Bucket
-
-__all__ = ['Connection', 'Key', 'Bucket']
+ def __init__(self, connection=None, name=None, endpoint=None):
+ from boto.rds import RDSConnection
+ RegionInfo.__init__(self, connection, name, endpoint,
+ RDSConnection)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/regioninfo.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/ec2/regioninfo.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/regioninfo.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/regioninfo.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/ec2/regioninfo.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/ec2/regioninfo.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/regioninfo.py Sun Jun 5 08:36:52 2011
@@ -1,4 +1,6 @@
-# Copyright (c) 2006-2008 Mitch Garnaat http://garnaat.org/
+# Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/
+# Copyright (c) 2010, Eucalyptus Systems, Inc.
+# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
@@ -21,13 +23,15 @@
class RegionInfo(object):
"""
- Represents an EC2 Region
+ Represents an AWS Region
"""
- def __init__(self, connection=None, name=None, endpoint=None):
+ def __init__(self, connection=None, name=None, endpoint=None,
+ connection_cls=None):
self.connection = connection
self.name = name
self.endpoint = endpoint
+ self.connection_cls = connection_cls
def __repr__(self):
return 'RegionInfo:%s' % self.name
@@ -45,16 +49,16 @@ class RegionInfo(object):
def connect(self, **kw_params):
"""
- Connect to this Region's endpoint. Returns an EC2Connection
+ Connect to this Region's endpoint. Returns an connection
object pointing to the endpoint associated with this region.
- You may pass any of the arguments accepted by the EC2Connection
- object's constructor as keyword arguments and they will be
- passed along to the EC2Connection object.
+ You may pass any of the arguments accepted by the connection
+ class's constructor as keyword arguments and they will be
+ passed along to the connection object.
- :rtype: :class:`boto.ec2.connection.EC2Connection`
+ :rtype: Connection object
:return: The connection to this regions endpoint
"""
- from boto.ec2.connection import EC2Connection
- return EC2Connection(region=self, **kw_params)
+ if self.connection_cls:
+ return self.connection_cls(region=self, **kw_params)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/resultset.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/resultset.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/resultset.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/resultset.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/resultset.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/resultset.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/resultset.py Sun Jun 5 08:36:52 2011
@@ -44,6 +44,10 @@ class ResultSet(list):
else:
self.markers = []
self.marker = None
+ self.key_marker = None
+ self.next_key_marker = None
+ self.next_version_id_marker = None
+ self.version_id_marker = None
self.is_truncated = False
self.next_token = None
self.status = True
@@ -67,6 +71,14 @@ class ResultSet(list):
self.is_truncated = self.to_boolean(value)
elif name == 'Marker':
self.marker = value
+ elif name == 'KeyMarker':
+ self.key_marker = value
+ elif name == 'VersionIdMarker':
+ self.version_id_marker = value
+ elif name == 'NextKeyMarker':
+ self.next_key_marker = value
+ elif name == 'NextVersionIdMarker':
+ self.next_version_id_marker = value
elif name == 'Prefix':
self.prefix = value
elif name == 'return':
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/__init__.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/fps/__init__.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/__init__.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/__init__.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/fps/__init__.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/fps/__init__.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/__init__.py Sun Jun 5 08:36:52 2011
@@ -1,4 +1,6 @@
-# Copyright (c) 2008, Chris Moyer http://coredumped.org
+# Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/
+# Copyright (c) 2010, Eucalyptus Systems, Inc.
+# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
@@ -20,4 +22,3 @@
# IN THE SOFTWARE.
#
-
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/acl.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/s3/acl.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/acl.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/acl.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/s3/acl.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/s3/acl.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/acl.py Sun Jun 5 08:36:52 2011
@@ -20,10 +20,12 @@
# IN THE SOFTWARE.
from boto.s3.user import User
-import StringIO
+
CannedACLStrings = ['private', 'public-read',
- 'public-read-write', 'authenticated-read']
+ 'public-read-write', 'authenticated-read',
+ 'bucket-owner-read', 'bucket-owner-full-control']
+
class Policy:
Added: incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/bucket.py
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/bucket.py?rev=1132068&view=auto
==============================================================================
--- incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/bucket.py (added)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/bucket.py Sun Jun 5 08:36:52 2011
@@ -0,0 +1,756 @@
+# Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/
+# Copyright (c) 2010, Eucalyptus Systems, Inc.
+# All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish, dis-
+# tribute, sublicense, and/or sell copies of the Software, and to permit
+# persons to whom the Software is furnished to do so, subject to the fol-
+# lowing conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+import boto
+from boto import handler
+from boto.resultset import ResultSet
+from boto.s3.acl import ACL, Policy, CannedACLStrings, Grant
+from boto.s3.key import Key
+from boto.s3.prefix import Prefix
+from boto.s3.deletemarker import DeleteMarker
+from boto.s3.user import User
+from boto.exception import S3ResponseError, S3PermissionsError, S3CopyError
+from boto.s3.bucketlistresultset import BucketListResultSet
+from boto.s3.bucketlistresultset import VersionedBucketListResultSet
+import boto.utils
+import xml.sax
+import urllib
+import re
+
+S3Permissions = ['READ', 'WRITE', 'READ_ACP', 'WRITE_ACP', 'FULL_CONTROL']
+
+class Bucket(object):
+
+ BucketLoggingBody = """<?xml version="1.0" encoding="UTF-8"?>
+ <BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
+ <LoggingEnabled>
+ <TargetBucket>%s</TargetBucket>
+ <TargetPrefix>%s</TargetPrefix>
+ </LoggingEnabled>
+ </BucketLoggingStatus>"""
+
+ EmptyBucketLoggingBody = """<?xml version="1.0" encoding="UTF-8"?>
+ <BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
+ </BucketLoggingStatus>"""
+
+ LoggingGroup = 'http://acs.amazonaws.com/groups/s3/LogDelivery'
+
+ BucketPaymentBody = """<?xml version="1.0" encoding="UTF-8"?>
+ <RequestPaymentConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
+ <Payer>%s</Payer>
+ </RequestPaymentConfiguration>"""
+
+ VersioningBody = """<?xml version="1.0" encoding="UTF-8"?>
+ <VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
+ <Status>%s</Status>
+ <MfaDelete>%s</MfaDelete>
+ </VersioningConfiguration>"""
+
+ VersionRE = '<Status>([A-Za-z]+)</Status>'
+ MFADeleteRE = '<MfaDelete>([A-Za-z]+)</MfaDelete>'
+
+ def __init__(self, connection=None, name=None, key_class=Key):
+ self.name = name
+ self.connection = connection
+ self.key_class = key_class
+
+ def __repr__(self):
+ return '<Bucket: %s>' % self.name
+
+ def __iter__(self):
+ return iter(BucketListResultSet(self))
+
+ def __contains__(self, key_name):
+ return not (self.get_key(key_name) is None)
+
+ def startElement(self, name, attrs, connection):
+ return None
+
+ def endElement(self, name, value, connection):
+ if name == 'Name':
+ self.name = value
+ elif name == 'CreationDate':
+ self.creation_date = value
+ else:
+ setattr(self, name, value)
+
+ def set_key_class(self, key_class):
+ """
+ Set the Key class associated with this bucket. By default, this
+ would be the boto.s3.key.Key class but if you want to subclass that
+ for some reason this allows you to associate your new class with a
+ bucket so that when you call bucket.new_key() or when you get a listing
+ of keys in the bucket you will get an instances of your key class
+ rather than the default.
+
+ :type key_class: class
+ :param key_class: A subclass of Key that can be more specific
+ """
+ self.key_class = key_class
+
+ def lookup(self, key_name, headers=None):
+ """
+ Deprecated: Please use get_key method.
+
+ :type key_name: string
+ :param key_name: The name of the key to retrieve
+
+ :rtype: :class:`boto.s3.key.Key`
+ :returns: A Key object from this bucket.
+ """
+ return self.get_key(key_name, headers=headers)
+
+ def get_key(self, key_name, headers=None, version_id=None):
+ """
+ Check to see if a particular key exists within the bucket. This
+ method uses a HEAD request to check for the existance of the key.
+ Returns: An instance of a Key object or None
+
+ :type key_name: string
+ :param key_name: The name of the key to retrieve
+
+ :rtype: :class:`boto.s3.key.Key`
+ :returns: A Key object from this bucket.
+ """
+ if version_id:
+ query_args = 'versionId=%s' % version_id
+ else:
+ query_args = None
+ response = self.connection.make_request('HEAD', self.name, key_name,
+ headers=headers,
+ query_args=query_args)
+ # Allow any success status (2xx) - for example this lets us
+ # support Range gets, which return status 206:
+ if response.status/100 == 2:
+ response.read()
+ k = self.key_class(self)
+ provider = self.connection.provider
+ k.metadata = boto.utils.get_aws_metadata(response.msg, provider)
+ k.etag = response.getheader('etag')
+ k.content_type = response.getheader('content-type')
+ k.content_encoding = response.getheader('content-encoding')
+ k.last_modified = response.getheader('last-modified')
+ k.size = int(response.getheader('content-length'))
+ k.name = key_name
+ k.handle_version_headers(response)
+ return k
+ else:
+ if response.status == 404:
+ response.read()
+ return None
+ else:
+ raise S3ResponseError(response.status, response.reason, '')
+
+ def list(self, prefix='', delimiter='', marker='', headers=None):
+ """
+ List key objects within a bucket. This returns an instance of an
+ BucketListResultSet that automatically handles all of the result
+ paging, etc. from S3. You just need to keep iterating until
+ there are no more results.
+ Called with no arguments, this will return an iterator object across
+ all keys within the bucket.
+
+ :type prefix: string
+ :param prefix: allows you to limit the listing to a particular
+ prefix. For example, if you call the method with
+ prefix='/foo/' then the iterator will only cycle
+ through the keys that begin with the string '/foo/'.
+
+ :type delimiter: string
+ :param delimiter: can be used in conjunction with the prefix
+ to allow you to organize and browse your keys
+ hierarchically. See:
+ http://docs.amazonwebservices.com/AmazonS3/2006-03-01/
+ for more details.
+
+ :type marker: string
+ :param marker: The "marker" of where you are in the result set
+
+ :rtype: :class:`boto.s3.bucketlistresultset.BucketListResultSet`
+ :return: an instance of a BucketListResultSet that handles paging, etc
+ """
+ return BucketListResultSet(self, prefix, delimiter, marker, headers)
+
+ def list_versions(self, prefix='', delimiter='', key_marker='',
+ version_id_marker='', headers=None):
+ """
+ List key objects within a bucket. This returns an instance of an
+ BucketListResultSet that automatically handles all of the result
+ paging, etc. from S3. You just need to keep iterating until
+ there are no more results.
+ Called with no arguments, this will return an iterator object across
+ all keys within the bucket.
+
+ :type prefix: string
+ :param prefix: allows you to limit the listing to a particular
+ prefix. For example, if you call the method with
+ prefix='/foo/' then the iterator will only cycle
+ through the keys that begin with the string '/foo/'.
+
+ :type delimiter: string
+ :param delimiter: can be used in conjunction with the prefix
+ to allow you to organize and browse your keys
+ hierarchically. See:
+ http://docs.amazonwebservices.com/AmazonS3/2006-03-01/
+ for more details.
+
+ :type marker: string
+ :param marker: The "marker" of where you are in the result set
+
+ :rtype: :class:`boto.s3.bucketlistresultset.BucketListResultSet`
+ :return: an instance of a BucketListResultSet that handles paging, etc
+ """
+ return VersionedBucketListResultSet(self, prefix, delimiter, key_marker,
+ version_id_marker, headers)
+
+ def _get_all(self, element_map, initial_query_string='',
+ headers=None, **params):
+ l = []
+ for k,v in params.items():
+ k = k.replace('_', '-')
+ if k == 'maxkeys':
+ k = 'max-keys'
+ if isinstance(v, unicode):
+ v = v.encode('utf-8')
+ if v is not None and v != '':
+ l.append('%s=%s' % (urllib.quote(k), urllib.quote(str(v))))
+ if len(l):
+ s = initial_query_string + '&' + '&'.join(l)
+ else:
+ s = initial_query_string
+ response = self.connection.make_request('GET', self.name,
+ headers=headers, query_args=s)
+ body = response.read()
+ boto.log.debug(body)
+ if response.status == 200:
+ rs = ResultSet(element_map)
+ h = handler.XmlHandler(rs, self)
+ xml.sax.parseString(body, h)
+ return rs
+ else:
+ raise S3ResponseError(response.status, response.reason, body)
+
+ def get_all_keys(self, headers=None, **params):
+ """
+ A lower-level method for listing contents of a bucket.
+ This closely models the actual S3 API and requires you to manually
+ handle the paging of results. For a higher-level method
+ that handles the details of paging for you, you can use the list method.
+
+ :type max_keys: int
+ :param max_keys: The maximum number of keys to retrieve
+
+ :type prefix: string
+ :param prefix: The prefix of the keys you want to retrieve
+
+ :type marker: string
+ :param marker: The "marker" of where you are in the result set
+
+ :type delimiter: string
+ :param delimiter: If this optional, Unicode string parameter
+ is included with your request, then keys that
+ contain the same string between the prefix and
+ the first occurrence of the delimiter will be
+ rolled up into a single result element in the
+ CommonPrefixes collection. These rolled-up keys
+ are not returned elsewhere in the response.
+
+ :rtype: ResultSet
+ :return: The result from S3 listing the keys requested
+
+ """
+ return self._get_all([('Contents', self.key_class),
+ ('CommonPrefixes', Prefix)],
+ '', headers, **params)
+
+ def get_all_versions(self, headers=None, **params):
+ """
+ A lower-level, version-aware method for listing contents of a bucket.
+ This closely models the actual S3 API and requires you to manually
+ handle the paging of results. For a higher-level method
+ that handles the details of paging for you, you can use the list method.
+
+ :type max_keys: int
+ :param max_keys: The maximum number of keys to retrieve
+
+ :type prefix: string
+ :param prefix: The prefix of the keys you want to retrieve
+
+ :type key_marker: string
+ :param key_marker: The "marker" of where you are in the result set
+ with respect to keys.
+
+ :type version_id_marker: string
+ :param version_id_marker: The "marker" of where you are in the result
+ set with respect to version-id's.
+
+ :type delimiter: string
+ :param delimiter: If this optional, Unicode string parameter
+ is included with your request, then keys that
+ contain the same string between the prefix and
+ the first occurrence of the delimiter will be
+ rolled up into a single result element in the
+ CommonPrefixes collection. These rolled-up keys
+ are not returned elsewhere in the response.
+
+ :rtype: ResultSet
+ :return: The result from S3 listing the keys requested
+
+ """
+ return self._get_all([('Version', self.key_class),
+ ('CommonPrefixes', Prefix),
+ ('DeleteMarker', DeleteMarker)],
+ 'versions', headers, **params)
+
+ def new_key(self, key_name=None):
+ """
+ Creates a new key
+
+ :type key_name: string
+ :param key_name: The name of the key to create
+
+ :rtype: :class:`boto.s3.key.Key` or subclass
+ :returns: An instance of the newly created key object
+ """
+ return self.key_class(self, key_name)
+
+ def generate_url(self, expires_in, method='GET',
+ headers=None, force_http=False):
+ return self.connection.generate_url(expires_in, method, self.name,
+ headers=headers,
+ force_http=force_http)
+
+ def delete_key(self, key_name, headers=None,
+ version_id=None, mfa_token=None):
+ """
+ Deletes a key from the bucket. If a version_id is provided,
+ only that version of the key will be deleted.
+
+ :type key_name: string
+ :param key_name: The key name to delete
+
+ :type version_id: string
+ :param version_id: The version ID (optional)
+
+ :type mfa_token: tuple or list of strings
+ :param mfa_token: A tuple or list consisting of the serial number
+ from the MFA device and the current value of
+ the six-digit token associated with the device.
+ This value is required anytime you are
+ deleting versioned objects from a bucket
+ that has the MFADelete option on the bucket.
+ """
+ if version_id:
+ query_args = 'versionId=%s' % version_id
+ else:
+ query_args = None
+ if mfa_token:
+ if not headers:
+ headers = {}
+ provider = self.connection.provider
+ headers[provider.mfa_header] = ' '.join(mfa_token)
+ response = self.connection.make_request('DELETE', self.name, key_name,
+ headers=headers,
+ query_args=query_args)
+ body = response.read()
+ if response.status != 204:
+ raise S3ResponseError(response.status, response.reason, body)
+
+ def copy_key(self, new_key_name, src_bucket_name,
+ src_key_name, metadata=None, src_version_id=None,
+ storage_class='STANDARD', preserve_acl=False):
+ """
+ Create a new key in the bucket by copying another existing key.
+
+ :type new_key_name: string
+ :param new_key_name: The name of the new key
+
+ :type src_bucket_name: string
+ :param src_bucket_name: The name of the source bucket
+
+ :type src_key_name: string
+ :param src_key_name: The name of the source key
+
+ :type src_version_id: string
+ :param src_version_id: The version id for the key. This param
+ is optional. If not specified, the newest
+ version of the key will be copied.
+
+ :type metadata: dict
+ :param metadata: Metadata to be associated with new key.
+ If metadata is supplied, it will replace the
+ metadata of the source key being copied.
+ If no metadata is supplied, the source key's
+ metadata will be copied to the new key.
+
+ :type storage_class: string
+ :param storage_class: The storage class of the new key.
+ By default, the new key will use the
+ standard storage class. Possible values are:
+ STANDARD | REDUCED_REDUNDANCY
+
+ :type preserve_acl: bool
+ :param preserve_acl: If True, the ACL from the source key
+ will be copied to the destination
+ key. If False, the destination key
+ will have the default ACL.
+ Note that preserving the ACL in the
+ new key object will require two
+ additional API calls to S3, one to
+ retrieve the current ACL and one to
+ set that ACL on the new object. If
+ you don't care about the ACL, a value
+ of False will be significantly more
+ efficient.
+
+ :rtype: :class:`boto.s3.key.Key` or subclass
+ :returns: An instance of the newly created key object
+ """
+ if preserve_acl:
+ acl = self.get_xml_acl(src_key_name)
+ src = '%s/%s' % (src_bucket_name, urllib.quote(src_key_name))
+ if src_version_id:
+ src += '?version_id=%s' % src_version_id
+ provider = self.connection.provider
+ headers = {provider.copy_source_header : src}
+ if storage_class != 'STANDARD':
+ headers[provider.storage_class_header] = storage_class
+ if metadata:
+ headers[provider.metadata_directive_header] = 'REPLACE'
+ headers = boto.utils.merge_meta(headers, metadata)
+ else:
+ headers[provider.metadata_directive_header] = 'COPY'
+ response = self.connection.make_request('PUT', self.name, new_key_name,
+ headers=headers)
+ body = response.read()
+ if response.status == 200:
+ key = self.new_key(new_key_name)
+ h = handler.XmlHandler(key, self)
+ xml.sax.parseString(body, h)
+ if hasattr(key, 'Error'):
+ raise S3CopyError(key.Code, key.Message, body)
+ key.handle_version_headers(response)
+ if preserve_acl:
+ self.set_xml_acl(acl, new_key_name)
+ return key
+ else:
+ raise S3ResponseError(response.status, response.reason, body)
+
+ def set_canned_acl(self, acl_str, key_name='', headers=None,
+ version_id=None):
+ assert acl_str in CannedACLStrings
+
+ if headers:
+ headers[self.connection.provider.acl_header] = acl_str
+ else:
+ headers={self.connection.provider.acl_header: acl_str}
+
+ query_args='acl'
+ if version_id:
+ query_args += '&versionId=%s' % version_id
+ response = self.connection.make_request('PUT', self.name, key_name,
+ headers=headers, query_args=query_args)
+ body = response.read()
+ if response.status != 200:
+ raise S3ResponseError(response.status, response.reason, body)
+
+ def get_xml_acl(self, key_name='', headers=None, version_id=None):
+ query_args = 'acl'
+ if version_id:
+ query_args += '&versionId=%s' % version_id
+ response = self.connection.make_request('GET', self.name, key_name,
+ query_args=query_args,
+ headers=headers)
+ body = response.read()
+ if response.status != 200:
+ raise S3ResponseError(response.status, response.reason, body)
+ return body
+
+ def set_xml_acl(self, acl_str, key_name='', headers=None, version_id=None):
+ query_args = 'acl'
+ if version_id:
+ query_args += '&versionId=%s' % version_id
+ response = self.connection.make_request('PUT', self.name, key_name,
+ data=acl_str,
+ query_args=query_args,
+ headers=headers)
+ body = response.read()
+ if response.status != 200:
+ raise S3ResponseError(response.status, response.reason, body)
+
+ def set_acl(self, acl_or_str, key_name='', headers=None, version_id=None):
+ if isinstance(acl_or_str, Policy):
+ self.set_xml_acl(acl_or_str.to_xml(), key_name,
+ headers, version_id)
+ else:
+ self.set_canned_acl(acl_or_str, key_name,
+ headers, version_id)
+
+ def get_acl(self, key_name='', headers=None, version_id=None):
+ query_args = 'acl'
+ if version_id:
+ query_args += '&versionId=%s' % version_id
+ response = self.connection.make_request('GET', self.name, key_name,
+ query_args=query_args,
+ headers=headers)
+ body = response.read()
+ if response.status == 200:
+ policy = Policy(self)
+ h = handler.XmlHandler(policy, self)
+ xml.sax.parseString(body, h)
+ return policy
+ else:
+ raise S3ResponseError(response.status, response.reason, body)
+
+ def make_public(self, recursive=False, headers=None):
+ self.set_canned_acl('public-read', headers=headers)
+ if recursive:
+ for key in self:
+ self.set_canned_acl('public-read', key.name, headers=headers)
+
+ def add_email_grant(self, permission, email_address,
+ recursive=False, headers=None):
+ """
+ Convenience method that provides a quick way to add an email grant
+ to a bucket. This method retrieves the current ACL, creates a new
+ grant based on the parameters passed in, adds that grant to the ACL
+ and then PUT's the new ACL back to S3.
+
+ :type permission: string
+ :param permission: The permission being granted. Should be one of:
+ (READ, WRITE, READ_ACP, WRITE_ACP, FULL_CONTROL).
+
+ :type email_address: string
+ :param email_address: The email address associated with the AWS
+ account your are granting the permission to.
+
+ :type recursive: boolean
+ :param recursive: A boolean value to controls whether the command
+ will apply the grant to all keys within the bucket
+ or not. The default value is False. By passing a
+ True value, the call will iterate through all keys
+ in the bucket and apply the same grant to each key.
+ CAUTION: If you have a lot of keys, this could take
+ a long time!
+ """
+ if permission not in S3Permissions:
+ raise S3PermissionsError('Unknown Permission: %s' % permission)
+ policy = self.get_acl(headers=headers)
+ policy.acl.add_email_grant(permission, email_address)
+ self.set_acl(policy, headers=headers)
+ if recursive:
+ for key in self:
+ key.add_email_grant(permission, email_address, headers=headers)
+
+ def add_user_grant(self, permission, user_id, recursive=False, headers=None):
+ """
+ Convenience method that provides a quick way to add a canonical user grant to a bucket.
+ This method retrieves the current ACL, creates a new grant based on the parameters
+ passed in, adds that grant to the ACL and then PUT's the new ACL back to S3.
+
+ :type permission: string
+ :param permission: The permission being granted. Should be one of:
+ (READ, WRITE, READ_ACP, WRITE_ACP, FULL_CONTROL).
+
+ :type user_id: string
+ :param user_id: The canonical user id associated with the AWS account your are granting
+ the permission to.
+
+ :type recursive: boolean
+ :param recursive: A boolean value to controls whether the command
+ will apply the grant to all keys within the bucket
+ or not. The default value is False. By passing a
+ True value, the call will iterate through all keys
+ in the bucket and apply the same grant to each key.
+ CAUTION: If you have a lot of keys, this could take
+ a long time!
+ """
+ if permission not in S3Permissions:
+ raise S3PermissionsError('Unknown Permission: %s' % permission)
+ policy = self.get_acl(headers=headers)
+ policy.acl.add_user_grant(permission, user_id)
+ self.set_acl(policy, headers=headers)
+ if recursive:
+ for key in self:
+ key.add_user_grant(permission, user_id, headers=headers)
+
+ def list_grants(self, headers=None):
+ policy = self.get_acl(headers=headers)
+ return policy.acl.grants
+
+ def get_location(self):
+ """
+ Returns the LocationConstraint for the bucket.
+
+ :rtype: str
+ :return: The LocationConstraint for the bucket or the empty string if
+ no constraint was specified when bucket was created.
+ """
+ response = self.connection.make_request('GET', self.name,
+ query_args='location')
+ body = response.read()
+ if response.status == 200:
+ rs = ResultSet(self)
+ h = handler.XmlHandler(rs, self)
+ xml.sax.parseString(body, h)
+ return rs.LocationConstraint
+ else:
+ raise S3ResponseError(response.status, response.reason, body)
+
+ def enable_logging(self, target_bucket, target_prefix='', headers=None):
+ if isinstance(target_bucket, Bucket):
+ target_bucket = target_bucket.name
+ body = self.BucketLoggingBody % (target_bucket, target_prefix)
+ response = self.connection.make_request('PUT', self.name, data=body,
+ query_args='logging', headers=headers)
+ body = response.read()
+ if response.status == 200:
+ return True
+ else:
+ raise S3ResponseError(response.status, response.reason, body)
+
+ def disable_logging(self, headers=None):
+ body = self.EmptyBucketLoggingBody
+ response = self.connection.make_request('PUT', self.name, data=body,
+ query_args='logging', headers=headers)
+ body = response.read()
+ if response.status == 200:
+ return True
+ else:
+ raise S3ResponseError(response.status, response.reason, body)
+
+ def get_logging_status(self, headers=None):
+ response = self.connection.make_request('GET', self.name,
+ query_args='logging', headers=headers)
+ body = response.read()
+ if response.status == 200:
+ return body
+ else:
+ raise S3ResponseError(response.status, response.reason, body)
+
+ def set_as_logging_target(self, headers=None):
+ policy = self.get_acl(headers=headers)
+ g1 = Grant(permission='WRITE', type='Group', uri=self.LoggingGroup)
+ g2 = Grant(permission='READ_ACP', type='Group', uri=self.LoggingGroup)
+ policy.acl.add_grant(g1)
+ policy.acl.add_grant(g2)
+ self.set_acl(policy, headers=headers)
+
+ def get_request_payment(self, headers=None):
+ response = self.connection.make_request('GET', self.name,
+ query_args='requestPayment', headers=headers)
+ body = response.read()
+ if response.status == 200:
+ return body
+ else:
+ raise S3ResponseError(response.status, response.reason, body)
+
+ def set_request_payment(self, payer='BucketOwner', headers=None):
+ body = self.BucketPaymentBody % payer
+ response = self.connection.make_request('PUT', self.name, data=body,
+ query_args='requestPayment', headers=headers)
+ body = response.read()
+ if response.status == 200:
+ return True
+ else:
+ raise S3ResponseError(response.status, response.reason, body)
+
+ def configure_versioning(self, versioning, mfa_delete=False,
+ mfa_token=None, headers=None):
+ """
+ Configure versioning for this bucket.
+ Note: This feature is currently in beta release and is available
+ only in the Northern California region.
+
+ :type versioning: bool
+ :param versioning: A boolean indicating whether version is
+ enabled (True) or disabled (False).
+
+ :type mfa_delete: bool
+ :param mfa_delete: A boolean indicating whether the Multi-Factor
+ Authentication Delete feature is enabled (True)
+ or disabled (False). If mfa_delete is enabled
+ then all Delete operations will require the
+ token from your MFA device to be passed in
+ the request.
+
+ :type mfa_token: tuple or list of strings
+ :param mfa_token: A tuple or list consisting of the serial number
+ from the MFA device and the current value of
+ the six-digit token associated with the device.
+ This value is required when you are changing
+ the status of the MfaDelete property of
+ the bucket.
+ """
+ if versioning:
+ ver = 'Enabled'
+ else:
+ ver = 'Suspended'
+ if mfa_delete:
+ mfa = 'Enabled'
+ else:
+ mfa = 'Disabled'
+ body = self.VersioningBody % (ver, mfa)
+ if mfa_token:
+ if not headers:
+ headers = {}
+ provider = self.connection.provider
+ headers[provider.mfa_header] = ' '.join(mfa_token)
+ response = self.connection.make_request('PUT', self.name, data=body,
+ query_args='versioning', headers=headers)
+ body = response.read()
+ if response.status == 200:
+ return True
+ else:
+ raise S3ResponseError(response.status, response.reason, body)
+
+ def get_versioning_status(self, headers=None):
+ """
+ Returns the current status of versioning on the bucket.
+
+ :rtype: dict
+ :returns: A dictionary containing a key named 'Versioning'
+ that can have a value of either Enabled, Disabled,
+ or Suspended. Also, if MFADelete has ever been enabled
+ on the bucket, the dictionary will contain a key
+ named 'MFADelete' which will have a value of either
+ Enabled or Suspended.
+ """
+ response = self.connection.make_request('GET', self.name,
+ query_args='versioning', headers=headers)
+ body = response.read()
+ boto.log.debug(body)
+ if response.status == 200:
+ d = {}
+ ver = re.search(self.VersionRE, body)
+ if ver:
+ d['Versioning'] = ver.group(1)
+ mfa = re.search(self.MFADeleteRE, body)
+ if mfa:
+ d['MfaDelete'] = mfa.group(1)
+ return d
+ else:
+ raise S3ResponseError(response.status, response.reason, body)
+
+ def delete(self, headers=None):
+ return self.connection.delete_bucket(self.name, headers=headers)
Added: incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/bucketlistresultset.py
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/bucketlistresultset.py?rev=1132068&view=auto
==============================================================================
--- incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/bucketlistresultset.py (added)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/s3/bucketlistresultset.py Sun Jun 5 08:36:52 2011
@@ -0,0 +1,99 @@
+# Copyright (c) 2006,2007 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
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish, dis-
+# tribute, sublicense, and/or sell copies of the Software, and to permit
+# persons to whom the Software is furnished to do so, subject to the fol-
+# lowing conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+def bucket_lister(bucket, prefix='', delimiter='', marker='', headers=None):
+ """
+ A generator function for listing keys in a bucket.
+ """
+ more_results = True
+ k = None
+ while more_results:
+ rs = bucket.get_all_keys(prefix=prefix, marker=marker,
+ delimiter=delimiter, headers=headers)
+ for k in rs:
+ yield k
+ if k:
+ marker = k.name
+ more_results= rs.is_truncated
+
+class BucketListResultSet:
+ """
+ A resultset for listing keys within a bucket. Uses the bucket_lister
+ generator function and implements the iterator interface. This
+ transparently handles the results paging from S3 so even if you have
+ many thousands of keys within the bucket you can iterate over all
+ keys in a reasonably efficient manner.
+ """
+
+ def __init__(self, bucket=None, prefix='', delimiter='', marker='', headers=None):
+ self.bucket = bucket
+ self.prefix = prefix
+ self.delimiter = delimiter
+ self.marker = marker
+ self.headers = headers
+
+ def __iter__(self):
+ return bucket_lister(self.bucket, prefix=self.prefix,
+ delimiter=self.delimiter, marker=self.marker, headers=self.headers)
+
+def versioned_bucket_lister(bucket, prefix='', delimiter='',
+ key_marker='', version_id_marker='', headers=None):
+ """
+ A generator function for listing versions in a bucket.
+ """
+ more_results = True
+ k = None
+ while more_results:
+ rs = bucket.get_all_versions(prefix=prefix, key_marker=key_marker,
+ version_id_marker=version_id_marker,
+ delimiter=delimiter, headers=headers)
+ for k in rs:
+ yield k
+ key_marker = rs.next_key_marker
+ version_id_marker = rs.next_version_id_marker
+ more_results= rs.is_truncated
+
+class VersionedBucketListResultSet:
+ """
+ A resultset for listing versions within a bucket. Uses the bucket_lister
+ generator function and implements the iterator interface. This
+ transparently handles the results paging from S3 so even if you have
+ many thousands of keys within the bucket you can iterate over all
+ keys in a reasonably efficient manner.
+ """
+
+ def __init__(self, bucket=None, prefix='', delimiter='', key_marker='',
+ version_id_marker='', headers=None):
+ self.bucket = bucket
+ self.prefix = prefix
+ self.delimiter = delimiter
+ self.key_marker = key_marker
+ self.version_id_marker = version_id_marker
+ self.headers = headers
+
+ def __iter__(self):
+ return versioned_bucket_lister(self.bucket, prefix=self.prefix,
+ delimiter=self.delimiter,
+ key_marker=self.key_marker,
+ version_id_marker=self.version_id_marker,
+ headers=self.headers)
+
+