<commit_before>from troposphere import Template, Select, Ref, Parameter, FindInMap, Output, Base64, Join, GetAtt, Retain
import troposphere.iam as iam
import troposphere.ec2 as ec2
import troposphere.s3 as s3
import troposphere.elasticloadbalancing as elb
import boto.vpc
import boto
import hashlib
import json
from environmentbase import EnvironmentBase
from datetime import datetime
from ipcalc import IP, Network


class NetworkBase(EnvironmentBase):
    '''
    Class creates all of the base networking infrastructure for a common deployment within AWS
    This is intended to be the 'base' template for deploying child templates
    '''

    def construct_network(self):
        network_config = self.config.get('network', {})
        template_config = self.config.get('template', {})

        self.vpc = None
        self.azs = []

        self.local_subnets = {}
        self.stack_outputs = {}
        self.add_vpc_az_mapping(boto_config=self.config.get('boto', {}),
                az_count=max(network_config.get('public_subnet_count', 2), network_config.get('private_subnet_count',2)))
        self.add_network_cidr_mapping(network_config=network_config)
        self.create_network(network_config=network_config)
        self.add_utility_bucket(name=template_config.get('s3_utility_bucket', 'demo'))

        self.common_sg = self.template.add_resource(ec2.SecurityGroup('commonSecurityGroup',
            GroupDescription='Security Group allows ingress and egress for common usage patterns throughout this deployed infrastructure.',
            VpcId=Ref(self.vpc),
            SecurityGroupEgress=[ec2.SecurityGroupRule(
                        FromPort='80',
                        ToPort='80',
                        IpProtocol='tcp',
                        CidrIp='0.0.0.0/0'),
                    ec2.SecurityGroupRule(
                        FromPort='443',
                        ToPort='443',
                        IpProtocol='tcp',
                        CidrIp='0.0.0.0/0'),
                    ec2.SecurityGroupRule(
                        FromPort='123',
                        ToPort='123',
                        IpProtocol='udp',
                        CidrIp='0.0.0.0/0')],
            SecurityGroupIngress= [
                    ec2.SecurityGroupRule(
                        FromPort='22',
                        ToPort='22',
                        IpProtocol='tcp',
                        CidrIp=FindInMap('networkAddresses', 'vpcBase', 'cidr'))]))

        for x in range(0, max(int(network_config.get('public_subnet_count', 2)), int(network_config.get('private_subnet_count', 2)))):
            self.azs.append(FindInMap('RegionMap', Ref('AWS::Region'), 'az' + str(x) + 'Name'))

    def create_action(self):
        self.initialize_template()
        self.construct_network()
        self.write_tempate_to_file()<commit_msg>bug in networkbase: spelling typo<commit_after>from troposphere import Template, Select, Ref, Parameter, FindInMap, Output, Base64, Join, GetAtt, Retain
import troposphere.iam as iam
import troposphere.ec2 as ec2
import troposphere.s3 as s3
import troposphere.elasticloadbalancing as elb
import boto.vpc
import boto
import hashlib
import json
from environmentbase import EnvironmentBase
from datetime import datetime
from ipcalc import IP, Network


class NetworkBase(EnvironmentBase):
    '''
    Class creates all of the base networking infrastructure for a common deployment within AWS
    This is intended to be the 'base' template for deploying child templates
    '''

    def construct_network(self):
        network_config = self.config.get('network', {})
        template_config = self.config.get('template', {})

        self.vpc = None
        self.azs = []

        self.local_subnets = {}
        self.stack_outputs = {}
        self.add_vpc_az_mapping(boto_config=self.config.get('boto', {}),
                az_count=max(network_config.get('public_subnet_count', 2), network_config.get('private_subnet_count',2)))
        self.add_network_cidr_mapping(network_config=network_config)
        self.create_network(network_config=network_config)
        self.add_utility_bucket(name=template_config.get('s3_utility_bucket', 'demo'))

        self.common_sg = self.template.add_resource(ec2.SecurityGroup('commonSecurityGroup',
            GroupDescription='Security Group allows ingress and egress for common usage patterns throughout this deployed infrastructure.',
            VpcId=Ref(self.vpc),
            SecurityGroupEgress=[ec2.SecurityGroupRule(
                        FromPort='80',
                        ToPort='80',
                        IpProtocol='tcp',
                        CidrIp='0.0.0.0/0'),
                    ec2.SecurityGroupRule(
                        FromPort='443',
                        ToPort='443',
                        IpProtocol='tcp',
                        CidrIp='0.0.0.0/0'),
                    ec2.SecurityGroupRule(
                        FromPort='123',
                        ToPort='123',
                        IpProtocol='udp',
                        CidrIp='0.0.0.0/0')],
            SecurityGroupIngress= [
                    ec2.SecurityGroupRule(
                        FromPort='22',
                        ToPort='22',
                        IpProtocol='tcp',
                        CidrIp=FindInMap('networkAddresses', 'vpcBase', 'cidr'))]))

        for x in range(0, max(int(network_config.get('public_subnet_count', 2)), int(network_config.get('private_subnet_count', 2)))):
            self.azs.append(FindInMap('RegionMap', Ref('AWS::Region'), 'az' + str(x) + 'Name'))

    def create_action(self):
        self.initialize_template()
        self.construct_network()
        self.write_template_to_file()
{'fraction_non_alphanumeric': 0.10348413936557463, 'fraction_numerical': 0.018027387762177154, 'mean_word_length': 2.214484679665738, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1192884', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1556, 'n_words': 313}