feat: integrate load_config method for VILLASnodeManager by bekiralti · Pull Request #75 · VILLASframework/controller · GitHub
Skip to content

feat: integrate load_config method for VILLASnodeManager - #75

Open
bekiralti wants to merge 1 commit into
VILLASframework:masterfrom
bekiralti:feat/integrate-load-config
Open

feat: integrate load_config method for VILLASnodeManager#75
bekiralti wants to merge 1 commit into
VILLASframework:masterfrom
bekiralti:feat/integrate-load-config

Conversation

@bekiralti

Copy link
Copy Markdown
Contributor

Integrates the existing load_config method from the villas-node
library into VILLASnodeManager to enable configuration loading
via RabbitMQ messages.

Example

Example (tx.py) Python Code to send messages to villas-controller via RabbitMQ:

import argparse
import json
import kombu

# CLI
parser = argparse.ArgumentParser()
parser.add_argument("action", type=str)
parser.add_argument("config", type=str, nargs="?", default=None)
args = parser.parse_args()

# Broker connection
connection = kombu.Connection("amqp://guest:guest@localhost/%2F")
exchange = kombu.Exchange(name="villas", type="headers", durable=True)
producer = connection.Producer()

# Message
payload = {"action": args.action}
if args.config:
    with open(args.config, "r", encoding="utf-8") as f:
        config = json.load(f)
    payload["config"] = config
producer.publish(payload, exchange=exchange, headers={"type": "villas-node"})

Minimal (example_ctl.json) configuration for villas-controller:

{
  "broker": {
    "url": "amqp://guest:guest@localhost/%2F"
  },
  "components": [
    {
      "category": "manager",
      "type": "villas-node"
    }
  ]
}

Minimal (example_node.json) configuration to sent via RabbitMQ to villas-controller, then villas-controller reloads the running villas-node with this configuration.

{
  "nodes": {
    "my_sig": {
      "type": "signal.v2",
      "rate": 1,
      "in": {
        "signals": [
          {
            "signal": "constant",
            "amplitude": 1
          }
        ]
      }
    }
  },
  "paths": [
    {
      "in": "my_sig",
      "hooks": [
        {
          "type": "print"
        }
      ]
    }
  ]
}
  1. Start RabbitMQ: docker run -p 5672:5672 -p 15672:15672 -d rabbitmq:management
  2. Start villas-node: villas-node
  3. Start villas-controller: villas-controller -c example_ctl.json -d DEBUG daemon
  4. Send example_node.json: python tx.py load_config example_node.json

Signed-off-by: Bekir Altindal <bekir.altindal@rwth-aachen.de>
@stv0g

stv0g commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

@bekiralti

bekiralti commented Jan 5, 2026

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants