예제 #1
0
    def create(self):
        if self.domain is not None:
            response = self._put_certificates_into_listener()
            if not response:
                raise Exception("You specified a domain for SSL but you net to upload first into IAM")

        securitygroup = securitygroups.get_or_create(
            region=self.region,
            name=self.name,
            process="%s-%s" % ("elb", self.process),
            platform=self.platform,
            env=self.env
        )
        securitygroup_ids = [securitygroup.id]

        if self.public:
            subnet_ids = [subnet for subnet in subnets.get(platform="public", region=self.region)]
        else:
            subnet_ids = [subnet for subnet in subnets.get(platform=self.platform, region=self.region)]

        loadbalancer = self.connection.create_load_balancer(
            name=self.loadbalancer_name,
            zones=None,
            listeners=self.listener,
            subnets=subnet_ids,
            security_groups=securitygroup_ids,
            scheme=None if self.public else "internal"
        )

        hc = self.create_health_check()
        loadbalancer.configure_health_check(hc)
        return loadbalancer
예제 #2
0
파일: ec2.py 프로젝트: rochacon/paaws
    def __init__(self,
                 name=None,
                 process=None,
                 platform=None,
                 env=None,
                 instance_class=None,
                 region=None,
                 zone=None,
                 instance_ids=[],
                 public=False,
                 instance_list=False):

        self.name = name
        self.process = process
        self.platform = platform
        self.env = env
        self.region = region
        self.zone = zone
        self.instance_class = instance_class
        self.connection = ec2.connect_to_region(self.region)
        self.public = public
        self.instance_ids = instance_ids
        self.instance_list = instance_list

        if instance_list is False and len(instance_ids) > 0:
            pass
        elif instance_list is True:
            pass
        elif instance_list is False and len(instance_ids) == 0:
            if zone is not None:
                self.subnet_id = subnets.get(
                    platform="public" if public else self.platform,
                    region=self.region,
                    zone=self.zone)
            else:
                subnet_list = subnets.get(
                    platform="public" if public else self.platform,
                    region=self.region)
                list_id = randint(0, len(subnet_list) - 1)
                self.subnet_id = subnet_list[list_id]

        self.instance_tag_filters = {
            'tag:Name': self.name,
            'tag:Process': self.process,
            'tag:Environment': self.env,
            'tag:Platform': self.platform,
        }
        #Clear empty tags
        self.instance_tag_filters = {
            tag: value
            for (tag, value) in self.instance_tag_filters.iteritems()
            if value is not None
        }
예제 #3
0
 def create_cache_subnet_group(self):
     cache_subnet_group = self.connection.create_cache_subnet_group(
         cache_subnet_group_name="subnetgroup-%s" % self.platform,
         cache_subnet_group_description="ElastiCache SubnetGroup of %s" % self.platform,
         subnet_ids=subnets.get(self.platform, self.region)
     )
     return cache_subnet_group['CreateCacheSubnetGroupResponse']['CreateCacheSubnetGroupResult']['CacheSubnetGroup']['CacheSubnetGroupName']
예제 #4
0
파일: autoscale.py 프로젝트: rochacon/paaws
    def create(self):
        launch_config = self.get_or_create_launch_config()
        subnet_ids = [
            subnet for subnet in subnets.get(
                platform="public" if self.public else self.platform,
                region=self.region)
        ]
        if self.public:
            try:
                subnet_ids.remove(
                    'subnet-0c9eea65'
                )  # RIDICULOUS HARDCODED FIX (3 SUBNETS PUBLIC)
            except ValueError:
                pass

        autoscale_group = autoscale.AutoScalingGroup(
            name=self.scale_name,
            launch_config=launch_config,
            availability_zones=self.availability_zones,
            desired_capacity=self.desired_capacity,
            min_size=self.minimum,
            max_size=self.maximum,
            termination_policies=['OldestInstance'],
            load_balancers=[self.elb],
            vpc_zone_identifier=','.join(subnet_ids),
            connection=self.connection)

        self.connection.create_auto_scaling_group(autoscale_group)
        self.create_notifications()

        return autoscale_group
예제 #5
0
    def create(self):
        launch_config = self.get_or_create_launch_config()
        subnet_ids = [subnet for subnet in subnets.get(platform="public" if self.public else self.platform, region=self.region)]
        if self.public:
            try:
                subnet_ids.remove('subnet-0c9eea65')  # RIDICULOUS HARDCODED FIX (3 SUBNETS PUBLIC)
            except ValueError:
                pass

        autoscale_group = autoscale.AutoScalingGroup(
            name=self.scale_name,
            launch_config=launch_config,
            availability_zones=self.availability_zones,
            desired_capacity=self.desired_capacity,
            min_size=self.minimum,
            max_size=self.maximum,
            termination_policies=['OldestInstance'],
            load_balancers=[self.elb],
            vpc_zone_identifier=','.join(subnet_ids),
            connection=self.connection
        )

        self.connection.create_auto_scaling_group(autoscale_group)
        self.create_notifications()

        return autoscale_group
예제 #6
0
 def create_cache_subnet_group(self):
     cache_subnet_group = self.connection.create_cache_subnet_group(
         cache_subnet_group_name="subnetgroup-%s" % self.platform,
         cache_subnet_group_description="ElastiCache SubnetGroup of %s" %
         self.platform,
         subnet_ids=subnets.get(self.platform, self.region))
     return cache_subnet_group['CreateCacheSubnetGroupResponse'][
         'CreateCacheSubnetGroupResult']['CacheSubnetGroup'][
             'CacheSubnetGroupName']
예제 #7
0
파일: ec2.py 프로젝트: phspagiari/paaws
    def __init__(self, name=None, process=None, platform=None, env=None, instance_class=None, region=None, zone=None, instance_ids=[], public=False, instance_list=False):

        self.name = name
        self.process = process
        self.platform = platform
        self.env = env
        self.region = region
        self.zone = zone
        self.instance_class = instance_class
        self.connection = ec2.connect_to_region(self.region)
        self.public = public
        self.instance_ids = instance_ids
        self.instance_list = instance_list

        if instance_list is False and len(instance_ids) > 0:
            pass
        elif instance_list is True:
            pass
        elif instance_list is False and len(instance_ids) == 0:
            if zone is not None:
                self.subnet_id = subnets.get(
                    platform="public" if public else self.platform,
                    region=self.region,
                    zone=self.zone
                )
            else:
                subnet_list = subnets.get(
                    platform="public" if public else self.platform,
                    region=self.region
                )
                list_id = randint(0, len(subnet_list)-1)
                self.subnet_id = subnet_list[list_id]

        self.instance_tag_filters = {
            'tag:Name': self.name,
            'tag:Process': self.process,
            'tag:Environment': self.env,
            'tag:Platform': self.platform,
        }
        #Clear empty tags
        self.instance_tag_filters = {tag: value for (tag, value) in self.instance_tag_filters.iteritems() if value is not None}
예제 #8
0
파일: rds.py 프로젝트: rochacon/paaws
    def create_db_subnet_group(self):
        try:
            db_subnet_group = self.connection.create_db_subnet_group(
                db_subnet_group_name = "subnetgroup.%s" % self.platform,
                db_subnet_group_description = "RDS SubnetGroup of %s" % self.platform,
                subnet_ids = subnets.get(platform=self.platform, region=self.region),
                tags = [ ("Platform", self.platform) ]
            )
            return db_subnet_group['CreateDBSubnetGroupResponse']['CreateDBSubnetGroupResult']['DBSubnetGroup']['DBSubnetGroupName']

        except exception.JSONResponseError as err:
            raise ValueError(err.body['Error']['Message'])
예제 #9
0
    def create(self):
        if self.domain is not None:
            response = self._put_certificates_into_listener()
            if not response:
                raise Exception(
                    "You specified a domain for SSL but you net to upload first into IAM"
                )

        securitygroup = securitygroups.get_or_create(region=self.region,
                                                     name=self.name,
                                                     process="%s-%s" %
                                                     ("elb", self.process),
                                                     platform=self.platform,
                                                     env=self.env)
        securitygroup_ids = [securitygroup.id]

        if self.public:
            subnet_ids = [
                subnet for subnet in subnets.get(platform="public",
                                                 region=self.region)
            ]
        else:
            subnet_ids = [
                subnet for subnet in subnets.get(platform=self.platform,
                                                 region=self.region)
            ]

        loadbalancer = self.connection.create_load_balancer(
            name=self.loadbalancer_name,
            zones=None,
            listeners=self.listener,
            subnets=subnet_ids,
            security_groups=securitygroup_ids,
            scheme=None if self.public else "internal")

        hc = self.create_health_check()
        loadbalancer.configure_health_check(hc)
        return loadbalancer