Commit 69add029 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

software/js-drone: define netIf independently

Network interface can now be defined for each computer.
parent 92efa014
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
* autopilotType: Select which autopilot wrapper should be used * autopilotType: Select which autopilot wrapper should be used
* autopilotIp: IPv4 address to identify the autopilot from the companion board * autopilotIp: IPv4 address to identify the autopilot from the companion board
* autopilotPort: Port on whichautopilot serviceis running * autopilotPort: Port on whichautopilot serviceis running
* droneGuidList: List of computer id on which flight script must be deployed * droneList: List of computer on which flight script must be deployed
* droneNetIf: Drone network interface used for multicast traffic
* debug: Must be set to 'true' to send drone logs through OPC-UA * debug: Must be set to 'true' to send drone logs through OPC-UA
* multicastIp: IPv6 of the multicast group of the swarm * multicastIp: IPv6 of the multicast group of the swarm
* operatorScript: URL of operator's script to prepare the flight * operatorScript: URL of operator's script to prepare the flight
...@@ -22,8 +21,7 @@ ...@@ -22,8 +21,7 @@
* flightScript: URL of user's script to execute to fly drone swarm * flightScript: URL of user's script to execute to fly drone swarm
* subscriptionScript: URL of the script which will be executed by subscribers * subscriptionScript: URL of the script which will be executed by subscribers
* loopPeriod: Minimal period (in milliseconds) between 2 executions of the flight script loop * loopPeriod: Minimal period (in milliseconds) between 2 executions of the flight script loop
* subscriberGuidList: List of computer id on which a GUI must be deployed * subscriberList: List of computer on which a GUI must be deployed
* subscriberNetIf: Subscriber network interface used for multicast traffic
## How it works ## ## How it works ##
......
...@@ -22,11 +22,11 @@ md5sum = 01425a1c77e79788e1948398b9136724 ...@@ -22,11 +22,11 @@ md5sum = 01425a1c77e79788e1948398b9136724
[instance-profile] [instance-profile]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = 3c00f072f6cc51007866bd0ae4435053 md5sum = 524247c6bbc8fb080e0140cac239f505
[instance-root] [instance-root]
filename = instance-root.cfg.jinja2 filename = instance-root.cfg.jinja2
md5sum = a217eddf949e6e838129e61cc2a48d34 md5sum = 2372a1cf3616ccbd97ada047a645cb32
[instance-subscriber] [instance-subscriber]
filename = instance-subscriber.cfg.in filename = instance-subscriber.cfg.in
......
{ {
"$schema": "http://json-schema.org/draft-06/schema#", "$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object", "type": "object",
"description": "Parameters to instantiate JS drone", "description": "Parameters to instantiate JS drone",
"additionalProperties": false, "additionalProperties": false,
"definitions": {
"entitie-list": {
"description": "List of entities able to listen/send OPC-UA messages from/to the swarm",
"type": "array",
"default": [],
"items": {
"type": "object",
"properties": {
"guid": {
"description": "Computer ID",
"type": "string"
},
"netIf": {
"description": "Interface used for multicast traffic.",
"type": "string",
"default": "eth0"
}
}
},
"uniqueItems": true
}
},
"properties": { "properties": {
"autopilotType": { "autopilotType": {
"title": "Type of the drone's autopilot", "title": "Type of the drone's autopilot",
...@@ -26,17 +48,9 @@ ...@@ -26,17 +48,9 @@
"type": "integer", "type": "integer",
"default": 7909 "default": 7909
}, },
"droneGuidList": { "droneList": {
"title": "List of drones computer ID", "$ref": "#/definitions/entitie-list",
"description": "List of computer ID of drones in the swarm", "title": "List of drones in the swarm"
"type": "array",
"default": []
},
"droneNetIf": {
"title": "Drones Network interface",
"description": "Interface used for multicast traffic.",
"type": "string",
"default": "eth0"
}, },
"debug": { "debug": {
"title": "Set debug mode", "title": "Set debug mode",
...@@ -80,17 +94,9 @@ ...@@ -80,17 +94,9 @@
"type": "integer", "type": "integer",
"default": 200 "default": 200
}, },
"subscriberGuidList": { "subscriberList": {
"title": "List of subscribers computer ID", "$ref": "#/definitions/entitie-list",
"description": "List of computer ID of swarms subscribers (entities able to listen/send OPC-UA messages from/to the swarm)", "title": "List of swarm subscribers"
"type": "array",
"default": []
},
"subscriberNetIf": {
"title": "Subscribers Network interface",
"description": "Interface used for multicast traffic.",
"type": "string",
"default": "eth0"
} }
} }
} }
{% set parameter_dict = dict(default_parameter_dict, **parameter_dict) -%} {% set parameter_dict = dict(default_parameter_dict, **parameter_dict) -%}
{% set guid_list = parameter_dict['droneGuidList'] + parameter_dict['subscriberGuidList'] -%} {% set entitie_list = parameter_dict['droneList'] + parameter_dict['subscriberList'] -%}
{% set drone_id_list = [] -%} {% set drone_id_list = [] -%}
{% set subscriber_id_list = [] -%} {% set subscriber_id_list = [] -%}
{% set part_list = ['publish-connection-information'] -%} {% set part_list = ['publish-connection-information'] -%}
{% for id, guid in enumerate(guid_list) -%} {% for id, entitie in enumerate(entitie_list) -%}
{% set request_peer_section_title = 'request-peer' ~ id -%} {% set request_peer_section_title = 'request-peer' ~ id -%}
{% do part_list.append(request_peer_section_title) %} {% do part_list.append(request_peer_section_title) %}
{% set guid = entitie['guid'] %}
[{{ request_peer_section_title }}] [{{ request_peer_section_title }}]
<= slap-connection <= slap-connection
recipe = slapos.cookbook:request.serialised recipe = slapos.cookbook:request.serialised
{% if id < len(parameter_dict['droneGuidList']) -%} {% if id < len(parameter_dict['droneList']) -%}
{% set sr_name = parameter_dict['autopilotType'] -%} {% set sr_name = parameter_dict['autopilotType'] -%}
name = Drone{{ id }}_{{ guid }} name = Drone{{ id }}_{{ guid }}
{% else -%} {% else -%}
{% set sr_name = 'subscriber' -%} {% set sr_name = 'subscriber' -%}
name = Subscriber{{ len(parameter_dict['droneGuidList']) - id }}_{{ guid }} name = Subscriber{{ len(parameter_dict['droneList']) - id }}_{{ guid }}
{% endif -%} {% endif -%}
software-url = {{ '/'.join(software_url.split('/')[:-1]) + '/software-%s.cfg' % sr_name }} software-url = {{ '/'.join(software_url.split('/')[:-1]) + '/software-%s.cfg' % sr_name }}
return = instance-path return = instance-path
sla-computer_guid = {{ guid }} sla-computer_guid = {{ guid }}
config-autopilotIp = {{ parameter_dict['autopilotIp'] }} config-autopilotIp = {{ parameter_dict['autopilotIp'] }}
config-autopilotPort = {{ dumps(parameter_dict['autopilotPort']) }} config-autopilotPort = {{ dumps(parameter_dict['autopilotPort']) }}
config-numberOfDrones = {{ dumps(len(parameter_dict['droneGuidList'])) }} config-numberOfDrones = {{ dumps(len(parameter_dict['droneList'])) }}
config-numberOfSubscribers = {{ dumps(len(parameter_dict['subscriberGuidList'])) }} config-numberOfSubscribers = {{ dumps(len(parameter_dict['subscriberList'])) }}
config-id = {{ dumps(id) }} config-id = {{ dumps(id) }}
config-debug = {{ dumps(parameter_dict['debug']) }} config-debug = {{ dumps(parameter_dict['debug']) }}
config-loopPeriod = {{ dumps(parameter_dict['loopPeriod']) }} config-loopPeriod = {{ dumps(parameter_dict['loopPeriod']) }}
{% if id < len(parameter_dict['droneGuidList']) -%} config-netIf = {{ entitie.get('netIf', 'eth0') }}
{% if id < len(parameter_dict['droneList']) -%}
{% do drone_id_list.append(id) %} {% do drone_id_list.append(id) %}
config-isADrone = {{ dumps(True) }} config-isADrone = {{ dumps(True) }}
config-flightScript = {{ parameter_dict['flightScript'] }} config-flightScript = {{ parameter_dict['flightScript'] }}
config-netIf = {{ parameter_dict['droneNetIf'] }}
{% else -%} {% else -%}
{% do subscriber_id_list.append(id) %} {% do subscriber_id_list.append(id) %}
config-isADrone = {{ dumps(False) }} config-isADrone = {{ dumps(False) }}
config-operatorScript = {{ parameter_dict['operatorScript'] }} config-operatorScript = {{ parameter_dict['operatorScript'] }}
config-mapJson = {{ parameter_dict['mapJson'] }} config-mapJson = {{ parameter_dict['mapJson'] }}
config-flightScript = {{ parameter_dict['subscriptionScript'] }} config-flightScript = {{ parameter_dict['subscriptionScript'] }}
config-netIf = {{ parameter_dict['subscriberNetIf'] }}
{% endif -%} {% endif -%}
config-multicastIp = {{ parameter_dict['multicastIp'] }} config-multicastIp = {{ parameter_dict['multicastIp'] }}
{% endfor %} {% endfor %}
......
...@@ -34,14 +34,12 @@ default-parameters = ...@@ -34,14 +34,12 @@ default-parameters =
"autopilotIp": "192.168.27.1", "autopilotIp": "192.168.27.1",
"autopilotPort": 7909, "autopilotPort": 7909,
"debug": false, "debug": false,
"droneGuidList": [], "droneList": [],
"droneNetIf": "eth0",
"operatorScript": "https://lab.nexedi.com/nexedi/flight-scripts/-/raw/v2.3/operator.js", "operatorScript": "https://lab.nexedi.com/nexedi/flight-scripts/-/raw/v2.3/operator.js",
"mapJson": "https://lab.nexedi.com/nexedi/flight-scripts/-/raw/v2.3/map.json", "mapJson": "https://lab.nexedi.com/nexedi/flight-scripts/-/raw/v2.3/map.json",
"flightScript": "https://lab.nexedi.com/nexedi/flight-scripts/-/raw/v2.3/default.js", "flightScript": "https://lab.nexedi.com/nexedi/flight-scripts/-/raw/v2.3/default.js",
"subscriptionScript": "https://lab.nexedi.com/nexedi/flight-scripts/-/raw/v2.3/subscribe.js", "subscriptionScript": "https://lab.nexedi.com/nexedi/flight-scripts/-/raw/v2.3/subscribe.js",
"loopPeriod": 200, "loopPeriod": 200,
"multicastIp": "ff15::1111", "multicastIp": "ff15::1111",
"subscriberGuidList":[], "subscriberList":[]
"subscriberNetIf": "eth0"
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment