diff --git a/kuryr/common/config.py b/kuryr/common/config.py index a6e77d5b..4845eb3b 100644 --- a/kuryr/common/config.py +++ b/kuryr/common/config.py @@ -42,6 +42,9 @@ neutron_opts = [ cfg.StrOpt('neutron_uri', default=os.environ.get('OS_URL', 'http://127.0.0.1:9696'), help=_('Neutron URL for accessing the network service.')), + cfg.StrOpt('enable_dhcp', + default='False', + help=_('Enable or Disable dhcp for neutron subnets.')), ] keystone_opts = [ cfg.StrOpt('auth_uri', diff --git a/kuryr/controllers.py b/kuryr/controllers.py index 933dee9a..cc7a7866 100644 --- a/kuryr/controllers.py +++ b/kuryr/controllers.py @@ -41,6 +41,7 @@ auth_token = keystone_conf.admin_token auth_uri = keystone_conf.auth_uri.rstrip('/') neutron_uri = cfg.CONF.neutron_client.neutron_uri +enable_dhcp = cfg.CONF.neutron_client.enable_dhcp if username and password: # Authenticate with password crentials @@ -146,6 +147,7 @@ def _process_subnet(neutron_network_id, endpoint_id, interface_cidr, 'network_id': neutron_network_id, 'ip_version': cidr.version, 'cidr': subnet_cidr, + 'enable_dhcp': enable_dhcp, } if pool_id: del new_subnet['cidr'] diff --git a/kuryr/tests/test_kuryr.py b/kuryr/tests/test_kuryr.py index 5a84b675..3df72a0b 100644 --- a/kuryr/tests/test_kuryr.py +++ b/kuryr/tests/test_kuryr.py @@ -156,7 +156,8 @@ class TestKuryr(base.TestKuryrBase): '192.168.1.0']), 'network_id': fake_neutron_network_id, 'ip_version': 4, - 'subnetpool_id': fake_kuryr_subnetpool_id + 'subnetpool_id': fake_kuryr_subnetpool_id, + 'enable_dhcp': 'False' }] } subnet_v4_id = str(uuid.uuid4()) @@ -258,13 +259,15 @@ class TestKuryr(base.TestKuryrBase): '192.168.1.0']), 'network_id': fake_neutron_network_id, 'ip_version': 4, - 'subnetpool_id': fake_kuryr_subnetpool_id + 'subnetpool_id': fake_kuryr_subnetpool_id, + 'enable_dhcp': 'False' }, { 'name': '-'.join([docker_endpoint_id, 'fe80::']), 'network_id': fake_neutron_network_id, 'ip_version': 6, - 'subnetpool_id': fake_kuryr6_subnetpool_id + 'subnetpool_id': fake_kuryr6_subnetpool_id, + 'enable_dhcp': 'False' }] } # The following fake response is retrieved from the Neutron doc: @@ -358,13 +361,15 @@ class TestKuryr(base.TestKuryrBase): '192.168.1.0']), 'network_id': fake_neutron_network_id, 'ip_version': 4, - "cidr": '192.168.1.0/24' + "cidr": '192.168.1.0/24', + 'enable_dhcp': 'False' }, { 'name': '-'.join([docker_endpoint_id, 'fe80::']), 'network_id': fake_neutron_network_id, 'ip_version': 6, - "cidr": 'fe80::/64' + "cidr": 'fe80::/64', + 'enable_dhcp': 'False' }] } # The following fake response is retrieved from the Neutron doc: diff --git a/kuryr/tests/test_kuryr_endpoint.py b/kuryr/tests/test_kuryr_endpoint.py index e877599f..b0b2d3ef 100644 --- a/kuryr/tests/test_kuryr_endpoint.py +++ b/kuryr/tests/test_kuryr_endpoint.py @@ -39,12 +39,14 @@ class TestKuryrEndpointFailures(base.TestKuryrFailures): 'name': '-'.join([docker_endpoint_id, '192.168.1.0']), 'network_id': neutron_network_id, 'ip_version': 4, - "cidr": '192.168.1.0/24' + "cidr": '192.168.1.0/24', + 'enable_dhcp': 'False' }, { 'name': '-'.join([docker_endpoint_id, 'fe80::']), 'network_id': neutron_network_id, 'ip_version': 6, - "cidr": 'fe80::/64' + "cidr": 'fe80::/64', + 'enable_dhcp': 'False' }] } fake_subnets = self._get_fake_subnets(