Cleanup default parameters.

This commit is contained in:
Steve Pulec 2014-11-23 18:16:22 -05:00
parent 93bd852419
commit 72a7946126
3 changed files with 48 additions and 9 deletions

View File

@ -12,29 +12,38 @@ class Cluster(object):
preferred_maintenance_window, cluster_parameter_group_name,
automated_snapshot_retention_period, port, cluster_version,
allow_version_upgrade, number_of_nodes, publicly_accessible,
encrypted):
encrypted, region):
self.cluster_identifier = cluster_identifier
self.node_type = node_type
self.master_username = master_username
self.master_user_password = master_user_password
self.db_name = db_name
self.db_name = db_name if db_name else "dev"
self.cluster_security_groups = cluster_security_groups
self.vpc_security_group_ids = vpc_security_group_ids
self.cluster_subnet_group_name = cluster_subnet_group_name
self.availability_zone = availability_zone
self.preferred_maintenance_window = preferred_maintenance_window
self.cluster_parameter_group_name = cluster_parameter_group_name
self.automated_snapshot_retention_period = automated_snapshot_retention_period
self.port = port
self.cluster_version = cluster_version
self.allow_version_upgrade = allow_version_upgrade
self.publicly_accessible = publicly_accessible
self.encrypted = encrypted
self.allow_version_upgrade = allow_version_upgrade if allow_version_upgrade is not None else True
self.cluster_version = cluster_version if cluster_version else "1.0"
self.port = port if port else 5439
self.automated_snapshot_retention_period = automated_snapshot_retention_period if automated_snapshot_retention_period else 1
self.preferred_maintenance_window = preferred_maintenance_window if preferred_maintenance_window else "Mon:03:00-Mon:03:30"
if availability_zone:
self.availability_zone = availability_zone
else:
# This could probably be smarter, but there doesn't appear to be a
# way to pull AZs for a region in boto
self.availability_zone = region + "a"
if cluster_type == 'single-node':
self.number_of_nodes = 1
else:
elif number_of_nodes:
self.number_of_nodes = number_of_nodes
else:
self.number_of_nodes = 1
def to_json(self):
return {

View File

@ -33,6 +33,7 @@ class RedshiftResponse(BaseResponse):
"number_of_nodes": self._get_int_param('NumberOfNodes'),
"publicly_accessible": self._get_param("PubliclyAccessible"),
"encrypted": self._get_param("Encrypted"),
"region": self.region,
}
cluster = self.redshift_backend.create_cluster(**cluster_kwargs)

View File

@ -76,6 +76,35 @@ def test_create_single_node_cluster():
cluster['NumberOfNodes'].should.equal(1)
@mock_redshift
def test_default_cluster_attibutes():
conn = boto.redshift.connect_to_region("us-east-1")
cluster_identifier = 'my_cluster'
conn.create_cluster(
cluster_identifier,
node_type="dw.hs1.xlarge",
master_username="username",
master_user_password="password",
)
cluster_response = conn.describe_clusters(cluster_identifier)
cluster = cluster_response['DescribeClustersResponse']['DescribeClustersResult']['Clusters'][0]
cluster['DBName'].should.equal("dev")
# cluster['ClusterSecurityGroups'].should.equal([])
# cluster['VpcSecurityGroups'].should.equal([])
# cluster['ClusterSubnetGroupName'].should.equal(None)
assert "us-east-" in cluster['AvailabilityZone']
cluster['PreferredMaintenanceWindow'].should.equal("Mon:03:00-Mon:03:30")
# cluster['ClusterParameterGroups'].should.equal([])
cluster['AutomatedSnapshotRetentionPeriod'].should.equal(1)
cluster['Port'].should.equal(5439)
cluster['ClusterVersion'].should.equal("1.0")
cluster['AllowVersionUpgrade'].should.equal(True)
cluster['NumberOfNodes'].should.equal(1)
@mock_redshift
def test_describe_non_existant_cluster():
conn = boto.redshift.connect_to_region("us-east-1")