From a1596fa3e3bee0e9306f503496fe671d776b6852 Mon Sep 17 00:00:00 2001 From: xuweibj Date: Thu, 7 Jun 2018 16:58:49 +0800 Subject: [PATCH] check ip whether static for networkmanager config (#5261) * check ip whether static by networkmanager --- xCAT-probe/lib/perl/probe_utils.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/xCAT-probe/lib/perl/probe_utils.pm b/xCAT-probe/lib/perl/probe_utils.pm index d9e93a84c..f8c1b2209 100644 --- a/xCAT-probe/lib/perl/probe_utils.pm +++ b/xCAT-probe/lib/perl/probe_utils.pm @@ -179,6 +179,24 @@ sub is_static_ip { my $os = get_os(); my $rst = 0; + `which nmcli > /dev/null 2>&1`; + unless ($?) { + my $device_connection = `nmcli device show $nic 2>&1 | grep GENERAL.CONNECTION`; + my $net_name; + if ($device_connection =~ /GENERAL.CONNECTION:\s*(.+)/) { + $net_name = $1; + } + if ($net_name) { + my $ipv4_method = `nmcli con show "$net_name" 2>&1 | grep -E 'ipv4.method'`; + unless ($?) { + if ($ipv4_method =~ /manual/) { + $rst = 1; + } + return $rst; + } + } + } + if ($os =~ /redhat/) { my $output1 = `cat /etc/sysconfig/network-scripts/ifcfg-$nic 2>&1 |grep -i IPADDR`; my $output2 = `cat /etc/sysconfig/network-scripts/ifcfg-$nic 2>&1 |grep -i BOOTPROTO`;