diff options
-rw-r--r-- | interface-definitions/include/interface/authentication.xml.i | 27 | ||||
-rw-r--r-- | interface-definitions/interfaces-pppoe.xml.in | 18 | ||||
-rw-r--r-- | interface-definitions/interfaces-wwan.xml.in | 1 | ||||
-rwxr-xr-x | src/conf_mode/interfaces-wwan.py | 11 |
4 files changed, 38 insertions, 19 deletions
diff --git a/interface-definitions/include/interface/authentication.xml.i b/interface-definitions/include/interface/authentication.xml.i new file mode 100644 index 000000000..c097ca9dd --- /dev/null +++ b/interface-definitions/include/interface/authentication.xml.i @@ -0,0 +1,27 @@ +<!-- include start from interface/authentication.xml.i --> +<node name="authentication"> + <properties> + <help>Authentication settings</help> + </properties> + <children> + <leafNode name="user"> + <properties> + <help>User name</help> + <valueHelp> + <format>txt</format> + <description>Username used for connection</description> + </valueHelp> + </properties> + </leafNode> + <leafNode name="password"> + <properties> + <help>Password</help> + <valueHelp> + <format>txt</format> + <description>Password used for connection</description> + </valueHelp> + </properties> + </leafNode> + </children> +</node> +<!-- include end --> diff --git a/interface-definitions/interfaces-pppoe.xml.in b/interface-definitions/interfaces-pppoe.xml.in index 8c2b50eba..96479e057 100644 --- a/interface-definitions/interfaces-pppoe.xml.in +++ b/interface-definitions/interfaces-pppoe.xml.in @@ -25,23 +25,7 @@ <constraintErrorMessage>Access concentrator name must be composed of uppper and lower case letters or numbers only</constraintErrorMessage> </properties> </leafNode> - <node name="authentication"> - <properties> - <help>Authentication settings</help> - </properties> - <children> - <leafNode name="user"> - <properties> - <help>User name</help> - </properties> - </leafNode> - <leafNode name="password"> - <properties> - <help>Password</help> - </properties> - </leafNode> - </children> - </node> + #include <include/interface/authentication.xml.i> #include <include/interface/interface-dial-on-demand.xml.i> <leafNode name="default-route"> <properties> diff --git a/interface-definitions/interfaces-wwan.xml.in b/interface-definitions/interfaces-wwan.xml.in index 55ac8eab1..ea3184a11 100644 --- a/interface-definitions/interfaces-wwan.xml.in +++ b/interface-definitions/interfaces-wwan.xml.in @@ -27,6 +27,7 @@ </leafNode> #include <include/interface/dhcp-options.xml.i> #include <include/interface/dhcpv6-options.xml.i> + #include <include/interface/authentication.xml.i> #include <include/interface/interface-description.xml.i> #include <include/interface/interface-disable.xml.i> #include <include/interface/interface-vrf.xml.i> diff --git a/src/conf_mode/interfaces-wwan.py b/src/conf_mode/interfaces-wwan.py index 02d2c723d..a477163b9 100755 --- a/src/conf_mode/interfaces-wwan.py +++ b/src/conf_mode/interfaces-wwan.py @@ -20,6 +20,7 @@ from sys import exit from vyos.config import Config from vyos.configdict import get_interface_dict +from vyos.configverify import verify_authentication from vyos.configverify import verify_interface_exists from vyos.configverify import verify_vrf from vyos.ifconfig import WWANIf @@ -52,6 +53,7 @@ def verify(wwan): raise ConfigError(f'No APN configured for "{ifname}"!') verify_interface_exists(ifname) + verify_authentication(wwan) verify_vrf(wwan) return None @@ -61,7 +63,7 @@ def generate(wwan): def apply(wwan): # we only need the modem number. wwan0 -> 0, wwan1 -> 1 - modem = wwan['ifname'].replace('wwan','') + modem = wwan['ifname'].lstrip('wwan') base_cmd = f'mmcli --modem {modem}' w = WWANIf(wwan['ifname']) @@ -70,7 +72,12 @@ def apply(wwan): cmd(f'{base_cmd} --simple-disconnect') return None - cmd(f'{base_cmd} --simple-connect=\"apn={wwan["apn"]}\"') + options = 'apn=' + wwan['apn'] + if 'authentication' in wwan: + options += ',user={user},password={password}'.format(**wwan['authentication']) + + command = f'{base_cmd} --simple-connect="{options}"' + cmd(command) w.update(wwan) return None |