Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alarm server command line options: Allow -export -import -config in any order #2268

Merged
merged 1 commit into from
May 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Oak Ridge National Laboratory.
* Copyright (c) 2018-2022 Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -554,6 +554,8 @@ public static void main(final String[] original_args) throws Exception
boolean use_args_server = false;
boolean use_args_config = false;
boolean use_settings = false;
String import_filename = null;
String export_filename = null;

// Handle arguments
final List<String> args = new ArrayList<>(List.of(original_args));
Expand Down Expand Up @@ -629,22 +631,16 @@ else if (cmd.equals("-import"))
if (! iter.hasNext())
throw new Exception("Missing -import file name");
iter.remove();
final String filename = iter.next();
import_filename = iter.next();
iter.remove();
logger.info("Import model from " + filename);
new AlarmConfigTool().importModel(filename, server, use_args_config ? args_config : config);
return;
}
else if (cmd.equals("-export"))
{
if (! iter.hasNext())
throw new Exception("Missing -export file name");
iter.remove();
final String filename = iter.next();
export_filename = iter.next();
iter.remove();
logger.info("Exporting model to " + filename);
new AlarmConfigTool().exportModel(filename, server, use_args_config ? args_config : config);
return;
}
else
throw new Exception("Unknown option " + cmd);
Expand All @@ -667,6 +663,22 @@ else if (cmd.equals("-export"))
config = args_config;
}

// Export or import requested?
// Actually allow _both_ export and import, first exporting
// so that existing config gets exported, then new one imported
if (export_filename != null)
{
logger.info("Exporting model to " + export_filename);
new AlarmConfigTool().exportModel(export_filename, server, use_args_config ? args_config : config);
}
if (import_filename != null)
{
logger.info("Import model from " + import_filename);
new AlarmConfigTool().importModel(import_filename, server, use_args_config ? args_config : config);
}
// Any export/import means we're done, not running alarm server
if (export_filename != null || import_filename != null)
return;
}
catch (final Exception ex)
{
Expand Down