From 2d3539f9dec19c0d5cec5bd962aaf9640a8cec23 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 8 Oct 2019 21:39:45 +0200 Subject: T1430: add dhcp vendor-class-id client option --- interface-definitions/interfaces-bonding.xml | 20 +++++++++++++++++++ interface-definitions/interfaces-bridge.xml | 5 +++++ interface-definitions/interfaces-ethernet.xml | 28 +++++++++++++++++++++++---- python/vyos/configdict.py | 5 +++++ python/vyos/ifconfig.py | 4 ++++ src/conf_mode/interface-bonding.py | 8 ++++++++ src/conf_mode/interface-bridge.py | 8 ++++++++ src/conf_mode/interface-ethernet.py | 11 +++++++++++ 8 files changed, 85 insertions(+), 4 deletions(-) diff --git a/interface-definitions/interfaces-bonding.xml b/interface-definitions/interfaces-bonding.xml index 88dbab6ab..7279e5993 100644 --- a/interface-definitions/interfaces-bonding.xml +++ b/interface-definitions/interfaces-bonding.xml @@ -101,6 +101,11 @@ DHCP client host name (overrides the system host name) + + + DHCP client vendor type + + @@ -339,6 +344,11 @@ DHCP client host name (overrides the system host name) + + + DHCP client vendor type + + @@ -480,6 +490,11 @@ DHCP client host name (overrides the system host name) + + + DHCP client vendor type + + @@ -605,6 +620,11 @@ DHCP client host name (overrides the system host name) + + + DHCP client vendor type + + diff --git a/interface-definitions/interfaces-bridge.xml b/interface-definitions/interfaces-bridge.xml index 4b82972dc..c026c29b3 100644 --- a/interface-definitions/interfaces-bridge.xml +++ b/interface-definitions/interfaces-bridge.xml @@ -85,6 +85,11 @@ DHCP client host name (overrides the system host name) + + + DHCP client vendor type + + diff --git a/interface-definitions/interfaces-ethernet.xml b/interface-definitions/interfaces-ethernet.xml index e4a56b216..96d2fda10 100644 --- a/interface-definitions/interfaces-ethernet.xml +++ b/interface-definitions/interfaces-ethernet.xml @@ -70,7 +70,12 @@ - DHCP client host name (overrides the system host name) + DHCP client host name (overrides system host name) + + + + + DHCP client vendor type @@ -454,7 +459,12 @@ - DHCP client host name (overrides the system host name) + DHCP client host name (overrides system host name) + + + + + DHCP client vendor type @@ -615,7 +625,12 @@ - DHCP client host name (overrides the system host name) + DHCP client host name (overrides system host name) + + + + + DHCP client vendor type @@ -760,7 +775,12 @@ - DHCP client host name (overrides the system host name) + DHCP client host name (overrides system host name) + + + + + DHCP client vendor type diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index 1c9cf6897..1022b88de 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -112,6 +112,7 @@ def vlan_to_dict(conf): 'description': '', 'dhcp_client_id': '', 'dhcp_hostname': '', + 'dhcp_vendor_class_id': '', 'dhcpv6_prm_only': False, 'dhcpv6_temporary': False, 'disable': False, @@ -145,6 +146,10 @@ def vlan_to_dict(conf): if conf.exists('dhcp-options host-name'): vlan['dhcp_hostname'] = conf.return_value('dhcp-options host-name') + # DHCP client vendor identifier + if conf.exists('dhcp-options vendor-class-id'): + vlan['dhcp_vendor_class_id'] = conf.return_value('dhcp-options vendor-class-id') + # DHCPv6 only acquire config parameters, no address if conf.exists('dhcpv6-options parameters-only'): vlan['dhcpv6_prm_only'] = conf.return_value('dhcpv6-options parameters-only') diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 0f80f4cea..23e66c089 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -35,6 +35,9 @@ interface "{{ intf }}" { {% if client_id -%} send dhcp-client-identifier "{{ client_id }}"; {% endif -%} + {% if vendor_class_id -%} + send vendor-class-identifier "{{ vendor_class_id }}"; + {% endif -%} request subnet-mask, broadcast-address, routers, domain-name-servers, rfc3442-classless-static-routes, domain-name, interface-mtu; require subnet-mask; @@ -91,6 +94,7 @@ class Interface: 'intf' : self._ifname, 'hostname' : '', 'client_id' : '', + 'vendor_class_id' : '' } def _debug_msg(self, msg): diff --git a/src/conf_mode/interface-bonding.py b/src/conf_mode/interface-bonding.py index 7caf9e0e8..49d2a05d4 100755 --- a/src/conf_mode/interface-bonding.py +++ b/src/conf_mode/interface-bonding.py @@ -34,6 +34,7 @@ default_config_data = { 'deleted': False, 'dhcp_client_id': '', 'dhcp_hostname': '', + 'dhcp_vendor_class_id': '', 'dhcpv6_prm_only': False, 'dhcpv6_temporary': False, 'disable': False, @@ -164,6 +165,10 @@ def get_config(): if conf.exists('dhcp-options host-name'): bond['dhcp_hostname'] = conf.return_value('dhcp-options host-name') + # DHCP client vendor identifier + if conf.exists('dhcp-options vendor-class-id'): + bond['dhcp_vendor_class_id'] = conf.return_value('dhcp-options vendor-class-id') + # DHCPv6 only acquire config parameters, no address if conf.exists('dhcpv6-options parameters-only'): bond['dhcpv6_prm_only'] = conf.return_value('dhcpv6-options parameters-only') @@ -377,6 +382,9 @@ def apply(bond): if bond['dhcp_hostname']: opt['hostname'] = bond['dhcp_hostname'] + if bond['dhcp_vendor_class_id']: + opt['vendor_class_id'] = bond['dhcp_vendor_class_id'] + # store DHCP config dictionary - used later on when addresses # are requested b.set_dhcp_options(opt) diff --git a/src/conf_mode/interface-bridge.py b/src/conf_mode/interface-bridge.py index b2755547c..57ac98444 100755 --- a/src/conf_mode/interface-bridge.py +++ b/src/conf_mode/interface-bridge.py @@ -34,6 +34,7 @@ default_config_data = { 'deleted': False, 'dhcp_client_id': '', 'dhcp_hostname': '', + 'dhcp_vendor_class_id': '', 'dhcpv6_prm_only': False, 'dhcpv6_temporary': False, 'disable': False, @@ -93,6 +94,10 @@ def get_config(): if conf.exists('dhcp-options host-name'): bridge['dhcp_hostname'] = conf.return_value('dhcp-options host-name') + # DHCP client vendor identifier + if conf.exists('dhcp-options vendor-class-id'): + bridge['dhcp_vendor_class_id'] = conf.return_value('dhcp-options vendor-class-id') + # DHCPv6 only acquire config parameters, no address if conf.exists('dhcpv6-options parameters-only'): bridge['dhcpv6_prm_only'] = conf.return_value('dhcpv6-options parameters-only') @@ -232,6 +237,9 @@ def apply(bridge): if bridge['dhcp_hostname']: opt['hostname'] = bridge['dhcp_hostname'] + if bridge['dhcp_vendor_class_id']: + opt['vendor_class_id'] = bridge['dhcp_vendor_class_id'] + # store DHCP config dictionary - used later on when addresses # are requested br.set_dhcp_options(opt) diff --git a/src/conf_mode/interface-ethernet.py b/src/conf_mode/interface-ethernet.py index 5f9b4d8b0..3cdc03ce5 100755 --- a/src/conf_mode/interface-ethernet.py +++ b/src/conf_mode/interface-ethernet.py @@ -31,6 +31,7 @@ default_config_data = { 'deleted': False, 'dhcp_client_id': '', 'dhcp_hostname': '', + 'dhcp_vendor_class_id': '', 'dhcpv6_prm_only': False, 'dhcpv6_temporary': False, 'disable': False, @@ -75,6 +76,9 @@ def apply_vlan_config(vlan, config): if config['dhcp_hostname']: opt['hostname'] = config['dhcp_hostname'] + if config['dhcp_vendor_class_id']: + opt['vendor_class_id'] = config['dhcp_vendor_class_id'] + # store DHCP config dictionary - used later on when addresses # are requested vlan.set_dhcp_options(opt) @@ -147,6 +151,10 @@ def get_config(): if conf.exists('dhcp-options host-name'): eth['dhcp_hostname'] = conf.return_value('dhcp-options host-name') + # DHCP client vendor identifier + if conf.exists('dhcp-options vendor-class-id'): + eth['dhcp_vendor_class_id'] = conf.return_value('dhcp-options vendor-class-id') + # DHCPv6 only acquire config parameters, no address if conf.exists('dhcpv6-options parameters-only'): eth['dhcpv6_prm_only'] = conf.return_value('dhcpv6-options parameters-only') @@ -295,6 +303,9 @@ def apply(eth): if eth['dhcp_hostname']: opt['hostname'] = eth['dhcp_hostname'] + if eth['dhcp_vendor_class_id']: + opt['vendor_class_id'] = eth['dhcp_vendor_class_id'] + # store DHCP config dictionary - used later on when addresses # are requested e.set_dhcp_options(opt) -- cgit v1.2.3