aboutsummaryrefslogtreecommitdiff
path: root/lnt/util
diff options
context:
space:
mode:
Diffstat (limited to 'lnt/util')
-rw-r--r--lnt/util/ImportData.py31
-rw-r--r--lnt/util/ServerUtil.py24
2 files changed, 34 insertions, 21 deletions
diff --git a/lnt/util/ImportData.py b/lnt/util/ImportData.py
index aca7bfa..3088240 100644
--- a/lnt/util/ImportData.py
+++ b/lnt/util/ImportData.py
@@ -14,11 +14,13 @@ import time
def import_and_report(config, db_name, db, session, file, format, ts_name,
show_sample_count=False, disable_email=False,
- disable_report=False, updateMachine=False,
- mergeRun='replace'):
+ disable_report=False, select_machine='match',
+ merge_run='replace'):
"""
- import_and_report(config, db_name, db, file, format, ts_name,
- [show_sample_count], [disable_email]) -> ... object ...
+ import_and_report(config, db_name, db, session, file, format, ts_name,
+ [show_sample_count], [disable_email],
+ [disable_report], [select_machine], [merge_run])
+ -> ... object ...
Import a test data file into an LNT server and generate a test report. On
success, run is the newly imported run.
@@ -32,6 +34,10 @@ def import_and_report(config, db_name, db, session, file, format, ts_name,
'import_file': file,
}
+ if select_machine not in ('match', 'update', 'split'):
+ result['error'] = "select_machine must be 'match', 'update' or 'split'"
+ return result
+
ts = db.testsuite.get(ts_name, None)
if ts is None:
result['error'] = "Unknown test suite '%s'!" % ts_name
@@ -89,8 +95,8 @@ def import_and_report(config, db_name, db, session, file, format, ts_name,
return result
run = ts.importDataFromDict(session, data, config=db_config,
- updateMachine=updateMachine,
- mergeRun=mergeRun)
+ select_machine=select_machine,
+ merge_run=merge_run)
except KeyboardInterrupt:
raise
except Exception as e:
@@ -98,8 +104,9 @@ def import_and_report(config, db_name, db, session, file, format, ts_name,
result['error'] = "import failure: %s" % e.message
result['message'] = traceback.format_exc()
if isinstance(e, lnt.server.db.testsuitedb.MachineInfoChanged):
- result['message'] += '\n\nNote: Use --update-machine to update ' \
- 'the existing machine information.\n'
+ result['message'] += \
+ '\n\nNote: Use --select-machine=update to update ' \
+ 'the existing machine information.\n'
return result
# If the import succeeded, save the import path.
@@ -157,7 +164,9 @@ def import_and_report(config, db_name, db, session, file, format, ts_name,
shadow_db, shadow_session, file,
format, ts_name,
show_sample_count, disable_email,
- disable_report, updateMachine)
+ disable_report,
+ select_machine=select_machine,
+ merge_run=merge_run)
# Append the shadow result to the result.
result['shadow_result'] = shadow_result
@@ -304,7 +313,7 @@ def print_report_result(result, out, err, verbose=True):
def import_from_string(config, db_name, db, session, ts_name, data,
- updateMachine=False, mergeRun='replace'):
+ select_machine='match', merge_run='replace'):
# Stash a copy of the raw submission.
#
# To keep the temporary directory organized, we keep files in
@@ -333,5 +342,5 @@ def import_from_string(config, db_name, db, session, ts_name, data,
result = lnt.util.ImportData.import_and_report(
config, db_name, db, session, path, '<auto>', ts_name,
- updateMachine=updateMachine, mergeRun=mergeRun)
+ select_machine=select_machine, merge_run=merge_run)
return result
diff --git a/lnt/util/ServerUtil.py b/lnt/util/ServerUtil.py
index c41cf9d..270f781 100644
--- a/lnt/util/ServerUtil.py
+++ b/lnt/util/ServerUtil.py
@@ -29,13 +29,13 @@ def _show_json_error(reply):
sys.stderr.write(message + '\n')
-def submitFileToServer(url, file, updateMachine, mergeRun):
+def submitFileToServer(url, file, select_machine, merge_run):
with open(file, 'rb') as f:
values = {
'input_data': f.read(),
'commit': "1", # compatibility with old servers.
- 'update_machine': "1" if updateMachine else "0",
- 'merge': mergeRun,
+ 'select_machine': select_machine,
+ 'merge': merge_run,
}
headers = {'Accept': 'application/json'}
data = urllib.urlencode(values)
@@ -63,7 +63,8 @@ def submitFileToServer(url, file, updateMachine, mergeRun):
return reply
-def submitFileToInstance(path, file, updateMachine=False, mergeRun='replace'):
+def submitFileToInstance(path, file, select_machine='match',
+ merge_run='replace'):
# Otherwise, assume it is a local url and submit to the default database
# in the instance.
instance = lnt.server.instance.Instance.frompath(path)
@@ -75,22 +76,25 @@ def submitFileToInstance(path, file, updateMachine=False, mergeRun='replace'):
session = db.make_session()
return lnt.util.ImportData.import_and_report(
config, db_name, db, session, file, format='<auto>', ts_name='nts',
- updateMachine=updateMachine, mergeRun=mergeRun)
+ select_machine=select_machine, merge_run=merge_run)
-def submitFile(url, file, verbose, updateMachine=False, mergeRun='replace'):
+def submitFile(url, file, verbose, select_machine='match',
+ merge_run='replace'):
# If this is a real url, submit it using urllib.
if '://' in url:
- result = submitFileToServer(url, file, updateMachine, mergeRun)
+ result = submitFileToServer(url, file, select_machine, merge_run)
else:
- result = submitFileToInstance(url, file, updateMachine, mergeRun)
+ result = submitFileToInstance(url, file, select_machine, merge_run)
return result
-def submitFiles(url, files, verbose, updateMachine=False, mergeRun='replace'):
+def submitFiles(url, files, verbose, select_machine='match',
+ merge_run='replace'):
results = []
for file in files:
- result = submitFile(url, file, verbose, updateMachine, mergeRun)
+ result = submitFile(url, file, verbose, select_machine=select_machine,
+ merge_run=merge_run)
if result:
results.append(result)
return results