Skip to content

Commit

Permalink
wwan: T1988: initial XML/Python representation
Browse files Browse the repository at this point in the history
  • Loading branch information
c-po committed Jan 26, 2020
1 parent 8d49ad0 commit dd4b310
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 0 deletions.
73 changes: 73 additions & 0 deletions interface-definitions/interfaces-wirelessmodem.xml.in
@@ -0,0 +1,73 @@
<?xml version="1.0"?>
<interfaceDefinition>
<node name="interfaces">
<children>
<tagNode name="wirelessmodem" owner="${vyos_conf_scripts_dir}/interfaces-wirelessmodem.py">
<properties>
<help>Wireless Modem (WWAN) Interface</help>
<priority>350</priority>
<constraint>
<regex>wlm[0-9]+$</regex>
</constraint>
<constraintErrorMessage>Wireless Modem interface must be named wlmN</constraintErrorMessage>
<valueHelp>
<format>wlmN</format>
<description>Wireless modem interface name</description>
</valueHelp>
</properties>
<children>
<node name="backup">
<properties>
<help>Insert backup default route</help>
</properties>
<children>
<leafNode name="distance">
<properties>
<help>Distance backup default route</help>
<valueHelp>
<format>1-255</format>
<description>Distance of the backup route (default: 10) </description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-255"/>
</constraint>
<constraintErrorMessage>Must be between (1-255)</constraintErrorMessage>
</properties>
</leafNode>
</children>
</node>
#include <include/interface-description.xml.i>
<leafNode name="device">
<properties>
<help>System device name (default: ttyUSB0)</help>
<valueHelp>
<format>&gt;ttyXXX%lt;</format>
<description>System TTY device name</description>
</valueHelp>
</properties>
</leafNode>
#include <include/interface-disable-link-detect.xml.i>
#include <include/interface-mtu-68-9000.xml.i>
<leafNode name="network">
<properties>
<help>Carrier network to define dial strings</help>
<completionHelp>
<script>ls /opt/vyatta/share/ppp/network/</script>
</completionHelp>
</properties>
</leafNode>
<leafNode name="no-dns">
<properties>
<help>Do not use peer supplied DNS server information</help>
</properties>
</leafNode>
<leafNode name="ondemand">
<properties>
<help>Only dial when traffic is available</help>
</properties>
</leafNode>
</children>
</tagNode>
</children>
</node>
</interfaceDefinition>
83 changes: 83 additions & 0 deletions src/conf_mode/interfaces-wirelessmodem.py
@@ -0,0 +1,83 @@
#!/usr/bin/env python3
#
# Copyright (C) 2020 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os

from sys import exit
from copy import deepcopy

from vyos.config import Config
from vyos import ConfigError

default_config_data = {
'address': [],
'deleted': False,
'description': '',
'disable': False
}

def get_config():
wwan = deepcopy(default_config_data)
conf = Config()

# determine tagNode instance
try:
wwan['intf'] = os.environ['VYOS_TAGNODE_VALUE']
except KeyError as E:
print("Interface not specified")

# Check if interface has been removed
if not conf.exists('interfaces wirelessmodem ' + wwan['intf']):
vxlan['deleted'] = True
return vxlan

# set new configuration level
conf.set_level('interfaces wirelessmodem ' + wwan['intf'])

tmp = conf.get_config_dict()

import pprint
pprint.pprint(tmp)

return wwan

def verify(wwan):
if wwan is None:
return None

return None

def generate(wwan):
if wwan is None:
return None

return None

def apply(wwan):
if wwan is None:
return None

return None

if __name__ == '__main__':
try:
c = get_config()
verify(c)
generate(c)
apply(c)
except ConfigError as e:
print(e)
exit(1)

0 comments on commit dd4b310

Please sign in to comment.