1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
############################################################
#
# Dominoes
#
# This method works with either Community of Enterprise
#
# If you want to test this on localhost, just edit /etc/hosts
# to add host1 host2 host3 host4 as aliases to localhost
#
############################################################
body common control
{
bundlesequence => { "dominoes_symphony" };
inputs => { "$(sys.libdir)/stdlib.cf" };
}
############################################################
bundle agent dominoes_symphony
{
methods:
# We have to seed the beginning by creating the dominoes
# /tmp/dominoes_localhost
host1::
"dominoes" usebundle => hand_over("localhost","host1","overture");
host2::
"dominoes" usebundle => hand_over("host1","host2","first_movement");
host3::
"dominoes" usebundle => hand_over("host2","host3","second_movement");
host4::
"dominoes" usebundle => hand_over("host3","host4","final_movement"),
classes => if_ok("finale");
reports:
finale::
"The visitors book of the Dominoes method"
printfile => visitors_book("/tmp/dominoes_host4");
}
############################################################
bundle agent hand_over(predecessor,myalias,method)
{
# This is a wrapper for the orchestration
files:
"/tmp/tip_the_dominoes"
comment => "Wait for our cue or relay/conductor baton",
copy_from => secure_cp("/tmp/dominoes_$(predecessor)","$(predecessor)"),
classes => if_repaired("cue_action");
methods:
cue_action::
"the music happens"
comment => "One off activity",
usebundle => $(method),
classes => if_ok("pass_the_stick");
files:
pass_the_stick::
"/tmp/tip_the_dominoes"
comment => "Add our signature to the dominoes's tail",
edit_line => append_if_no_line("Knocked over $(myalias) and did: $(method)");
"/tmp/dominoes_$(myalias)"
comment => "Dominoes in position to be beamed up by next agent",
copy_from => local_cp("/tmp/tip_the_dominoes");
}
############################################################
bundle agent overture
{
reports:
"Singing the overture...";
}
bundle agent first_movement
{
reports:
"Singing the first adagio...";
}
bundle agent second_movement
{
reports:
"Singing second allegro...";
}
bundle agent final_movement
{
reports:
"Trumpets for the finale";
}
############################################################
bundle server access_rules()
{
access:
"/tmp"
admit => { "127.0.0.1" };
"did.*"
resource_type => "context",
admit => { "127.0.0.1" };
}
body printfile visitors_book(file)
{
file_to_print => "$(file)";
number_of_lines => "10";
}
|