aboutsummaryrefslogtreecommitdiffstats
path: root/vespaclient
diff options
context:
space:
mode:
authorTor Egge <tegge@oath.com>2018-04-09 11:46:36 +0000
committerTor Egge <tegge@oath.com>2018-04-09 11:46:36 +0000
commit704435b261f20644a6169c607f21ef29a3f43ba1 (patch)
tree193daf5c40c5a3d4ccac78b7b35f0e18ef23c41e /vespaclient
parentf7f89419cc6e91045b520244e9cc128db647c04e (diff)
Adjust vespa-set-node-state to require cluster argument if more than
one cluster is present in model.
Diffstat (limited to 'vespaclient')
-rw-r--r--vespaclient/src/perl/lib/Yahoo/Vespa/Bin/SetNodeState.pm18
-rw-r--r--vespaclient/src/perl/lib/Yahoo/Vespa/ContentNodeSelection.pm4
2 files changed, 22 insertions, 0 deletions
diff --git a/vespaclient/src/perl/lib/Yahoo/Vespa/Bin/SetNodeState.pm b/vespaclient/src/perl/lib/Yahoo/Vespa/Bin/SetNodeState.pm
index 894ab7feca4..5461c50ee30 100644
--- a/vespaclient/src/perl/lib/Yahoo/Vespa/Bin/SetNodeState.pm
+++ b/vespaclient/src/perl/lib/Yahoo/Vespa/Bin/SetNodeState.pm
@@ -31,6 +31,7 @@ sub setNodeState { # (Command line arguments)
&handleCommandLine($argsref);
detectClusterController();
&showSettings();
+ &maybeRequireClusterSelection();
&execute();
}
@@ -78,6 +79,23 @@ sub showSettings { # ()
Yahoo::Vespa::ClusterController::showSettings();
}
+sub maybeRequireClusterSelection
+{
+ return if Yahoo::Vespa::ContentNodeSelection::hasClusterSelection();
+ my %clusters;
+ VespaModel::visitServices(sub {
+ my ($info) = @_;
+ if ($$info{'type'} =~ /^(?:distributor|storage|storagenode)$/ ) {
+ $clusters{$$info{'cluster'}} = 1;
+ }
+ });
+ my $clusterCount = scalar keys %clusters;
+ if ($clusterCount > 1) {
+ printWarning "More than one cluster is present but no cluster is selected\n";
+ exitApplication(1);
+ }
+}
+
# Sets the node state
sub execute { # ()
$success = 1;
diff --git a/vespaclient/src/perl/lib/Yahoo/Vespa/ContentNodeSelection.pm b/vespaclient/src/perl/lib/Yahoo/Vespa/ContentNodeSelection.pm
index d15fd4a75df..d23471c8910 100644
--- a/vespaclient/src/perl/lib/Yahoo/Vespa/ContentNodeSelection.pm
+++ b/vespaclient/src/perl/lib/Yahoo/Vespa/ContentNodeSelection.pm
@@ -127,6 +127,10 @@ sub validateCommandLineArguments { # (WantedState)
return 1;
}
+sub hasClusterSelection {
+ return defined $CLUSTER;
+}
+
############## Utility functions - Not intended for external use #############
sub validType { # (ServiceType) -> Bool