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

    Plugin for switch vlan changes

    General
    4
    11
    1060
    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.
    • andyb2000
      andyb2000 last edited by

      Hi all,
      I’d written a plugin many years ago on old Fog, and now bringing it back to life I’m writing it for fog1.4.4.
      I’m pleased to see Hook method allowing me to tie in to many base fog functions, so have pages, database and config all working great.

      One element I need to do, is when an image is deployed, before/during the reboot I need to trigger my code. Originally I did that in Post_Stage3.php and called my code in the plugin class from there, but looking in the new improved Fog, Post_Stage3 looks a bit like a placeholder/backward compatibility.

      So two questions, first, is there a Hook register I can call to tie into what would be in Post_Stage3 (Obviously this would be ideal, means no change to existing Fog code, as per the Hook/register principles).
      Secondly, would I just be able to add my code into Post_Stage3 (A bit hacky, but would work) and execute it as I did previously.

      Thanks in advance!
      Andy

      Regards,
      Andy
      http://www.thebmwz3.co.uk/
      https://github.com/andyb2000

      Wayne Workman 1 Reply Last reply Reply Quote 0
      • andyb2000
        andyb2000 last edited by

        Thats excellent, thank you Sebastian for taking the time to reply, I’ll get onto that code now, that’s what I’m after.

        And yes, the find/awk trick was also what I was looking for, who needs docs, like you say, it’s in the code 🙂

        Regards,
        Andy
        http://www.thebmwz3.co.uk/
        https://github.com/andyb2000

        1 Reply Last reply Reply Quote 0
        • S
          Sebastian Roth Moderator last edited by Sebastian Roth

          @andyb2000 If you are looking for more hooks I can recommend this find/awk foo magic command:
          find /var/www/fog -type f -exec awk '/processEvent\(/,/\);/' {} \; | less

          And for events (note there are only a few as of now):
          find /var/www/fog -type f -exec awk '/notify\(/,/\);/' {} \; | less

          When you find an interesting hook name you can find out where it is defined by running:
          find /var/www/fog -type f -exec grep "HOST_IMAGE_COMPLETE" {} /dev/null \;

          I know this is not perfect and we should have all this documented better. But hey, it’s all in the code… 😉

          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

          1 Reply Last reply Reply Quote 1
          • S
            Sebastian Roth Moderator last edited by Sebastian Roth

            @andyb2000 Thanks for your patience! So basically there are two mechanisms you can use for what you want to achieve. One is hooks (that you already know) and the other one is events.

            So to answer your question. The Post_Stage3.php is still the right place (for end of deploy) but the actual code is being refactored and moved to lib/reg-task/taskqueue.class.php (ref). So you were on the right track already. Either hook HOST_TASKING_COMPLETE or event HOST_IMAGE_COMPLETE should work for you. For examples see lib/plugins/windowskey/hooks/changehostkey.hook.php or lib/plugins/slack/events/imagecomplete_slack.event.php (note hook and event in the filename).

            I’m also looking to tie in (again preferably with the Hook ->register function in my plugin) to when an image is triggered to be deployed to a host, I need to call a function before the host is WOL’d so what would be the register code for that?

            You want to use HOST_DEPLOY_POST or GROUP_DEPLOY_POST hook (code ref) for that - first one for single host tasking and the later one for group tasking. Mind you those hooks apply for deploy and capture tasking - the name of the hook might be a bit misleading here.

            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

            1 Reply Last reply Reply Quote 2
            • andyb2000
              andyb2000 last edited by

              Hi!
              Thank you, I appreciate it’s difficult to look into items like this quickly! Fully understand and appreciate you taking the time to get back to me.

              Regards,
              Andy
              http://www.thebmwz3.co.uk/
              https://github.com/andyb2000

              1 Reply Last reply Reply Quote 0
              • S
                Sebastian Roth Moderator last edited by

                @andyb2000 I am very sorry for not having responded properly to your request yet. Just too many other things need attention. But I have this on my list, promise!

                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

                1 Reply Last reply Reply Quote 0
                • S
                  Sebastian Roth Moderator last edited by

                  I’ll take a look when I have a bit more time. But please Tom, do so as well. You know the web UI way better than I do.

                  @andyb2000 I am sure we can help you out. Just needs a bit more time for a profound question to answer.

                  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

                  1 Reply Last reply Reply Quote 0
                  • Wayne Workman
                    Wayne Workman last edited by Wayne Workman

                    @Tom-Elliott can you look through this thread please? I have no idea about this.

                    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!
                    Daily Clean Installation Results:
                    https://fogtesting.fogproject.us/
                    FOG Reporting:
                    https://fog-external-reporting-results.fogproject.us/

                    1 Reply Last reply Reply Quote 0
                    • andyb2000
                      andyb2000 last edited by

                      Thanks for the replies, yes I’m trying to tie in to the postinstall scripts, preferably through the plugin architecture as that then requires no other code changes.

                      Code isn’t in the repo as yet as it’s totally not working and nowhere near a release, so will look into that for future as I maintain a few git repo’s myself.

                      The plugin allows fog to change VLANs on Cisco switches when deployments complete, so to switch the deployed machines to specific VLANs based on the image deployed. It does this using snmpset to the switches. I’ve hooked into the host view (to capture switch and interface for the config), and image view to set the vlan to switch to. This all works.

                      So my key question is within the plugin Hook ->register functions, can I tie in to the postinstall or Post_Stage3 part.

                      I’m also looking to tie in (again preferably with the Hook ->register function in my plugin) to when an image is triggered to be deployed to a host, I need to call a function before the host is WOL’d so what would be the register code for that? I’ve tried

                                  ->register(
                                      'HOST_TASKING_COMPLETE',
                                      array(
                                          $this,
                                          'hostTaskingComplete'
                                      )
                      

                      But I suspect that is for the completion of a task, rather than at the creation of the task?
                      Thanks in advance for any dev’s to help out.

                      Regards,
                      Andy

                      Regards,
                      Andy
                      http://www.thebmwz3.co.uk/
                      https://github.com/andyb2000

                      1 Reply Last reply Reply Quote 0
                      • Wayne Workman
                        Wayne Workman @andyb2000 last edited by Wayne Workman

                        @andyb2000 is your plugin in fog’s repo? If it’s useful, you can donate the code - and then we all (as a community) will try to maintain it (or you can still).

                        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!
                        Daily Clean Installation Results:
                        https://fogtesting.fogproject.us/
                        FOG Reporting:
                        https://fog-external-reporting-results.fogproject.us/

                        1 Reply Last reply Reply Quote 0
                        • george1421
                          george1421 Moderator last edited by

                          I can’t help from a programming/hook standpoint. But I can tell you the point you are talking about is where the postinstall scripts are called. The post install scripts are new to FOG 1.3.0+

                          I am a bit intrigued by your subject line. What are you trying to accomplish with this new plugin?

                          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!

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

                          228
                          Online

                          10.4k
                          Users

                          16.4k
                          Topics

                          150.6k
                          Posts

                          Copyright © 2012-2023 FOG Project