diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2017-04-18 17:12:37 +0100 |
---|---|---|
committer | Alex Bennée <alex.bennee@linaro.org> | 2017-04-18 17:12:37 +0100 |
commit | 98d564861e42415beaf95a9feb1ca402641b1569 (patch) | |
tree | 9ee645df981216a078cdf7b59e330510e6494bdf | |
parent | 55c1bbe68fc5c1011b4b8ba71be1c20bf03396dc (diff) |
lava-jobs/rpc: store lava_host in job hash
This is needed so we can track which jobs have been submitted to which
server and have multiple server job lists.
-rw-r--r-- | lava-jobs.el | 6 | ||||
-rw-r--r-- | lava-mode.el | 15 | ||||
-rw-r--r-- | lava-rpc.el | 15 |
3 files changed, 26 insertions, 10 deletions
diff --git a/lava-jobs.el b/lava-jobs.el index bc662ef..26816dc 100644 --- a/lava-jobs.el +++ b/lava-jobs.el @@ -66,13 +66,15 @@ symbols.") (setq lava-job-info (assq-delete-all index lava-job-info)))) (defun lava-jobs-create-hash (job-id &optional status) - "Add a new hash (if needed) for `JOB-ID' to the list of jobs." + "Add a new hash (if needed) for numeric `JOB-ID' to the list of jobs. +The optional `STATUS' sets that field up." (let ((index (lava-jobs-make-index job-id))) - (unless (lava-job-get-hash index) + (unless (lava-jobs-get-hash index) (let ((hash (make-hash-table :test 'equal)) (status-string (if status status "Submitted"))) + (puthash "lava_host" lava-host hash) (puthash "job_id" (format "%d" job-id) hash) (puthash "job_status" status-string hash) (puthash "updated" (current-time) hash) diff --git a/lava-mode.el b/lava-mode.el index 9ce2a03..59fb6c8 100644 --- a/lava-mode.el +++ b/lava-mode.el @@ -47,9 +47,18 @@ evaluation." (let* ((new-name (concat "*Expanded " (buffer-name orig-buff) "*")) (new-buffer (get-buffer-create new-name)) - (new-mode (with-current-buffer orig-buff major-mode))) + (host) + (user) + (token) + (new-mode)) (with-current-buffer orig-buff + ;; Copy buffer variables + (setq host lava-host + user lava-user-name + token lava-api-token + new-mode major-mode) + ;; Copy buffer text, substituting as we go (goto-char (point-min)) (let ((last-pos (point))) (while (re-search-forward lava-mode-elisp-escape-regex nil t) @@ -71,6 +80,10 @@ evaluation." (with-current-buffer new-buffer (insert last-chunk))))) (with-current-buffer new-buffer + ;; Set local buffer variables + (setq lava-host host + lava-user-name user + lava-api-token token) (funcall new-mode) (not-modified)) new-buffer)) diff --git a/lava-rpc.el b/lava-rpc.el index 592131d..02634bb 100644 --- a/lava-rpc.el +++ b/lava-rpc.el @@ -46,15 +46,21 @@ (defvar lava-host "validation.linaro.org" "Location of your LAVA instance.") +(make-variable-buffer-local 'lava-host) +(put 'lava-host 'permanent-local t) (defvar lava-user-name nil "Your username on the LAVA instance.") +(make-variable-buffer-local 'lava-user-name) +(put 'lava-user-name 'permanent-local t) (defvar lava-api-token nil "The API token on the LAVA instance. If the variable is a function pointer it is called at evaluation time.") +(make-variable-buffer-local 'lava-api-token) +(put 'lava-api-token 'permanent-local t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; LAVA XML-RPC Calls @@ -116,13 +122,8 @@ The `CALLBACK' function is called with the response." ;;; Handle the response and create initial alist. (defun lava-rpc--job-submitted (resp) "Handle the response `RESP' from a submitted job." - (let ((job (intern (format "lava-job-%d" resp))) - (hash (make-hash-table :test 'equal))) - (puthash "job_id" (format "%d" resp) hash) - (puthash "job_status" "Submitted" hash) - (puthash "updated" (current-time) hash) - (setq lava-job-info - (cons `(,job . ,hash) lava-job-info)) + (let ((job (lava-jobs-make-index resp))) + (lava-jobs-create-hash resp) job)) ;;; Submit the current job definition as a lava-job |