App-MBUtiny

 view release on metacpan or  search on metacpan

lib/App/MBUtiny/Storage/Command.pm  view on Meta::CPAN

package App::MBUtiny::Storage::Command; # $Id: Command.pm 121 2019-07-01 19:51:50Z abalama $
use strict;
use utf8;

=encoding utf-8

=head1 NAME

App::MBUtiny::Storage::Command - App::MBUtiny::Storage subclass for Command storage support

=head1 VIRSION

Version 1.00

=head1 SYNOPSIS

  <Host "foo">
    <Command>
        #FixUP   on
        test    "test -d ./foo  && ls -1 ./foo || mkdir ./foo"
        put     "cp [FILE] ./foo/[NAME]"
        get     "cp ./foo/[NAME] [FILE]"
        del     "test -e ./foo/[NAME] && unlink ./foo/[NAME] || true"
        list    "ls -1 ./foo"
        comment Command storage said blah-blah-blah # Optional for collector
    </Command>

    # . . .

  </Host>

=head1 DESCRIPTION

App::MBUtiny::Storage subclass for Command storage support

=head2 del

Removes the specified file.
This is backend method of L<App::MBUtiny::Storage/del>

Variables: B<PATH>, B<HOST>, B<NAME>

=head2 get

Gets the backup file from storage and saves it to specified path.
This is backend method of L<App::MBUtiny::Storage/get>

Variables: B<PATH>, B<HOST>, B<NAME>, B<FILE>

=head2 init

The method performs initialization of storage.
This is backend method of L<App::MBUtiny::Storage/init>

=head2 list

Gets backup file list on storage.
This is backend method of L<App::MBUtiny::Storage/list>

Variables: B<PATH>, B<HOST>

=head2 cmd_storages

    my @list = $storage->cmd_storages;

Returns list of command storage nodes

=head2 put

Sends backup file to storage.
This is backend method of L<App::MBUtiny::Storage/put>

Variables: B<PATH>, B<HOST>, B<SIZE>, B<NAME>, B<FILE>

=head2 test

Storage testing.
This is backend method of L<App::MBUtiny::Storage/test>

Variables: B<PATH>, B<HOST>

=head1 VARIABLES

=over 4

=item B<FILE>

Full file path of backup file

For example:

    /tmp/mbutiny/files/foo-2019-06-20.tar.gz

=item B<HOST>

MBUtiny host name

For example:

    foo

=item B<NAME>

File name of backup file

For example:

    foo-2019-06-20.tar.gz

=item B<PATH>

Path to backup files

For example:

    /tmp/mbutiny/files

=item B<SIZE>

Size of backup file (bytes)

For example:

    32423

=back

=head1 HISTORY

See C<Changes> file

=head1 TO DO

See C<TODO> file

=head1 BUGS

* none noted

=head1 SEE ALSO

L<App::MBUtiny::Storage>

=head1 AUTHOR

Serż Minus (Sergey Lepenkov) L<http://www.serzik.com> E<lt>abalama@cpan.orgE<gt>

=head1 COPYRIGHT

Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved

=head1 LICENSE

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

See C<LICENSE> file and L<https://dev.perl.org/licenses/>

=cut

use vars qw/ $VERSION /;
$VERSION = '1.00';

use Storable qw/dclone/;
use List::Util qw/uniq/;
use CTK::Util qw/dformat trim execute/;
use CTK::ConfGenUtil;
use CTK::TFVals qw/ :ALL /;
use App::MBUtiny::Util qw/ node2anode /;

use constant {
        STORAGE_SIGN => 'Command',
    };

sub init {
    my $self = shift;
    $self->maybe::next::method();
    $self->storage_status(STORAGE_SIGN, -1);
    my $usecmd = 0;



( run in 0.854 second using v1.01-cache-2.11-cpan-39bf76dae61 )