FOG Project

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

    FOG API Question

    General
    2
    9
    172
    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.
    • Chris Whiteley
      Chris Whiteley last edited by

      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
      • Chris Whiteley
        Chris Whiteley @Sebastian Roth last edited by

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

        1 Reply Last reply Reply Quote 0
        • S
          Sebastian Roth Moderator last edited by Sebastian Roth

          @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.

          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

          Chris Whiteley 1 Reply Last reply Reply Quote 0
          • Chris Whiteley
            Chris Whiteley @Sebastian Roth last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • Chris Whiteley
              Chris Whiteley @Sebastian Roth last edited by

              @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
              • S
                Sebastian Roth Moderator last edited by Sebastian Roth

                @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.

                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

                Chris Whiteley 2 Replies Last reply Reply Quote 0
                • Chris Whiteley
                  Chris Whiteley @Sebastian Roth last edited by

                  @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
                  • Chris Whiteley
                    Chris Whiteley last edited by

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

                    1 Reply Last reply Reply Quote 0
                    • S
                      Sebastian Roth Moderator last edited by

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

                      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

                      Chris Whiteley 1 Reply Last reply Reply Quote 1
                      • 1 / 1
                      • First post
                        Last post

                      183
                      Online

                      10.2k
                      Users

                      16.3k
                      Topics

                      149.9k
                      Posts

                      Copyright © 2012-2020 FOG Project