Allow configuration for separate Imaging server and NFS server
-
As of now, if you store your images on an NFS (network attached storage, SAN, etc) source other than your primary imaging server, you get errors when creating images and deleting them.
I have hacked together some changes in the PHP scripts which have resolved this for my particular installation. But this could be included in the interface as a choice (Separate NAS? Y/N) which could then be used as an if/then in the affected PHP scripts.
Here is my changed code, which works nicely. So hey - half the work is done already!
[B]/var/www/fog/service/Post_Stage2.php[/B]
[CODE]
â /var/www/fog/service/Post_Stage2.php 2014-03-31 12:06:08.858336572 -0400
+++ /var/www/fog/service/Post_Stage2.php.bak 2014-03-31 11:38:44.394410423 -0400
@@ -86,21 +86,20 @@
$ftp_loginres = ftp_login($ftp, getSetting($conn, âFOG_TFTP_FTP_USERNAMEâ), getSetting($conn, âFOG_TFTP_FTP_PASSWORDâ) );
if ((!$ftp) || (!$ftp_loginres ))
{-
echo _("FTP connection to TFTP Server has failed! - in stage 1");
-
echo _("FTP connection to TFTP Server has failed!"); exit; } $mac = str_replace( ":", "-", $mac ); @ftp_delete ( $ftp, getSetting($conn, "FOG_TFTP_PXE_CONFIG_DIR") . "01-". $mac );
-
// @ftp_close($ftp);
-
@ftp_close($ftp);
-
//$ftp = ftp_connect( $nodeip );
-
//$ftp_loginres = ftp_login($ftp, $nodeuser, $nodepass);
-/* if ((!$ftp) || (!$ftp_loginres ))
-
$ftp = ftp_connect( $nodeip );
-
$ftp_loginres = ftp_login($ftp, $nodeuser, $nodepass);
-
if ((!$ftp) || (!$ftp_loginres )) {
-
echo _("FTP connection to Storage Server has failed! in stage 2");
-
echo _("FTP connection to Storage Server has failed!"); exit; }
-*/
$mac = str_replace( â-â, â:â, $mac );
[/CODE][B]/var/www/fog/commons/functions.include.php[/B]
[CODE]
â /var/www/fog/commons/functions.include.php 2014-04-07 10:01:51.839510566 -0400
+++ /var/www/fog/commons/functions.include.orig.php 2014-04-07 10:07:18.135495912 -0400
@@ -1160,8 +1160,7 @@
$path = $ar[ângmRootPathâ] . $ar[âimagePathâ];
$user = $ar[ângmUserâ];
$pass = $ar[ângmPassâ];
-// $server = $ar[ângmHostnameâ];-
$server = getSetting($conn, "FOG_TFTP_HOST");
-
$server = $ar["ngmHostname"]; if ( $path != null && $user != null && $pass != null && $server != null ) {
@@ -1202,8 +1201,7 @@
$path = $ar[ângmRootPathâ] . $ar[âimagePathâ];
$user = $ar[ângmUserâ];
$pass = $ar[ângmPassâ];-
// $server = $ar["ngmHostname"];
-
$server = getSetting($conn, "FOG_TFTP_HOST");
-
$server = $ar["ngmHostname"]; if ( $path != null && $user != null && $pass != null && $server != null ) {
[/CODE]
I am reluctant to attach these files as patches, because I donât know what I am doing. Best you folks that know what you are doing put this code to good use ⊠or copy and paste the above into files and apply them to a clean build of 0.32.
-
-
Iâll admit, FOG not playing well with my NAS boxes actually did me a favor. I started digging deep enough in the boxes to find out that their linux kernel that lived on the board was insecure, and there was no good way to go about patching it, let alone ever get it to support the security features that I required. I ended up wiping the drives and giving them away. Had I not attempted to attach them to FOG, I may have never realized how insecure they were.
-
I just upgraded from 0.32 to 0.1.0 and then today to 1.1.1. I am [B]deeply saddened[/B] that this problem has not yet been resolved. Further, the code has been rewritten in such a way that I am now back to square one in getting things to work.
Just to reiterate the issue:
- When you upload an image to FOG, it writes out the file to /imagestoredir/dev with a filename of the hosts MAC address.
- Once the task completes, it should rename the directory containing the new image files, and then move that directory up one level to the parent directory (/imagestoredir).
- This [B]FAILS[/B] when you are not storing your images in the same place that the FOG server is running.
The reason that it failed before is that FOG was âhanging upâ with the place that it had just stored the file to (in my case, the SAN) and then connects to the host server and tries to rename the file from there using FTP. I assume itâs doing that same thing again, but in a new way that involves changing a few more PHP files.
Can someone please consider rewriting this to make it a feature? It takes a lot for a guy like me to figure this out and attempt to write patches. It would probably be an easy fix for the developer group. All you would need to do is throw out a Boolean that asks if your image store is âsomewhere elseâ, and then add a field to specify the IP/hostname of that location. And when you get to that point where you would drop the connection, and connect back to the host - simply do not disconnect! Continue with your host connected and rename the dang file!
Please?
-
The reason youâre seeing a âdouble connect/disconnectâ in 0.32 was to connect to the âtftpâ server using ftp means to delete/remove the 01-XX-XX-XX-XX-XX-XX files. This was in the Post_Stage3.php file.
Your modâs where to basically use the same connection as the server initiated to rename move the files.
This same method is still employed, but it only works on the transfer of the image now. This is simply because the we donât need to delete/remove the 01-XX-XX-XX-XX-XX-XX files.
We are using a class based ftp function to do ftp now, but essentially the difference you need is about the root share of the folder. This is only affecting the NAS boxes you have.
Basically the NFS works properly as itâs understanding of the
/volume1/images share.FTP is failing on these boxes because it removes the /volume1/images part. When you connect it makes the ârootâ as /images.
So your FTP arenât working properly. This isnât something I can fix. While adding a âcheckboxâ for Synalogy/NAS setup would help you out, I imagine thereâs actually a simpler configuration setting that can be performed on the NAS Boxes.
-
Hello Tom, thank you for the feedback! Perhaps this will be easier to fix than I thought.
[quote=âTom Elliott, post: 30434, member: 7271â]We are using a class based ftp function to do ftp now, but essentially the difference you need is about the root share of the folder. This is only affecting the NAS boxes you have.
Basically the NFS works properly as itâs understanding of the
/volume1/images share.
[/quote]In my case, I have an /images directory on my FOG server which is actually an NFS mount.
[CODE]root@KCHIMAGE2:/# mount | grep nfs
10.205.205.20:/imaging_filesystem on /images type nfs (rw,rsize=8192,wsize=8192,timeo=14,intr,addr=10.205.205.20)
nfsd on /proc/fs/nfsd type nfsd (rw)
[/CODE]For my DefaultMember storage node, the path is /imaging_filesystem. And the IP address is 10.205.205.20.
[quote=âTom Elliott, post: 30434, member: 7271â]
FTP is failing on these boxes because it removes the /volume1/images part. When you connect it makes the ârootâ as /images.So your FTP arenât working properly. This isnât something I can fix. While adding a âcheckboxâ for Synalogy/NAS setup would help you out, I imagine thereâs actually a simpler configuration setting that can be performed on the NAS Boxes.[/quote]
Are you saying that the client is writing the file out to /imaging_filesystem/dev/filename okay - but then trying to rename it (using FTP) as if it exists in /imaging_filesystem/images/dev/filename? In other words, are you suggesting that this is a mount point issue?
-
I think I may be doing a lousy job of explaining the problem at hand. Or I was confused about what the problem was. Either way, here is a shorter explanation of what is happening.
- An upload task is started, using the DefaultMember StorageNode, which is my SAN, 10.205.205.20 and a path of /imaging_filesystem.
- Client connects directly to the SAN, using the magic of NFS and copies the data at high speeds.
- The image upload works fine, and finishes.
- Client attempts to make an FTP connection[B] to the SAN[/B] to rename the file. My SAN is not running FTP, nor does it need to!
Prior to the upgrade, I had made this possible by altering the code to make FOG look to itself instead of the SAN when it got to the FTP elements. On my FOG server, I have an NFS mount to 10.205.205.20 named /imaging_filesystem - which I have symbolically linked to /images. So if it can manage to FTP back to itself, we are in good shape. Because it can reach out to /imaging_filesystem/dev/* or /images/dev/* (doesnât matter, they are one in the same).
I think I may have found the code that I need to alter, and I am testing it now. Likely, my upload will not complete until I have left for the day, but I will report my progress later for anyone who cares.
My code change is to /var/www/fog/service/Post_Stage2.php, lines 53 and 54:
[CODE] //Attempt transfer of image file to Storage Node
$ftp->set(âhostâ,$StorageNode->get(âipâ))[/CODE]
Becomes âŠ
[CODE] //Attempt transfer of image file to Storage Node
$ftp->set(âhostâ,$this->FOGCore->getIPAddress())[/CODE] -
Your situation is quite different, but this should fix it for you.
Hopefully I helped, but this isnât the ânormalâ operational mode of things expected and is fairly on a âhigherâ technical scale than I could have appropriately guessed somebody would try to do. I appreciate the feedback as well and hope the best with this. It should work perfectly fine now that I understand exactly what youâre trying to do.
I have a similar setup, but rather than a pure NFS connection to the storage server, Iâm using Glusterfs to mount as itâs own point, and using the actual FOG Server to be the Node AND the NFS share.
-
[quote=âTom Elliott, post: 30566, member: 7271â]Your situation is quite different, but this should fix it for you.[/quote]
I think I am close! But I get this error âŠ
[CODE][Tue Jun 17 14:56:49 2014] [error] [client 10.10.5.16] PHP Fatal error: Using $this when not in object context in /var/www/fog/service/Post_Stage2.php on line 54[/CODE]I am not sure how I can refer to FOGCore in that context? I am not a very good programmer. Any ideas?
-
Incidentally, if I just bang the IP address in there, it works fine!
Like so âŠ
[CODE]$ftp->set(âhostâ,â10.10.5.10â)[/CODE] -
This InContext usually refers to a class file where the post_stage III and stage two files or any of the service files for that matter are not class files if you take your get IP address function and just called dollar fog core youâll be good to go
-
Sorry about my last post, I was on google translate so it probably made no sense.
The problem is this right here:
[CODE] //Attempt transfer of image file to Storage Node
$ftp->set(âhostâ,$this->FOGCore->getIPAddress())[/CODE]
It should read as:
[code] //Attempt transfer of image file to Storage Node
$ftp->set(âhostâ,$FOGCore->getIPAddress())[/code] -
Thanks Tom,
I know that I didnât try that syntax. I will try to make some time tomorrow and test this code snippet.
-
If this works, is there a systematic way to have this be an option in the UI? It would be a really nice feature for me and a couple of other people. In general we have NFS storage nearby that I would like to use but which I canât turn into a full fledged fog storage node.
-
I am upgrading from 1.1.1 to 1.2.0 and I can see that I will have this same problem again. Again, you would need to do this in the case that your NFS server (the FOG server) is not the same as where your files are (on a NAS or SAN). I wrote up this patch file. You would want to change 10.205.205.20 to the IP address of your SAN/NAS and you would want to change [FONT=Consolas]10.10.5.10 to the IP address of your FOG server.[/FONT]
[CODE]â packages/web/service/Post_Stage2.php.orig 2015-02-20 08:59:27.731899437 -0500
+++ packages/web/service/Post_Stage2.php 2015-02-20 08:59:51.191898383 -0500
@@ -52,7 +52,7 @@
// Where is it going?
$dest = $StorageNode->get(âpathâ).â/â.$_REQUEST[âtoâ];
//Attempt transfer of image file to Storage Node-
$ftp->set('host',$StorageNode->get('ip'))
-
$ftp->set('host','10.10.5.10') ->set('username',$StorageNode->get('user')) ->set('password',$StorageNode->get('pass')); if (!$ftp->connect())
â packages/web/lib/fog/ImageReplicator.class.php.orig 2015-02-20 09:02:09.363892178 -0500
+++ packages/web/lib/fog/ImageReplicator.class.php 2015-02-20 09:03:14.135889269 -0500
@@ -16,7 +16,7 @@
}
private function commonOutput()
{-
$StorageNode = current($this->FOGCore->getClass('StorageNodeManager')->find(array('isMaster' => 1,'isEnabled' => 1, 'ip' => $this->FOGCore->getIPAddress())));
-
$StorageNode = current($this->FOGCore->getClass('StorageNodeManager')->find(array('isMaster' => 1,'isEnabled' => 1, 'ip' => '10.205.205.20'))); try { if ($StorageNode)
â packages/web/lib/fog/MulticastManager.class.php.orig 2015-02-20 09:04:44.975885190 -0500
+++ packages/web/lib/fog/MulticastManager.class.php 2015-02-20 09:05:23.587883456 -0500
@@ -78,7 +78,7 @@
{
try
{-
$StorageNode = current($this->FOGCore->getClass('StorageNodeManager')->find(array('isMaster' => 1,'isEnabled' => 1,'ip' => $this->FOGCore->getIPAddress())));
-
$StorageNode = current($this->FOGCore->getClass('StorageNodeManager')->find(array('isMaster' => 1,'isEnabled' => 1, 'ip' => '10.205.205.20'))); if (!$StorageNode || !$StorageNode->isValid()) throw new Exception(sprintf(" | StorageNode Not found on this system.")); $myroot = $StorageNode->get('path');
â packages/web/lib/fog/Image.class.php.orig 2015-02-20 09:06:19.163880960 -0500
+++ packages/web/lib/fog/Image.class.php 2015-02-20 09:07:02.043879034 -0500
@@ -159,7 +159,7 @@
$SNME = ($SN && $SN->get(âisEnabledâ) == â1â ? true : false);
if ($SNME)
{-
$ftphost = $SN->get('ip');
-
$ftphost = '10.10.5.10'; $ftpuser = $SN->get('user'); $ftppass = $SN->get('pass'); $ftproot = rtrim($SN->get('path'),'/').'/'.$this->get('path');
â packages/web/lib/fog/FOGFTP.class.php.orig 2015-02-20 09:07:59.171876468 -0500
+++ packages/web/lib/fog/FOGFTP.class.php 2015-02-20 09:08:28.223875164 -0500
@@ -28,7 +28,7 @@
if (($this->link && $this->lastConnectionHash == $connectionHash) || !$this->get(âhostâ) || !$this->get(âusernameâ) || !$this->get(âpasswordâ) || !$this->get(âportâ))
return $this;
// Connect-
$this->link = @ftp_connect($this->get('host'), $this->get('port'), $this->get('timeout'));
-
$this->link = @ftp_connect(('10.10.5.10'), $this->get('port'), $this->get('timeout')); if (!$this->link) { $error = error_get_last();
[/CODE]
Apply it like this âŠ
Save the above file to fog_1.2.0.patch, and then:
[CODE]
tar xzf fog_1.2.0.tar.gz
cp ~/fog_1.2.0.patch fog_1.2.0
cd fog_1.2.0
patch -p0 < fog_1.2.0.patch
[/CODE] -