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

Commit

Permalink
Merge branch 'rds-2012-09-17' into develop, fixes #1028, #1033
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesls committed Oct 4, 2012
2 parents 442b316 + acec1e2 commit bbb11fb
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 5 deletions.
34 changes: 30 additions & 4 deletions boto/rds/__init__.py
Expand Up @@ -20,7 +20,6 @@
# IN THE SOFTWARE.
#

import boto.utils
import urllib
from boto.connection import AWSQueryConnection
from boto.rds.dbinstance import DBInstance
Expand Down Expand Up @@ -81,7 +80,7 @@ class RDSConnection(AWSQueryConnection):

DefaultRegionName = 'us-east-1'
DefaultRegionEndpoint = 'rds.us-east-1.amazonaws.com'
APIVersion = '2011-04-01'
APIVersion = '2012-09-17'

def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
is_secure=True, port=None, proxy=None, proxy_port=None,
Expand Down Expand Up @@ -161,8 +160,9 @@ def create_dbinstance(self,
db_subnet_group_name = None,
license_model = None,
option_group_name = None,
iops=None,
):
# API version: 2012-04-23
# API version: 2012-09-17
# Parameter notes:
# =================
# id should be db_instance_identifier according to API docs but has been left
Expand Down Expand Up @@ -348,6 +348,17 @@ def create_dbinstance(self,
:param option_group_name: Indicates that the DB Instance should be associated
with the specified option group.
:type iops: int
:param iops: The amount of IOPS (input/output operations per second) to Provisioned
for the DB Instance. Can be modified at a later date.
Must scale linearly. For every 1000 IOPS provision, you must allocated
100 GB of storage space. This scales up to 1 TB / 10 000 IOPS for MySQL
and Oracle. MSSQL is limited to 700 GB / 7 000 IOPS.
If you specify a value, it must be at least 1000 IOPS and you must
allocate 100 GB of storage.
:rtype: :class:`boto.rds.dbinstance.DBInstance`
:return: The new db instance.
"""
Expand Down Expand Up @@ -388,6 +399,7 @@ def create_dbinstance(self,
'DBSubnetGroupName': db_subnet_group_name,
'Engine': engine,
'EngineVersion': engine_version,
'Iops': iops,
'LicenseModel': license_model,
'MasterUsername': master_username,
'MasterUserPassword': master_password,
Expand Down Expand Up @@ -488,7 +500,8 @@ def modify_dbinstance(self, id, param_group=None, security_groups=None,
backup_retention_period=None,
preferred_backup_window=None,
multi_az=False,
apply_immediately=False):
apply_immediately=False,
iops=None):
"""
Modify an existing DBInstance.
Expand Down Expand Up @@ -548,6 +561,17 @@ def modify_dbinstance(self, id, param_group=None, security_groups=None,
:param multi_az: If True, specifies the DB Instance will be
deployed in multiple availability zones.
:type iops: int
:param iops: The amount of IOPS (input/output operations per second) to Provisioned
for the DB Instance. Can be modified at a later date.
Must scale linearly. For every 1000 IOPS provision, you must allocated
100 GB of storage space. This scales up to 1 TB / 10 000 IOPS for MySQL
and Oracle. MSSQL is limited to 700 GB / 7 000 IOPS.
If you specify a value, it must be at least 1000 IOPS and you must
allocate 100 GB of storage.
:rtype: :class:`boto.rds.dbinstance.DBInstance`
:return: The modified db instance.
"""
Expand Down Expand Up @@ -578,6 +602,8 @@ def modify_dbinstance(self, id, param_group=None, security_groups=None,
params['MultiAZ'] = 'true'
if apply_immediately:
params['ApplyImmediately'] = 'true'
if iops:
params['Iops'] = iops

return self.get_object('ModifyDBInstance', params, DBInstance)

Expand Down
20 changes: 19 additions & 1 deletion boto/rds/dbinstance.py
Expand Up @@ -58,9 +58,11 @@ class DBInstance(object):
:ivar preferred_maintenance_window: Specifies the weekly time
range (in UTC) during which system maintenance can occur. (string)
:ivar latest_restorable_time: Specifies the latest time to which
a database can be restored with point-in-time restore. TODO: type?
a database can be restored with point-in-time restore. (string)
:ivar multi_az: Boolean that specifies if the DB Instance is a
Multi-AZ deployment.
:ivar iops: The current number of provisioned IOPS for the DB Instance.
Can be None if this is a standard instance.
:ivar pending_modified_values: Specifies that changes to the
DB Instance are pending. This element is only included when changes
are pending. Specific changes are identified by subelements.
Expand All @@ -84,6 +86,7 @@ def __init__(self, connection=None, id=None):
self.preferred_maintenance_window = None
self.latest_restorable_time = None
self.multi_az = False
self.iops = None
self.pending_modified_values = None
self._in_endpoint = False
self._port = None
Expand Down Expand Up @@ -145,6 +148,8 @@ def endElement(self, name, value, connection):
elif name == 'MultiAZ':
if value.lower() == 'true':
self.multi_az = True
elif name == 'Iops':
self.iops = int(value)
else:
setattr(self, name, value)

Expand Down Expand Up @@ -217,6 +222,7 @@ def modify(self, param_group=None, security_groups=None,
backup_retention_period=None,
preferred_backup_window=None,
multi_az=False,
iops=None,
apply_immediately=False):
"""
Modify this DBInstance.
Expand Down Expand Up @@ -271,6 +277,17 @@ def modify(self, param_group=None, security_groups=None,
:param multi_az: If True, specifies the DB Instance will be
deployed in multiple availability zones.
:type iops: int
:param iops: The amount of IOPS (input/output operations per second) to Provisioned
for the DB Instance. Can be modified at a later date.
Must scale linearly. For every 1000 IOPS provision, you must allocated
100 GB of storage space. This scales up to 1 TB / 10 000 IOPS for MySQL
and Oracle. MSSQL is limited to 700 GB / 7 000 IOPS.
If you specify a value, it must be at least 1000 IOPS and you must
allocate 100 GB of storage.
:rtype: :class:`boto.rds.dbinstance.DBInstance`
:return: The modified db instance.
"""
Expand All @@ -284,6 +301,7 @@ def modify(self, param_group=None, security_groups=None,
backup_retention_period,
preferred_backup_window,
multi_az,
iops,
apply_immediately)


Expand Down
Empty file added tests/unit/rds/__init__.py
Empty file.
131 changes: 131 additions & 0 deletions tests/unit/rds/test_connection.py
@@ -0,0 +1,131 @@
#!/usr/bin/env python
# Copyright (c) 2012 Amazon.com, Inc. or its affiliates. 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.
#

from tests.unit import unittest
from tests.unit import AWSMockServiceTestCase

from boto.rds import RDSConnection


class TestRDSConnection(AWSMockServiceTestCase):
connection_class = RDSConnection

def setUp(self):
super(TestRDSConnection, self).setUp()

def default_body(self):
return """
<DescribeDBInstancesResponse>
<DescribeDBInstancesResult>
<DBInstances>
<DBInstance>
<Iops>2000</Iops>
<BackupRetentionPeriod>1</BackupRetentionPeriod>
<MultiAZ>false</MultiAZ>
<DBInstanceStatus>backing-up</DBInstanceStatus>
<DBInstanceIdentifier>mydbinstance2</DBInstanceIdentifier>
<PreferredBackupWindow>10:30-11:00</PreferredBackupWindow>
<PreferredMaintenanceWindow>wed:06:30-wed:07:00</PreferredMaintenanceWindow>
<OptionGroupMembership>
<OptionGroupName>default:mysql-5-5</OptionGroupName>
<Status>in-sync</Status>
</OptionGroupMembership>
<AvailabilityZone>us-west-2b</AvailabilityZone>
<ReadReplicaDBInstanceIdentifiers/>
<Engine>mysql</Engine>
<PendingModifiedValues/>
<LicenseModel>general-public-license</LicenseModel>
<DBParameterGroups>
<DBParameterGroup>
<ParameterApplyStatus>in-sync</ParameterApplyStatus>
<DBParameterGroupName>default.mysql5.5</DBParameterGroupName>
</DBParameterGroup>
</DBParameterGroups>
<Endpoint>
<Port>3306</Port>
<Address>mydbinstance2.c0hjqouvn9mf.us-west-2.rds.amazonaws.com</Address>
</Endpoint>
<EngineVersion>5.5.27</EngineVersion>
<DBSecurityGroups>
<DBSecurityGroup>
<Status>active</Status>
<DBSecurityGroupName>default</DBSecurityGroupName>
</DBSecurityGroup>
</DBSecurityGroups>
<DBName>mydb2</DBName>
<AutoMinorVersionUpgrade>true</AutoMinorVersionUpgrade>
<InstanceCreateTime>2012-10-03T22:01:51.047Z</InstanceCreateTime>
<AllocatedStorage>200</AllocatedStorage>
<DBInstanceClass>db.m1.large</DBInstanceClass>
<MasterUsername>awsuser</MasterUsername>
</DBInstance>
</DBInstances>
</DescribeDBInstancesResult>
</DescribeDBInstancesResponse>
"""

def test_get_all_db_instances(self):
self.set_http_response(status_code=200)
response = self.service_connection.get_all_dbinstances('instance_id')
self.assertEqual(len(response), 1)
self.assert_request_parameters({
'Action': 'DescribeDBInstances',
'DBInstanceIdentifier': 'instance_id',
}, ignore_params_values=['AWSAccessKeyId', 'Timestamp', 'Version',
'SignatureVersion', 'SignatureMethod'])
db = response[0]
self.assertEqual(db.id, 'mydbinstance2')
self.assertEqual(db.create_time, '2012-10-03T22:01:51.047Z')
self.assertEqual(db.engine, 'mysql')
self.assertEqual(db.status, 'backing-up')
self.assertEqual(db.allocated_storage, 200)
self.assertEqual(
db.endpoint,
(u'mydbinstance2.c0hjqouvn9mf.us-west-2.rds.amazonaws.com', 3306))
self.assertEqual(db.instance_class, 'db.m1.large')
self.assertEqual(db.master_username, 'awsuser')
self.assertEqual(db.availability_zone, 'us-west-2b')
self.assertEqual(db.backup_retention_period, '1')
self.assertEqual(db.preferred_backup_window, '10:30-11:00')
self.assertEqual(db.preferred_maintenance_window,
'wed:06:30-wed:07:00')
self.assertEqual(db.latest_restorable_time, None)
self.assertEqual(db.multi_az, False)
self.assertEqual(db.iops, 2000)
self.assertEqual(db.pending_modified_values, {})

self.assertEqual(db.parameter_group.name,
'default.mysql5.5')
self.assertEqual(db.parameter_group.description, None)
self.assertEqual(db.parameter_group.engine, None)

self.assertEqual(db.security_group.owner_id, None)
self.assertEqual(db.security_group.name, 'default')
self.assertEqual(db.security_group.description, None)
self.assertEqual(db.security_group.ec2_groups, [])
self.assertEqual(db.security_group.ip_ranges, [])


if __name__ == '__main__':
unittest.main()

0 comments on commit bbb11fb

Please sign in to comment.