boto/boto — pull request #1507 by andresriancho (2013-05-20 23:56:26+00:00)
Title: Added DBSubnetGroup feature to boto

Added DBSubnetGroup feature to boto. All credit goes to @franc-carter for his work on the code, I just made sure the formatting was correct and verified it works using the following test:

```python
from boto.vpc import VPCConnection
from boto.rds import RDSConnection
from boto.rds.dbsubnetgroup import DBSubnetGroup
from boto.exception import BotoServerError

vpc_conn = VPCConnection()
new_vpc = vpc_conn.create_vpc('10.0.0.0/16')

SUBNETS = [(u'10.0.0.0/18', u'us-east-1b'),
(u'10.0.64.0/18', u'us-east-1c'),
(u'10.0.128.0/18', u'us-east-1d')]

subnet_instances = []

for subnet_net, subnet_zone in SUBNETS:
subnet_inst = vpc_conn.create_subnet(new_vpc.id, subnet_net,
availability_zone=subnet_zone)

subnet_instances.append(subnet_inst)

rds_conn = RDSConnection()

assert len(rds_conn.get_all_db_subnet_groups()), 0

dbsg = rds_conn.create_db_subnet_group('name', 'desc',
[s.id for s in subnet_instances])

assert isinstance(dbsg, DBSubnetGroup)
assert dbsg.name in [d.name for d in rds_conn.get_all_db_subnet_groups()]

# Can't create two with the same name
try:
dbsg = rds_conn.create_db_subnet_group('name', 'desc',
[s.id for s in subnet_instances])
except BotoServerError:
pass
else:
assert False

assert set(dbsg.subnet_ids) == set([s.id for s in subnet_instances])

assert len(dbsg.subnet_ids), 3

dbsg_mod = rds_conn.modify_db_subnet_group('name',
subnet_ids=[s.id for s in subnet_instances][:2])
assert len(dbsg_mod.subnet_ids), 2

dbsg_mod = rds_conn.get_all_db_subnet_groups('name')[0]
assert len(dbsg_mod.subnet_ids), 2

rds_conn.delete_db_subnet_group('name')

assert len(rds_conn.get_all_db_subnet_groups()), 0
```

If required I can refactor this test to be part of `tests.unit.rds` or any other test suite. I didn't add it to those modules because I was unsure of the possibility of really interacting with AWS from unittests.

Also, run the full test suite and it passes.

Please merge :+1: