• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login
    1. Home
    2. CWDS
    C
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 8
    • Best 0
    • Controversial 0
    • Groups 0

    CWDS

    @CWDS

    0
    Reputation
    5
    Profile views
    8
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    CWDS Unfollow Follow

    Latest posts made by CWDS

    • RE: How to create a FOG Event?

      Update

      Still unable to get the MACs from Host(), but I think I’m getting closer. I just dont know what I’m supposed to do with the output of a ->get() call.

          public function onEvent($event, $data)
          {
              $hostData["name"] = $data['HostName'];
              $iData = var_export($hostData,true);
              $hostObj = new Host($hostData);
              $hData = var_export($hostObj,true);
              $primaryMac = $hostObj->get('primac')->get('mac');
              $macList = array();
      
              foreach ((array)$hostObj->get('additionalMACs') as $ind => &$MAC) {
                     	$macList[] = $MAC;
              }
              $oData1 = var_export($primaryMac,true);
              $oData2 = var_export($macList,true);
              file_put_contents("/var/www/fog/ds_fw.log",$iData . "\n" . $hData . "\n" . $oData1 . "\n" . $oData2);
          }
      }
      

      $primaryMac results in NULL, and $macList results in an empty array. I picked/adjusted the $macList loop from one of the pages code, so that ‘should’ theoretically work, as long as the get()'s actually return data.

      posted in General
      C
      CWDS
    • RE: How to create a FOG Event?

      @Tom-Elliott Thanks, understood.

      I was able to get my log file test writing out the $data info. I think I’m doing something else wrong now, trying to get the host object based on that data. Ideas?

          public function onEvent($event, $data)
          {
      	$hostData["name"] = $data['HostName'];
      	$iData = var_export($hostData,true);
      	$hostObj = new Host($hostData);
      	$macList = $hostObj->getMyMacs();
      	$oData = var_export($macList,true);
      	file_put_contents("/var/www/fog/ds_fw.log",$iData . "\n" . $oData);
          }
      }
      

      Based on my reading of the code; I can call ‘new Host()’ with an array that gets passed for searching for a host, and in return, I should get a Host object, for that host. I’ve tried every variation in the $hostData[] entry; ‘Name’, ‘name’, ‘hostName’, ‘HostName’.

      Is there somewhere I can read about how these classes are supposed to act together, or how I’m supposed to actually initiate/call them?

      (Edit:) - $macList returns an empty array. which leads me to believe I’m calling/loading Host() wrong (thus, my questions)

      posted in General
      C
      CWDS
    • Speeding up iPXE kickoff?

      I have a few systems which have 4+ nic ports; and iPXE takes a long time to boot these systems as it tries to wait for each port to come up before proceeding. I wouldnt entirely care, except it seems to try each port twice.

      Is there a way to speed this up? Obviously theres at least a port up, and its the port that really matters as iPXE had started, but having to wait 2-5 minutes for the other ports to come up is just taking away from the imaging window I have available to me.

      posted in General
      C
      CWDS
    • RE: How to create a FOG Event?

      @Sebastian-Roth Actually, the link I mentioned, doesnt have HOST_IMAGE_COMPLETE listed there. am I looking at the wrong type of things or is this event name changing soon?

      posted in General
      C
      CWDS
    • RE: How to create a FOG Event?

      @Sebastian-Roth Well that would certainly explain why I’m not seeing it then! I was testing using Hosts -> List. I added HOST_LIST_EVENT as a test, so that I wasnt having to do imaging all the time to test it.

      Can you/the rest of the mods/team please update the wiki?! Forum posts are great, but having to search and hope the information is correct kind of sucks. The wiki should be the central knowledge repo, not the forum. I mean, at one point while working with the API, I had to dive into the code in order to find the requirements each endpoint needed. Using an API shouldnt require code diving!

      I did find this list: https://forums.fogproject.org/assets/uploads/files/1545241373509-hooks_and_tie-ins.txt but it references 1.6, not 1.5.5

      posted in General
      C
      CWDS
    • RE: How to create a FOG Event?

      @Sebastian-Roth The extra _ did appear to be preventing it from loading, however, the event does not appear to be firing? I changed the file_put_contents to something that I knew would fail; and it threw an error in /var/log/httpd/ssl_error_log. However, when I fixed it back to file_put_contents (even tried other functions too, echo, print, var_dump), the file loads, but doesnt seem to execute the onEvent call. I even set php error_reporting to E_ALL, and all I get is an unrelated notice. I even changed from file_put_contents to fopen/fwrite/fclose; and attached ‘or die(“Some message”)’ to them, no errors, no messages, no death, no writing to the file either.

      posted in General
      C
      CWDS
    • RE: How to create a FOG Event?

      @Sebastian-Roth The file+path is ‘/var/www/html/fog/lib/events/imagecomplete_ds_fw.event.php’

      posted in General
      C
      CWDS
    • How to create a FOG Event?

      I am trying to make an image complete event hook that is executed on the FOG server side. I copied the Slack ImageComplete event to /var/www/fog/lib/events/, and modified it to do what I want.

      Unfortunately, it doesnt appear to be executing. Class is below.

      What am I missing or doing wrong? Currently I’m just trying to log the data to a file to prove that I can make this work. I also added HOST_LIST_EVENT to try to get it to trigger elsewhere so I could see if it would work there, but nothing.

      class ImageComplete_DS_FW extends Event
      {
          /**
           * The name of this event
           *
           * @var string
           */
          public $name = 'ImageComplete_DS_FWEvent';
          /**
           * The description of this event
           *
           * @var string
           */
          public $description = 'Triggers when a host finishes imaging';
          /**
           * The event is active
           *
           * @var bool
           */
          public $active = true;
          /**
           * Initialize object.
           *
           * @return void
           */
          public function __construct()
          {
              parent::__construct();
              self::$EventManager->register(
                  'HOST_LIST_EVENT',
      	    $this
              )->register(
                  'HOST_IMAGE_COMPLETE',
                  $this
              )->register(
                  'HOST_IMAGEUP_COMPLETE',
                  $this
              );
          }
          /**
           * Perform action
           *
           * @param string $event the event to enact
           * @param mixed  $data  the data
           *
           * @return void
           */
          public function onEvent($event, $data)
          {
      	$d = var_export($data);
      	file_put_contents(self::$logpath . "ds_fw.log",$d);
          }
      }
      
      posted in General events hooks 1.5.5
      C
      CWDS