From 9422219be9e4c65b477d979c8dadf18c5ce19a5b Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 29 Mar 2010 13:19:13 +0000 Subject: [PATCH] add isStateful routine git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5595 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Utils.pm | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index d23480455..e0f47c756 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -5571,7 +5571,53 @@ sub fsp_api_action { } +#------------------------------------------------------------------------------- +=head3 isStateful + returns 1 if localHost is a Stateful install + Arguments: + none + Returns: + 1 - localHost is Stateful + 0 - localHost is not Stateful + Globals: + none + Error: + none + Example: + if (xCAT::Utils->isStateful()) { } + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub isStateful +{ + # check to see if / is a real directory + my $dir = "\/"; + my $cmd = "df -P $dir "; + my @output = xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) + { # error + xCAT::MsgUtils->message("", " Could not determine Stateful\n"); + return 0; + } + foreach my $line (@output) + { + my ($file_sys, $blocks, $used, $avail, $cap, $mount_point) = + split(' ', $line); + $mount_point=~ s/\s*//g; # remove blanks + if ($mount_point eq $dir) { + if ( -e ($file_sys)) + { + return 1; + } else { + return 0; + } + } + } + return 0; +}