Do not show error on dhcp status

This commit is contained in:
ricardopolo 2019-11-01 10:19:48 -05:00
parent 4ad657dc65
commit bc335781fe

View File

@ -326,25 +326,27 @@ function getInterfaceConnectionName(interfaceName) {
} }
function getDHCPstatus(connectionName) { function getDHCPstatus(connectionName) {
const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.method;`; if(connectionName) {
try { const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.method;`;
console.log(1); try {
const result = execSync(cmd).toString(); const result = execSync(cmd).toString();
console.log(2); const resultFormat = result.replace(/\s+/g,' ').trim();
const resultFormat = result.replace(/\s+/g,' ').trim();
let dhcStatus = resultFormat.split(" ").slice(1).toString();
let dhcStatus = resultFormat.split(" ").slice(1).toString(); switch (dhcStatus) {
switch (dhcStatus) { case 'auto':
case 'auto': dhcStatus = true;
dhcStatus = true; break;
break;
default:
default: dhcStatus = false;
dhcStatus = false; break;
break; }
return dhcStatus;
} catch (e) {
return 'Unknow';
} }
return dhcStatus; } else {
} catch (e) {
return 'Unknow'; return 'Unknow';
} }
} }