本文整理汇总了Python中disco_aws_automation.DiscoAWS.provision方法的典型用法代码示例。如果您正苦于以下问题:Python DiscoAWS.provision方法的具体用法?Python DiscoAWS.provision怎么用?Python DiscoAWS.provision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类disco_aws_automation.DiscoAWS
的用法示例。
在下文中一共展示了DiscoAWS.provision方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_provision_hc_with_chaos_using_config
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import provision [as 别名]
def test_provision_hc_with_chaos_using_config(self, mock_config, **kwargs):
"""
Provision creates the proper launch configuration and autoscaling group with chaos from config
"""
config_dict = get_default_config_dict()
config_dict["mhcunittest"]["chaos"] = "True"
aws = DiscoAWS(config=get_mock_config(config_dict), environment_name=TEST_ENV_NAME,
log_metrics=MagicMock())
mock_ami = self._get_image_mock(aws)
aws.update_elb = MagicMock(return_value=None)
aws.discogroup.elastigroup.spotinst_client = MagicMock()
with patch("disco_aws_automation.DiscoAWS.get_meta_network", return_value=_get_meta_network_mock()):
with patch("boto.ec2.connection.EC2Connection.get_all_snapshots", return_value=[]):
with patch("disco_aws_automation.DiscoAWS.create_scaling_schedule", return_value=None):
with patch("boto.ec2.autoscale.AutoScaleConnection.create_or_update_tags",
return_value=None):
metadata = aws.provision(ami=mock_ami, hostclass="mhcunittest",
owner="unittestuser",
min_size=1, desired_size=1, max_size=1)
self.assertEqual(metadata["hostclass"], "mhcunittest")
self.assertFalse(metadata["no_destroy"])
self.assertTrue(metadata["chaos"])
_lc = aws.discogroup.get_configs()[0]
self.assertRegexpMatches(_lc.name, r".*_mhcunittest_[0-9]*")
self.assertEqual(_lc.image_id, mock_ami.id)
self.assertTrue(aws.discogroup.get_existing_group(hostclass="mhcunittest"))
_ag = aws.discogroup.get_existing_groups()[0]
self.assertRegexpMatches(_ag['name'], r"unittestenv_mhcunittest_[0-9]*")
self.assertEqual(_ag['min_size'], 1)
self.assertEqual(_ag['max_size'], 1)
self.assertEqual(_ag['desired_capacity'], 1)
示例2: test_provision_hc_simple_with_no_chaos
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import provision [as 别名]
def test_provision_hc_simple_with_no_chaos(self, mock_config, **kwargs):
"""
Provision creates the proper launch configuration and autoscaling group with no chaos
"""
aws = DiscoAWS(config=mock_config, environment_name=TEST_ENV_NAME)
mock_ami = self._get_image_mock(aws)
aws.log_metrics = MagicMock()
aws.update_elb = MagicMock(return_value=None)
with patch("disco_aws_automation.DiscoAWS.get_meta_network", return_value=_get_meta_network_mock()):
with patch("boto.ec2.connection.EC2Connection.get_all_snapshots", return_value=[]):
with patch("disco_aws_automation.DiscoAWS.create_scaling_schedule", return_value=None):
with patch("boto.ec2.autoscale.AutoScaleConnection.create_or_update_tags",
return_value=None):
metadata = aws.provision(ami=mock_ami, hostclass="mhcunittest",
owner="unittestuser",
min_size=1, desired_size=1, max_size=1,
chaos="False")
self.assertEqual(metadata["hostclass"], "mhcunittest")
self.assertFalse(metadata["no_destroy"])
self.assertFalse(metadata["chaos"])
_lc = aws.autoscale.get_configs()[0]
self.assertRegexpMatches(_lc.name, r".*_mhcunittest_[0-9]*")
self.assertEqual(_lc.image_id, mock_ami.id)
self.assertTrue(aws.autoscale.has_group("mhcunittest"))
_ag = aws.autoscale.get_groups()[0]
self.assertEqual(_ag.name, "unittestenv_mhcunittest")
self.assertEqual(_ag.min_size, 1)
self.assertEqual(_ag.max_size, 1)
self.assertEqual(_ag.desired_capacity, 1)
示例3: test_provision_hostclass_sched_some_none
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import provision [as 别名]
def test_provision_hostclass_sched_some_none(self, mock_config, **kwargs):
"""
Provision creates the proper autoscaling group sizes with scheduled sizes
"""
aws = DiscoAWS(config=mock_config, environment_name=TEST_ENV_NAME, log_metrics=MagicMock())
aws.update_elb = MagicMock(return_value=None)
aws.discogroup.elastigroup.spotinst_client = MagicMock()
with patch("disco_aws_automation.DiscoAWS.get_meta_network", return_value=_get_meta_network_mock()):
with patch("boto.ec2.connection.EC2Connection.get_all_snapshots", return_value=[]):
with patch("disco_aws_automation.DiscoAWS.create_scaling_schedule", return_value=None):
with patch("boto.ec2.autoscale.AutoScaleConnection.create_or_update_tags",
return_value=None):
aws.provision(ami=self._get_image_mock(aws),
hostclass="mhcunittest", owner="unittestuser",
min_size="",
desired_size="[email protected] 0 * * *:[email protected] 0 * * *", max_size="")
_ag = aws.discogroup.get_existing_groups()[0]
print("({0}, {1}, {2})".format(_ag['min_size'], _ag['desired_capacity'], _ag['max_size']))
self.assertEqual(_ag['min_size'], 0) # minimum of listed sizes
self.assertEqual(_ag['desired_capacity'], 3) # maximum of listed sizes
self.assertEqual(_ag['max_size'], 3) # maximum of listed sizes
示例4: test_provision_hostclass_schedules
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import provision [as 别名]
def test_provision_hostclass_schedules(self, mock_config, **kwargs):
"""
Provision creates the proper autoscaling group sizes with scheduled sizes
"""
aws = DiscoAWS(config=mock_config, environment_name=TEST_ENV_NAME)
aws.log_metrics = MagicMock()
aws.update_elb = MagicMock(return_value=None)
with patch("disco_aws_automation.DiscoAWS.get_meta_network", return_value=_get_meta_network_mock()):
with patch("boto.ec2.connection.EC2Connection.get_all_snapshots", return_value=[]):
with patch("disco_aws_automation.DiscoAWS.create_scaling_schedule", return_value=None):
with patch("boto.ec2.autoscale.AutoScaleConnection.create_or_update_tags",
return_value=None):
aws.provision(ami=self._get_image_mock(aws),
hostclass="mhcunittest", owner="unittestuser",
min_size="[email protected] 0 * * *:[email protected] 0 * * *",
desired_size="[email protected] 0 * * *:[email protected] 0 * * *",
max_size="[email protected] 0 * * *:[email protected] 0 * * *")
_ag = aws.autoscale.get_groups()[0]
self.assertEqual(_ag.min_size, 1) # minimum of listed sizes
self.assertEqual(_ag.desired_capacity, 3) # maximum of listed sizes
self.assertEqual(_ag.max_size, 9) # maximum of listed sizes