Skip to content

Commit

Permalink
Add :compute to group phases
Browse files Browse the repository at this point in the history
Adds a compute service entry in the target map for the group creation
and removal phases.
  • Loading branch information
hugoduncan committed Aug 12, 2015
1 parent 94d32c6 commit 011466a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/pallet/core/api.clj
Expand Up @@ -248,25 +248,29 @@
(defn groups-to-create
"Return a sequence of groups that currently have no nodes, but will have nodes
added."
[group-deltas]
[group-deltas compute-service]
(letfn [(new-group? [{:keys [actual target]}]
(and (zero? actual) (pos? target)))]
(->>
group-deltas
(filter #(new-group? (val %)))
(map key)
(map (fn [group-spec] (assoc group-spec :target-type :group))))))
(map (fn [group-spec] (assoc group-spec
:target-type :group
:compute compute-service))))))

(defn groups-to-remove
"Return a sequence of groups that have nodes, but will have all nodes
removed."
[group-deltas]
[group-deltas compute-service]
(letfn [(remove-group? [{:keys [actual target]}]
(and (zero? target) (pos? actual)))]
(->>
group-deltas
(filter #(remove-group? (second %)))
(map #(assoc (first %) :target-type :group)))))
(map #(assoc (first %)
:target-type :group
:compute compute-service)))))

(defn nodes-to-remove
"Finds the specified number of nodes to be removed from the given groups.
Expand Down
4 changes: 2 additions & 2 deletions src/pallet/core/operations.clj
Expand Up @@ -30,12 +30,12 @@
[results2 plan-state] (primitives/build-and-execute-phase
targets plan-state environment
:destroy-group
(api/groups-to-remove group-deltas)
(api/groups-to-remove group-deltas compute-service)
execution-settings-f)
[results3 plan-state] (primitives/build-and-execute-phase
targets plan-state environment
:create-group
(api/groups-to-create group-deltas)
(api/groups-to-create group-deltas compute-service)
execution-settings-f)
new-nodes (primitives/create-group-nodes
compute-service environment nodes-to-add)]
Expand Down

0 comments on commit 011466a

Please sign in to comment.