Skip to content
Snippets Groups Projects
Commit 53549e20 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- added permanent-volume to init

parent fce12d56
Branches
Tags
No related merge requests found
......@@ -51,7 +51,7 @@ BEGIN {
sub common_global_validate {
my ($self, $opt, $args) = @_;
foreach my $override (qw(elasticsearch_host elasticsearch_port http_only)) {
foreach my $override (qw(elasticsearch_host elasticsearch_port http_only permanent-volume)) {
if (
(exists $opt->{$override})
and ($config{$override} ne $opt->{$override})
......@@ -77,6 +77,7 @@ sub common_global_opt_spec {
[ "elasticsearch-host|e=s" => "host adress where Archivematica's ElasticSearch runs, overrides config value (command 'init')" ],
[ "elasticsearch-port|E=s" => "port of Archivematica's ElasticSearch, overrides config value (command 'init')", {default => 9200} ],
[ "http-only" => "use HTTP instead HTTPS, overrides config value (command 'init')"],
[ "permanent-volume|P=s@" => "path[s] to volume where Archivematica stores AIPs permanently, overrides config value (command 'init'), repeatable)"],
#[ "logdir|l=s" => "logdir where Archivematica stores it server log files"],
);
}
......
......@@ -16,15 +16,17 @@ sub description { return "Initialize $0, preparing config file using given optio
sub opt_spec {
my @global_opts= grep {
defined $_->[0]
and $_->[0] !~ m/^(elasticsearch-(host|port))|(http-only)/;
and $_->[0] !~ m/^(elasticsearch-(host|port))|(http-only)|(permanent-volume)/;
} SLUB::LZA::TA::common_global_opt_spec();
my @local_opts = (
[ "elasticsearch-host|e=s" => "host adress of Archivematica's ElasticSearch (mandatory)" ],
[ "elasticsearch-port|E=s" => "port of Archivematica's ElasticSearch", { default => 9200 } ],
[ "http-only" => "use HTTP instead HTTPS" ],
[ "permanent-volume|P=s@" => "path[s] to volume where Archivematica stores AIPs permanently (mandatory, repeatable)"],
);
return (@global_opts, [], @local_opts);
}
sub validate_args {
my ($self, $opt, $args) = @_;
# no args allowed but options!
......@@ -33,6 +35,13 @@ sub validate_args {
!exists($opt->{elasticsearch_host})
and !exists($opt->{help})
);
$self->usage_error("Missed mandatory parameter '--permanent-volume'") if (
!exists($opt->{permanent_volume})
and !exists($opt->{help})
);
foreach my $vol (@{ $opt->{permanent_volume} }) {
$self->usage_error("Parameter '--permanent-volume' expects an existing dir, got '$vol'!") unless -d $vol;
}
return 1;
}
......@@ -43,6 +52,7 @@ sub execute {
$config{elasticsearch_port} = $opt->{elasticsearch_port};
#$config{logdir} = $opt->{logdir};
$config{http_only} = $opt->{http_only};
$config{permanent_volume} = $opt->{permanent_volume};
my $in_test = $ENV{TEST_ACTIVE};
# next lines to fake interactive for testing
local *IO::Prompt::Tiny::_is_interactive = *IO::Prompt::Tiny::_is_interactive;
......
......@@ -26,6 +26,7 @@ sub is_testhost_available {
my $config_file;
my $cache_dir;
my $cache_file;
my @permanent_volumes;
sub testapp {
# contains common code for tests under t/
my $perl = $^X;
......@@ -44,6 +45,12 @@ sub is_testhost_available {
$cache_file = $cache_dir->child('ta-tool.cache');
my $testhost = testhost();
my $testport = testport();
my $permanent_path = path($testapp->workpath)->child('permanent');
$permanent_path->mkpath();
@permanent_volumes = map { $permanent_path->child($_); } qw(foo bar);
foreach $vol (@permanent_volumes) {
$vol->mkpath();
}
$config_file->spew_utf8(<<_CFG_);
---
elasticsearch_host: $testhost
......@@ -51,6 +58,7 @@ elasticsearch_port: $testport
http_only: 1
logdir: /tmp
password: 839852bed005a7f1237578a6ac1197c142f7d0dd58bb248446dc7849d4bf770902e7f980ad83d39008ad638bc41e2345
permanent_volumes:
user: lza
_CFG_
return $testapp;
......
......@@ -14,6 +14,8 @@ my $testhost = Test::TA::testhost();
my $cache_dir = path($testapp->workpath())->child('.cache');
$cache_dir->mkpath();
my $cache_file = $cache_dir->child('ta-tool.cache');
my $permanent_path = path($testapp->workpath)->child('permanent');
my @permanent_volumes = map { $permanent_path->child($_); } qw(foo bar);
# tests
use_ok("SLUB::LZA::TA::Crypt");
......@@ -41,7 +43,7 @@ lza
199fc76b9d086d8937976634e93413bcd005d941
199fc76b9d086d8937976634e93413bcd005d941
_EOF_
args => 'init -D -v -e ' . $testhost,
args => 'init -D -v -e ' . $testhost .join("", map {" -P $_"} @permanent_volumes),
#args => 'init -e sdvlzaamtestfotothek01.slub-dresden.de -l /tmp',
);
#say "STDOUT:",$testapp->stdout;
......@@ -57,6 +59,9 @@ elasticsearch_host: $testhost
elasticsearch_port: 9200
http_only: ~
password: 839852bed005a7f1237578a6ac1197c142f7d0dd58bb248446dc7849d4bf770902e7f980ad83d39008ad638bc41e2345
permanent_volume:
- $permanent_volumes[0]
- $permanent_volumes[1]
user: lza
_EXP_
my $cache = $cache_file->slurp_utf8();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment