diff --git a/plugins/modules/pfsense_dhcp_static.py b/plugins/modules/pfsense_dhcp_static.py index eb1e435f..db58a81f 100644 --- a/plugins/modules/pfsense_dhcp_static.py +++ b/plugins/modules/pfsense_dhcp_static.py @@ -223,10 +223,15 @@ def _validate_params(self): self.module.fail_json(msg='A valid MAC address must be specified.') if params['netif'] is not None: - self.pfsense.parse_interface(params['netif']) + if self.pfsense.is_interface_group(params['netif']): + self.module.fail_json(msg='DHCP cannot be configured for interface groups') + else: + netif = self.pfsense.parse_interface(params['netif']) + else: + netif = None # find staticmaps and determine interface - self._find_staticmaps(params['netif']) + self._find_staticmaps(netif) if params['ipaddr'] is not None: addr = ip_address(u'{0}'.format(params['ipaddr'])) diff --git a/tests/unit/plugins/modules/fixtures/pfsense_dhcp_static_config.xml b/tests/unit/plugins/modules/fixtures/pfsense_dhcp_static_config.xml index b2589ca5..ed5eabfa 100644 --- a/tests/unit/plugins/modules/fixtures/pfsense_dhcp_static_config.xml +++ b/tests/unit/plugins/modules/fixtures/pfsense_dhcp_static_config.xml @@ -1741,6 +1741,13 @@ acme.com + + + opt1 opt2 opt3 + + IFGROUP1 + + vmx0 diff --git a/tests/unit/plugins/modules/test_pfsense_dhcp_static.py b/tests/unit/plugins/modules/test_pfsense_dhcp_static.py index fb6059c5..3563c01e 100644 --- a/tests/unit/plugins/modules/test_pfsense_dhcp_static.py +++ b/tests/unit/plugins/modules/test_pfsense_dhcp_static.py @@ -86,6 +86,14 @@ def test_dhcp_static_create_empty(self): ) self.do_module_test(obj, command=command) + def test_dhcp_static_create_display(self): + """ test create with netif display name """ + obj = dict(name='test_entry', macaddr='ab:ab:ab:ab:ab:ac', ipaddr='10.0.0.101', netif='pub') + command = ( + "create dhcp_static 'test_entry', macaddr='ab:ab:ab:ab:ab:ac', ipaddr='10.0.0.101'" + ) + self.do_module_test(obj, command=command) + def test_dhcp_static_create_wrong_subnet(self): """ test create with IP address in the wrong subnet """ obj = dict(name='test_entry', macaddr='ab:ab:ab:ab:ab:ab', ipaddr='1.2.3.4', netif='opt1') @@ -96,6 +104,11 @@ def test_dhcp_static_create_no_netif(self): obj = dict(name='test_entry', macaddr='ab:ab:ab:ab:ab:ab', ipaddr='1.2.3.4') self.do_module_test(obj, failed=True, msg='Multiple DHCP servers enabled and no netif specified') + def test_dhcp_static_create_ifgroup(self): + """ test create with interface group """ + obj = dict(name='test_entry', macaddr='ab:ab:ab:ab:ab:ab', ipaddr='1.2.3.4', netif='IFGROUP1') + self.do_module_test(obj, failed=True, msg='DHCP cannot be configured for interface groups') + def test_dhcp_static_create_invalid_macaddr(self): """ test create with invalid macaddr """ msg = 'A valid MAC address must be specified.'