diff --git a/xCAT-server-2.0/lib/xcat/plugins/iscsi.pm b/xCAT-server-2.0/lib/xcat/plugins/iscsi.pm index 8fa76de0a..b1bfbefb7 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/iscsi.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/iscsi.pm @@ -2,6 +2,7 @@ package xCAT_plugin::iscsi; use xCAT::Table; use Socket; use File::Path; +use File::Basename; use Getopt::Long; Getopt::Long::Configure("bundling"); Getopt::Long::Configure("pass_through"); @@ -79,20 +80,30 @@ sub process_request { my $iscsient = $iscsitab->getNodeAttribs($node,['file']); if ($iscsient and $iscsient->{file}) { $fileloc = $iscsient->{file}; + unless ($fileloc =~ /^\//) { + unless ($iscsiprefix) { + $rsp{error}=["$node: Unable to identify file to back iSCSI LUN, no iscsidir in site table and iscsi.file entry for node is a relative path"]; + $rsp{errorcode}=[1]; + $callback->({node=>[\%rsp]}); + %rsp=(name=>[$node]); + next; + } + $fileloc.=$iscsient->{file}; + } } else { unless ($iscsiprefix) { - $rsp{error}=["$node: Unable to identify file to back iSCSI LUN, no iscsidir in site table nor iscsi.file entry for node"]; + $rsp{error}=["$node: Unable to identify file to back iSCSI LUN, no iscsidir in site table nor iscsi.file entry for node (define at least either)"]; $rsp{errorcode}=[1]; $callback->({node=>[\%rsp]}); %rsp=(name=>[$node]); next; } - unless (-d $iscsiprefix) { - mkpath $iscsiprefix; - } $fileloc = "$iscsiprefix/$node"; $iscsitab->setNodeAttribs($node,{file=>$fileloc}); } + unless (-d dirname($fileloc)) { + mkpath dirname($fileloc); + } unless (-f $fileloc) { $rsp{name}=[$node]; $rsp{data}=["Creating $fileloc ($lunsize MB)"];