Can globally-defined arrays be accessed? Because if so, I can't figure
out how and I can't find any reference to this in the documentation.
Here's an example:
body common control {
bundlesequence => { "test" };
}
### Read in lines of the form KEY="VALUE" from the
### cache file into the global array "asset_cache"
bundle common g {
vars:
"asset_cache_file" string => "/var/tmp/.asset_data_cache.cf3";
"num_asset_cache_entries" int => readstringarray(
"asset_cache", "$(asset_cache_file)", "#[^\n]*", "=", 30,
3000
), comment => "Number of entries read in from asset cache
file.";
}
### Print out the contents of the global array
bundle agent test {
vars:
"at_fields" slist => getindices("$(g.asset_cache)"); ###### THIS
DOES NOT WORK
reports:
linux::
"Read $(g.num_asset_cache_entries) entries from
$(g.asset_cache_file)";
"Asset cache value: $(at_fields) =
$(g.asset_cache[$(at_fields)][1])";
}
This results in the following output:
R: Read 19 entries from /var/tmp/.asset_data_cache.cf3
R: Asset cache value: $(at_fields) = $(g.asset_cache[$(at_fields)][1])
I know you can't iterate over global LISTS and have to make local copies
to access their contents. So how, if possible, do you access global
arrays?
Thanks,
Justin
--
Justin C. Lloyd
Unix Infrastructure Engineer
DigitalGlobe, An Imaging and Information Company
This electronic communication and any attachments may contain confidential and
proprietary
information of DigitalGlobe, Inc. If you are not the intended recipient, or an
agent or employee
responsible for delivering this communication to the intended recipient, or if
you have received
this communication in error, please do not print, copy, retransmit, disseminate
or
otherwise use the information. Please indicate to the sender that you have
received this
communication in error, and delete the copy you received. DigitalGlobe reserves
the
right to monitor any electronic communication sent or received by its
employees, agents
or representatives.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine