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

FOG API Question

Scheduled Pinned Locked Moved
General
2
9
847
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.
  • C
    Chris Whiteley
    last edited by Nov 4, 2020, 7:23 PM

    I was looking at the FOG API and tried to copy examples like the one here: https://raw.githubusercontent.com/FOGProject/fog-community-scripts/master/PowershellModules/Snippets/Fog-Commands.psm1

    I can’t seem to even get a list of users out. I guess I have no idea what I am doing.

    My end goal is to take the fields of the machine that is being imaged of the “other tag #1” and “other tag #2” and output them.

    I hope this is easy to do.

    1 Reply Last reply Reply Quote 0
    • S
      Sebastian Roth Moderator
      last edited by Nov 4, 2020, 7:24 PM

      @Chris-Whiteley Enabled the FOG API both in FOG Configuration as well as user’s settings? Using both API tokens?

      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

      C 1 Reply Last reply Nov 4, 2020, 9:40 PM Reply Quote 1
      • C
        Chris Whiteley
        last edited by Nov 4, 2020, 7:45 PM

        I did not have it set in the FOG Configuration. That was a good start 🙂

        1 Reply Last reply Reply Quote 0
        • C
          Chris Whiteley @Sebastian Roth
          last edited by Nov 4, 2020, 9:40 PM

          @Sebastian-Roth So that helped after I checked the box. Now I need to add another question in the Full Host Registration. I have set it up to ask it and assigned it a variable. How do I get that to show up within FOG?

          I used “price” assigned as “$price”

          price=""
          
          echo -n " * What is the purchase price of this device (1393.01): "
          read price
          price=$(echo $price | base64)
          

          I also added this in the last long line

          &price=$price
          
          1 Reply Last reply Reply Quote 0
          • S
            Sebastian Roth Moderator
            last edited by Sebastian Roth Nov 5, 2020, 6:53 AM Nov 5, 2020, 12:52 PM

            @Chris-Whiteley Do you want to save the price variable into “other tag #1” in the DB? I am not sure I get what you are trying to achieve.

            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

            C 2 Replies Last reply Nov 5, 2020, 2:46 PM Reply Quote 0
            • C
              Chris Whiteley @Sebastian Roth
              last edited by Nov 5, 2020, 2:46 PM

              @Sebastian-Roth I am trying to create a new variable. I don’t care if it shows up in FOG at all as long as it gets stored somewhere for me to be able to recall it via the FOG API.

              1 Reply Last reply Reply Quote 0
              • C
                Chris Whiteley @Sebastian Roth
                last edited by Nov 6, 2020, 3:46 PM

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • S
                  Sebastian Roth Moderator
                  last edited by Sebastian Roth Nov 11, 2020, 12:41 PM Nov 11, 2020, 6:36 PM

                  @Chris-Whiteley Sorry for the long delay! Now that I found some time to think through this I can give you two answers.

                  • Using the “other #1” tag should be simple! When registering a host you enter the price information when asked for the “other #1” and it will be saved to the database. After enabling the FOG API (user settings as well as general FOG settings) you should be able to query that information from any host using the following commands (make sure you have curl and jq installed) to get a long list of all host IDs together with the corresponding “other #1” tag values.
                  curl --silent -H "fog-api-token: xxx" -H "fog-user-token: yyy" -X GET http://x.x.x.x/fog/inventory | jq '.inventorys | .[] | [.id,.other1]'
                  
                  • Now you request on adding another “price” value to the full registration process is a lot more work. You start by adding the question to the fog.man.reg file as posted below. Then edit /var/www/html/fog/lib/reg-task/registration.class.php and add your price element similar to what you see in line 160 for other1/other2 as well as line 288 where the information is pushed to the database. As well edit /var/www/html/fog/lib/fog/inventory.class.php and add your new price field to the class definition just after line 40. Now as a final step you need to add that new column to the database for it to work properly as well!
                  shell> mysql -u root -p
                  Password:
                  ...
                  mysql> use fog;
                  ...
                  mysql> ALTER TABLE `inventory` ADD COLUMN `iPrice` VARCHAR(50) NOT NULL AFTER `iOtherTag1`;
                  ...
                  mysql> quit
                  

                  IMHO it’s way easier to chose the first route if you don’t use the other #1 or #2 tags yet! Why add the price field and risk causing issues on a later FOG updates when you can use what is officially part of FOG already.

                  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

                  C 1 Reply Last reply Nov 13, 2020, 3:23 PM Reply Quote 0
                  • C
                    Chris Whiteley @Sebastian Roth
                    last edited by Nov 13, 2020, 3:23 PM

                    @sebastian-roth Thank you! I am going to give this a shot.

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

                    169

                    Online

                    12.0k

                    Users

                    17.3k

                    Topics

                    155.2k

                    Posts
                    Copyright © 2012-2024 FOG Project