Plugin for switch vlan changes



  • 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



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


  • Developer

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


  • Developer

    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.


  • Moderator

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



  • 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


  • Moderator

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


  • Moderator

    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?


Log in to reply
 

443
Online

39.8k
Users

11.2k
Topics

106.8k
Posts

Looks like your connection to FOG Project was lost, please wait while we try to reconnect.