示例#1
0
文件: context.py 项目: Tout/china
    def create_environment(self, unit_name):
        # Create the EC2 group
        env_name = self.specific_environment['name']
        group_name = util.env_prefix(self) + env_name
        region_name = self.region_config['EC2_REGION']
        ec2.create_group(group_name, 'Environment ' + env_name, region_name)

        for env in [ self.default_environment, self.specific_environment ]:
            if 'authorizations' in env:
                for auth in env['authorizations']:
                    ec2.authorize(auth, group_name, self.region_config)

        active_unit = unit.ChinaUnit(self, unit_name)
        active_unit.create_ec2_group()
        if 'authorizations' in active_unit.config:
            authorizations = active_unit.config['authorizations']

            # default and env-specific grants
            for env in ['default', active_unit.env_name]:
                if env in authorizations:
                    for auth in authorizations[env]:
                        ec2.authorize(auth, active_unit.group_name, self.region_config)
示例#2
0
文件: unit.py 项目: Tout/china
 def create_ec2_group(self):
     region_name = self.region_context.region_config['EC2_REGION']
     ec2.create_group(self.group_name, "Environment "+self.env_name+" Unit "+self.unit_name, region_name)