本文整理汇总了Python中troposphere.autoscaling.AutoScalingGroup类的典型用法代码示例。如果您正苦于以下问题:Python AutoScalingGroup类的具体用法?Python AutoScalingGroup怎么用?Python AutoScalingGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AutoScalingGroup类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_none
def test_none(self):
group = AutoScalingGroup(
'mygroup',
MaxSize="1",
MinSize="1",
)
with self.assertRaises(ValueError):
self.assertTrue(group.validate())
开发者ID:Arvoreen,项目名称:troposphere,代码行数:8,代码来源:test_asg.py
示例2: test_instanceid
def test_instanceid(self):
group = AutoScalingGroup(
'mygroup',
InstanceId="i-1234",
MaxSize="1",
MinSize="1",
)
self.assertTrue(group.validate())
开发者ID:DualSpark,项目名称:troposphere,代码行数:8,代码来源:test_asg.py
示例3: test_launchconfigurationname
def test_launchconfigurationname(self):
group = AutoScalingGroup(
'mygroup',
LaunchConfigurationName="I'm a test",
MaxSize="1",
MinSize="1",
)
self.assertTrue(group.validate())
开发者ID:DualSpark,项目名称:troposphere,代码行数:8,代码来源:test_asg.py
示例4: test_launchconfigurationname
def test_launchconfigurationname(self):
group = AutoScalingGroup(
"mygroup",
AvailabilityZones=["eu-west-1a", "eu-west-1b"],
LaunchConfigurationName="I'm a test",
MaxSize="1",
MinSize="1",
)
self.assertTrue(group.validate())
开发者ID:cloudtools,项目名称:troposphere,代码行数:9,代码来源:test_asg.py
示例5: test_instanceid
def test_instanceid(self):
group = AutoScalingGroup(
'mygroup',
AvailabilityZones=['eu-west-1a', 'eu-west-1b'],
InstanceId="i-1234",
MaxSize="1",
MinSize="1",
)
self.assertTrue(group.validate())
开发者ID:Arvoreen,项目名称:troposphere,代码行数:9,代码来源:test_asg.py
示例6: test_exclusive
def test_exclusive(self):
group = AutoScalingGroup(
'mygroup',
InstanceId="i-1234",
LaunchConfigurationName="I'm a test",
MaxSize="1",
MinSize="1",
)
with self.assertRaises(ValueError):
self.assertTrue(group.validate())
开发者ID:Arvoreen,项目名称:troposphere,代码行数:10,代码来源:test_asg.py
示例7: test_AutoScalingRollingUpdate_all_defaults
def test_AutoScalingRollingUpdate_all_defaults(self):
group = AutoScalingGroup(
'mygroup',
AvailabilityZones=['eu-west-1a', 'eu-west-1b'],
LaunchConfigurationName="I'm a test",
MaxSize="1",
MinSize="1",
UpdatePolicy=UpdatePolicy(
AutoScalingRollingUpdate=AutoScalingRollingUpdate())
)
self.assertTrue(group.validate())
开发者ID:Arvoreen,项目名称:troposphere,代码行数:11,代码来源:test_asg.py
示例8: test_working
def test_working(self):
group = AutoScalingGroup('mygroup',
LaunchConfigurationName="I'm a test",
MaxSize="4",
MinSize="2",
UpdatePolicy=UpdatePolicy('AutoScalingRollingUpdate',
PauseTime='PT1M5S',
MinInstancesInService='2',
MaxBatchSize='1',
)
)
self.assertTrue(group.validate())
开发者ID:fishdaemon,项目名称:troposphere,代码行数:12,代码来源:test_basic.py
示例9: test_mininstances
def test_mininstances(self):
group = AutoScalingGroup('mygroup',
LaunchConfigurationName="I'm a test",
MaxSize="1",
MinSize="1",
UpdatePolicy=UpdatePolicy('AutoScalingRollingUpdate',
PauseTime='PT1M5S',
MinInstancesInService='1',
MaxBatchSize='1',
)
)
with self.assertRaises(ValueError):
self.assertTrue(group.validate())
开发者ID:fishdaemon,项目名称:troposphere,代码行数:13,代码来源:test_basic.py
示例10: test_size_if
def test_size_if(self):
group = AutoScalingGroup(
"mygroup",
AvailabilityZones=["eu-west-1a", "eu-west-1b"],
LaunchConfigurationName="I'm a test",
MaxSize=If("isstage", "1", "5"),
MinSize="1",
UpdatePolicy=UpdatePolicy(
AutoScalingRollingUpdate=AutoScalingRollingUpdate(
PauseTime="PT5M", MinInstancesInService="1", MaxBatchSize="1", WaitOnResourceSignals=True
)
),
)
self.assertTrue(group.validate())
开发者ID:cloudtools,项目名称:troposphere,代码行数:14,代码来源:test_asg.py
示例11: test_helperfn_as_updatepolicy
def test_helperfn_as_updatepolicy(self):
update_policy = UpdatePolicy(
AutoScalingRollingUpdate=AutoScalingRollingUpdate(
PauseTime="PT5M", MinInstancesInService="1", MaxBatchSize="1", WaitOnResourceSignals=True
)
)
group = AutoScalingGroup(
"mygroup",
AvailabilityZones=["eu-west-1a", "eu-west-1b"],
LaunchConfigurationName="I'm a test",
MaxSize=If("isstage", "1", "5"),
MinSize="1",
UpdatePolicy=If("UseUpdatePolicy", update_policy, Ref("AWS::NoValue")),
)
self.assertTrue(group.validate())
开发者ID:cloudtools,项目名称:troposphere,代码行数:15,代码来源:test_asg.py
示例12: test_mininstances_mininstancesinservice_is_ref
def test_mininstances_mininstancesinservice_is_ref(self):
paramMinInstancesInService = Parameter(
"ParamMinInstancesInService",
Type="String"
)
group = AutoScalingGroup(
'mygroup',
LaunchConfigurationName="I'm a test",
MaxSize="4",
MinSize="2",
UpdatePolicy=UpdatePolicy(
'AutoScalingRollingUpdate',
PauseTime='PT1M5S',
MinInstancesInService=Ref(paramMinInstancesInService),
MaxBatchSize="2",
)
)
self.assertTrue(group.validate())
开发者ID:EITC-IRPD,项目名称:troposphere,代码行数:18,代码来源:test_basic.py
示例13: test_AutoScalingRollingUpdate_validation
def test_AutoScalingRollingUpdate_validation(self):
update_policy = UpdatePolicy(
AutoScalingRollingUpdate=AutoScalingRollingUpdate(
MinInstancesInService="2",
MaxBatchSize='1'
)
)
group = AutoScalingGroup(
'mygroup',
AvailabilityZones=['eu-west-1a', 'eu-west-1b'],
LaunchConfigurationName="I'm a test",
MaxSize="2",
MinSize="1",
UpdatePolicy=update_policy
)
with self.assertRaises(ValueError):
self.assertTrue(group.validate())
开发者ID:Arvoreen,项目名称:troposphere,代码行数:18,代码来源:test_asg.py
示例14: test_mininstances_maxsize_is_ref
def test_mininstances_maxsize_is_ref(self):
paramMaxSize = Parameter(
"ParamMaxSize",
Type="String"
)
group = AutoScalingGroup(
'mygroup',
AvailabilityZones=['eu-west-1a', 'eu-west-1b'],
LaunchConfigurationName="I'm a test",
MaxSize=Ref(paramMaxSize),
MinSize="2",
UpdatePolicy=UpdatePolicy(
AutoScalingRollingUpdate=AutoScalingRollingUpdate(
PauseTime='PT1M5S',
MinInstancesInService='2',
MaxBatchSize="1"
)
)
)
self.assertTrue(group.validate())
开发者ID:bpholt,项目名称:troposphere,代码行数:20,代码来源:test_policies.py
示例15: test_instanceid
def test_instanceid(self):
group = AutoScalingGroup(
"mygroup", AvailabilityZones=["eu-west-1a", "eu-west-1b"], InstanceId="i-1234", MaxSize="1", MinSize="1"
)
self.assertTrue(group.validate())
开发者ID:cloudtools,项目名称:troposphere,代码行数:5,代码来源:test_asg.py
示例16: create_microservice_asg
def create_microservice_asg(template,
name,
ami,
key_name,
instance_profile,
instance_type,
vpc_id,
instance_port=8080,
subnets=None,
security_groups=[],
availability_zones=None,
region='us-east-1',
load_balancer=None,
load_balancer_security_group=None,
min_size=1,
max_size=1,
desired_capacity=None,
creation_policy=None,
update_policy=None,
depends_on=None,
metadata=None,
tags=[]):
template.mappings[name] = {
region: {'instanceType': instance_type, 'ami': ami, 'profile': instance_profile}
}
if not availability_zones:
availability_zones = _all_az(region)
if load_balancer:
security_groups.append(template.add_resource(ec2.SecurityGroup(
"InstanceSecurityGroup" + name,
GroupDescription="Enable access from ELB",
SecurityGroupIngress=[
ec2.SecurityGroupRule(
IpProtocol='tcp',
FromPort=load_balancer['elb'].Listeners[0].InstancePort,
ToPort=load_balancer['elb'].Listeners[0].InstancePort,
SourceSecurityGroupId=Ref(load_balancer_security_group)
),
],
VpcId=vpc_id
)))
if not creation_policy:
creation_policy = _default_creation_policy(name)
if not update_policy:
update_policy = _default_update_policy()
security_group_refs = [Ref(sg) for sg in security_groups]
asg_name = "AutoscalingGroup" + name
lc_name = "LaunchConfiguration" + name
lc = LaunchConfiguration(
lc_name,
UserData=Base64(Join('', [
"#!/bin/bash -ex\n",
"# redirect output to syslog\n",
"exec 1> >(logger -s -t user-data) 2>&1\n",
"# running cfn-init\n",
"/usr/local/bin/cfn-init --stack ", Ref("AWS::StackName"), " --resource {}".format(lc_name), " --region ",
Ref("AWS::Region"), "\n",
"echo \"cfn-init finished\"\n",
"printf '%b\n' \"$(cat /home/ubuntu/application.properties)\"\n",
"# restart services\n",
"service supervisor restart\n",
"echo \"restarting services\"\n",
"# wait until microservice is ready\n",
"until $(curl --output /dev/null --silent --head --fail http://localhost:{}/health); do\n".format(
instance_port),
" printf '.'\n",
" sleep 5\n",
"done\n"
"echo \"springboot is up\"\n",
"# signal asg\n"
"cfn-signal -e 0",
" --resource {}".format(asg_name),
" --stack ", Ref("AWS::StackName"),
" --region ", Ref("AWS::Region"), "\n"
])),
ImageId=FindInMap(name, Ref("AWS::Region"), 'ami'),
KeyName=key_name,
SecurityGroups=security_group_refs,
InstanceType=FindInMap(name, Ref("AWS::Region"), 'instanceType'),
IamInstanceProfile=Ref(instance_profile)
)
if metadata:
lc.Metadata = metadata
lc = template.add_resource(lc)
if not desired_capacity:
desired_capacity = max_size
if not subnets:
subnets = _get_vpc_subnets(vpc_id, region)
asg = AutoScalingGroup(
asg_name,
DesiredCapacity=desired_capacity,
#.........这里部分代码省略.........
开发者ID:amiryesh,项目名称:microservices,代码行数:101,代码来源:micorservice.py
示例17: BlockDeviceMapping
consul_block_device_mapping = BlockDeviceMapping(config['name'] + 'ConsulBlockDeviceMapping')
consul_block_device_mapping.DeviceName = '/dev/sda1'
consul_block_device_mapping.Ebs = consul_block_device
consul_launch_config = LaunchConfiguration(config['name'] + 'ConsulLaunchConfig')
consul_launch_config.AssociatePublicIpAddress = True
consul_launch_config.EbsOptimized = config['consul_launch_config']['ebs_optimized']
consul_launch_config.ImageId = config['consul_launch_config']['image_id']
consul_launch_config.KeyName = config['consul_launch_config']['key_name']
consul_launch_config.InstanceType = config['consul_launch_config']['instance_type']
consul_launch_config.BlockDeviceMappings = [consul_block_device_mapping]
consul_launch_config.SecurityGroups = [Ref(config['name'] + 'homeSsh'), Ref(consul_sg)]
t.add_resource(consul_launch_config)
# auto scale group for consul server
consul_asg = AutoScalingGroup(config['name'] + 'ConsulAsg')
consul_asg.AvailabilityZones = config['consul_asg']['availability_zones']
consul_asg.LaunchConfigurationName = Ref(consul_launch_config)
consul_asg.MaxSize = config['consul_asg']['max_size']
consul_asg.MinSize = config['consul_asg']['min_size']
consul_asg.VPCZoneIdentifier = [Ref(subnet.title) for subnet in app_subnets]
name_tag = {'Key': 'Name', 'Value': config['consul_asg']['instance_name'], 'PropagateAtLaunch': True}
consul_asg.Tags = [name_tag]
t.add_resource(consul_asg)
# launch configuration for application
block_device = EBSBlockDevice(config['name'] + 'Ebs')
block_device.DeleteOnTermination = config['app_launch_config']['block_device']['delete_on_termination']
block_device_mapping = BlockDeviceMapping(config['name'] + 'BlockDeviceMapping')
block_device_mapping.DeviceName = '/dev/sda1'
开发者ID:cfortier2,项目名称:cs90-final,代码行数:31,代码来源:final-project.py
注:本文中的troposphere.autoscaling.AutoScalingGroup类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论