Lints.
This commit is contained in:
parent
1433f28846
commit
f37bad0e00
260 changed files with 6363 additions and 3766 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
from .models import redshift_backends
|
||||
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
|
||||
from ..core.models import base_decorator, deprecated_base_decorator
|
||||
|
||||
redshift_backend = redshift_backends['us-east-1']
|
||||
mock_redshift = base_decorator(redshift_backends)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from werkzeug.exceptions import BadRequest
|
|||
|
||||
|
||||
class RedshiftClientError(BadRequest):
|
||||
|
||||
def __init__(self, code, message):
|
||||
super(RedshiftClientError, self).__init__()
|
||||
self.description = json.dumps({
|
||||
|
|
@ -18,6 +19,7 @@ class RedshiftClientError(BadRequest):
|
|||
|
||||
|
||||
class ClusterNotFoundError(RedshiftClientError):
|
||||
|
||||
def __init__(self, cluster_identifier):
|
||||
super(ClusterNotFoundError, self).__init__(
|
||||
'ClusterNotFound',
|
||||
|
|
@ -25,6 +27,7 @@ class ClusterNotFoundError(RedshiftClientError):
|
|||
|
||||
|
||||
class ClusterSubnetGroupNotFoundError(RedshiftClientError):
|
||||
|
||||
def __init__(self, subnet_identifier):
|
||||
super(ClusterSubnetGroupNotFoundError, self).__init__(
|
||||
'ClusterSubnetGroupNotFound',
|
||||
|
|
@ -32,6 +35,7 @@ class ClusterSubnetGroupNotFoundError(RedshiftClientError):
|
|||
|
||||
|
||||
class ClusterSecurityGroupNotFoundError(RedshiftClientError):
|
||||
|
||||
def __init__(self, group_identifier):
|
||||
super(ClusterSecurityGroupNotFoundError, self).__init__(
|
||||
'ClusterSecurityGroupNotFound',
|
||||
|
|
@ -39,6 +43,7 @@ class ClusterSecurityGroupNotFoundError(RedshiftClientError):
|
|||
|
||||
|
||||
class ClusterParameterGroupNotFoundError(RedshiftClientError):
|
||||
|
||||
def __init__(self, group_identifier):
|
||||
super(ClusterParameterGroupNotFoundError, self).__init__(
|
||||
'ClusterParameterGroupNotFound',
|
||||
|
|
@ -46,6 +51,7 @@ class ClusterParameterGroupNotFoundError(RedshiftClientError):
|
|||
|
||||
|
||||
class InvalidSubnetError(RedshiftClientError):
|
||||
|
||||
def __init__(self, subnet_identifier):
|
||||
super(InvalidSubnetError, self).__init__(
|
||||
'InvalidSubnet',
|
||||
|
|
|
|||
|
|
@ -13,13 +13,14 @@ from .exceptions import (
|
|||
|
||||
|
||||
class Cluster(object):
|
||||
|
||||
def __init__(self, redshift_backend, cluster_identifier, node_type, master_username,
|
||||
master_user_password, db_name, cluster_type, cluster_security_groups,
|
||||
vpc_security_group_ids, cluster_subnet_group_name, availability_zone,
|
||||
preferred_maintenance_window, cluster_parameter_group_name,
|
||||
automated_snapshot_retention_period, port, cluster_version,
|
||||
allow_version_upgrade, number_of_nodes, publicly_accessible,
|
||||
encrypted, region):
|
||||
master_user_password, db_name, cluster_type, cluster_security_groups,
|
||||
vpc_security_group_ids, cluster_subnet_group_name, availability_zone,
|
||||
preferred_maintenance_window, cluster_parameter_group_name,
|
||||
automated_snapshot_retention_period, port, cluster_version,
|
||||
allow_version_upgrade, number_of_nodes, publicly_accessible,
|
||||
encrypted, region):
|
||||
self.redshift_backend = redshift_backend
|
||||
self.cluster_identifier = cluster_identifier
|
||||
self.node_type = node_type
|
||||
|
|
@ -34,7 +35,8 @@ class Cluster(object):
|
|||
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 = int(port) if port else 5439
|
||||
self.automated_snapshot_retention_period = int(automated_snapshot_retention_period) if automated_snapshot_retention_period else 1
|
||||
self.automated_snapshot_retention_period = int(
|
||||
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 cluster_parameter_group_name:
|
||||
|
|
@ -68,7 +70,8 @@ class Cluster(object):
|
|||
properties = cloudformation_json['Properties']
|
||||
|
||||
if 'ClusterSubnetGroupName' in properties:
|
||||
subnet_group_name = properties['ClusterSubnetGroupName'].cluster_subnet_group_name
|
||||
subnet_group_name = properties[
|
||||
'ClusterSubnetGroupName'].cluster_subnet_group_name
|
||||
else:
|
||||
subnet_group_name = None
|
||||
cluster = redshift_backend.create_cluster(
|
||||
|
|
@ -78,13 +81,17 @@ class Cluster(object):
|
|||
master_user_password=properties.get('MasterUserPassword'),
|
||||
db_name=properties.get('DBName'),
|
||||
cluster_type=properties.get('ClusterType'),
|
||||
cluster_security_groups=properties.get('ClusterSecurityGroups', []),
|
||||
cluster_security_groups=properties.get(
|
||||
'ClusterSecurityGroups', []),
|
||||
vpc_security_group_ids=properties.get('VpcSecurityGroupIds', []),
|
||||
cluster_subnet_group_name=subnet_group_name,
|
||||
availability_zone=properties.get('AvailabilityZone'),
|
||||
preferred_maintenance_window=properties.get('PreferredMaintenanceWindow'),
|
||||
cluster_parameter_group_name=properties.get('ClusterParameterGroupName'),
|
||||
automated_snapshot_retention_period=properties.get('AutomatedSnapshotRetentionPeriod'),
|
||||
preferred_maintenance_window=properties.get(
|
||||
'PreferredMaintenanceWindow'),
|
||||
cluster_parameter_group_name=properties.get(
|
||||
'ClusterParameterGroupName'),
|
||||
automated_snapshot_retention_period=properties.get(
|
||||
'AutomatedSnapshotRetentionPeriod'),
|
||||
port=properties.get('Port'),
|
||||
cluster_version=properties.get('ClusterVersion'),
|
||||
allow_version_upgrade=properties.get('AllowVersionUpgrade'),
|
||||
|
|
@ -214,6 +221,7 @@ class SubnetGroup(object):
|
|||
|
||||
|
||||
class SecurityGroup(object):
|
||||
|
||||
def __init__(self, cluster_security_group_name, description):
|
||||
self.cluster_security_group_name = cluster_security_group_name
|
||||
self.description = description
|
||||
|
|
@ -293,7 +301,8 @@ class RedshiftBackend(BaseBackend):
|
|||
|
||||
def modify_cluster(self, **cluster_kwargs):
|
||||
cluster_identifier = cluster_kwargs.pop('cluster_identifier')
|
||||
new_cluster_identifier = cluster_kwargs.pop('new_cluster_identifier', None)
|
||||
new_cluster_identifier = cluster_kwargs.pop(
|
||||
'new_cluster_identifier', None)
|
||||
|
||||
cluster = self.describe_clusters(cluster_identifier)[0]
|
||||
|
||||
|
|
@ -313,7 +322,8 @@ class RedshiftBackend(BaseBackend):
|
|||
raise ClusterNotFoundError(cluster_identifier)
|
||||
|
||||
def create_cluster_subnet_group(self, cluster_subnet_group_name, description, subnet_ids):
|
||||
subnet_group = SubnetGroup(self.ec2_backend, cluster_subnet_group_name, description, subnet_ids)
|
||||
subnet_group = SubnetGroup(
|
||||
self.ec2_backend, cluster_subnet_group_name, description, subnet_ids)
|
||||
self.subnet_groups[cluster_subnet_group_name] = subnet_group
|
||||
return subnet_group
|
||||
|
||||
|
|
@ -332,7 +342,8 @@ class RedshiftBackend(BaseBackend):
|
|||
raise ClusterSubnetGroupNotFoundError(subnet_identifier)
|
||||
|
||||
def create_cluster_security_group(self, cluster_security_group_name, description):
|
||||
security_group = SecurityGroup(cluster_security_group_name, description)
|
||||
security_group = SecurityGroup(
|
||||
cluster_security_group_name, description)
|
||||
self.security_groups[cluster_security_group_name] = security_group
|
||||
return security_group
|
||||
|
||||
|
|
@ -351,8 +362,9 @@ class RedshiftBackend(BaseBackend):
|
|||
raise ClusterSecurityGroupNotFoundError(security_group_identifier)
|
||||
|
||||
def create_cluster_parameter_group(self, cluster_parameter_group_name,
|
||||
group_family, description):
|
||||
parameter_group = ParameterGroup(cluster_parameter_group_name, group_family, description)
|
||||
group_family, description):
|
||||
parameter_group = ParameterGroup(
|
||||
cluster_parameter_group_name, group_family, description)
|
||||
self.parameter_groups[cluster_parameter_group_name] = parameter_group
|
||||
|
||||
return parameter_group
|
||||
|
|
|
|||
|
|
@ -134,7 +134,8 @@ class RedshiftResponse(BaseResponse):
|
|||
|
||||
def describe_cluster_subnet_groups(self):
|
||||
subnet_identifier = self._get_param("ClusterSubnetGroupName")
|
||||
subnet_groups = self.redshift_backend.describe_cluster_subnet_groups(subnet_identifier)
|
||||
subnet_groups = self.redshift_backend.describe_cluster_subnet_groups(
|
||||
subnet_identifier)
|
||||
|
||||
return json.dumps({
|
||||
"DescribeClusterSubnetGroupsResponse": {
|
||||
|
|
@ -160,7 +161,8 @@ class RedshiftResponse(BaseResponse):
|
|||
})
|
||||
|
||||
def create_cluster_security_group(self):
|
||||
cluster_security_group_name = self._get_param('ClusterSecurityGroupName')
|
||||
cluster_security_group_name = self._get_param(
|
||||
'ClusterSecurityGroupName')
|
||||
description = self._get_param('Description')
|
||||
|
||||
security_group = self.redshift_backend.create_cluster_security_group(
|
||||
|
|
@ -180,8 +182,10 @@ class RedshiftResponse(BaseResponse):
|
|||
})
|
||||
|
||||
def describe_cluster_security_groups(self):
|
||||
cluster_security_group_name = self._get_param("ClusterSecurityGroupName")
|
||||
security_groups = self.redshift_backend.describe_cluster_security_groups(cluster_security_group_name)
|
||||
cluster_security_group_name = self._get_param(
|
||||
"ClusterSecurityGroupName")
|
||||
security_groups = self.redshift_backend.describe_cluster_security_groups(
|
||||
cluster_security_group_name)
|
||||
|
||||
return json.dumps({
|
||||
"DescribeClusterSecurityGroupsResponse": {
|
||||
|
|
@ -196,7 +200,8 @@ class RedshiftResponse(BaseResponse):
|
|||
|
||||
def delete_cluster_security_group(self):
|
||||
security_group_identifier = self._get_param("ClusterSecurityGroupName")
|
||||
self.redshift_backend.delete_cluster_security_group(security_group_identifier)
|
||||
self.redshift_backend.delete_cluster_security_group(
|
||||
security_group_identifier)
|
||||
|
||||
return json.dumps({
|
||||
"DeleteClusterSecurityGroupResponse": {
|
||||
|
|
@ -230,7 +235,8 @@ class RedshiftResponse(BaseResponse):
|
|||
|
||||
def describe_cluster_parameter_groups(self):
|
||||
cluster_parameter_group_name = self._get_param("ParameterGroupName")
|
||||
parameter_groups = self.redshift_backend.describe_cluster_parameter_groups(cluster_parameter_group_name)
|
||||
parameter_groups = self.redshift_backend.describe_cluster_parameter_groups(
|
||||
cluster_parameter_group_name)
|
||||
|
||||
return json.dumps({
|
||||
"DescribeClusterParameterGroupsResponse": {
|
||||
|
|
@ -245,7 +251,8 @@ class RedshiftResponse(BaseResponse):
|
|||
|
||||
def delete_cluster_parameter_group(self):
|
||||
cluster_parameter_group_name = self._get_param("ParameterGroupName")
|
||||
self.redshift_backend.delete_cluster_parameter_group(cluster_parameter_group_name)
|
||||
self.redshift_backend.delete_cluster_parameter_group(
|
||||
cluster_parameter_group_name)
|
||||
|
||||
return json.dumps({
|
||||
"DeleteClusterParameterGroupResponse": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue