From 0e4e5f1c7173b6a15877bc3bd88e43468c87dda5 Mon Sep 17 00:00:00 2001 From: phamt Date: Fri, 9 Dec 2011 19:29:33 +0000 Subject: [PATCH] Enable check for classless networks. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11202 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/zvm.pm | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/zvm.pm b/xCAT-server/lib/xcat/plugins/zvm.pm index defcd0ca3..e670706e8 100644 --- a/xCAT-server/lib/xcat/plugins/zvm.pm +++ b/xCAT-server/lib/xcat/plugins/zvm.pm @@ -16,6 +16,7 @@ use xCAT::MsgUtils; use Sys::Hostname; use xCAT::Table; use xCAT::Utils; +use xCAT::NetworkUtils; use Getopt::Long; use strict; @@ -3219,27 +3220,21 @@ sub nodeSet { return; } } - - # Get first 3 octets of node IP (IPv4) - @words = split( /\./, $hostIP ); - my $octets = "$words[0].$words[1].$words[2]"; - # Class B and A networks - my $octetsB = "$words[0].$words[1].0"; - my $octetsA = "$words[0].0.0"; - # Get networks in 'networks' table my $entries = xCAT::zvmUtils->getAllTabEntries('networks'); # Go through each network - my $network; + my $network = ""; + my $mask; foreach (@$entries) { - # Get network + # Get network and mask $network = $_->{'net'}; - - # If networks contains the first 3 octets of the node IP - if ( $network =~ m/$octets/i || $network =~ m/$octetsB/i || $network =~ m/$octetsA/i) { + $mask = $_->{'mask'}; + + # If the host IP address is in this subnet, return + if (xCAT::NetworkUtils->ishostinsubnet($hostIP, $mask, $network)) { # Exit loop last; @@ -3248,7 +3243,7 @@ sub nodeSet { $network = ""; } } - + # If no network found if ( !$network ) {