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

FOG API

Scheduled Pinned Locked Moved
General
5
19
4.4k
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.
  • M
    maikBat
    last edited by maikBat Nov 8, 2017, 4:28 PM Nov 8, 2017, 10:27 PM

    Hi, I need to know if FOG has an API implemented. I’m trying to build a script that to create “Tasks” for specifics computers. Is there any way to do this in an elegant way with the current version of Fog? If not, there is a way to get the specific table and fields that need be changed/added on the DB for do this.

    i.e: I have a list of MACs. I want to deploy a specific image to these PCs without any user interaction. I know the Image ID Number.

    Thanks so much

    1 Reply Last reply Reply Quote 0
    • G
      george1421 Moderator
      last edited by Nov 8, 2017, 10:41 PM

      Yes there is a restful api that you communicate with json files.

      I can’t seem to find the wiki page at the moment, but here is some examples @Wayne-Workman posted in this thread: https://forums.fogproject.org/topic/9779/can-i-use-some-kind-of-script-to-create-image-and-ghost-my-lab-machines/11

      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!

      1 Reply Last reply Reply Quote 0
      • M
        maikBat
        last edited by Nov 8, 2017, 10:44 PM

        Thank so much for the fast respond. I will check it.

        G 1 Reply Last reply Nov 8, 2017, 10:45 PM Reply Quote 0
        • G
          george1421 Moderator @maikBat
          last edited by Nov 8, 2017, 10:45 PM

          @maikbat Here is another thread: https://forums.fogproject.org/topic/10036/api That official document is hidden really well from me.

          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!

          G 1 Reply Last reply Nov 8, 2017, 10:46 PM Reply Quote 0
          • G
            george1421 Moderator @george1421
            last edited by Nov 8, 2017, 10:46 PM

            @george1421 Ah hidden under news (??) https://news.fogproject.org/simplified-api-documentation/

            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!

            M 1 Reply Last reply Nov 9, 2017, 12:58 PM Reply Quote 1
            • W
              Wayne Workman
              last edited by Wayne Workman Nov 8, 2017, 7:19 PM Nov 9, 2017, 1:18 AM

              @Tom-Elliott could you post a copy of your Insomnia environment export for the FOG API? If you don’t have it anymore I can create one - but was just asking since it’s only like 15 seconds to export and post here. I’m sure others here would like to have it besides me.

              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!
              Daily Clean Installation Results:
              https://fogtesting.fogproject.us/
              FOG Reporting:
              https://fog-external-reporting-results.fogproject.us/

              1 Reply Last reply Reply Quote 0
              • M
                maikBat @george1421
                last edited by Nov 9, 2017, 12:58 PM

                @george1421 I checked the API info, Is amazing to know that this is available. Now I have a couple questions:

                Where I can find the task IDs? Will be great to have the “Task IDs” and other options related with them.

                In summary, this is what I want to try to do:

                • Register a host (name:MAC, MAC:MAC, ImageID:ImageIDNumber)
                • Deploy Image on host
                • Unregister Host

                I pretend do all this using php and json

                Thanks

                W 1 Reply Last reply Nov 10, 2017, 1:13 AM Reply Quote 0
                • W
                  Wayne Workman @maikBat
                  last edited by Nov 10, 2017, 1:13 AM

                  @maikbat this will probably get you going :

                  https://forums.fogproject.org/topic/11059/clearing-specific-kinds-of-task-types-using-sql

                  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!
                  Daily Clean Installation Results:
                  https://fogtesting.fogproject.us/
                  FOG Reporting:
                  https://fog-external-reporting-results.fogproject.us/

                  M 1 Reply Last reply Dec 15, 2017, 10:51 PM Reply Quote 0
                  • M
                    maikBat @Wayne Workman
                    last edited by Dec 15, 2017, 10:51 PM

                    @wayne-workman I got everything setup in my server but when I try to send a post i’m receiving this:

                    <!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”>
                    <html><head>
                    <title>404 Not Found</title>
                    </head><body>
                    <h1>Not Found</h1>
                    <p>The requested URL /fog/host/AABBCC/task was not found on this server.</p>
                    <hr>
                    <address>Apache/2.4.29 (Ubuntu) Server at 192.168.70.3 Port 9000</address>
                    </body></html>

                    I’m using port 9000 because I have other service running on 80. I need to run fog and my app in the same server.
                    The Fog management, PXE and image clone services are working properly and the API is enabled.

                    Fog running Version: 1.4.4

                    Thanks

                    W 1 Reply Last reply Dec 16, 2017, 1:00 AM Reply Quote 0
                    • W
                      Wayne Workman @maikBat
                      last edited by Dec 16, 2017, 1:00 AM

                      @maikbat Read through this entire thread: https://forums.fogproject.org/topic/9779/can-i-use-some-kind-of-script-to-create-image-and-ghost-my-lab-machines/12?page=2

                      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!
                      Daily Clean Installation Results:
                      https://fogtesting.fogproject.us/
                      FOG Reporting:
                      https://fog-external-reporting-results.fogproject.us/

                      M 1 Reply Last reply Dec 28, 2017, 3:53 PM Reply Quote 0
                      • M
                        maikBat @Wayne Workman
                        last edited by Dec 28, 2017, 3:53 PM

                        @wayne-workman Just let you know that everything is working now. The problem was that I was using the “Host’s name” instead “Host’s ID” as parameter.

                        Thanks so much

                        1 Reply Last reply Reply Quote 1
                        • M
                          MarkG
                          last edited by Apr 1, 2019, 3:10 PM

                          I’m struggling somewhat with the format of the API requests

                          I know I can list all snapin associations with (assume I’m sending correct token headers, just for clarity)

                          curl  http://localhost/fog/snapinassociation
                          

                          and this returns

                          { "count": 1, "snapinassociations": [ { "id": "6135", "hostID": "52", "snapinID": "2484" } ]
                          

                          Now, what I want to do is to remove ALL snapins from hostID 52, but I can’t find a way to do this

                          The closest I’ve come is to do the above query, then parse the output and do

                           curl -X DELETE http://localhost/fog/snapinassociation/6135/delete
                          

                          But this feels clunky and I’m sure I’m missing something fundamental. The URIs aren’t quite making sense in my head, because I know I can create a snapin association with

                          curl  -X PUT -d '{"snapins":[2484]}' http://localhost/fog/host/52/edit
                          

                          but I can’t clear them with

                          curl  -X PUT -d '{"snapins":[]}' http://localhost/fog/host/52/edit
                          

                          What am I missing?

                          Tom ElliottT 1 Reply Last reply Apr 1, 2019, 3:20 PM Reply Quote 0
                          • Tom ElliottT
                            Tom Elliott @MarkG
                            last edited by Tom Elliott Apr 1, 2019, 9:21 AM Apr 1, 2019, 3:20 PM

                            @MarkG What do you mean you can’t clear them?

                            After you run the curl -X PUT -d '{"snapins":[]}' http://localhost/fog/host/52/edit
                            What’s the output of:

                            curl -X GET http://localhost/fog/host/52

                            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
                            • M
                              MarkG
                              last edited by Apr 1, 2019, 3:28 PM

                              @Tom-Elliott By “I can’t clear them” I mean that I’d expect sending an empty array would clear all snapin associations from that host, but it doesn’t, as evidenced by me looking in the FOG GUI and seeing the snapin association still there.

                              Here’s your GET command after my PUT with an empty array.

                              { "id": "52", "name": "HPProDesk", "description": "Created by FOG Reg on April 1, 2019, 2:19 pm", "ip": "", "imageID": "85", "building": "0", "createdTime": "2019-04-01 14:19:01", "deployed": "0000-00-00 00:00:00", "createdBy": "fog", "useAD": "", "ADDomain": "", "ADOU": "", "ADUser": "", "ADPass": "", "ADPassLegacy": "", "productKey": "", "printerLevel": "", "kernelArgs": "", "kernel": "", "kernelDevice": "", "init": "", "pending": "", "pub_key": "72c8515c7251f909e54b10ccfa26776a118fba25c333f7f9c3c3021c6d53e8f6", "sec_tok": "c3cd9236c7c2f3ea4d8f90e93b4b910179759f30af2cf47b4a3b3b2b24ea2afc6419d0ede3a0b465f354299c7a027999defd59bd11f93902382f3e827c8a3aa4", "sec_time": "2019-04-01 15:25:55", "pingstatus": "<i class=\"icon-ping-down fa fa-exclamation-circle red\" data-toggle=\"tooltip\" data-placement=\"right\" title=\"Connection timed out\"><\/i>", "biosexit": "grub", "efiexit": "refind_efi", "enforce": "", "primac": "a0:d3:c1:4e:49:45", "imagename": "HPProDesk_Win8_64_Pro_Prepped", "hostscreen": { "id": "", "hostID": "", "width": "", "height": "", "refresh": "", "orientation": "", "other1": "", "other2": "" }, "hostalo": { "id": "", "hostID": "", "time": "" }, "inventory": { "id": "50", "hostID": "52", "primaryUser": "fog", "other1": "", "other2": "", "createdTime": "2019-04-01 14:19:01", "deleteDate": "0000-00-00 00:00:00", "sysman": "Hewlett-Packard", "sysproduct": "HP ProDesk 405 G2 MT", "sysversion": "", "sysserial": "CZC43626MJ", "sysuuid": "8d1f307a-6b12-7ee0-d0c5-d2601e0e7c03", "systype": "Type: Desktop", "biosversion": "02.28", "biosvendor": "AMI", "biosdate": "09\/05\/2018", "mbman": "Hewlett-Packard", "mbproductname": "2240", "mbversion": "1.0", "mbserial": "CZC43626MJ", "mbasset": "CZC43626MJ", "cpuman": "AuthenticAMD", "cpuversion": "AMD A4-6250J APU with AMD Radeon R3 Graphics", "cpucurrent": "Current Speed: 2000 MHz", "cpumax": "Max Speed: 2000 MHz", "mem": "MemTotal: 3440588 kB", "hdmodel": "Hitachi HDS721616PLA380", "hdserial": "PVE331Z9RYDSZU", "hdfirmware": "P22OAB3A", "caseman": "Hewlett-Packard", "casever": "", "caseserial": "CZC43626MJ", "caseasset": "CZC43626MJ", "memory": "3.28 GiB" }, "image": { "imageTypeID": "1", "imagePartitionTypeID": "1", "id": "85", "name": "HPProDesk_Win8_64_Pro_Prepped", "description": "", "path": "HPProDesk_Win8_64_Pro_Prepped", "createdTime": "2018-11-21 09:49:17", "createdBy": "fog", "building": "0", "size": "366997504.000000:19634143232.000000:", "osID": "7", "deployed": "2018-11-21 12:15:29", "format": "0", "magnet": "", "protected": "0", "compress": "6", "isEnabled": "1", "toReplicate": "1", "srvsize": "4096", "os": {}, "imagepartitiontype": {}, "imagetype": {} }, "macs": [ "a0:d3:c1:4e:49:45" ]
                              
                              
                              Tom ElliottT 1 Reply Last reply Apr 1, 2019, 3:42 PM Reply Quote 0
                              • Tom ElliottT
                                Tom Elliott @MarkG
                                last edited by Apr 1, 2019, 3:42 PM

                                @MarkG What version of FOG are you running?

                                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
                                • M
                                  MarkG
                                  last edited by Apr 1, 2019, 3:43 PM

                                  @Tom-Elliott Sorry, should have mentioned that, 1.5.5

                                  Tom ElliottT 1 Reply Last reply Apr 2, 2019, 1:09 AM Reply Quote 0
                                  • Tom ElliottT
                                    Tom Elliott @MarkG
                                    last edited by Apr 2, 2019, 1:09 AM

                                    @MarkG Might I ask you to update to working-1.6 branch?

                                    While I’m sure I could fix 1.5.x, @Sebastian-Roth has been working really well with it and that’s left me some time to focus my efforts towards completing 1.6 a little easier.

                                    I did make some interesting finds for 1.6 and they will likely translate fairly easily to 1.5 as well.

                                    I’m fairly confident that what I adjusted works a bit more proper for the adding/removing items now.

                                    In the past, initially, it was intended that you needed to send the item as you are: "snapins":[] but time and mindset were not my friends.

                                    If you’re not able to update to 1.6, I do understand. I just want to say the interface is 100% different from 1.5.x. Hopefully for the better!

                                    As far as stability goes, the backend is essentially identical to 1.5.x, as my main focus has been on fixing the GUI and making it as usable and functional as possible. With that, some changes have been introduced with regards to the API, and while I try to adjust and make additions into the 1.5.x when I make a 1.6 change to the API, some of the stuff will only work with 1.6.

                                    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
                                    • M
                                      MarkG
                                      last edited by Apr 2, 2019, 8:50 AM

                                      @Tom-Elliott unfortunately this is in a production environment and we can’t currently afford the down time, but I appreciate your efforts and thanks for the reply - at least it has given me confidence that I’m not doing it “wrong”.

                                      As it happens I’m currently automating the entire FOG process by writing entries directly into the database and that is working fine for now, but I was looking at moving to the API as I’m sure it will be better for forwards compatibility - so when time allows I’l update my test server for 1.6 and work with that until we can update the production server.

                                      Thanks for the advice.

                                      1 Reply Last reply Reply Quote 0
                                      • Tom ElliottT
                                        Tom Elliott
                                        last edited by Apr 6, 2019, 1:52 PM

                                        I’ve updated the rout.class.php in 1.5.X branch (dev-branch)

                                        I will ask @MarkG if you would like to install this to see if it address what you need directly?

                                        I know you don’t want to move to the alpha build, but dev-branch is where the bug fixes found since 1.5.5 have been addressed.

                                        If anything, you can simply copy this dev-branches router class with:

                                        wget -O /var/www/fog/lib/router/route.class.php https://raw.githubusercontent.com/FOGProject/fogproject/489ba2952f5750e1483083eedade17dde6bb3cd8/packages/web/lib/router/route.class.php
                                        

                                        This should allow you to clear out items such as snapins with the code you were using:

                                        {
                                            "snapins": [],
                                            "printers": [1,2,3,4]
                                        }
                                        

                                        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
                                        • 1 / 1
                                        • First post
                                          Last post

                                        159

                                        Online

                                        12.0k

                                        Users

                                        17.3k

                                        Topics

                                        155.2k

                                        Posts
                                        Copyright © 2012-2024 FOG Project