= Quattor-specific Perl Namespaces = [[TracNav]] [[TOC(inline)]] == Current State == As of early 2009, the various Quattor tools use the following PERL namespaces for modules: ''EDG::WP4::CCM::'' The namespace used for accessing the locally installed configuration profile (whether it's for the local node, or downloaded in order to discover configuration of a foreign node). ''NCM::'' Utility libraries used by dispatcher components, and by the dispatcher itself. Under this namespace is a subnamespace "Components" - all quattor ncm components are accessed via this namespace. For example, NCM::Component::filecopy is the namespace used by the "filecopy" component. ''NCD::'' For the Node Configuration Dispatcher. Only used by the dispatcher itself. ''SPM::'' For SPMA. Note that the perl namespace is only "SPM" and not "SPMA". ''CAF::'' The Common Application Framework ''LC::'' Lionel Cons' utilities for interacting with the system with extra caution. Used/wrapped extensively by the CAF toolset. == Proposal == * All quattor specific modules should move to a new Quattor:: namespace. * The "CCM" acronym can be renamed as "Profile". * The NCM and NCD namespaces could be merged. * The CAF namespace should be merged into the Quattor toplevel namespace. In other words, "perl-CAF" package should become "perl-Quattor", since it provides the base libraries for driving Quattor. * The LC package should be included within CAF/perl-Quattor. An explicit fork of the LC codebase. This would give the following mapping: || '''From''' || '''To''' || '''Examples''' ||EDG::WP4::CCM:: || Quattor::Profile:: ||Quattor::Profile::Element, Quattor::Profile::CacheManager ||NCM:: || Quattor::Config:: ||Quattor::Config::Component::filecopy, Quattor::Config::Check::File ||NCD:: ||Quattor::Config:: ||Quattor::Config::ComponentProxy ||SPM:: ||Quattor::SPMA:: ||Quattor::SPMA::Package ||CAF:: || Quattor:: ||Quattor::Lock, Quattor::Log, Quattor::Process, Quattor::Reporter, etc. ||LC:: ||Quattor:: || Quattor::Check, Quattor::File, Quattor::Stat == Implementation Plan == This involves changing almost every bit of perl there is. === SPMA === This can be changed at any time. The library is purely used by the "spma" tool itself. === EDG::WP4::CCM, a.k.a. the 'ccm' tools === The EDG::WP4::CCM:: namespace is defined by the "ccm" package and consumed by "ncm-query", "ncm-ncd", "aii" and some of the components, therefore care must be taken in changing this namespace. Possibly the trampoline mechanism described below could be used. === Components === Significantly, every component places itself into the namespace with a header that says something along the lines of "package NCM::Component::@COMP@". Therefore, the dispatcher (ncm-ncd) needs to support *both* namespaces (with a priority ordering biased towards the new name). Since the namespace is only used within ncm-ncd, this means that ncm-ncd has to be changed first before any components. From that point on, components can change at whatever pace they want. == Namespace Compatibility Mechanism == You can make a compatability later by playing tricks like the following: {{{ package EDG::WP4::CCM::Element; use base 'Quattor::Legacy::Factory'; }}} Where the legacy factory looks like: {{{ package Quattor::Legacy::Factory; use Carp; our $mapping = { "EDG::WP4::CCM" => "Quattor::Profile", }; sub new { my ($class) = shift; if (ref $class) { return $class->SUPER::new(@_); } # find the best match in the mapping my $best = "" foreach my $maybe (%$mapping) { if ($class =~ /^$maybe/ && length($class) > $best) { $best = $maybe; } } if (!$best) { Carp::confess("legacy support requested for $class, which is unsupported"); } my $final = $mapping->{$best}; if ($class =~ /${best}::(.*)/)) { $final .= "::$1"; } print STDERR "WARNING: Quattor legacy code causing conversion of $class to $final\n"; eval "require $final"; if ($@) { Carp::confess("legacy support of $class failed: $@"); } $final->new(@_); } }}} === Concerns === Any code that uses the "isa()" method will need to be modified. The exception handling code within ncm-ncd might also need to change.