[GUIDE] DIY Plugin Development Part 1-3

  • Hi


    I need help, I am trying to migrate fail2ban plugin for omv3, almost everything works but i have an error :


    JavaScript
    TypeError: vtypes[vtype] is not a function
    if (!vtypes[vtype](value, me)) {


    See : https://github.com/prbond/openmediavault-fail2ban.git branch master-omv3

  • Get rid of all of the vtype entries in your jails.js. Most (all) of those vtypes don't exist. port is the only one I see that actually exists.

    omv 5.6.6 usul | 64 bit | 5.11 proxmox kernel | omvextrasorg 5.6.1
    omv-extras.org plugins source code and issue tracker - github


    Please read this before posting a question.
    Please don't PM for support... Too many PMs!

  • BIG THANKS, it's been days that I have a hard time ...


    PS: where i could find list of vtype allowed ?

  • Some vtypes are built-in into extjs and others are here. You don't have to use them. It just helps formatting the field and only allowing certain types of entry.

    omv 5.6.6 usul | 64 bit | 5.11 proxmox kernel | omvextrasorg 5.6.1
    omv-extras.org plugins source code and issue tracker - github


    Please read this before posting a question.
    Please don't PM for support... Too many PMs!

  • I have read your post about building a plugin and it is quite helpful. Unfortunately it is not mentioned anywhere how you can survive to the inevitable mistakes that one makes when coding.


    Perhaps this is the not right place to ask such a dumb novice question but I am sure you have already resolved this time ago. Sorry if thi is not the right place to do this. Please tell me where I must go if this is the case.


    So, how do you debug the plugin? I mean, how dou you 'print_r' or whatever the value of a variable or object? May be it is evident but I have not been able to figure it out so far.



    I am extending the borg plugin. One of the things that I am now with is executing a call to an external program and getting (supposedly) a result back in JSON format. Then I decode it with


    $output = json_decode($output,true);


    Now I expect to have an array with the values returned in $output. The same call by hand from the shell return this JSON result:


    root@openmediavault:~# borg info --json xxxxx@xxxxxxxxxx.repo.borgbase.com:repo
    {
    "cache": {
    "path": "/root/.cache/borg/bla-bla-bla",
    "stats": {
    "total_chunks": 27260,
    "total_csize": 9056317707,
    "total_size": 10897350512,
    "total_unique_chunks": 2921,
    "unique_csize": 975903007,
    "unique_size": 1180942311
    }
    },
    "encryption": {
    "keyfile": "/root/.config/borg/keys/xxxxx_borgbase_com__repo",
    "mode": "keyfile"
    },
    "repository": {
    "id": "e7b91xxxxxx",
    "last_modified": "2019-11-09T03:38:40.000000",
    "location": "ssh://xxxxx@xxxxxxx.repo.borgbase.com/./repo"
    },
    "security_dir": "/root/.config/borg/security/exxxxxxxxxxxxxxxx"
    }



    Now I need to check if I have something returned because I am noy getting anything when I use $output["cache"]["stats"]["total_csize"] to send the data to the front-end. If I use a constant of rand() function I get the value so it is not the renderer itself so it must be the content of $output variable.


    Something is going bad but I do not know what is so I need a way to show the contents of the variables to be able to fix it.


    Any ideas?


    Thanks in advance.

  • So, how do you debug the plugin? I mean, how dou you 'print_r' or whatever the value of a variable or object?

    Put engined in debug mode:: by stopping it monit stop omv-engined and then starting it in debug mode omv-engined -df

    I am extending the borg plugin.

    Any ideas?

    I appreciate the effort and learning is good but you may want to wait until I have finished porting it. I was going to add the columns you are trying to add.

    omv 5.6.6 usul | 64 bit | 5.11 proxmox kernel | omvextrasorg 5.6.1
    omv-extras.org plugins source code and issue tracker - github


    Please read this before posting a question.
    Please don't PM for support... Too many PMs!

  • Is the plugin development tutorial still accurate? I tried running through it but at the end of part 1, when I create example.inc and restart the engine, it breaks my OMV. Just trying to log into OMV results in "Failed to connect to socket: No such file or directory". This happens on both OMV5 and OMV4.

  • Is the plugin development tutorial still accurate? I tried running through it but at the end of part 1, when I create example.inc and restart the engine, it breaks my OMV. Just trying to log into OMV results in "Failed to connect to socket: No such file or directory". This happens on both OMV5 and OMV4.

    This one is the most current - https://github.com/skyajal/diypluginguide3.x - but it applies to OMV 3.x. It should work for most things for OMV 4.x. OMV 5.x uses saltstack for configuration management though. I suggest looking at the source for simple plugins like the minidlna plugin - https://github.com/OpenMediaVa…s/openmediavault-minidlna

    omv 5.6.6 usul | 64 bit | 5.11 proxmox kernel | omvextrasorg 5.6.1
    omv-extras.org plugins source code and issue tracker - github


    Please read this before posting a question.
    Please don't PM for support... Too many PMs!

  • This one is the most current - https://github.com/skyajal/diypluginguide3.x - but it applies to OMV 3.x. It should work for most things for OMV 4.x. OMV 5.x uses saltstack for configuration management though. I suggest looking at the source for simple plugins like the minidlna plugin - https://github.com/OpenMediaVa…s/openmediavault-minidlna

    Thanks. I was going to see if I could write a quick plugin that creates a webdav container in OMV5, but it doesn't look like I'll have time to learn all that right now. I'll just launch a container by hand and go with that for now. Maybe I'll come back to this when work is slow. I appreciate all your attention though.

  • Thanks. I was going to see if I could write a quick plugin that creates a webdav container in OMV5, but it doesn't look like I'll have time to learn all that right now. I'll just launch a container by hand and go with that for now. Maybe I'll come back to this when work is slow. I appreciate all your attention though.

    I might look at converting the minidlna plugin to run minidlna in a docker. Then it would make a good model.

    omv 5.6.6 usul | 64 bit | 5.11 proxmox kernel | omvextrasorg 5.6.1
    omv-extras.org plugins source code and issue tracker - github


    Please read this before posting a question.
    Please don't PM for support... Too many PMs!

  • I was going to see if I could write a quick plugin that creates a webdav container in OMV5, but it doesn't look like I'll have time to learn all that right now

    It isn't done yet but I have a good amount done making the minidlna plugin use docker - https://github.com/OpenMediaVa…ediavault-minidlna-docker


    The part I think is cool is using saltstack to deploy the container. I might have to convert omv-extras to using this method. Here is code that is doing that - https://github.com/OpenMediaVa…ploy/minidlna/default.sls

    omv 5.6.6 usul | 64 bit | 5.11 proxmox kernel | omvextrasorg 5.6.1
    omv-extras.org plugins source code and issue tracker - github


    Please read this before posting a question.
    Please don't PM for support... Too many PMs!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!