Umm,

Any taker for  this?

Marco

________________________________
From: help-cfengine-boun...@cfengine.org 
[mailto:help-cfengine-boun...@cfengine.org] On Behalf Of Lebel, Marco
Sent: Friday, June 18, 2010 8:56 AM
To: help-cfengine@cfengine.org
Subject: List expander and array --- cfengine 3.0.5

Hello all,

Since the advent of V3 I have been fighting with the list expander and array.  
So I have created a water down version of a script that I thought, base on my 
understanding, would work and I found myself having to come up with a work 
around to what I believe to be a bug.  According to my understanding all six 
test cases should work and I would of prefer the first one... but hey it does 
not!!!!.  So can someone here validate that all six cases should work but only 
the last one actually does.  Of course if my understanding is wrong please let 
me know why the first five cases are not working.

So here is the water down version with six test cases (case_1.....)  each test 
case can be run using cf-agent -K -D case_1.... Assuming you have a server name 
madrid and a server name london and that you run the script on server madrid 
;-).

body common control
{
version      => "1.0.0";

bundlesequence  => { "do_main" };
}

bundle common main
{
vars:
   "export"     string  => "/corp/export",
                comment => "Directory for data producer to store their data 
files that are to be exported";

   "import"     string  => "/corp/import",
                comment => "Directory for data warehouse to store imported data 
files from data producer server";
case_1::
   "tier1_clients[madrid]"      slist => { "madrid", "london" };
   "tier1_list"                 slist => getindices("tier1_clients");

case_2::
   "tier1_clients_madrid"       slist => { "madrid", "london" };
   "tier1_list"                 slist => { "madrid" };

case_3::
   "tier1_clients"      slist => { "madrid", "london" };
   "tier1_list"         slist => { "madrid" };

classes:
case_1|case_2|case_3::
   "tier1_warehouse"            or => { @(tier1_list) };
   "data_warehouse"             or => { "tier1_warehouse" };

case_4|case_5|case_6::
   "tier1_warehouse"            or => { "madrid" };
   "data_warehouse"             or => { "tier1_warehouse" };
}

bundle agent do_main
{
methods:
   data_warehouse::
      "import"  usebundle => do_data_import;
}

bundle agent do_data_import
{
vars:
case_4::
   "tier1_clients[madrid]"      slist => { "madrid", "london" };
   "tier1_list"                 slist => getindices("tier1_clients");

case_5::
   "tier1_clients_madrid"       slist => { "madrid", "london" };
   "tier1_list"                 slist => { "madrid" };

case_6::
   "tier1_clients"      slist => { "madrid", "london" };
   "tier1_list"         slist => { "madrid" };

files:
   tier1_warehouse.case_1::
      "$(main.import)"
         comment             => "Remote copy files from the export directory of 
remote servers into the import directory of tier 1 warehouse",
         depth_search        => recurse("inf"),
         file_select         => include(".*"),
         action              => immediate,
         copy_from           => rcp("$(main.export)", 
"$(main.tier1_clients[$(sys.uqhost)])");

   tier1_warehouse.case_2::
      "$(main.import)"
         comment             => "Remote copy files from the export directory of 
remote servers into the import directory of tier 1 warehouse",
         depth_search        => recurse("inf"),
         file_select         => include(".*"),
         action              => immediate,
         copy_from           => rcp("$(main.export)", 
"$(main.tier1_clients_$(sys.uqhost))");

   tier1_warehouse.case_3::
      "$(main.import)"
         comment             => "Remote copy files from the export directory of 
remote servers into the import directory of tier 1 warehouse",
         depth_search        => recurse("inf"),
         file_select         => include(".*"),
         action              => immediate,
         copy_from           => rcp("$(main.export)", "$(main.tier1_clients)");

   tier1_warehouse.case_4::
      "$(main.import)"
         comment             => "Remote copy files from the export directory of 
remote servers into the import directory of tier 1 warehouse",
         depth_search        => recurse("inf"),
         file_select         => include(".*"),
         action              => immediate,
         copy_from           => rcp("$(main.export)", 
"$(tier1_clients[$(sys.uqhost)])");

   tier1_warehouse.case_5::
      "$(main.import)"
         comment             => "Remote copy files from the export directory of 
remote servers into the import directory of tier 1 warehouse",
         depth_search        => recurse("inf"),
         file_select         => include(".*"),
         action              => immediate,
         copy_from           => rcp("$(main.export)", 
"$(tier1_clients_$(sys.uqhost))");

   tier1_warehouse.case_6::
      "$(main.import)"
         comment             => "Remote copy files from the export directory of 
remote servers into the import directory of tier 1 warehouse",
         depth_search        => recurse("inf"),
         file_select         => include(".*"),
         action              => immediate,
         copy_from           => rcp("$(main.export)", "$(tier1_clients)");
}

body depth_search recurse(d)
{
   depth => "$(d)";
}

body file_select include(name)
{
   leaf_name  => { "$(name)"};
   file_result => "leaf_name";
}

body action immediate
{
   ifelapsed    => "1";
}

body copy_from rcp(from,server)
{
   servers      => { "$(server)" };
   source       => "$(from)";
   compare      => "hash";
   copy_backup  => "false";
   trustkey     => "true";
}

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to