Initial boilerplate for implementing the upgrade cli.
Signed-off-by: Rabi Panda <adnapibar@gmail.com>
This commit is contained in:
parent
96e16c68d6
commit
3692d67c1e
|
@ -268,7 +268,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
|
|||
* Properties to expand when copying packaging files *
|
||||
*****************************************************************************/
|
||||
configurations {
|
||||
['libs', 'libsPluginCli', 'libsKeystoreCli', 'libsSecurityCli'].each {
|
||||
['libs', 'libsPluginCli', 'libsKeystoreCli', 'libsSecurityCli', 'libsUpgradeCli'].each {
|
||||
create(it) {
|
||||
canBeConsumed = false
|
||||
canBeResolved = true
|
||||
|
@ -289,6 +289,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
|
|||
|
||||
libsPluginCli project(':distribution:tools:plugin-cli')
|
||||
libsKeystoreCli project(path: ':distribution:tools:keystore-cli')
|
||||
libsUpgradeCli project(path: ':distribution:tools:upgrade-cli')
|
||||
}
|
||||
|
||||
project.ext {
|
||||
|
@ -306,6 +307,9 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
|
|||
into('tools/keystore-cli') {
|
||||
from(configurations.libsKeystoreCli)
|
||||
}
|
||||
into('tools/upgrade-cli') {
|
||||
from(configurations.libsUpgradeCli)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
OPENSEARCH_MAIN_CLASS=org.opensearch.upgrade.UpgradeCli \
|
||||
OPENSEARCH_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/upgrade-cli \
|
||||
"`dirname "$0"`"/opensearch-cli \
|
||||
"$@"
|
|
@ -0,0 +1,16 @@
|
|||
@echo off
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
setlocal enableextensions
|
||||
|
||||
set OPENSEARCH_MAIN_CLASS=org.opensearch.upgrade.UpgradeCli
|
||||
set OPENSEARCH_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/upgrade-cli
|
||||
call "%~dp0opensearch-cli.bat" ^
|
||||
%%* ^
|
||||
|| goto exit
|
||||
|
||||
|
||||
endlocal
|
||||
endlocal
|
||||
:exit
|
||||
exit /b %ERRORLEVEL%
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* The OpenSearch Contributors require contributions made to
|
||||
* this file be licensed under the Apache-2.0 license or a
|
||||
* compatible open source license.
|
||||
*
|
||||
*/
|
||||
|
||||
apply plugin: 'opensearch.build'
|
||||
|
||||
archivesBaseName = 'opensearch-upgrade-cli'
|
||||
|
||||
dependencies {
|
||||
compileOnly project(":server")
|
||||
compileOnly project(":libs:opensearch-cli")
|
||||
testImplementation project(":test:framework")
|
||||
testRuntimeOnly 'com.google.guava:guava:18.0'
|
||||
}
|
||||
|
||||
test {
|
||||
systemProperty 'tests.security.manager', 'false'
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* The OpenSearch Contributors require contributions made to
|
||||
* this file be licensed under the Apache-2.0 license or a
|
||||
* compatible open source license.
|
||||
*/
|
||||
|
||||
package org.opensearch.upgrade;
|
||||
|
||||
import org.opensearch.cli.LoggingAwareMultiCommand;
|
||||
import org.opensearch.cli.Terminal;
|
||||
|
||||
/**
|
||||
* CLI tool for upgrading from a supported Elasticsearch version to
|
||||
* an OpenSearch version.
|
||||
*
|
||||
* - It will autodetect the presence of a running ES server
|
||||
* - If the ES Server is not running, it will need the path to the ES installation.
|
||||
* - Copy the configurations across
|
||||
* - Shutdown the ES server (if running)
|
||||
* - Start the OpenSearch server
|
||||
*
|
||||
*/
|
||||
public class UpgradeCli extends LoggingAwareMultiCommand {
|
||||
public UpgradeCli() {
|
||||
super("A tool for migrating from a supported Elasticsearch version to an OpenSearch version");
|
||||
subcommands.put("upgrade", new UpgradeToOpenSearchCommand());
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
exit(new UpgradeCli().main(args, Terminal.DEFAULT));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* The OpenSearch Contributors require contributions made to
|
||||
* this file be licensed under the Apache-2.0 license or a
|
||||
* compatible open source license.
|
||||
*/
|
||||
|
||||
package org.opensearch.upgrade;
|
||||
|
||||
import joptsimple.OptionSet;
|
||||
import joptsimple.OptionSpec;
|
||||
import org.opensearch.cli.EnvironmentAwareCommand;
|
||||
import org.opensearch.cli.ExitCodes;
|
||||
import org.opensearch.cli.Terminal;
|
||||
import org.opensearch.cli.UserException;
|
||||
import org.opensearch.env.Environment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UpgradeToOpenSearchCommand extends EnvironmentAwareCommand {
|
||||
private final OptionSpec<String> arguments;
|
||||
public UpgradeToOpenSearchCommand() {
|
||||
super("Upgrade to OpenSearch", () -> {
|
||||
});
|
||||
arguments =parser.nonOptions("elasticsearch installation path");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void execute(Terminal terminal, OptionSet options, Environment env) throws Exception {
|
||||
final List<String> argumentValues = arguments.values(options);
|
||||
if (argumentValues.size() != 1) {
|
||||
throw new UserException(ExitCodes.USAGE, "Missing elasticsearch installation location");
|
||||
}
|
||||
terminal.println("Thanks! we're bringing this out soon!!");
|
||||
}
|
||||
|
||||
}
|
|
@ -55,6 +55,7 @@ List projects = [
|
|||
'distribution:tools:launchers',
|
||||
'distribution:tools:plugin-cli',
|
||||
'distribution:tools:keystore-cli',
|
||||
'distribution:tools:upgrade-cli',
|
||||
'server',
|
||||
'server:cli',
|
||||
'test:framework',
|
||||
|
|
Loading…
Reference in New Issue