• Hi, I’m having problems figuring out why won’t FOG’s hosts list get populated if I try to add one using the API.
    My PHP code:

    <?php
    $url = 'http://192.250.0.2/fog/host/create';
    
    $ch = curl_init($url);
    $data = array (
            'name' => 'test',
            'description' => 'test',
            'macs' => '["12:5D:50:F7:6B:B4"]',
            'imageID' => '1',
            'imagename' => 'Windows 11'
    );
    $payload = json_encode($data);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('fog-user-token:dontsteal,'fog-api-token:ourhardwork,'Content-Type:application/json'));
    $result = curl_exec($ch);
    curl_close($ch);
    echo $result;
    echo $payload;
    ?>
    

    The JSON should be (in theory) properly formatted:

    {"name":"test,"description":"test","macs":"[\"12:5D:50:F7:6B:B4\"]","imageID":"1","imagename":"Windows 11"}
    

    I get a “1” as response from the server.
    I referenced this solved forum post for the JSON data.
    If I try to list my hosts either through the web ui or through the API I can see that my attempts got somewhere, since the “ID” incremented, but my hosts won’t show up, only the ones that were added through the web ui / pxe menu.

    curl -H 'fog-user-token: dontsteal' -H 'fog-api-token: ourhardwork' -X GET localhost/fog/host
    { "count": 2, "hosts": [ { "id": "1", "name": "template-win11", "description": "Created by FOG Reg on October 25, 2021, 5:36 pm", "ip": "", "imageID": "1", "building": "0", "createdTime": "2021-10-25 17:36:39", "deployed": "0000-00-00 00:00:00", "createdBy": "fog", "useAD": "", "ADDomain": "", "ADOU": "", "ADUser": "", "ADPass": "", "ADPassLegacy": "", "productKey": "", "printerLevel": "", "kernelArgs": "", "kernel": "", "kernelDevice": "", "init": "", "pending": "", "pub_key": "", "sec_tok": "ac690437b59635eb7f8c58218ea9682aa27c6325798c4d124db6cc972697c30b9fbd14110464ef605a947c99e985f8bfc396648af70a19a7a4c1825fc561f8e3", "sec_time": "2021-10-27 01:46:27", "pingstatus": "<i class=\"icon-ping-down fa fa-exclamation-circle red\" data-toggle=\"tooltip\" data-placement=\"right\" title=\"Unknown\"><\/i>", "biosexit": "", "efiexit": "", "enforce": "", "primac": "62:75:e6:d6:ba:24", "imagename": "Windows 11", "hostscreen": { "id": null, "hostID": null, "width": null, "height": null, "refresh": null, "orientation": null, "other1": null, "other2": null }, "hostalo": { "id": null, "hostID": null, "time": null }, "inventory": { "id": "1", "hostID": "1", "primaryUser": "", "other1": "", "other2": "", "createdTime": "2021-10-25 17:36:50", "deleteDate": "0000-00-00 00:00:00", "sysman": "QEMU", "sysproduct": "Standard PC (Q35 + ICH9, 2009)", "sysversion": "pc-q35-6.0", "sysserial": "Not Specified", "sysuuid": "e1495a03-cf19-49a3-8dba-d470f50b6584", "systype": "Type: Other", "biosversion": "0.0.0", "biosvendor": "EFI Development Kit II \/ OVMF", "biosdate": "02\/06\/2015", "mbman": "", "mbproductname": "", "mbversion": "", "mbserial": "", "mbasset": "", "cpuman": "QEMU", "cpuversion": "pc-q35-6.0", "cpucurrent": "Current Speed: 2000 MHz", "cpumax": "Max Speed: 2000 MHz", "mem": "MemTotal: 3988088 kB", "hdmodel": "", "hdserial": "", "hdfirmware": "", "caseman": "QEMU", "casever": "pc-q35-6.0", "caseserial": "Not Specified", "caseasset": "Not Specified", "memory": "3.80 GiB" }, "image": { "imageTypeID": "1", "imagePartitionTypeID": "1", "id": "1", "name": "Windows 11", "description": "Windows 11 x64 English master image", "path": "Windows11", "createdTime": "2021-10-24 19:12:49", "createdBy": "fog", "building": "0", "size": "409600.000000:209715200.000000:2759020.000000:11300945920.000000:", "osID": "4", "deployed": "2021-10-25 17:41:21", "format": "5", "magnet": "", "protected": "0", "compress": "6", "isEnabled": "1", "toReplicate": "1", "srvsize": "4859406094", "os": {}, "imagepartitiontype": {}, "imagetype": {} }, "pingstatuscode": 6, "pingstatustext": "No such device or address", "macs": [ "62:75:e6:d6:ba:24" ] }, { "id": "5", "name": "test", "description": "", "ip": "", "imageID": "1", "building": "0", "createdTime": "2021-11-10 01:47:40", "deployed": "0000-00-00 00:00:00", "createdBy": "fog", "useAD": "0", "ADDomain": "", "ADOU": "", "ADUser": "", "ADPass": "", "ADPassLegacy": "", "productKey": "", "printerLevel": "", "kernelArgs": "", "kernel": "", "kernelDevice": "", "init": "", "pending": "", "pub_key": "", "sec_tok": "", "sec_time": "0000-00-00 00:00:00", "pingstatus": "<i class=\"icon-ping-down fa fa-exclamation-circle red\" data-toggle=\"tooltip\" data-placement=\"right\" title=\"Unknown\"><\/i>", "biosexit": "", "efiexit": "", "enforce": "1", "primac": "00:00:00:00:00:00", "imagename": "Windows 11", "hostscreen": { "id": null, "hostID": null, "width": null, "height": null, "refresh": null, "orientation": null, "other1": null, "other2": null }, "hostalo": { "id": null, "hostID": null, "time": null }, "inventory": { "id": null, "hostID": null, "primaryUser": null, "other1": null, "other2": null, "createdTime": null, "deleteDate": null, "sysman": null, "sysproduct": null, "sysversion": null, "sysserial": null, "sysuuid": null, "systype": null, "biosversion": null, "biosvendor": null, "biosdate": null, "mbman": null, "mbproductname": null, "mbversion": null, "mbserial": null, "mbasset": null, "cpuman": null, "cpuversion": null, "cpucurrent": null, "cpumax": null, "mem": null, "hdmodel": null, "hdserial": null, "hdfirmware": null, "caseman": null, "casever": null, "caseserial": null, "caseasset": null, "memory": "0.00 iB" }, "image": { "imageTypeID": "1", "imagePartitionTypeID": "1", "id": "1", "name": "Windows 11", "description": "Windows 11 x64 English master image", "path": "Windows11", "createdTime": "2021-10-24 19:12:49", "createdBy": "fog", "building": "0", "size": "409600.000000:209715200.000000:2759020.000000:11300945920.000000:", "osID": "4", "deployed": "2021-10-25 17:41:21", "format": "5", "magnet": "", "protected": "0", "compress": "6", "isEnabled": "1", "toReplicate": "1", "srvsize": "4859406094", "os": {}, "imagepartitiontype": {}, "imagetype": {} }, "pingstatuscode": 6, "pingstatustext": "No such device or address", "macs": [ "00:00:00:00:00:00" ] } ]
    

    Any help would be greatly appreciated! 🙂


  • Sorry, I only noticed after posting that I accidentally removed a single ’ character when I edited my tokens for the post.

288
Online

9.0k
Users

15.6k
Topics

145.1k
Posts