• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Allow configuration for separate Imaging server and NFS server

    Scheduled Pinned Locked Moved
    Feature Request
    4
    14
    4.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rayhaque
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • N
        need2 Moderator
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • R
          rayhaque
          last edited by

          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:

          1. When you upload an image to FOG, it writes out the file to /imagestoredir/dev with a filename of the hosts MAC address.
          2. 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).
          3. 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? 🙂

          1 Reply Last reply Reply Quote 0
          • Tom ElliottT
            Tom Elliott
            last edited by

            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.

            Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

            Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

            Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

            1 Reply Last reply Reply Quote 0
            • R
              rayhaque
              last edited by

              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?

              1 Reply Last reply Reply Quote 0
              • R
                rayhaque
                last edited by

                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.

                1. An upload task is started, using the DefaultMember StorageNode, which is my SAN, 10.205.205.20 and a path of /imaging_filesystem.
                2. Client connects directly to the SAN, using the magic of NFS and copies the data at high speeds.
                3. The image upload works fine, and finishes.
                4. 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]

                1 Reply Last reply Reply Quote 0
                • Tom ElliottT
                  Tom Elliott
                  last edited by

                  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.

                  Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                  Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                  Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                  1 Reply Last reply Reply Quote 0
                  • R
                    rayhaque
                    last edited by

                    [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?

                    1 Reply Last reply Reply Quote 0
                    • R
                      rayhaque
                      last edited by

                      Incidentally, if I just bang the IP address in there, it works fine! 🙂

                      Like so …
                      [CODE]$ftp->set(‘host’,‘10.10.5.10’)[/CODE]

                      1 Reply Last reply Reply Quote 0
                      • Tom ElliottT
                        Tom Elliott
                        last edited by

                        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

                        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                        1 Reply Last reply Reply Quote 0
                        • Tom ElliottT
                          Tom Elliott
                          last edited by

                          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]

                          Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                          Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                          Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                          1 Reply Last reply Reply Quote 0
                          • R
                            rayhaque
                            last edited by

                            Thanks Tom,

                            I know that I didn’t try that syntax. I will try to make some time tomorrow and test this code snippet.

                            1 Reply Last reply Reply Quote 0
                            • I
                              ianabc Testers
                              last edited by

                              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.

                              1 Reply Last reply Reply Quote 0
                              • R
                                rayhaque
                                last edited by

                                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]

                                1 Reply Last reply Reply Quote 0
                                • 1 / 1
                                • First post
                                  Last post

                                194

                                Online

                                12.0k

                                Users

                                17.3k

                                Topics

                                155.2k

                                Posts
                                Copyright © 2012-2024 FOG Project