How to configure or address all resources within a defined group, and use simple substitutions

1. Prerequisites

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

  • 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 allGroups command to configure some parameters on all the nodes in all the groups
    • Line 19: allGroups is followed by a Resource Path net.w0, which specify a network interface resource (net), and more specifically the 1st wireless one (w0). In the following block (line 20-24), this net.w0 network resource is known as interface.
    • Line 20: configure the mode parameter of the interface to the value "adhoc". This would have been equivalent to the net.w0.mode = "adhoc" line used in the Hello World tutorial
    • Line 24: uses OMF's substitution feature to configure the ip parameter of the interface:
      • 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 parameter net.w0.ip
        • %net.XX.YYY% - replaced by the value of the resource's parameter net.XX.YYY
      • Note: This substitution is done locally at the Resource Controller running on the resource.
  • 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 its udp:local_host parameter set to the IP address of the 1sst wireless interface
  • Line 29, 31, 33, 35: we use the group command to address a specific group
    • Line 29: we send the request startApplications only 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
  • 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

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:


using-groups.rb (1021 Bytes) Thierry Rakotoarivelo, 10/09/2010 03:14 pm