• 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

  • 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]

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

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

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

  • @MarkG What version of FOG are you running?

  • @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" ]

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

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

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

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

    <title>404 Not Found</title>
    <h1>Not Found</h1>
    <p>The requested URL /fog/host/AABBCC/task was not found on this server.</p>
    <address>Apache/2.4.29 (Ubuntu) Server at Port 9000</address>

    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


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


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

  • Moderator

  • Moderator

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

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

  • Moderator

    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