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

FOG 1.5.4 API host module settings

Scheduled Pinned Locked Moved Solved
FOG Problems
fogapi-psmodule
5
10
1.3k
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.
  • K
    KaterKarlo99
    last edited by JJ Fullmer Mar 31, 2023, 7:40 AM Jul 2, 2018, 8:22 AM

    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.

    0_1530519546865_fog_host-module-settings.JPG

    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!

    T 1 Reply Last reply Jul 2, 2018, 1:13 PM Reply Quote 0
    • T
      Tom Elliott @KaterKarlo99
      last edited by Jul 2, 2018, 1:13 PM

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

      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

      J 1 Reply Last reply Jun 17, 2020, 10:50 AM Reply Quote 1
      • K
        KaterKarlo99
        last edited by Jul 3, 2018, 12:43 PM

        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"
                    }
                Try{
                    $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 = $createHostResult.id          
                $TaskURL = $baseUri + "/host/" + $HostID + "/task"
                $TaskdataSet = @{
                    "hostname" = $createHostResult.name
                    "taskTypeID" = $AllSnapinID
                    }
                Try{
                    $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!

        1 Reply Last reply Reply Quote 0
        • J
          Jamaal @Tom Elliott
          last edited by Jun 17, 2020, 10:50 AM

          @Tom-Elliott said in FOG 1.5.4 API host module settings:

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

          Did you all ever get this figured out in Powershell?
          I’m trying to activate hostname changer as well so the computer automatically joins the domain. In the PowerShell script I got from this forum, it has the force AD, but if the hostname changer is not selected by default, it won’t join the domain. If you got this working, can you please tell me what you did exactly?

          1 Reply Last reply Reply Quote 0
          • S
            Sebastian Roth Moderator
            last edited by Jun 17, 2020, 12:28 PM

            Pinging @JJ-Fullmer on this. 🙂

            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

            J 2 Replies Last reply Jun 17, 2020, 1:24 PM Reply Quote 1
            • J
              Jamaal @Sebastian Roth
              last edited by Jun 17, 2020, 1:24 PM

              @Sebastian-Roth said in FOG 1.5.4 API host module settings:

              Pinging @JJ-Fullmer on this. 🙂

              Thanks Sebastian,

              Appreciate you and everyone else assisting. I’m still learning PowerShell up to this day
              and like the fact the scripts on this forum is making Fog work even more dynamic.

              1 Reply Last reply Reply Quote 0
              • J
                Jamaal @Sebastian Roth
                last edited by Jun 17, 2020, 6:32 PM

                @Sebastian-Roth said in FOG 1.5.4 API host module settings:

                Pinging @JJ-Fullmer on this. 🙂

                All,

                I figured this out! I got hostname changer via PowerShell. So here’s what I did to resolve it.
                So with the script I got from this forum last week, I know it had the Json in a splat format. I’m so so with PowerShell
                and doing a lot better than a few years back. So basically what KaterKarlo said, he has moduleid = 9.

                It wasn’t working for me. To get the correct name and ID number, I ended up going to my fog server via the browser, then right click on the browser and view page source did a search for hostname changer. Then it came up the name modules and the value of 9. I finally ended up putting it with the rest of the splat and joined it with no issues:

                “modules” = 9

                I hope this helps someone as well if they need to get the values of a host.
                But thank you guys always for pointing me in the right direction.

                JJ FullmerJ 1 Reply Last reply Jun 18, 2020, 7:34 PM Reply Quote 1
                • JJ FullmerJ
                  JJ Fullmer Testers @Jamaal
                  last edited by Jun 18, 2020, 7:34 PM

                  @Jamaal Glad you got it figured out, sorry I didn’t see this early as adding it to the host splat that you convert to json adds it to the json data that @Tom-Elliott references here. I will make a note about adding something with setting modules to my module in the future

                  Have you tried the FogApi powershell module? It's pretty cool IMHO
                  https://github.com/darksidemilk/FogApi
                  https://fogapi.readthedocs.io/en/latest/
                  https://www.powershellgallery.com/packages/FogApi
                  https://forums.fogproject.org/topic/12026/powershell-api-module

                  JJ FullmerJ 1 Reply Last reply Jun 19, 2020, 1:19 PM Reply Quote 0
                  • JJ FullmerJ
                    JJ Fullmer Testers @JJ Fullmer
                    last edited by Jun 19, 2020, 1:19 PM

                    @JJ-Fullmer said in FOG 1.5.4 API host module settings:

                    @Jamaal Glad you got it figured out, sorry I didn’t see this early as adding it to the host splat that you convert to json adds it to the json data that @Tom-Elliott references here. I will make a note about adding something with setting modules to my module in the future

                    Look, I made a note https://github.com/darksidemilk/FogApi/issues/1

                    Have you tried the FogApi powershell module? It's pretty cool IMHO
                    https://github.com/darksidemilk/FogApi
                    https://fogapi.readthedocs.io/en/latest/
                    https://www.powershellgallery.com/packages/FogApi
                    https://forums.fogproject.org/topic/12026/powershell-api-module

                    JJ FullmerJ 1 Reply Last reply Mar 26, 2021, 5:23 PM Reply Quote 0
                    • JJ FullmerJ
                      JJ Fullmer Testers @JJ Fullmer
                      last edited by Mar 26, 2021, 5:23 PM

                      @jj-fullmer said in FOG 1.5.4 API host module settings:

                      @JJ-Fullmer said in FOG 1.5.4 API host module settings:

                      @Jamaal Glad you got it figured out, sorry I didn’t see this early as adding it to the host splat that you convert to json adds it to the json data that @Tom-Elliott references here. I will make a note about adding something with setting modules to my module in the future

                      Look, I made a note https://github.com/darksidemilk/FogApi/issues/1

                      @Jamaal I also finally did something with this. I hope to at some point develop this a lot further and have dynamic parameters for snapins and groups when adding a host in powershell. But for now there is at least a basic new-foghost function that will create a host with a given name and mac list and enable the modules that you have set as default in your fog server.

                      This is published in version 2103.2.12
                      https://www.powershellgallery.com/packages/FogApi/2103.2.12
                      https://github.com/darksidemilk/FogApi/releases/tag/2103.2.12

                      Have you tried the FogApi powershell module? It's pretty cool IMHO
                      https://github.com/darksidemilk/FogApi
                      https://fogapi.readthedocs.io/en/latest/
                      https://www.powershellgallery.com/packages/FogApi
                      https://forums.fogproject.org/topic/12026/powershell-api-module

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post

                      145

                      Online

                      12.0k

                      Users

                      17.3k

                      Topics

                      155.2k

                      Posts
                      Copyright © 2012-2024 FOG Project