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

Commit

Permalink
Rename vpc_security_groups_ids -> vpc_security_groups for consistency…
Browse files Browse the repository at this point in the history
… with security_groups option; Modify behavior to allow passing in SecurityGroup instances from EC2.
  • Loading branch information
danielgtaylor committed Aug 22, 2013
1 parent 012aa0c commit d5c6dfa
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions boto/rds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def create_dbinstance(self,
license_model = None,
option_group_name = None,
iops=None,
vpc_security_groups_ids=None,
vpc_security_groups=None,
):
# API version: 2012-09-17
# Parameter notes:
Expand Down Expand Up @@ -366,8 +366,8 @@ def create_dbinstance(self,
If you specify a value, it must be at least 1000 IOPS and you must
allocate 100 GB of storage.
:type vpc_security_groups_ids: list of str or list of VPCSecurityGroup ids
:param vpc_security_groups_ids: List of ids of VPCSecurityGroup to
:type vpc_security_groups: list of str or list of VPCSecurityGroup ids
:param vpc_security_groups: List of ids of VPCSecurityGroup to
authorize on this DBInstance.
:rtype: :class:`boto.rds.dbinstance.DBInstance`
Expand Down Expand Up @@ -397,6 +397,11 @@ def create_dbinstance(self,
# port => Port
# preferred_backup_window => PreferredBackupWindow
# preferred_maintenance_window => PreferredMaintenanceWindow

# Importing here rather than at the top of the file to prevent
# circular imports.
from boto.ec2.securitygroup import SecurityGroup

params = {
'AllocatedStorage': allocated_storage,
'AutoMinorVersionUpgrade': str(auto_minor_version_upgrade).lower() if auto_minor_version_upgrade else None,
Expand Down Expand Up @@ -431,8 +436,14 @@ def create_dbinstance(self,
l.append(group)
self.build_list_params(params, l, 'DBSecurityGroups.member')

if vpc_security_groups_ids:
self.build_list_params(params, vpc_security_groups_ids, 'VpcSecurityGroupIds.member')
if vpc_security_groups:
l = []
for group in vpc_security_groups:
if isinstance(group, SecurityGroup):
l.append(group.name)
else:
l.append(group)
self.build_list_params(params, l, 'VpcSecurityGroupIds.member')

# Remove any params set to None
for k, v in params.items():
Expand Down Expand Up @@ -518,7 +529,7 @@ def modify_dbinstance(self, id, param_group=None, security_groups=None,
multi_az=False,
apply_immediately=False,
iops=None,
vpc_security_groups_ids=None):
vpc_security_groups=None):
"""
Modify an existing DBInstance.
Expand Down Expand Up @@ -594,13 +605,17 @@ def modify_dbinstance(self, id, param_group=None, security_groups=None,
If you specify a value, it must be at least 1000 IOPS and you must
allocate 100 GB of storage.
:type vpc_security_groups_ids: list of str or list of VPCSecurityGroup ids
:param vpc_security_groups_ids: List of ids of VPCSecurityGroup to
:type vpc_security_groups: list of str or list of VPCSecurityGroup ids
:param vpc_security_groups: List of ids of VPCSecurityGroup to
authorize on this DBInstance.
:rtype: :class:`boto.rds.dbinstance.DBInstance`
:return: The modified db instance.
"""
# Importing here rather than at the top of the file to prevent
# circular imports.
from boto.ec2.securitygroup import SecurityGroup

params = {'DBInstanceIdentifier': id}
if param_group:
params['DBParameterGroupName'] = (param_group.name
Expand All @@ -614,8 +629,14 @@ def modify_dbinstance(self, id, param_group=None, security_groups=None,
else:
l.append(group)
self.build_list_params(params, l, 'DBSecurityGroups.member')
if vpc_security_groups_ids:
self.build_list_params(params, vpc_security_groups_ids, 'VpcSecurityGroupIds.member')
if vpc_security_groups:
l = []
for group in vpc_security_groups:
if isinstance(group, SecurityGroup):
l.append(group.name)
else:
l.append(group)
self.build_list_params(params, l, 'VpcSecurityGroupIds.member')
if preferred_maintenance_window:
params['PreferredMaintenanceWindow'] = preferred_maintenance_window
if master_password:
Expand Down

0 comments on commit d5c6dfa

Please sign in to comment.