Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/ytl-linux-digabi2-examnet/lib/network.just
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ configure-networkmanager connection-name interface-name ip-and-netmask:
just log info "Configuring NetworkManager connection '{{connection-name}}' for interface '{{interface-name}}' with IP and netmask '{{ip-and-netmask}}'"

just log debug "Checking if NetworkManager connection '{{connection-name}}' already exists"
if nmcli connection show "{{connection-name}}" > /dev/null 2>&1; then
if nmcli --wait 30 connection show "{{connection-name}}" > /dev/null 2>&1; then
just log debug "NetworkManager connection '{{connection-name}}' already exists, deleting it before creating a new one"
if ! nmcli connection delete "{{connection-name}}"; then
if ! nmcli --wait 30 connection delete "{{connection-name}}"; then
just log error "Failed to delete existing NetworkManager connection '{{connection-name}}'"
exit $EXIT_CODE_CANNOT_CONFIGURE_EXAMNET
fi
fi

just log debug "Adding NetworkManager connection '{{connection-name}}' for interface '{{interface-name}}' with IP and netmask '{{ip-and-netmask}}'"
if ! nmcli connection add \
if ! nmcli --wait 30 connection add \
type ethernet \
ifname "{{interface-name}}" \
con-name "{{connection-name}}" \
Expand All @@ -78,18 +78,18 @@ configure-networkmanager connection-name interface-name ip-and-netmask:
fi

just log debug "Disabling IPv6 for NetworkManager connection '{{connection-name}}'"
nmcli connection modify "{{connection-name}}" ipv6.method disabled
nmcli --wait 30 connection modify "{{connection-name}}" ipv6.method disabled

just log debug "Bringing up NetworkManager connection '{{connection-name}}'"
nmcli connection up "{{connection-name}}"
nmcli --wait 60 connection up "{{connection-name}}"

just log info "Successfully configured NetworkManager connection '{{connection-name}}' for interface '{{interface-name}}' with IP and netmask '{{ip-and-netmask}}'"

get-connections error-code:
#!/usr/bin/env bash
set -euo pipefail

if ! CONNECTIONS=$(nmcli -f UUID,NAME connection show); then
if ! CONNECTIONS=$(nmcli --wait 30 --fields UUID,NAME connection show); then
just log error "Failed to enumerate NetworkManager connections"
exit {{error-code}}
fi
Expand All @@ -101,7 +101,7 @@ delete-connection connection-name connection-uuid error-code:
set -euo pipefail

just log debug "Deleting NetworkManager connection '{{connection-name}}' with UUID {{connection-uuid}}"
if ! nmcli connection delete "{{connection-uuid}}"; then
if ! nmcli --wait 30 connection delete "{{connection-uuid}}"; then
just log error "Failed to delete NetworkManager connection '{{connection-name}}' with UUID {{connection-uuid}}"
exit {{error-code}}
fi
Expand Down
12 changes: 7 additions & 5 deletions packages/ytl-linux-digabi2-examnet/test/examnet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1438,21 +1438,23 @@ function callApparmorParser(profile: string) {
}

function callNmicliConnectionShow(connectionName: string) {
return { cmd: 'nmcli', argv: ['connection', 'show', connectionName] }
return { cmd: 'nmcli', argv: ['--wait', '30', 'connection', 'show', connectionName] }
}

function callNmicliConnectionDelete(connectionName: string) {
return { cmd: 'nmcli', argv: ['connection', 'delete', connectionName] }
return { cmd: 'nmcli', argv: ['--wait', '30', 'connection', 'delete', connectionName] }
}

function callNmicliConnectionModify(connectionName: string) {
return { cmd: 'nmcli', argv: ['connection', 'modify', connectionName, 'ipv6.method', 'disabled'] }
return { cmd: 'nmcli', argv: ['--wait', '30', 'connection', 'modify', connectionName, 'ipv6.method', 'disabled'] }
}

function callNmicliConnectionAdd(connectionName: string, ipRange: string) {
return {
cmd: 'nmcli',
argv: [
'--wait',
'30',
'connection',
'add',
'type',
Expand All @@ -1472,7 +1474,7 @@ function callNmicliConnectionAdd(connectionName: string, ipRange: string) {
}

function callNmicliConnectionUp(deviceName: string) {
return { cmd: 'nmcli', argv: ['connection', 'up', deviceName] }
return { cmd: 'nmcli', argv: ['--wait', '60', 'connection', 'up', deviceName] }
}

function callNmonline(timeout: number = 30) {
Expand All @@ -1495,7 +1497,7 @@ function callSed(path: string) {
}

function callNmcli() {
return { cmd: 'nmcli', argv: ['-f', 'UUID,NAME', 'connection', 'show'] }
return { cmd: 'nmcli', argv: ['--wait', '30', '--fields', 'UUID,NAME', 'connection', 'show'] }
}

function callOpenssl(path: string) {
Expand Down
Loading