From aadf1a8be990b4df1225e5e97dbb5cb5200c42db Mon Sep 17 00:00:00 2001 From: pipeacosta Date: Tue, 26 Sep 2023 16:55:10 +0000 Subject: [PATCH] Added lab for universal API server and client testing Signed-off-by: pipeacosta --- etc/labs/lab18_rest_api/docker-compose.yml | 27 +++++ .../lab18_rest_api/lab18_rest_api_ri1.conf | 108 ++++++++++++++++++ .../lab18_rest_api/lab18_rest_api_ri2.conf | 102 +++++++++++++++++ 3 files changed, 237 insertions(+) create mode 100644 etc/labs/lab18_rest_api/docker-compose.yml create mode 100644 etc/labs/lab18_rest_api/lab18_rest_api_ri1.conf create mode 100644 etc/labs/lab18_rest_api/lab18_rest_api_ri2.conf diff --git a/etc/labs/lab18_rest_api/docker-compose.yml b/etc/labs/lab18_rest_api/docker-compose.yml new file mode 100644 index 000000000..d7b814a45 --- /dev/null +++ b/etc/labs/lab18_rest_api/docker-compose.yml @@ -0,0 +1,27 @@ +version: '3.1' + +services: + node1: + container_name: villas_1 + # The following image is build from the VILLASnode Github repository, branch rest-api-lab, see: + image: node:config-mvp + ports: + - "8080:8080/tcp" + - "4445:4445/udp" + volumes: + - ./lab18_rest_api_ri1.conf:/etc/node/lab18_rest_api_ri1.conf + command: + - node + - /etc/node/lab18_rest_api_ri1.conf + + # node2: + # container_name: villas_2 + # image: node:config-mvp + # ports: + # - "8080:8080/tcp" + # - "4446:4446/udp" + # volumes: + # - ./node_ri2.conf:/etc/node/node_ri2.conf + # command: + # - node + # - /etc/node/node_ri2.conf diff --git a/etc/labs/lab18_rest_api/lab18_rest_api_ri1.conf b/etc/labs/lab18_rest_api/lab18_rest_api_ri1.conf new file mode 100644 index 000000000..95a737e2f --- /dev/null +++ b/etc/labs/lab18_rest_api/lab18_rest_api_ri1.conf @@ -0,0 +1,108 @@ +http = { + port = 8080 +} + +nodes = { + node_ri1_api = { + type = "api" + + in = { + signals = ( + { + name = "ri2-amp-p", + type = "float", + unit = "mW", + description = "Active power", + rate = 1, + readable = true, + writable = false, + payload = "samples" + }, + { + name = "ri2-amp-q", + type = "float", + unit = "pu", + description = "Reactive power", + rate = 1, + readable = true, + writable = false, + payload = "samples" + } + ) + } + + out = { + signals = ( + # Output signals have no name, type and unit settings as those are implicitly + # derived from the signals which are routed to this node + { + description = "Frequency", + rate = 1, + readable = true, + writable = false, + payload = "samples" + }, + { + description = "Voltage", + rate = 1, + readable = true, + writable = false, + payload = "samples" + } + ) + } + }, + + node_ri1_rtds = { + type = "signal.v2" + rate = 1.0 + # signal = "mixed" + + in = { + signals = ( + { name = "ri1-rtds-f", signal = "constant", amplitude = 1.0, enabled = true }, + { name = "ri1-rtds-u", signal = "constant", amplitude = 2.0, enabled = true } + ) + } + }, + + loopback_node = { + type = "loopback", + queuelen = 1024 + } + + # node_ri1_rtds = { + # type = "socket", + # format = "gtnet", + + # in = { + # address = "*:4445", + # signals = ( + # { name = "ri1-rtds-f", type = "float", enabled = true}, + # { name = "ri1-rtds-u", type = "float", enabled = true} + # ) + # }, + # out = { + # address = "134.130.169.107:4446" + # } + # } +} + +paths = ( + { + in = [ + "node_ri1_api" + ] + out = [ + "loopback_node" + ] + }, + { + in = [ + "node_ri1_rtds" + ] + out = [ + "node_ri1_api" + ] + } +) diff --git a/etc/labs/lab18_rest_api/lab18_rest_api_ri2.conf b/etc/labs/lab18_rest_api/lab18_rest_api_ri2.conf new file mode 100644 index 000000000..aca2156aa --- /dev/null +++ b/etc/labs/lab18_rest_api/lab18_rest_api_ri2.conf @@ -0,0 +1,102 @@ +nodes = { + node_ri2_client = { + type = "api-client", + + # The HTTP REST API endpoint of the uAPI server + endpoint = "http://137.226.133.196:8080/api/v2/universal/node_ri1_api", + + rate = 1 # Rate at which we poll the broker for updates + timeout = 0.5, # Timeout of HTTP request in seconds (default is 1, must be smaller than 1 / rate) + verify_ssl = false, # Verification of SSL server certificates (default is true) + + in = { + signals = ( + { + name = "ri1-rtds-f", + type = "float", + unit = "Hz", + description = "Frequency", + rate = 1, + readable = true, + writable = false, + payload = "samples" + }, + { + name = "ri1-rtds-u", + type = "float", + unit = "kV", + description = "Voltage", + rate = 1, + readable = true, + writable = false, + payload = "samples" + } + ) + }, + + out = { + signals = ( + # Output signals have no name, type and unit settings as those are implicitly + # derived from the signals which are routed to this node + { + description = "Active power", + rate = 1, + readable = true, + writable = false, + payload = "samples" + }, + { + description = "Reactive power", + rate = 1, + readable = true, + writable = false, + payload = "samples" + } + ) + } + }, + + node_ri2_amp = { + type = "socket", + layer = "udp", + + format = { + type = "json", + compact = true + }, + + in = { + address = "*:4446", + signals = ( + { name = "ri2-amp-p", type = "float", enabled = true}, + { name = "ri2-amp-q", type = "float", enabled = true} + ) + }, + + out = { + address = "137.226.133.196:4445" + } + } +} + +paths = ( + { + in = [ + "node_ri2_client" + ] + out = [ + "node_ri2_amp" + ] + }, + { + in = [ + "node_ri2_amp" + ] + out = [ + "node_ri2_client" + ], + hooks = ( + { type = "print" } + ) + } +)