Skip to content

Commit

Permalink
Merge pull request #18 from brettswift/fix/flake8
Browse files Browse the repository at this point in the history
Fix flake8 errors from PR #11
  • Loading branch information
brettswift committed Sep 25, 2018
2 parents 825e1a9 + 1f2ffd8 commit fe93b5b
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 40 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -7,6 +7,7 @@ install:
- pip install .[test]
script:
- py.test -s tests/unit --color=yes -v
- flake8 cumulus tests
#after_success:
#- coveralls
deploy:
Expand Down
1 change: 0 additions & 1 deletion cumulus/__init__.py
Expand Up @@ -3,4 +3,3 @@
__author__ = """Brett Swift"""
__email__ = 'brettswift@gmail.com'
__version__ = '0.1.5'

4 changes: 2 additions & 2 deletions cumulus/steps/ec2/alb.py
Expand Up @@ -28,13 +28,13 @@ def handle(self, chain_context):
def create_conditions(self, template):
template.add_condition(
"UseSSL",
Not(Equals(Ref("ALBCertName"), "")))
Not(Equals(Ref("ALBCertName"), ""))
)
template.add_condition(
"UseIAMCert",
Not(Equals(Ref("ALBCertType"), "acm")))

def create_security_groups(self, template, instance_name):
asg_sg = CLUSTER_SG_NAME % instance_name
alb_sg = ALB_SG_NAME % instance_name

# ALB Security group
Expand Down
4 changes: 2 additions & 2 deletions cumulus/steps/ec2/alb_port.py
@@ -1,5 +1,6 @@
from troposphere import (
Ref, ec2, Join)
Ref, ec2)

from cumulus.chain import step
from cumulus.steps.ec2 import META_SECURITY_GROUP_REF

Expand Down Expand Up @@ -28,4 +29,3 @@ def handle(self, chain_context):
SourceSecurityGroupId=Ref(self.alb_sg_name),
GroupId=chain_context.metadata[META_SECURITY_GROUP_REF]
))

3 changes: 1 addition & 2 deletions cumulus/steps/ec2/block_device_data.py
@@ -1,9 +1,8 @@
from cumulus.chain import step
from cumulus.util.tropo import TemplateQuery
from cumulus.util.template_query import TemplateQuery
from troposphere import autoscaling



class BlockDeviceData(step.Step):

def __init__(self,
Expand Down
5 changes: 3 additions & 2 deletions cumulus/steps/ec2/dns.py
@@ -1,6 +1,7 @@
from troposphere import route53
from troposphere import (
Ref, Join, ec2)
Ref, Join)
from troposphere import route53

from cumulus.chain import step


Expand Down
8 changes: 4 additions & 4 deletions cumulus/steps/ec2/ingress_rule.py
@@ -1,7 +1,8 @@
from troposphere import elasticloadbalancingv2 as alb
from troposphere import (
Ref, ec2)
import re

from troposphere import (
ec2)

from cumulus.chain import step
from cumulus.steps.ec2 import META_SECURITY_GROUP_REF

Expand Down Expand Up @@ -30,4 +31,3 @@ def handle(self, chain_context):
CidrIp=self.cidr,
GroupId=chain_context.metadata[META_SECURITY_GROUP_REF]
))

3 changes: 1 addition & 2 deletions cumulus/steps/ec2/instance_profile_role.py
Expand Up @@ -3,7 +3,7 @@
from cumulus.chain import step
from troposphere.iam import InstanceProfile

from cumulus.util.tropo import TemplateQuery
from cumulus.util.template_query import TemplateQuery


class InstanceProfileRole(step.Step):
Expand All @@ -29,4 +29,3 @@ def handle(self, chain_context):
self.instance_profile_name,
Roles=[Ref(self.role)]
))

6 changes: 3 additions & 3 deletions cumulus/steps/ec2/launch_config.py
Expand Up @@ -37,6 +37,8 @@ def handle(self, chain_context):
asg_name="Asg%s" % chain_context.instance_name,
configsets='default', # TODO: Fix this
)
else:
user_data = self.user_data

launch_config = autoscaling.LaunchConfiguration(
lc_name,
Expand All @@ -49,8 +51,7 @@ def handle(self, chain_context):
template.add_resource(launch_config)

def _get_security_group_parameters(self):
config = {
}
config = {}

if self.vpc_id:
config['VpcId'] = self.vpc_id
Expand All @@ -71,4 +72,3 @@ def _get_launch_configuration_parameters(self, chain_context):
}

return parameters

3 changes: 2 additions & 1 deletion cumulus/steps/ec2/scaling_group.py
@@ -1,6 +1,7 @@
from troposphere import Ref, autoscaling, FindInMap, Base64, ec2
from troposphere import Ref, autoscaling
from troposphere.autoscaling import Tag as ASTag
from troposphere.policies import UpdatePolicy, AutoScalingReplacingUpdate, AutoScalingRollingUpdate

from cumulus.chain import step
from cumulus.steps.ec2 import META_TARGET_GROUP_NAME

Expand Down
6 changes: 2 additions & 4 deletions cumulus/steps/ec2/target_group.py
@@ -1,6 +1,5 @@
from troposphere import elasticloadbalancingv2 as alb, route53
from troposphere import (
Ref, Join, ec2)
from troposphere import elasticloadbalancingv2 as alb

from cumulus.chain import step
from cumulus.steps.ec2 import META_TARGET_GROUP_NAME

Expand Down Expand Up @@ -39,4 +38,3 @@ def handle(self, chain_context):
UnhealthyThresholdCount="3",
VpcId=self.vpc_id
))

17 changes: 4 additions & 13 deletions tests/stacker_test/blueprints/alb.py
@@ -1,13 +1,8 @@
from awacs.aws import Allow, Principal, Policy, Statement
from awacs.sts import AssumeRole
from stacker.blueprints.base import Blueprint
from stacker.blueprints.variables.types import EC2VPCId, EC2SubnetIdList, CFNCommaDelimitedList, CFNString, CFNNumber, \
EC2KeyPairKeyName
from troposphere import cloudformation, ec2, iam, Ref
from troposphere.iam import Role
from stacker.blueprints.variables.types import EC2VPCId, EC2SubnetIdList, CFNCommaDelimitedList, CFNString, CFNNumber

from cumulus.chain import chain, chaincontext
from cumulus.steps.ec2 import scaling_group, launch_config, block_device_data, ingress_rule, target_group, dns, alb
from cumulus.steps.ec2.instance_profile_role import InstanceProfileRole
from cumulus.steps.ec2 import alb


class Alb(Blueprint):
Expand Down Expand Up @@ -46,18 +41,14 @@ class Alb(Blueprint):

def create_template(self):

instance_profile_name = "InstanceProfile" + self.name

t = self.template
t.add_description("Acceptance Tests for cumulus scaling groups")

instance = self.context.environment['namespace'] + self.context.environment['env']

the_chain = chain.Chain()


the_chain.add(alb.Alb(
))
the_chain.add(alb.Alb())

chain_context = chaincontext.ChainContext(
template=t,
Expand Down
4 changes: 2 additions & 2 deletions tests/stacker_test/blueprints/scaling_group_simple.py
Expand Up @@ -4,9 +4,9 @@
from stacker.blueprints.variables.types import EC2VPCId, EC2SubnetIdList, CFNCommaDelimitedList, CFNString, CFNNumber, \
EC2KeyPairKeyName
from troposphere import cloudformation, ec2, iam
from troposphere.iam import Role

from cumulus.chain import chain, chaincontext
from cumulus.steps.ec2 import scaling_group, launch_config, security_group, block_device_data, ingress_rule
from cumulus.steps.ec2 import scaling_group, launch_config, block_device_data, ingress_rule
from cumulus.steps.ec2.instance_profile_role import InstanceProfileRole


Expand Down
4 changes: 2 additions & 2 deletions tests/stacker_test/blueprints/website_simple.py
@@ -1,10 +1,10 @@
from awacs.aws import Allow, Principal, Policy, Statement
from awacs.sts import AssumeRole
from stacker.blueprints.base import Blueprint
from stacker.blueprints.variables.types import EC2VPCId, EC2SubnetIdList, CFNCommaDelimitedList, CFNString, CFNNumber, \
from stacker.blueprints.variables.types import EC2SubnetIdList, CFNCommaDelimitedList, CFNString, CFNNumber, \
EC2KeyPairKeyName
from troposphere import cloudformation, ec2, iam, Ref
from troposphere.iam import Role

from cumulus.chain import chain, chaincontext
from cumulus.steps.ec2 import scaling_group, launch_config, block_device_data, ingress_rule, target_group, dns, \
alb_port, listener_rule
Expand Down

0 comments on commit fe93b5b

Please sign in to comment.