defGroup¶
Define a group of resource to use
This command defines a set of resources (i.e. a group), which can then be used in an experiment. An experiment can contain multiple group declarations, and a given resource (e.g. a node) can belong to multiple groups within the same experiment. Furthermore, a group can be defined as a collection of other already defined groups.
Syntax¶
defGroup( groupName, selector, &block = nil )
where:
- groupName: name of the defined set of resources. This is a simple string that is used throughout the Experiment Description to refer to this set of resources.
- selector : selects the resources to be contained in this set. A selector can have the following forms:
- topology : the URI of a previously defined topology (see defTopology)
- [x,y] : Describes a single resource at location x@y
- [x1..x2, y] : Describes a set of resources along a line starting at x1@y and ending at x2@y. For instance, [2..4, 5] defines the resources [2,5], [3,5], [4,5].
- [x, y1..y2] : Same as previous, but for the y coordinate.
- [x1..x2, y1..y2] : This defines a rectangle area of resources within the grid.
- [[x1,y1], [x2,y2], ...] : An arbitrary list of single resources. Any entry in this list can also use any of the above defined syntax.
- ['anotherGroup']: Includes in this group all the resources within the previously defined group called 'anotherGroup'.
- ['agroup', 'anotherGroup', ...] : An arbitrary list of existing groups. All the resources in these groups will be included in this group.
- block: instructions for all resources in the group. The optional 'block' enables you to configure all the resources in the group as a single entity. The following sub-commands can be used inside this optional block:
| Sub-Commands defined for a defGroup's block | Description |
|---|---|
| addApplication | Associate a defined application to the resources/nodes in this group. |
| prototype | Associate a defined prototype to the resources/nodes in this group. |
| exec | Execute a given command on all the nodes in this group. |
| Resource Paths | Call this Resource Path on all the nodes within this group. A Resource Path allows the configuration of specific parameters of the node in this group (e.g. their IP addresses, etc...). Refer to the Resource Path section for more details on available Resource Paths. |
| image | Check whether the nodes in this group boots in the required image (obsolete - removed from latest releases). |
| pxeImage | Instructs the nodes in this group to boot from a network PXE image (not documented - only for development). |
Usage Examples¶
Example 1¶
Some simple usages of defGroup
1
2 # Define a group called 'sender' that contains 1 specific node
3 # Then define a group called 'receivers' that includes 2 specific nodes
4 #
5 defGroup('sender', [1,1])
6 defGroup('receivers', [ [1,2], [1,3] ])
7
8 # Define a group called 'others' that contains 8 nodes: [2,4], [2,5], ... [2,11]
9 #
10 defGroup('others', [2, 4..11])
11
12 # Define a group called 'relays' that contains all the nodes in the
13 # previously defined 'receivers' group
14 #
15 defGroup('relays', ['receivers'])
16
17 # Define a group called 'workers' that contains all the nodes in the
18 # previously defined 'sender' and 'receivers' group
19 #
20 defGroup('workers', ['sender', 'receivers'])
21
Example 2¶
Using defGroup with a block of command containing Resource Paths, which will configure parameters of the nodes in this group.
Please refer to the Resource Path section for more details on available Resource Paths.
1
2 # Define a 'receivers' group with two nodes (i.e. [1,1] and [1,5]) having wifi cards
3 # Then configure the 1st wifi interface of these nodes
4 # (e.g. put the interface in ad-hoc mode, on channel 6, with essid 'test_network')
5 #
6 defGroup('receivers', [[1,1], [1,5]]) { |node|
7
8 node.net.w0.mode = "adhoc"
9 node.net.w0.channel = "6"
10 node.net.w0.essid = "test_network"
11
12 }
13
14 # Define a 'relays' group with four nodes (i.e. [9,1] to [9,4]).
15 # Then add a new IP route which will be associaged to their 2nd fixed ethernet interface
16 # This is equivalent to running the following route command on the nodes:
17 # 'route add -net 10.42.0.0 gw 10.40.0.20 netmask 255.255.0.0 dev eth1'
18 #
19 defGroup('relays', [9,1..4]) { |node|
20
21 node.net.e1.route({:op => 'add',
22 :net => '10.42.0.0',
23 :gw => '10.40.0.20',
24 :mask => '255.255.0.0'})
25
26 }
Example 3¶
Using defGroup with a block of command, which associates an application to all the nodes in this group.
Please refer to the addApplication description page for more details on its syntax. Also please refer to the How-To run Application on nodes tutorial, for another usage example.
1
2 # Define 'lsApp' which is a simple OMF application to interface with the
3 # exiting '/bin/ls' application
4 #
5 defApplication('lsWrapper', 'lsApp') {|app|
6
7 app.shortDescription = "This is a simple application listing the content of the /tmp directory"
8 app.path="/bin/ls -l /tmp"
9
10 }
11
12 # Define a 'workers' group with two nodes (i.e. [3,1] and [2,5])
13 # Then associate the above 'lsApp' with the nodes in this group.
14 #
15 defGroup('receivers', [[3,1], [2,5]]) { |node|
16
17 node.addApplication('lsWrapper', 'lsApp', nil, nil)
18
19 }
20
Example 4¶
Using defGroup with a block of command, which associates a prototype to all the nodes in this group.
Please refer to the prototype and the DefPrototype description pages for more details on its syntax. Also please refer to the How-To associate Prototypes on nodes tutorial, and to the "Hello World" tutorial for other usage examples.
1
2 # Define 'echoApp' which is a simple OMF application to interface with the
3 # exiting '/bin/echo' application.
4 # Also define the 'txt' property for this application, which is an interface
5 # to the command line argument of '/bin/echo'
6 # (Refer to the defApplication description page for more detail on the syntax)
7 #
8 defApplication('echoWrapper', 'echoApp') {|app|
9
10 app.shortDescription = "This is a simple application writing a message on standard-out"
11 app.path="/bin/echo"
12
13 app.defProperty("txt", "Message to print on standard-out", nil,
14 {:dynamic => false, :type => :string, :use_name => false})
15 }
16
17 # Define 'echo' which is a simple OMF prototype using the 'echoApp' application
18 # We also define a property named 'message' for this prototype, which we will
19 # bind to the 'txt' property of 'echoApp' (i.e. the command line argument of /bin/echo)
20 # Refer to the defPrototype description page for more detail on the syntax)
21 #
22 # Moreover, we give the default value "Hello there." to this 'message' property.
23 #
24 defPrototype("echo") { |proto|
25
26 proto.name = "echo" proto.description = "A simple prototype for writing messages on standard-out"
27
28 proto.defProperty('message', 'The message to display', "Hello there.")
29
30 proto.addApplication("echoApp", "echoWrapper") { |app|
31 app.bindProperty('txt', 'message')
32 }
33 }
34
35 # Define a 'english_man' group with one nodes (i.e. [1,1])
36 # Then associate the above 'echo' prototype with the node in this group.
37 #
38 defGroup('english_man', [1,1]) {|node|
39
40 node.prototype('echo')
41
42 }
43
44 # Define a 'aussie_man' group with one nodes (i.e. [1,2])
45 # Then associate the above 'echo' prototype with the node in this group.
46 # AND configure the 'echo' prototype with another value of message.
47 #
48 defGroup('aussie_man', [1,2]) {|node|
49
50 node.prototype('echo', { 'message' => 'Gday mate!' })
51
52 }
53