Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dhcp: T6611: add vendor support for ShoreTel IP phones #3884

Open
wants to merge 9 commits into
base: current
Choose a base branch
from
6 changes: 6 additions & 0 deletions data/templates/dhcp-server/kea-dhcp4.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
"code": 1,
"type": "ipv4-address",
"space": "ubnt"
},
{
"name": "shoretel-server",
"code": 156,
"type": "string",
"space": "shoretel"
}
],
"hooks-libraries": [
Expand Down
19 changes: 19 additions & 0 deletions interface-definitions/include/dhcp/option-v4.xml.i
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,25 @@
</leafNode>
</children>
</node>
<node name="shoretel">
<properties>
<help>ShoreTel-specfic parameters</help>
</properties>
<children>
<leafNode name="shoretel-server">
sarthurdev marked this conversation as resolved.
Show resolved Hide resolved
<properties>
<help>ShoreTel phone configuration</help>
<valueHelp>
<format>text</format>
<description>Comma-seperated parameters for ShoreTel phone configuration</description>
bk2zsto marked this conversation as resolved.
Show resolved Hide resolved
</valueHelp>
<constraint>
<validator name="shoretel-server"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the validator and instead just put the regex in the XML instead.

Example here: https://github.com/vyos/vyos-1x/blob/current/interface-definitions/firewall.xml.in#L14

</constraint>
</properties>
</leafNode>
</children>
</node>
</children>
</node>
<leafNode name="wins-server">
Expand Down
8 changes: 8 additions & 0 deletions python/vyos/kea.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ def kea_parse_options(config):
'space': 'ubnt'
})

shoretel_server = dict_search_args(config, 'vendor_option', 'shoretel', 'shoretel_server')
if shoretel_server:
options.append({
'name': 'shoretel-server',
'data': shoretel_server,
'space': 'shoretel'
})

return options

def kea_parse_subnet(subnet, config):
Expand Down
9 changes: 9 additions & 0 deletions smoketest/scripts/cli/test_service_dhcp-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ def test_dhcp_single_pool_options(self):
wpad = 'http://wpad.vyos.io/foo/bar'
server_identifier = bootfile_server
ipv6_only_preferred = '300'
shoretel_space = 'ShoreTel IP Phone'
shoretel_server = 'ftpservers=10.0.0.1,country=1,language=1,layer2tagging=1,vlanid=123'

pool = base_path + ['shared-network-name', shared_net_name, 'subnet', subnet]
self.cli_set(pool + ['subnet-id', '1'])
Expand All @@ -193,6 +195,7 @@ def test_dhcp_single_pool_options(self):
self.cli_set(pool + ['option', 'static-route', '10.0.0.0/24', 'next-hop', '192.0.2.1'])
self.cli_set(pool + ['option', 'ipv6-only-preferred', ipv6_only_preferred])
self.cli_set(pool + ['option', 'time-zone', 'Europe/London'])
self.cli_set(pool + ['option', 'vendor-option', 'shoretel', 'shoretel-server', shoretel_server])

self.cli_set(pool + ['range', '0', 'start', range_0_start])
self.cli_set(pool + ['range', '0', 'stop', range_0_stop])
Expand Down Expand Up @@ -278,6 +281,12 @@ def test_dhcp_single_pool_options(self):
['Dhcp4', 'shared-networks', 0, 'subnet4', 0, 'option-data'],
{'name': 'tcode', 'data': 'Europe/London'})

# Vendor options
self.verify_config_object(
obj,
['Dhcp4', 'shared-networks', 0, 'subnet4', 0, 'option-data'],
{'name': 'shoretel-server', 'data': shoretel_server, 'space': shoretel_space})

# Verify pools
self.verify_config_object(
obj,
Expand Down
6 changes: 6 additions & 0 deletions src/validators/shoretel-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

### how far to get into vendor option validation?
### ftpservers=10.0.0.1,country=1,language=1,layer2tagging=1,vlanid=123

${vyos_libexec_dir}/validate-value --regex "[A-Za-z0-9,=\.]+" --value "$1"
Loading