From d086433fbae74dc9ed65970dcb59809708bfcaf9 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Fri, 10 Jul 2009 18:55:58 +0000 Subject: [PATCH] -Ensure datastore name stays at no more than 42 characters, while preserving as much detail as possible git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3757 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/esx.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/esx.pm b/xCAT-server/lib/xcat/plugins/esx.pm index 8ddc1c34c..04337724d 100644 --- a/xCAT-server/lib/xcat/plugins/esx.pm +++ b/xCAT-server/lib/xcat/plugins/esx.pm @@ -1508,6 +1508,22 @@ sub mount_nfs_datastore { ($server,$path) = split /\//,$location,2; $location =~ s/\//_/g; $location= 'nfs_'.$location; + #VMware has a 42 character limit, we will start mangling to get under 42. + #Will try to preserve as much informative detail as possible, hence several conditionals instead of taking the easy way out + if (length($location) > 42) { + $location =~ s/nfs_//; #Ditch unique names for different protocols to the same path, seems unbelievably unlikely + } + if (length($location) > 42) { + $location =~ s/\.//g; #Next, ditch host delimiter, it is unlikely that hosts will have unique names if their dots are removed + } + if (length($location) > 42) { + $location =~ s/_//g; #Next, ditch path delimiter, it is unlikely that two paths will happen to look the same without delimiters + } + if (length($location) > 42) { #finally, replace the middle with ellipsis + substr($location,20,-20,'..'); + } + + my $nds = HostNasVolumeSpec->new(accessMode=>'readWrite', remoteHost=>$server, localPath=>$location,