Commit 14b9f141 authored by Heinz N. Gies's avatar Heinz N. Gies

Forbid rolling back backups when snapshots exist.

parent 1b759a79
......@@ -25,7 +25,7 @@
[org.omcljs/om "0.9.0"]
[com.lucasbradstreet/instaparse-cljs "1.4.1.0"]
[prismatic/om-tools "0.4.0"]
[racehub/om-bootstrap "0.5.3"]
[racehub/om-bootstrap "0.6.1"]
[secretary "1.2.3"]
[clj-http "2.0.0"]
[jarohen/chord "0.6.0"]
......
......@@ -22,7 +22,6 @@
401 (check-login)
404 (do
(raise :warning (str (name (first state-path)) " " (nth state-path 2) " not found!"))
(pr error-dest)
(if error-dest (goto error-dest))
(delete-state! state-path))
200 (set-state! state-path (js->clj (:body resp)))))))
......
......@@ -21,7 +21,6 @@
(defn state-modal [state owner name-fn delete-fn]
(let [id (get-in state [:delete :id])]
(pr state (name-fn state))
(d/div
{:style {:display (if id "block" "none")} }
(md/modal
......
......@@ -29,7 +29,6 @@
(print-conf-rows uuid (str pfx (name c) ".") v)
(let [k (str pfx (name c))
path (cstr/split k #"\.")]
(pr path)
(d/tr
(d/td k)
(d/td v)
......
......@@ -128,12 +128,9 @@
match (re-matches #".*[?]page=([0-9]+)$" href)
entries (count all-rows)
sel-page (if match (str->int (second match)) 0)
page-size 5
page-size 20
max-page (dec (Math/ceil (/ entries page-size)))
_ (pr "max-page:" max-page)
_ (pr "sel-page:" sel-page)
page (min max-page sel-page)
_ (pr "page:" page)
all-rows (drop (* page page-size) all-rows)
all-rows (take page-size all-rows)
......
......@@ -159,7 +159,6 @@
(render-state [_ state]
(let [element (get-in app [root :elements uuid])
networks (vals (get-in app [:networks :elements]))]
(pr networks)
(r/well
{}
(row
......
......@@ -339,7 +339,6 @@
(defn token-modal [owner state]
(pr state)
(d/div
{:style {:display (if (:token state) "block" "none")} }
(md/modal
......
......@@ -159,7 +159,6 @@
(g/col
{:xs 6}
(let [checked (boolean (get-in data [:data :config :delegate_dataset]))]
(pr (get-in data [:data :config]))
(i/input
{:type "checkbox"
:checked checked
......@@ -170,7 +169,6 @@
(g/col
{:xs 6}
(let [checked (boolean (get-in data [:data :config :indestructible_delegated]))]
(pr (get-in data [:data :config]))
(i/input
{:type "checkbox"
:checked checked
......@@ -183,7 +181,6 @@
(g/col
{:xs 10}
(let [checked (boolean (get-in data [:data :config :indestructible_zoneroot]))]
(pr (get-in data [:data :config]))
(i/input
{:type "checkbox"
:checked checked
......
......@@ -609,7 +609,7 @@
"failed" (r/label {:bs-style "danger"} state)
(r/label {:bs-style "default"} state)))
(defn backup-row [owner vm hypervisor
(defn backup-row [owner vm hypervisor has-snapshots
[uuid {comment :comment timestamp :timestamp
state :state old-size :size files :files}]]
(let [size (reduce + (map #(:size (second %)) files))
......@@ -626,14 +626,14 @@
(menu-items
["Incremental" #(vms/backup vm uuid (val-by-id "backup-comment"))]
(if (and hypervisor (not (empty? hypervisor)))
["Restore" #(vms/restore-backup vm hypervisor uuid)]
["Roll Back" #(vms/restore-backup vm uuid)])
["Restore" {:class (if has-snapshots "disabled")} #(vms/restore-backup vm hypervisor uuid)]
["Roll Back" {:class (if has-snapshots "disabled")} #(vms/restore-backup vm uuid)])
["Delete" #(do
(om/set-state! owner [:delete :name] comment)
(del/state-show owner (name uuid)))]))))))
(defn backup-table [state owner vm hypervisor backups]
(defn backup-table [state owner vm hypervisor has-snapshots backups]
(g/col
{:md 11}
(del/state-modal state owner #(get-in % [:delete :name]) #(vms/delete-backup vm %))
......@@ -650,7 +650,7 @@
(apply d/tbody
{}
(map
(partial backup-row owner vm hypervisor)
(partial backup-row owner vm hypervisor has-snapshots)
(sort-by (fn [[_ {t :timestamp}]] t) backups))))))
(defn render-backups [app owner {:keys [uuid]}]
......@@ -665,33 +665,42 @@
(r/well {} (d/p "Backups can not be created for zones that have delegated datasets!"))
(r/well
{}
(if (not (empty? (:hypervisor data)))
(row
(g/col
{:xs 12}
(d/p
"Once a backup is made it is possible to remove a zone from"
" a hypervisor without deleting the backups, that way the"
" zone can later on be deployed again."
(b/button {:bs-style "danger"
:disabled? (empty? (:backups data))
:on-click #(vms/delete-hypervisor (:uuid data))
:class "pull-right"} "Delete from hypervisor"))))
(row
(g/col {}
(d/p
"This vm is in 'limbo' it currently has no hypervisors assigned"
" that means it can be re-deployed.")
(i/input {:type "select"
:value (:target state)
:on-change (->state owner :target)}
(d/option "")
(map
(fn [[h-uidd {alias :alias}]]
(d/option {:value h-uidd} alias))
(get-in app [:hypervisors :elements])))
)))
[(if (not (empty? (:snapshots data)))
(row
(g/col
{:xs 12}
(p/panel (merge {:header (d/h3 "Snapshots")}
{:bs-style "warning"})
"This VM has snapshots, caution is adviced when using snapshots"
" and backups together. Rolling back a backup will not be possible "
" as long as snapshots exist!"))))
(if (not (empty? (:hypervisor data)))
(row
(g/col
{:xs 12}
(d/p
"Once a backup is made it is possible to remove a zone from"
" a hypervisor without deleting the backups, that way the"
" zone can later on be deployed again."
(b/button {:bs-style "danger"
:disabled? (empty? (:backups data))
:on-click #(vms/delete-hypervisor (:uuid data))
:class "pull-right"} "Delete from hypervisor"))))
(row
(g/col {}
(d/p
"This vm is in 'limbo' it currently has no hypervisors assigned"
" that means it can be re-deployed.")
(i/input {:type "select"
:value (:target state)
:on-change (->state owner :target)}
(d/option "")
(map
(fn [[h-uidd {alias :alias}]]
(d/option {:value h-uidd} alias))
(get-in app [:hypervisors :elements])))
)))]
(row
(g/col
......@@ -711,7 +720,7 @@
:wrapper-classname "col-xs-2"
:disabled? (empty? (:name state))
:on-click #(vms/backup (:uuid data) (cstr/trim (:name state)))} "Create")))))
(backup-table state owner uuid (:target state) (:backups data)))))))))
(backup-table state owner uuid (:target state) (not (empty? (:snapshots data))) (:backups data)))))))))
(defn o-state! [owner id]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment