本文整理汇总了Python中disco_aws_automation.DiscoAWS.update_elb方法的典型用法代码示例。如果您正苦于以下问题:Python DiscoAWS.update_elb方法的具体用法?Python DiscoAWS.update_elb怎么用?Python DiscoAWS.update_elb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类disco_aws_automation.DiscoAWS
的用法示例。
在下文中一共展示了DiscoAWS.update_elb方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_elb_delete
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import update_elb [as 别名]
def test_update_elb_delete(self, mock_config, **kwargs):
'''Update ELB deletes ELBs that are no longer configured'''
aws = DiscoAWS(config=mock_config, environment_name=TEST_ENV_NAME, elb=MagicMock())
aws.elb.get_elb = MagicMock(return_value=True)
aws.elb.delete_elb = MagicMock()
aws.update_elb("mhcfoo", update_autoscaling=False)
aws.elb.delete_elb.assert_called_once_with("mhcfoo")
示例2: test_update_elb_all_defaults
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import update_elb [as 别名]
def test_update_elb_all_defaults(self, mock_config, **kwargs):
"""
update_elb calls get_or_create_elb with default port and protocol values if all are missing
"""
aws = DiscoAWS(config=self._get_elb_config(), environment_name=TEST_ENV_NAME, elb=MagicMock())
aws.elb.get_or_create_elb = MagicMock(return_value=MagicMock())
aws.get_meta_network_by_name = _get_meta_network_mock()
aws.elb.delete_elb = MagicMock()
aws.update_elb("mhcelb", update_autoscaling=False)
aws.elb.delete_elb.assert_not_called()
aws.elb.get_or_create_elb.assert_called_once_with(
'mhcelb',
health_check_url='/foo',
hosted_zone_name='example.com',
port_config=DiscoELBPortConfig(
[
DiscoELBPortMapping(80, 'HTTP', 80, 'HTTP'),
]
),
security_groups=['sg-1234abcd'], elb_public=False,
sticky_app_cookie=None, subnets=['s-1234abcd', 's-1234abcd', 's-1234abcd'],
elb_dns_alias=None,
connection_draining_timeout=300, idle_timeout=300, testing=False,
tags={
'environment': 'unittestenv',
'hostclass': 'mhcelb',
'is_testing': '0',
'productline': 'mock_productline'
},
cross_zone_load_balancing=True,
cert_name=None
)
示例3: test_provision_hc_with_chaos_using_config
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import update_elb [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)
示例4: test_provision_hc_simple_with_no_chaos
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import update_elb [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)
示例5: test_update_elb_create
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import update_elb [as 别名]
def test_update_elb_create(self, mock_config, **kwargs):
'''DiscoELB called to update or create ELB when one is configured'''
aws = DiscoAWS(config=self._get_elb_config(), environment_name=TEST_ENV_NAME)
aws.elb.get_or_create_elb = MagicMock(return_value=MagicMock())
aws.get_meta_network_by_name = _get_meta_network_mock()
aws.elb.delete_elb = MagicMock()
aws.update_elb("mhcelb", update_autoscaling=False)
aws.elb.delete_elb.assert_not_called()
aws.elb.get_or_create_elb.assert_called_once_with(
'mhcelb', elb_port=80, health_check_url='/foo',
hosted_zone_name='example.com', instance_port=80,
elb_protocol='HTTP', instance_protocol='HTTP',
security_groups=['sg-1234abcd'], elb_public=False,
sticky_app_cookie=None, subnets=['s-1234abcd', 's-1234abcd', 's-1234abcd'],
connection_draining_timeout=300, idle_timeout=300)
示例6: test_update_elb_mismatch
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import update_elb [as 别名]
def test_update_elb_mismatch(self, mock_config, **kwargs):
"""
update_elb sets instance=ELB when given mismatched numbers of instance and ELB ports
"""
overrides = {
'elb_instance_port': '80, 9001',
'elb_instance_protocol': 'HTTP, HTTP',
'elb_port': '443, 80, 9002',
'elb_protocol': 'HTTPS, HTTP, HTTP'
}
aws = DiscoAWS(
config=self._get_elb_config(overrides),
environment_name=TEST_ENV_NAME,
elb=MagicMock()
)
aws.elb.get_or_create_elb = MagicMock(return_value=MagicMock())
aws.get_meta_network_by_name = _get_meta_network_mock()
aws.elb.delete_elb = MagicMock()
aws.update_elb("mhcelb", update_autoscaling=False)
aws.elb.delete_elb.assert_not_called()
aws.elb.get_or_create_elb.assert_called_once_with(
'mhcelb',
health_check_url='/foo',
hosted_zone_name='example.com',
port_config=DiscoELBPortConfig(
[
DiscoELBPortMapping(80, 'HTTP', 443, 'HTTPS'),
DiscoELBPortMapping(9001, 'HTTP', 80, 'HTTP'),
DiscoELBPortMapping(9002, 'HTTP', 9002, 'HTTP')
]
),
security_groups=['sg-1234abcd'], elb_public=False,
sticky_app_cookie=None, subnets=['s-1234abcd', 's-1234abcd', 's-1234abcd'],
elb_dns_alias=None,
connection_draining_timeout=300, idle_timeout=300, testing=False,
tags={
'environment': 'unittestenv',
'hostclass': 'mhcelb',
'is_testing': '0',
'productline': 'mock_productline'
},
cross_zone_load_balancing=True,
cert_name=None
)
示例7: test_provision_hostclass_sched_all_none
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import update_elb [as 别名]
def test_provision_hostclass_sched_all_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="", max_size="")
_ag0 = aws.discogroup.get_existing_groups()[0]
self.assertEqual(_ag0['min_size'], 0) # minimum of listed sizes
self.assertEqual(_ag0['desired_capacity'], 0) # maximum of listed sizes
self.assertEqual(_ag0['max_size'], 0) # maximum of listed sizes
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="3", desired_size="6", max_size="9")
_ag1 = aws.discogroup.get_existing_groups()[0]
self.assertEqual(_ag1['min_size'], 3) # minimum of listed sizes
self.assertEqual(_ag1['desired_capacity'], 6) # maximum of listed sizes
self.assertEqual(_ag1['max_size'], 9) # maximum of listed sizes
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="", max_size="")
_ag2 = aws.discogroup.get_existing_groups()[0]
self.assertEqual(_ag2['min_size'], 3) # minimum of listed sizes
self.assertEqual(_ag2['desired_capacity'], 6) # maximum of listed sizes
self.assertEqual(_ag2['max_size'], 9) # maximum of listed sizes
示例8: test_provision_hostclass_sched_some_none
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import update_elb [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)
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="",
desired_size="[email protected] 0 * * *:[email protected] 0 * * *", max_size="")
_ag = aws.autoscale.get_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