OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Profile of ndejong »
  • Show Posts »
  • Topics
  • Profile Info
    • Summary
    • Show Stats
    • Show Posts...
      • Messages
      • Topics
      • Attachments

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

  • Messages
  • Topics
  • Attachments

Topics - ndejong

Pages: [1]
1
Development and Code Review / [SOLVED] Accessing the UUID of a config item in (Jinja2) templates
« on: August 22, 2018, 02:52:03 am »
I'm having a challenge in figuring out out to obtain the UUID of an item when rendering templates - by way of example I have this configuration structure:-
Code: [Select]
<VerbNetworks>
  <autossh version="0.1.0">
    <tunnels>
      <tunnel uuid="490829b9-f1b0-42ad-8dad-182de0c06afb">
        <user>myuser</name>
        <host>panic.verbnetworks.com</type>
      </tunnel>
    </tunnels>
  </autossh>
</VerbNetworks>

I note the template helper functions `getUUID()` and `getUUIDtag()` in `template_helpers.py` that take a UUID as an input parameter and return data associated with that UUID - this is not what I want despite the `getUUID()` function having a correct sounding name.

What (I think) I want to write is something like the following:-
Code: [Select]
{% for tunnel_uuid, tunnel_item in 'VerbNetworks.autossh.tunnels.tunnel'.iteritems() %}
[autossh_{{ tunnel_uuid }}]
{% endfor %}
It is not clear to me how to write or express the tag-name that gets passed to `.iteritems()` and thus the above code fails.

In a maybe-perfect world it might be nice if you could obtain a list of UUIDs for a tag-name using a helper function that I imagine might be called "getUUIDs()"
Code: [Select]
{% for tunnel_uuid in helpers.getUUIDs('VerbNetworks.autossh.tunnels.tunnel') %}
{% set tunnel = helpers.getUUID(tunnel_uuid) %}
Host {{ tunnel_uuid }}
  User {{ tunnel.user }}
  HostName {{ tunnel.host }}
{% endfor %}

Before I set about trying to write and introduce such a new helper function is there another way of achieving what I'm setting out to do here?

2
Development and Code Review / Registering callbacks on controller actions?
« on: August 18, 2018, 11:35:52 am »
Recently I found myself writing a whole monitoring daemon [#1] to watch for system changes which then called some function - in the back of my mind what I really wanted was some way to register myself for a callback action when other system actions occurred.

I also noticed recently that a plugin and package for Redis exists which might open up a reasonable mechanism to implement a system wide callback mechanism using Redis pubsub [#2]

My high level estimate is for something to be added to `ControllerBase.php` that extends the Phalcon `afterDispatch()` or `afterExecuteRoute()` functions that publish details of controller actions to Redis - this then would allow other components to subscribe to events published and then cause actions etc.

That said, I'm not sure this would entirely address my own use case because the event I'm looking for is anything that causes the configuration to change which can happen via legacy code that does not come down the MVC route - maybe there is another place to catch all `save()` calls somewhere which writes appropriate data to the Redis pubsub.

Also, it is not clear to me how much pressure Redis might put on the limited resources of lower end hardware and if this then has flow on effects on other functionality.

Links:-
[#1] - https://github.com/verbnetworks/opnsense-plugins/blob/master/net-mgmt/configsync/src/opnsense/scripts/VerbNetworks/ConfigSync/MonitorDaemon.py
[#2] - https://redis.io/topics/pubsub


3
Development and Code Review / [SOLVED] Adding package(s) dependencies for plugins?
« on: August 10, 2018, 06:12:40 pm »
Hi,

We are in the process of writing another OPNsense plugin that requires an additional standard FreeBSD distribution package, namely autossh.

Have done dirty hacks in the past by manually pulling in packages from the FreeBSD repo and installing manually when those packages are not available via the opnsense repo but this is surely not the right thing to be doing.

What is the correct way (if any) to add package dependencies to a plugin?  If anyone could point to other plugin examples that handle any part this that would be great.

Thanks in advance.

N

4
Development and Code Review / a Terraform module for OPNsense on AWS
« on: August 06, 2018, 03:28:16 pm »
A few weeks ago we posted "a Terraform module for OPNsense on Digital Ocean" and we are now following up with the same thing for creating Amazon Machine Images (AMI) for EC2 instances on AWS.
 - https://github.com/verbnetworks/terraform-aws-opnsense-image
 - https://registry.terraform.io/modules/verbnetworks/opnsense-image/aws

This now means you are free to create multi compute-provider private networks, allowing you to establish private networks between providers and shift workloads to more cost effective providers/regions/zones as appropriate.

Or connect your onsite OPNsense hosts with OPNsense instances running in your cloud provider(s) of choice to create your own inter-office transit links.

Read more about our OPNsense stuff here:-
 - https://verbnetworks.com/projects/devops-for-opnsense/

N

5
Development and Code Review / a Terraform module for OPNsense on Digital Ocean
« on: June 30, 2018, 06:41:17 pm »
Hi,

Anyone wanting to get OPNsense running on Digital Ocean will find this Terraform module helpful:-
 - https://github.com/verbnetworks/terraform-digitalocean-opnsense-image
 - https://registry.terraform.io/modules/verbnetworks/opnsense-image/digitalocean

The module is designed to create a Digital Ocean Droplet snapshot-image that can subsequently be used to start an OPNsense instance within Digital Ocean.

Of particular note is the support for the Digital Ocean (OpenStack based) approach to providing Droplets their seed data, including public-IPv4, public-IPv6, private-IPv4, root-sshkey and user-data which is all be parsed and injected into the OPNsense /conf/config.xml file at boot time. This allows the resulting OPNsense image to be used in Terraform devops automation situations.

By adding appropriate User Data to a Droplet when establishing it becomes possible to fetch an external confg.xml which will be loaded at startup thus making devops automated OPNsense in Digital Ocean possible.

Love to hear feedback, suggestions and the like.

... currently working on AWS and Azure implementations next with a view to making automated multi-cloud private network infrastructure possible.

N

6
Development and Code Review / Logging and debugging in development?
« on: July 30, 2017, 02:57:20 pm »
I'm working on putting together an OPNsense plugin at the moment and have run into what would otherwise seem like a trivial problem to resolve if I could observe what the OPNsense web-app framework is doing under the covers.

I've tried switching debug=true in opnsense/mvc/app/config/config.php but I can't really see where the debug or logging messages are going or where to find them.

Could anyone point me in the right direction?

Pages: [1]
OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2