[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

    • Offizieller Beitrag

    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 7.0-32 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.9 | compose 7.0.9 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    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 ?

    • Offizieller Beitrag

    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 7.0-32 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.9 | compose 7.0.9 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    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.

    • Offizieller Beitrag

    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 7.0-32 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.9 | compose 7.0.9 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

    • Offizieller Beitrag

    So in this mode var_dumps are shown, right?

    Should be.

    omv 7.0-32 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.9 | compose 7.0.9 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    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.

    • Offizieller Beitrag

    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 7.0-32 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.9 | compose 7.0.9 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    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.

    • Offizieller Beitrag

    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 7.0-32 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.9 | compose 7.0.9 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

    • Offizieller Beitrag

    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 7.0-32 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.9 | compose 7.0.9 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!