As part of porting the LCFG client to the new core libraries the qxprof and sxprof utilities have been updated. This has led to the development of a new high-level LCFG::Client::Resources
Perl library which can be used to import, merge and export resources in all the various required forms. The intention is that eventually all code which uses the LCFG::Resources
Perl library (in particular the LCFG::Component
framework) will be updated to use this new library. The new library provides a very similar set of functionality and will appear familiar but I’ve taken the opportunity to improve some of the more awkward parts. Here’s a simple example taken from the perldoc:
# Load client resources from DB my $res1 = LCFG::Client::Resources::LoadProfile("mynode","client"); # Import client resources from environment variables my $res2 = LCFG::Client::Resources::Import("client"); # Merge two sets of resources my $res3 = LCFG::Client::Resources::Merge( $res1, $res2 ); # Save the result as a status file LCFG::Client::Resources::SaveState( "client", $res3 );
The library can import resources from: Berkeley DB, status files, override files, shell environment and explicit resource specification strings. It can export resources as status files, in a form that can be evaluated in the shell environment and also in various terse and verbose forms (e.g. the output styles for qxprof).
The LCFG::Resources
library provides access to resources via a reference to a hash which is structured something like:
{ 'sysinfo' => { 'os_id_full' => { 'DERIVE' => '/var/lcfg/conf/server/releases/develop/core/include/lcfg/defaults/sysinfo.h:42', 'VALUE' => 'sl74', 'TYPE' => undef, 'CONTEXT' => undef }, 'path_lcfgconf' => { 'DERIVE' => '/var/lcfg/conf/server/releases/develop/core/include/lcfg/defaults/sysinfo.h:100', 'VALUE' => '/var/lcfg/conf', 'TYPE' => undef, 'CONTEXT' => undef }, } }
The top level key is the component name, the second level is the resource name and the third level is the name of the resource attribute (e.g. VALUE
or TYPE
).
The new LCFG::Client::Resources
library takes a similar approach with the top level key being the component name but the value for that key is a reference to a LCFG::Profile::Component
object. Resource objects can then be accessed by using the find_resource
method which returns a reference to a LCFG::Resource
object. For example:
my $res = LCFG::Client::Resources::LoadProfile("mynode","sysinfo"); my $sysinfo = $res->{sysinfo}; my $os_id_full = $sysinfo->find_resource('os_id_full'); say $os_id_full->value;
Users of the qxprof
and sxprof
utilities should not notice any differences but hopefully the changes will be appreciated by those developing new code.