Author: bsallen
Date: 2016-06-19 22:30:44 -0700 (Sun, 19 Jun 2016)
New Revision: 1995
Modified:
trunk/provision/cgi-bin/
vnfs.pl
trunk/provision/etc/
warewulf-httpd.conf.in
Log:
Revamp to redirect to a statically served vnfs once cached. Cleanup headers
Modified: trunk/provision/cgi-bin/
vnfs.pl
===================================================================
--- trunk/provision/cgi-bin/
vnfs.pl 2016-06-20 01:03:02 UTC (rev 1994)
+++ trunk/provision/cgi-bin/
vnfs.pl 2016-06-20 05:30:44 UTC (rev 1995)
@@ -74,17 +74,10 @@
my $cache_in_progress;
#&nprint("Sending VNFS '$vnfs_name' to node '$node_name'\n");
- $q->print("Content-Type: application/octet-stream; name=\"vnfs.img\"\r\n");
- if (my $size = $obj->size()) {
- $q->print("Content-length: $size\r\n");
- }
- $q->print("Content-Disposition: attachment; filename=\"vnfs.img\"\r\n");
- $q->print("\r\n");
if (! $vnfs_nocache) {
if (-f "$vnfs_cachedir/$vnfs_name/image.$vnfs_checksum") {
&dprint("Found VNFS cache\n");
- # Perhaps do a better job checking here... one day.
$use_cache = 1;
} else {
&dprint("Building VNFS cache\n");
@@ -132,62 +125,44 @@
if ($use_cache) {
&dprint("Sending cached VNFS\n");
- my $cache_fh;
- if (open($cache_fh, "$vnfs_cachedir/$vnfs_name/image.$vnfs_checksum")) {
- my $buffer;
- while($buffer = <$cache_fh>) {
- $q->print($buffer);
- }
- close($cache_fh);
- } else {
- &eprint("Can't open VNFS cache!\n");
- $q->print("Content-Type: application/octet-stream\r\n");
- $q->print("Status: 500\r\n");
- $q->print("\r\n");
- }
+ print $q->redirect("/WW/vnfs_cache/$vnfs_name/image.$vnfs_checksum");
} elsif(! $cache_in_progress) {
&dprint("Sending VNFS from the data store\n");
+ $q->header(-type=>'application/octet-stream',
+ -status=>'200',
+ -attachment=>'vnfs.img');
+ if (my $size = $obj->size()) {
+ $q->header(-Content_length=>$size);
+ }
my $binstore = $db->binstore($obj->get("_id"));
while(my $buffer = $binstore->get_chunk()) {
$q->print($buffer);
}
} else {
&eprint("VNFS is being cached via a different request, try again.\n");
- $q->print("Content-Type: application/octet-stream\r\n");
- $q->print("Status: 503\r\n");
- $q->print("\r\n");
+ $q->header( -status => '503 Service Unavailable' );
}
} else {
&eprint("VNFS request for an unknown VNFS (VNFSID: $vnfsid)\n");
- $q->print("Content-Type: application/octet-stream\r\n");
- $q->print("Status: 404\r\n");
- $q->print("\r\n");
+ $q->header( -status => '404 Not Found' );
}
} else {
&eprint("$node_name has no VNFS set\n");
- $q->print("Content-Type: application/octet-stream\r\n");
- $q->print("Status: 404\r\n");
- $q->print("\r\n");
+ $q->header( -status => '404 Not Found' );
}
} else {
&eprint("VNFS request for an unknown node (HWADDR: $hwaddr)\n");
- $q->print("Content-Type: application/octet-stream\r\n");
- $q->print("Status: 404\r\n");
- $q->print("\r\n");
+ $q->header( -status => '404 Not Found' );
}
} else {
&eprint("VNFS request for a bad hwaddr\n");
- $q->print("Content-Type: application/octet-stream\r\n");
- $q->print("Status: 404\r\n");
- $q->print("\r\n");
+ $q->header( -status => '404 Not Found' );
}
} else {
&eprint("VNFS request without a hwaddr\n");
- $q->print("Content-Type: application/octet-stream\r\n");
- $q->print("Status: 404\r\n");
- $q->print("\r\n");
+ $q->header( -status => '404 Not Found' );
}
# vim: filetype=perl:syntax=perl:expandtab:ts=4:sw=4:
Modified: trunk/provision/etc/
warewulf-httpd.conf.in
===================================================================
--- trunk/provision/etc/
warewulf-httpd.conf.in 2016-06-20 01:03:02 UTC (rev 1994)
+++ trunk/provision/etc/
warewulf-httpd.conf.in 2016-06-20 05:30:44 UTC (rev 1995)
@@ -8,7 +8,8 @@
# This is disabled as RHEL6 perl_mod seems to be missing this support
#PerlPreConnectionHandler Apache2::Reload
-Alias /WW/static /usr/share/warewulf/www
+Alias /WW/static @fulldatadir@/warewulf/www
+Alias /WW/vnfs_cache /var/tmp/warewulf_cache
ScriptAlias /WW/file @fulllibexecdir@/warewulf/cgi-bin/
file.pl
ScriptAlias /WW/script @fulllibexecdir@/warewulf/cgi-bin/
script.pl
@@ -30,6 +31,16 @@
AllowOverride None
Order allow,deny
Allow from all
+ <IfVersion >= 2.4>
+ Require all granted
+ </IfVersion>
</Directory>
-
+<Directory /var/tmp/warewulf_cache>
+ AllowOverride None
+ Order allow,deny
+ Allow from all
+ <IfVersion >= 2.4>
+ Require all granted
+ </IfVersion>
+</Directory>