summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshoward <showard@592f7852-d20e-0410-864c-8624ca9c26a4>2009-05-08 18:24:36 +0000
committershoward <showard@592f7852-d20e-0410-864c-8624ca9c26a4>2009-05-08 18:24:36 +0000
commit0a8ca6e66b19c588c55365361fd577fffad5394b (patch)
treeec6ddbd957906ad9463a9881c4415ca0974bd10e
parentb5488d8b74cdcc92825bdd23637497beccd3354e (diff)
Added ability to clone a job on specific hosts.
Risk: low Visibility: medium (UI change) Signed-off-by: James Ren <jamesren@google.com> git-svn-id: svn://test.kernel.org/autotest/trunk@3100 592f7852-d20e-0410-864c-8624ca9c26a4
-rw-r--r--frontend/afe/rpc_interface.py10
-rw-r--r--frontend/afe/rpc_utils.py8
-rw-r--r--frontend/client/src/autotest/afe/JobDetailView.java25
3 files changed, 33 insertions, 10 deletions
diff --git a/frontend/afe/rpc_interface.py b/frontend/afe/rpc_interface.py
index 394605f2..7e83725a 100644
--- a/frontend/afe/rpc_interface.py
+++ b/frontend/afe/rpc_interface.py
@@ -478,14 +478,14 @@ def get_jobs_summary(**filter_data):
return rpc_utils.prepare_for_serialization(jobs)
-def get_info_for_clone(id, preserve_metahosts):
+def get_info_for_clone(id, preserve_metahosts, queue_entry_ids=None):
"""\
Retrieves all the information needed to clone a job.
"""
-
job = models.Job.objects.get(id=id)
job_info = rpc_utils.get_job_info(job,
- preserve_metahosts=preserve_metahosts)
+ preserve_metahosts=preserve_metahosts,
+ queue_entry_ids=queue_entry_ids)
host_dicts = []
for host in job_info['hosts']:
@@ -503,9 +503,9 @@ def get_info_for_clone(id, preserve_metahosts):
locked_text='')
host_dicts.append(host_dict)
- # convert keys from Label objects to strings (names of labels
+ # convert keys from Label objects to strings (names of labels)
meta_host_counts = dict((meta_host.name, count) for meta_host, count
- in job_info['meta_host_counts'])
+ in job_info['meta_host_counts'].iteritems())
info = dict(job=job.get_object_dict(),
meta_host_counts=meta_host_counts,
diff --git a/frontend/afe/rpc_utils.py b/frontend/afe/rpc_utils.py
index 082a53e3..18c0c31d 100644
--- a/frontend/afe/rpc_utils.py
+++ b/frontend/afe/rpc_utils.py
@@ -330,13 +330,17 @@ def _get_metahost_counts(metahost_objects):
return metahost_counts
-def get_job_info(job, preserve_metahosts=False):
+def get_job_info(job, preserve_metahosts=False, queue_entry_ids=None):
hosts = []
one_time_hosts = []
meta_hosts = []
atomic_group = None
- for queue_entry in job.hostqueueentry_set.filter():
+ queue_entries = job.hostqueueentry_set.all()
+ if queue_entry_ids is not None:
+ queue_entries = queue_entries.filter(id__in=queue_entry_ids)
+
+ for queue_entry in queue_entries:
if (queue_entry.host and (preserve_metahosts or
not queue_entry.meta_host)):
if queue_entry.deleted:
diff --git a/frontend/client/src/autotest/afe/JobDetailView.java b/frontend/client/src/autotest/afe/JobDetailView.java
index bf4c2be7..760317e4 100644
--- a/frontend/client/src/autotest/afe/JobDetailView.java
+++ b/frontend/client/src/autotest/afe/JobDetailView.java
@@ -234,22 +234,33 @@ public class JobDetailView extends DetailView implements TableWidgetFactory, Tab
ContextMenu menu = new ContextMenu();
menu.addItem("Reuse any similar hosts (default)", new Command() {
public void execute() {
- cloneJob(false);
+ cloneJob(false, null);
}
});
menu.addItem("Reuse same specific hosts", new Command() {
public void execute() {
- cloneJob(true);
+ cloneJob(true, null);
}
});
menu.showAt(cloneButton.getAbsoluteLeft(),
cloneButton.getAbsoluteTop() + cloneButton.getOffsetHeight());
}
- private void cloneJob(boolean preserveMetahosts) {
+ private void cloneJobOnSelectedHosts() {
+ Set<JSONObject> hostsQueueEntries = selectionManager.getSelectedObjects();
+ JSONArray queueEntryIds = new JSONArray();
+ for (JSONObject queueEntry : hostsQueueEntries) {
+ queueEntryIds.set(queueEntryIds.size(), queueEntry.get("id"));
+ }
+
+ cloneJob(true, queueEntryIds);
+ }
+
+ private void cloneJob(boolean preserveMetahosts, JSONArray queueEntryIds) {
JSONObject params = new JSONObject();
params.put("id", new JSONNumber(jobId));
params.put("preserve_metahosts", JSONBoolean.getInstance(preserveMetahosts));
+ params.put("queue_entry_ids", queueEntryIds);
rpcProxy.rpcCall("get_info_for_clone", params, new JsonRpcCallback() {
@Override
public void onSuccess(JSONValue result) {
@@ -383,11 +394,19 @@ public class JobDetailView extends DetailView implements TableWidgetFactory, Tab
public ContextMenu getActionMenu() {
ContextMenu menu = new ContextMenu();
+
menu.addItem("Abort hosts", new Command() {
public void execute() {
abortSelectedHosts();
}
});
+
+ menu.addItem("Clone job on selected hosts", new Command() {
+ public void execute() {
+ cloneJobOnSelectedHosts();
+ }
+ });
+
return menu;
}
}