Changeset 974:8db9610c2999 in repository


Ignore:
Timestamp:
Sep 17, 2018, 5:39:24 PM (6 months ago)
Author:
GomoR <gomor@…>
Branch:
default
Message:
  • new: client::elasticsearch: list_index_readonly Command
  • bugfix: client::elasticsearch: correctly reset readonly indices on reset_index_readonly Command
  • new: system::virtualbox: register Command
Location:
lib/Metabrik
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/Metabrik/Client/Elasticsearch.pm

    r972 r974  
    115115         put_settings => [ qw(settings_hash index|indices_list|OPTIONAL) ],
    116116         set_index_readonly => [ qw(index|indices_list boolean|OPTIONAL) ],
    117          reset_index_readonly => [ qw(index|indices_list) ],
     117         reset_index_readonly => [ qw(index|indices_list|OPTIONAL) ],
     118         list_index_readonly => [ ],
    118119         set_index_number_of_replicas => [ qw(index|indices_list number) ],
    119120         set_index_refresh_interval => [ qw(index|indices_list number) ],
     
    21122113#}
    21132114#
     2115#
     2116# If it fails with the following error:
     2117#
     2118# [2018-09-12T13:38:40,012][INFO ][logstash.outputs.elasticsearch] retrying failed action with response code: 403 ({"type"=>"cluster_block_exception", "reason"=>"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"})
     2119#
     2120# Use Kibana dev console and copy/paste both requests:
     2121#
     2122# PUT _settings
     2123# {
     2124#    "index": {
     2125#       "blocks": {
     2126#          "read_only_allow_delete": "false"
     2127#       }
     2128#    }
     2129# }
     2130#   
     2131# PUT your_index/_settings
     2132# {
     2133#    "index": {
     2134#       "blocks": {
     2135#          "read_only_allow_delete": "false"
     2136#       }
     2137#    }
     2138# }
     2139#
    21142140sub reset_index_readonly {
    21152141   my $self = shift;
    21162142   my ($indices) = @_;
    21172143
    2118    my $es = $self->_es;
    2119    $self->brik_help_run_undef_arg('open', $es) or return;
    2120    $self->brik_help_run_undef_arg('reset_index_readonly', $indices) or return;
     2144   $indices ||= '*';
     2145   my $es = $self->_es;
     2146   $self->brik_help_run_undef_arg('open', $es) or return;
    21212147   $self->brik_help_run_invalid_arg('reset_index_readonly', $indices, 'ARRAY', 'SCALAR')
    21222148      or return;
    21232149
    21242150   my $settings = {
    2125       'blocks.read_only_allow_delete' => undef,
    2126    };
    2127 
    2128    return $self->put_settings($settings, $indices);
     2151      'blocks.read_only_allow_delete' => 'false',
     2152   };
     2153
     2154   my $r = $self->put_settings($settings);
     2155   $self->log->info(Data::Dumper::Dumper($r));
     2156
     2157   $r = $self->put_settings($settings, $indices);
     2158   $self->log->info(Data::Dumper::Dumper($r));
     2159
     2160   return 1;
     2161}
     2162
     2163sub list_index_readonly {
     2164   my $self = shift;
     2165
     2166   my $es = $self->_es;
     2167   $self->brik_help_run_undef_arg('open', $es) or return;
     2168
     2169   my $list = $self->list_indices or return;
     2170
     2171   my @indices = ();
     2172   for my $this (@$list) {
     2173      my $ro = $self->get_index_readonly($this) or next;
     2174      if (defined($ro->{index}{provided_name})) {
     2175         push @indices, $ro->{index}{provided_name};
     2176      }
     2177   }
     2178
     2179   return \@indices;
    21292180}
    21302181
  • lib/Metabrik/System/Virtualbox.pm

    r969 r974  
    2929         command => [ qw(command) ],
    3030         list => [ ],
     31         register => [ qw(file_vbox) ],
    3132         start => [ qw(name type|OPTIONAL) ],
    3233         restore => [ qw(name type|OPTIONAL) ], # Alias for start
     
    8990}
    9091
     92sub register {
     93   my $self = shift;
     94   my ($vbox) = @_;
     95
     96   $self->brik_help_run_undef_arg('register', $vbox) or return;
     97   $self->brik_help_run_file_not_found('register', $vbox) or return;
     98
     99   if ($vbox !~ m{\.vbox$}) {
     100      return $self->log->error("register: give a .vbox file as input");
     101   }
     102
     103   return $self->command("registervm \"$vbox\"");
     104}
     105
    91106sub start {
    92107   my $self = shift;
Note: See TracChangeset for help on using the changeset viewer.