Skip to content

Commit

Permalink
Merge pull request #162 from stdweird/more_cleanup
Browse files Browse the repository at this point in the history
Cleanup: move internal modules in subdirectories and remove/integrate util scripts
  • Loading branch information
ned21 committed Mar 22, 2017
2 parents 2bacde7 + da555dd commit 4d4b1c0
Show file tree
Hide file tree
Showing 39 changed files with 1,823 additions and 1,931 deletions.
180 changes: 0 additions & 180 deletions Data/Compare.pm

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/conf/quattor-ccm
Expand Up @@ -136,7 +136,7 @@ _quattor_ccm_Options_options=(cfgfile cid component metaconfig profpath showcids

# sorted list of options for CCM::CLI based tools
# (except those already in _quattor_ccm_CCfg_options and _quattor_ccm_Options_options)
_quattor_ccm_CLI_options=(format show)
_quattor_ccm_CLI_options=(dumpdb format show)

# generate the longoptions
_quattor_ccm_CCfg_longoptions=`_quattor_ccm_make_long_options ${_quattor_ccm_CCfg_options[@]}`
Expand Down
61 changes: 61 additions & 0 deletions src/main/perl/CLI.pm
Expand Up @@ -2,12 +2,15 @@

use parent qw(EDG::WP4::CCM::Options);
use CAF::Object qw(SUCCESS);
use EDG::WP4::CCM::CacheManager::DB qw(read_db);
use EDG::WP4::CCM::CacheManager::Encode qw(encode_eids decode_eid $PATH2EID $EID2DATA @EIDS_PACK);
use EDG::WP4::CCM::TextRender qw(ccm_format @CCM_FORMATS);
use EDG::WP4::CCM::Path qw(set_safe_unescape reset_safe_unescape);
use Readonly;

Readonly::Hash my %CLI_ACTIONS => {
show => 'Print the tree starting from the selected path.',
dumpdb => 'Print path2eid and eid2path DBs.',
};

Readonly my $DEFAULT_ACTION => 'show';
Expand Down Expand Up @@ -117,6 +120,64 @@ sub action_show
return SUCCESS;
}


=item action_dumpdb
Lowlevel debugging function to dump the profile DBs
C<path2eid> and C<eid2data>.
=cut

sub action_dumpdb
{
my $self = shift;

my $cfg = $self->getCCMConfig();
return if (! defined($cfg));

my $prof_dir = $cfg->getConfigPath();

my (%path2eid, %eid2data);

foreach my $db ([$PATH2EID, \%path2eid],
[$EID2DATA, \%eid2data]) {
my $err = read_db($db->[1], "$prof_dir/$db->[0]");
if ($err) {
$self->error("could not read $prof_dir/$db->[0]: $err\n");
untie(%path2eid);
untie(%eid2data);
return;
}
};

$self->_print("$PATH2EID:\n");
foreach my $path (sort keys %path2eid) {
$self->_print("$path => ", sprintf("%x", decode_eid($path2eid{$path})), "\n");
}

$self->_print("$EID2DATA:\n");
foreach my $enc_eid (sort keys %eid2data) {
$self->_print(sprintf("%x", decode_eid($enc_eid)), " => ", $eid2data{$enc_eid}, "\n");
}

$self->_print("\n$PATH2EID and $EID2DATA combined:\n");
foreach my $path (sort keys %path2eid) {
my $eid = decode_eid($path2eid{$path});
my $eids = encode_eids($eid);

$self->_print("$path ($eid) =>\n");
foreach my $type (@EIDS_PACK) {
my $value = $eid2data{$eids->{$type}};
$self->_print(' ' x 2, substr($type, 0, 1), ": ", defined($value) ? $value : '<undef>', "\n");
};
}

untie(%path2eid);
untie(%eid2data);

return SUCCESS;
}

=pod
=back
Expand Down
8 changes: 4 additions & 4 deletions src/main/perl/CacheManager.pm
@@ -1,7 +1,7 @@
#${PMpre} EDG::WP4::CCM::CacheManager${PMpost}

use LC::Exception qw(SUCCESS throw_error);
use EDG::WP4::CCM::Configuration qw();
use EDG::WP4::CCM::CacheManager::Configuration qw();
use EDG::WP4::CCM::CCfg qw(initCfg getCfgValue);
use MIME::Base64 qw(encode_base64);
use parent qw(Exporter);
Expand Down Expand Up @@ -315,7 +315,7 @@ This method is deprecated in favour of C<getConfiguration>.
Returns unlocked Configuration object.
Unless the object is locked explicitly later by calling the C<lock> method,
C<CCM::Element>s will always be fetched from the current CID,
C<CCM::CacheManager::Element>s will always be fetched from the current CID,
not the CID passed via C<$cid>. (If the $cid parameter is omitted,
the most recently downloaded configuration (when the cache
was not globally locked) is returned.)
Expand Down Expand Up @@ -365,7 +365,7 @@ This method is deprecated in favour of C<getConfiguration>.
Returns unlocked anonymous Configuration object.
Unless the object is locked explicitly later by calling the C<lock> method,
C<CCM::Element>s will always be fetched from the current CID,
C<CCM::CacheManager::Element>s will always be fetched from the current CID,
not the CID passed via C<$cid>. (If the $cid parameter is omitted,
the most recently downloaded configuration (when the cache
was not globally locked) is returned.)
Expand Down Expand Up @@ -414,7 +414,7 @@ sub _getConfig

my $name_template = exists($opts{name_template}) ? $opts{name_template} : $self->{name_template};

my $cfg = EDG::WP4::CCM::Configuration->new($self, $cid, $lc, $anonymous, $name_template);
my $cfg = EDG::WP4::CCM::CacheManager::Configuration->new($self, $cid, $lc, $anonymous, $name_template);
unless (defined($cfg)) {
$ec->rethrow_error();
return ();
Expand Down

0 comments on commit 4d4b1c0

Please sign in to comment.