From b06d439a81a494870dddb69072e331980fc0c286 Mon Sep 17 00:00:00 2001 From: Rene Martin Date: Sat, 8 Oct 2016 10:34:55 +0100 Subject: [PATCH 1/4] Set the right dhcp_options id in the response If the vpc has a dhcp_options associated with it the response should include the right association. --- moto/ec2/responses/vpcs.py | 4 ++-- tests/test_ec2/test_vpcs.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/moto/ec2/responses/vpcs.py b/moto/ec2/responses/vpcs.py index 86df332aa..bcd482567 100644 --- a/moto/ec2/responses/vpcs.py +++ b/moto/ec2/responses/vpcs.py @@ -50,7 +50,7 @@ CREATE_VPC_RESPONSE = """ {{ vpc.id }} pending {{ vpc.cidr_block }} - dopt-1a2b3c4d2 + {% if vpc.dhcp_options %}{{ vpc.dhcp_options.id }}{% else %}dopt-7a8b9c2d{% endif %} default {% for tag in vpc.get_tags() %} @@ -74,7 +74,7 @@ DESCRIBE_VPCS_RESPONSE = """ {{ vpc.id }} {{ vpc.state }} {{ vpc.cidr_block }} - dopt-7a8b9c2d + {% if vpc.dhcp_options %}{{ vpc.dhcp_options.id }}{% else %}dopt-7a8b9c2d{% endif %} default {{ vpc.is_default }} diff --git a/tests/test_ec2/test_vpcs.py b/tests/test_ec2/test_vpcs.py index 7860584e5..8349b8f6f 100644 --- a/tests/test_ec2/test_vpcs.py +++ b/tests/test_ec2/test_vpcs.py @@ -321,3 +321,14 @@ def test_vpc_modify_enable_dns_hostnames(): response = vpc.describe_attribute(Attribute='enableDnsHostnames') attr = response.get('EnableDnsHostnames') attr.get('Value').should.be.ok + +@mock_ec2 +def test_vpc_associate_dhcp_options(): + conn = boto.connect_vpc() + dhcp_options = conn.create_dhcp_options(SAMPLE_DOMAIN_NAME, SAMPLE_NAME_SERVERS) + vpc = conn.create_vpc("10.0.0.0/16") + + conn.associate_dhcp_options(dhcp_options.id, vpc.id) + + vpc.update() + dhcp_options.id.should.equal(vpc.dhcp_options_id) From 4fa838e9fd4dce9c36f5e96eddbe5bfd06d8dd22 Mon Sep 17 00:00:00 2001 From: Rene Martin Date: Sat, 8 Oct 2016 10:37:57 +0100 Subject: [PATCH 2/4] Keep default dhcp_options id backwards compatiblity --- moto/ec2/responses/vpcs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moto/ec2/responses/vpcs.py b/moto/ec2/responses/vpcs.py index bcd482567..58c5e80dd 100644 --- a/moto/ec2/responses/vpcs.py +++ b/moto/ec2/responses/vpcs.py @@ -50,7 +50,7 @@ CREATE_VPC_RESPONSE = """ {{ vpc.id }} pending {{ vpc.cidr_block }} - {% if vpc.dhcp_options %}{{ vpc.dhcp_options.id }}{% else %}dopt-7a8b9c2d{% endif %} + {% if vpc.dhcp_options %}{{ vpc.dhcp_options.id }}{% else %}dopt-1a2b3c4d2{% endif %} default {% for tag in vpc.get_tags() %} From 7f3daf4755aff19d04acf865df39f7d188655b15 Mon Sep 17 00:00:00 2001 From: Rene Martin Date: Sat, 8 Oct 2016 10:39:52 +0100 Subject: [PATCH 3/4] Bumping the version reflecting the bugfix --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 928f28c75..64caa5992 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ extras_require = { setup( name='moto', - version='0.4.27', + version='0.4.28', description='A library that allows your python tests to easily' ' mock out the boto library', author='Steve Pulec', From 75a8d2ed6a3fa03ca132388182b1e7876fb6413e Mon Sep 17 00:00:00 2001 From: Rene Martin Date: Mon, 10 Oct 2016 07:46:00 +0100 Subject: [PATCH 4/4] Revert "Bumping the version reflecting the bugfix" This reverts commit 7f3daf4755aff19d04acf865df39f7d188655b15. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 64caa5992..928f28c75 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ extras_require = { setup( name='moto', - version='0.4.28', + version='0.4.27', description='A library that allows your python tests to easily' ' mock out the boto library', author='Steve Pulec',