diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-10-08 21:23:57 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-10-09 17:19:03 +0200 |
commit | afc82770cce851da31267829f1726f85093d9d76 (patch) | |
tree | 737581797aa07cebad9d3f1cec8eb50b29505ca4 /src/conf_mode/interface-bridge.py | |
parent | 21fe962befb2ebd1625eb7a6c28cb3e9005fe37e (diff) | |
download | vyos-1x-afc82770cce851da31267829f1726f85093d9d76.tar.gz vyos-1x-afc82770cce851da31267829f1726f85093d9d76.zip |
Python/ifconfig: T1557: add generic support for DHCP client options
Diffstat (limited to 'src/conf_mode/interface-bridge.py')
-rwxr-xr-x | src/conf_mode/interface-bridge.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/conf_mode/interface-bridge.py b/src/conf_mode/interface-bridge.py index 37b5c4979..b2755547c 100755 --- a/src/conf_mode/interface-bridge.py +++ b/src/conf_mode/interface-bridge.py @@ -32,6 +32,10 @@ default_config_data = { 'arp_cache_tmo': 30, 'description': '', 'deleted': False, + 'dhcp_client_id': '', + 'dhcp_hostname': '', + 'dhcpv6_prm_only': False, + 'dhcpv6_temporary': False, 'disable': False, 'disable_link_detect': 1, 'forwarding_delay': 14, @@ -81,6 +85,22 @@ def get_config(): if conf.exists('description'): bridge['description'] = conf.return_value('description') + # get DHCP client identifier + if conf.exists('dhcp-options client-id'): + bridge['dhcp_client_id'] = conf.return_value('dhcp-options client-id') + + # DHCP client host name (overrides the system host name) + if conf.exists('dhcp-options host-name'): + bridge['dhcp_hostname'] = conf.return_value('dhcp-options host-name') + + # 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') + + # DHCPv6 temporary IPv6 address + if conf.exists('dhcpv6-options temporary'): + bridge['dhcpv6_temporary'] = conf.return_value('dhcpv6-options temporary') + # Disable this bridge interface if conf.exists('disable'): bridge['disable'] = True @@ -203,6 +223,19 @@ def apply(bridge): # update interface description used e.g. within SNMP br.set_alias(bridge['description']) + # get DHCP config dictionary and update values + opt = br.get_dhcp_options() + + if bridge['dhcp_client_id']: + opt['client_id'] = bridge['dhcp_client_id'] + + if bridge['dhcp_hostname']: + opt['hostname'] = bridge['dhcp_hostname'] + + # store DHCP config dictionary - used later on when addresses + # are requested + br.set_dhcp_options(opt) + # Change interface MAC address if bridge['mac']: br.set_mac(bridge['mac']) |