FOG 1.5.4 API host module settings

  • Hi,

    when i create a new host via the api i figured out that the host module settings of this new host are all not enabled.


    All of these modules are enabled at fog server level. If i create the new host via the gui or the pxe menu (full host registration) they
    are also enabled.

    My question now is if somebody can give me an example how i can enable these settings on the new host via the api after the
    new host creation task. I use windows powershell to access the fog api, based on this forum post.

    Any help is appreciated!

  • Hi Tom,

    thanks for the answer, this works fine during the host creation.

    I’ve tryed to activate the modules after the host creation by creating a moduleassociation for the newly created host object.
    For example:

     #Hostname Changer
            $TaskdataSet = @{
                "hostID" = $HostID
                "moduleID" = "9"
                "state" = "1"
                $taskdataToSend = ConvertTo-JSON($TaskdataSet)
                New-FogObject -type object -coreObject moduleassociation -jsonData $TaskdataSet
                }Catch{Write-Host "Failed to create Module association for Module 4 in Fog" -ForegroundColor Red
                    $error[0] | Format-List -Force
                    Exit 1

    But i think this was the wrong way. Could you tell me the right way to activate the modules after the host creation step?

    And one further question:
    If i try to define a ‘AllSnapin task’ for the new created host it doesn’t work.
    So my last step should be the deployment of the already, successfully assigned snapins after the hostname was
    changed (which is now working if i activate the hostchanger module during the host creation step). That’s why i try to create a “AllSnapin” task for
    the newly created host object like this:

    #Create Snapin Tasks for new Host    
            $HostID = $          
            $TaskURL = $baseUri + "/host/" + $HostID + "/task"
            $TaskdataSet = @{
                "hostname" = $
                "taskTypeID" = $AllSnapinID
                $taskdataToSend = ConvertTo-JSON($TaskdataSet)
                $TaskResult = Invoke-RestMethod -Method Post -Uri $TaskURL -Headers $headers -Body $taskdataToSend -ContentType "application/json"
                }Catch{Write-Host "Failed to create All Snapin Task in Fog" -ForegroundColor Red
                    $error[0] | Format-List -Force
                    Exit 1

    But this dosen’t work, i guess because the deployment task is in the queue for the new host? Would it be the right way to create the “AllSnapin Task”
    after the deployment task has finished? Is that the clue?

    Thank you for your support!

  • Senior Developer

    @katerkarlo99 when creating the host via api, you can associate snapins, printers, groups, and modules using the ids of the relevant item as an array using the respective key as the object identifier.

    For example, creating a host with associating the client modules your data element would be:

      "macs" : [ "00:01:02:03:04:05" ],
      "name" : "hostname",
      "modules" : [ 1,2,3,4,5,6,7,8,9,10,11,12 ]

    Or very similar.

    The api call would be to /fog/host/create of POST request.

Log in to reply