advanced routing #1

Supports: bionic


This charm can be deployed alongside principal charms to enable custom network routes management.


This subordinate charm allows for the configuration of policy routing rules on the deployed host, as well as routes to configured services. A list of hash maps, in JSON format, is expected.

Charm supports IPv4 addressing.


cd charm-advanced-routing
make build


Add to an existing application using juju-info relation.


juju deploy cs:advanced-routing
juju add-relation ubuntu advanced-routing


The user can configure the following parameters: * enable-advanced-routing: Enable routing. This requires for the charm to have routing information configured in JSON format: juju config advanced-routing --file path/to/your/config

  • advanced-routing-config parameter contains 3 types of entities: 'table', 'route', 'rule'. The 'type' parameter is always required.

table: routing table to put the rules in (used in rules)

route: defines a static route with the following params: - default_route: should this be a default route or not (boolean: true|false) (optional, requires gateway and table) - net: IPv4 CIDR for a destination network (string) (mutually exclusive with default_route, and requires gateway) - gateway: IPv4 gateway address (string) (required) - table: routing table name (string) (optional, except if default_route is used) - metric: metric for the route (int) (optional) - device: device (interface) (string) (optional)

rule: - from-net: IPv4 CIDR source network (string) (required) - to-net: IPv4 CIDR destination network (string) (optional) - table: routing table name (string) (optional, default is main) - priority: priority (int) (optional)

An example yaml config file below:

    value: |-
      [ {
          "type": "table",
          "table": "SF1"
      }, {
          "type": "route",
          "default_route": true,  
          "net": "",
          "gateway": "",      
          "table": "SF1",
          "metric": 101,
          "device": "eth0"
      }, {
          "type": "route",
          "net": "",
          "gateway": ""
      }, {
          "type": "rule",
          "from-net": "",
          "to-net": "",
          "table": "SF1",
          "priority": 101
      } ]
    value: true

The example_config.yaml file is also provided with the codebase.


To run lint tests:

tox -e lint

To run unit tests:

tox -e unit

Functional tests have been developed using python-libjuju, deploying a simple ubuntu charm and adding the charm as a subordinate.

To run tests using python-libjuju:

tox -e functional

Contact Information


(boolean) Changes need to be applied by running the 'apply-changes' action.
(string) A json array consisting of objects, e.g. [ { "type": "route", "net": "", "device": "eth5" }, { ... } ] @ see example_config.yaml for more examples
(boolean) Whether to use the custom routing configuration provided by the charm.