How to configure or address all resources within a defined group, and use simple substitutions¶
1. Prerequisites¶
- Make sure that you understand how OMF works from a user's point of view.
- Make sure that you have completed and understood the basic "Hello World" tutorial.
2. Goal¶
- This tutorial shows you:
- how to configure or address all the resources in one specific group or all the groups defined in your experiment
- how to use the basic substitution feature of OMF
3. Scenario¶
- Here we are using the same simple scenario as in the basic "Hello World" tutorial.
- We will modify this example, to allow us to:
- configure the 1st wireless interface of all the resources in all the groups in a unique block of command
- address all the resource in a specific group with a given request, e.g. start all applications.
4. The New "Hello World" Experiment Description¶
The Experiment Description (ED) describing this simple experiment is (download it here: using-groups.rb):
1 defGroup('Sender', "omf.nicta.node2") do |node|
2 node.addApplication("test:app:otg2") do |app|
3 app.setProperty('udp:local_host', '%net.w0.ip%')
4 app.setProperty('udp:dst_host', '192.168.255.255')
5 app.setProperty('udp:broadcast', 1)
6 app.setProperty('udp:dst_port', 3000)
7 app.measure('udp_out', :samples => 1)
8 end
9 end
10
11 defGroup('Receiver', "omf.nicta.node3") do |node|
12 node.addApplication("test:app:otr2") do |app|
13 app.setProperty('udp:local_host', '192.168.255.255')
14 app.setProperty('udp:local_port', 3000)
15 app.measure('udp_in', :samples => 1)
16 end
17 end
18
19 allGroups.net.w0 do |interface|
20 interface.mode = "adhoc"
21 interface.type = 'g'
22 interface.channel = "6"
23 interface.essid = "helloworld"
24 interface.ip = "192.168.0.%index%"
25 end
26
27 onEvent(:ALL_UP_AND_INSTALLED) do |event|
28 wait 10
29 group("Receiver").startApplications
30 wait 5
31 group("Sender").startApplications
32 wait 30
33 group("Sender").stopApplications
34 wait 5
35 group("Receiver").stopApplications
36 Experiment.done
37 end
The Experiment Description (ED) describing this simple experiment is (download it here: using-groups.rb):
- Line 19-25: we use the
allGroupscommand to configure some parameters on all the nodes in all the groups- Line 19:
allGroupsis followed by a Resource Pathnet.w0, which specify a network interface resource (net), and more specifically the 1st wireless one (w0). In the following block (line 20-24), thisnet.w0network resource is known asinterface. - Line 20: configure the
modeparameter of theinterfaceto the value "adhoc". This would have been equivalent to thenet.w0.mode = "adhoc"line used in the Hello World tutorial - Line 24: uses OMF's substitution feature to configure the
ipparameter of theinterface:- Here the value is set to
"192.168.0%index%" - OMF assign a unique integer value to each resource, i.e. an index
- When OMF sees
%index%, for each node in all the groups it will substitute the%index%string by the node's index value - For example, on a resource which as the index 3, the value
"192.168.0.%index%"will be replaced by"192.168.0.3" - The following substitution strings are valid in OMF 5.3:
%index%- replaced by the resource's unique index%hostname%- replaced by the resource's hostname, if any%net.w0.ip%- replaced by the value of the resource's parameternet.w0.ip%net.XX.YYY%- replaced by the value of the resource's parameternet.XX.YYY
- Note: This substitution is done locally at the Resource Controller running on the resource.
- Here the value is set to
- Line 19:
- Line 3: we configure one parameter of the application OTG2 using the substitution
net.w0.ip- On each resource in the group
Sender, the application OTG2 will have itsudp:local_hostparameter set to the IP address of the 1sst wireless interface
- On each resource in the group
- Line 29, 31, 33, 35: we use the
groupcommand to address a specific group- Line 29: we send the request
startApplicationsonly to the resources which are in the specific group "Receiver". This is different from what we did in the Hello World tutorial. - We do the same for different request with different groups in the remaining lines
- Line 29: we send the request
- Another example of the these features is:
group('Sender').net.w0.channel = 11- which assign the value 11 to the channel parameter of the 1st wireless interface of all the resources in the group
Sender
- Finally... Please refer to the basic "Hello World" tutorial if you do not understand the remaining lines of the above ED.
5. Running the experiment & using the results¶
Running this experiment and accessing/using its results are exactly similar as running the "Hello World" tutorial and accessing/using its results. Thus, please refer to the "Hello World" tutorial.
6. What is Next?¶
Now that you know how to configure/address groups of resources, you may want to read the following basic OMF tutorials. Each one of them is introducing an OMF feature, using the simple "Hello World" experiment as a base. You do not need to follow them in the order suggested below.
And finally, a "Conference Room" scenario which combines all of the above features: