Lints.
This commit is contained in:
parent
1433f28846
commit
f37bad0e00
260 changed files with 6363 additions and 3766 deletions
|
|
@ -1,6 +1,5 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import copy
|
||||
import datetime
|
||||
|
||||
import boto.rds
|
||||
|
|
@ -11,10 +10,10 @@ from moto.core import BaseBackend
|
|||
from moto.core.utils import get_random_hex
|
||||
from moto.ec2.models import ec2_backends
|
||||
from moto.rds2.models import rds2_backends
|
||||
from .exceptions import DBInstanceNotFoundError, DBSecurityGroupNotFoundError, DBSubnetGroupNotFoundError
|
||||
|
||||
|
||||
class Database(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.status = "available"
|
||||
|
||||
|
|
@ -35,7 +34,8 @@ class Database(object):
|
|||
self.storage_type = kwargs.get("storage_type")
|
||||
self.master_username = kwargs.get('master_username')
|
||||
self.master_password = kwargs.get('master_password')
|
||||
self.auto_minor_version_upgrade = kwargs.get('auto_minor_version_upgrade')
|
||||
self.auto_minor_version_upgrade = kwargs.get(
|
||||
'auto_minor_version_upgrade')
|
||||
if self.auto_minor_version_upgrade is None:
|
||||
self.auto_minor_version_upgrade = True
|
||||
self.allocated_storage = kwargs.get('allocated_storage')
|
||||
|
|
@ -57,7 +57,8 @@ class Database(object):
|
|||
self.db_subnet_group_name = kwargs.get("db_subnet_group_name")
|
||||
self.instance_create_time = str(datetime.datetime.utcnow())
|
||||
if self.db_subnet_group_name:
|
||||
self.db_subnet_group = rds_backends[self.region].describe_subnet_groups(self.db_subnet_group_name)[0]
|
||||
self.db_subnet_group = rds_backends[
|
||||
self.region].describe_subnet_groups(self.db_subnet_group_name)[0]
|
||||
else:
|
||||
self.db_subnet_group = []
|
||||
|
||||
|
|
@ -239,6 +240,7 @@ class Database(object):
|
|||
|
||||
|
||||
class SecurityGroup(object):
|
||||
|
||||
def __init__(self, group_name, description):
|
||||
self.group_name = group_name
|
||||
self.description = description
|
||||
|
|
@ -284,7 +286,8 @@ class SecurityGroup(object):
|
|||
properties = cloudformation_json['Properties']
|
||||
group_name = resource_name.lower() + get_random_hex(12)
|
||||
description = properties['GroupDescription']
|
||||
security_group_ingress_rules = properties.get('DBSecurityGroupIngress', [])
|
||||
security_group_ingress_rules = properties.get(
|
||||
'DBSecurityGroupIngress', [])
|
||||
tags = properties.get('Tags')
|
||||
|
||||
ec2_backend = ec2_backends[region_name]
|
||||
|
|
@ -300,10 +303,12 @@ class SecurityGroup(object):
|
|||
if ingress_type == "CIDRIP":
|
||||
security_group.authorize_cidr(ingress_value)
|
||||
elif ingress_type == "EC2SecurityGroupName":
|
||||
subnet = ec2_backend.get_security_group_from_name(ingress_value)
|
||||
subnet = ec2_backend.get_security_group_from_name(
|
||||
ingress_value)
|
||||
security_group.authorize_security_group(subnet)
|
||||
elif ingress_type == "EC2SecurityGroupId":
|
||||
subnet = ec2_backend.get_security_group_from_id(ingress_value)
|
||||
subnet = ec2_backend.get_security_group_from_id(
|
||||
ingress_value)
|
||||
security_group.authorize_security_group(subnet)
|
||||
return security_group
|
||||
|
||||
|
|
@ -313,6 +318,7 @@ class SecurityGroup(object):
|
|||
|
||||
|
||||
class SubnetGroup(object):
|
||||
|
||||
def __init__(self, subnet_name, description, subnets):
|
||||
self.subnet_name = subnet_name
|
||||
self.description = description
|
||||
|
|
@ -352,7 +358,8 @@ class SubnetGroup(object):
|
|||
tags = properties.get('Tags')
|
||||
|
||||
ec2_backend = ec2_backends[region_name]
|
||||
subnets = [ec2_backend.get_subnet(subnet_id) for subnet_id in subnet_ids]
|
||||
subnets = [ec2_backend.get_subnet(subnet_id)
|
||||
for subnet_id in subnet_ids]
|
||||
rds_backend = rds_backends[region_name]
|
||||
subnet_group = rds_backend.create_subnet_group(
|
||||
subnet_name,
|
||||
|
|
@ -385,4 +392,6 @@ class RDSBackend(BaseBackend):
|
|||
def rds2_backend(self):
|
||||
return rds2_backends[self.region]
|
||||
|
||||
rds_backends = dict((region.name, RDSBackend(region.name)) for region in boto.rds.regions())
|
||||
|
||||
rds_backends = dict((region.name, RDSBackend(region.name))
|
||||
for region in boto.rds.regions())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue