Added options to (node) function in compute.clj, currently a single option to show/fetch details.

Extended the doc in blobstore.clj.
This commit is contained in:
Alex Yarmula 2010-04-19 15:20:08 -07:00
parent eda0eebfb5
commit 25c7345177
2 changed files with 21 additions and 7 deletions

View File

@ -115,6 +115,7 @@ Options can also be specified for extension modules
:after-marker string :after-marker string
:in-direcory path :in-direcory path
:max-results n :max-results n
:with-details true
:recursive true" :recursive true"
[blobstore & args] [blobstore & args]
(if (blobstore? blobstore) (if (blobstore? blobstore)

View File

@ -60,7 +60,7 @@ See http://code.google.com/p/jclouds for details."
[org.jclouds.compute.domain [org.jclouds.compute.domain
Template TemplateBuilder ComputeMetadata NodeMetadata Size OsFamily Template TemplateBuilder ComputeMetadata NodeMetadata Size OsFamily
Image Architecture] Image Architecture]
org.jclouds.compute.options.TemplateOptions [org.jclouds.compute.options TemplateOptions GetNodesOptions]
[com.google.common.collect ImmutableSet])) [com.google.common.collect ImmutableSet]))
(try (try
@ -119,15 +119,28 @@ See http://code.google.com/p/jclouds for details."
([#^ComputeService compute] ([#^ComputeService compute]
(seq-from-immutable-set (.getLocations compute)))) (seq-from-immutable-set (.getLocations compute))))
(defn nodes-with-tag
[#^String tag #^ComputeService compute]
(seq-from-immutable-set (.getNodesWithTag compute tag)))
(def #^{:private true} list-nodes-map
{ :with-details #(when %2 (.withDetails %1)) })
(defn nodes (defn nodes
"Retrieve the existing nodes for the compute context." "Retrieve the existing nodes for the compute context.
Options are:
:with-details true"
([] (nodes *compute*)) ([] (nodes *compute*))
([compute-or-tag] ([compute-or-tag & options]
(if (compute-service? compute-or-tag) (if (compute-service? compute-or-tag)
(seq-from-immutable-set (.getNodes compute-or-tag)) (let [options (apply hash-map options)
(nodes compute-or-tag *compute*))) list-nodes-options (reduce
([#^String tag #^ComputeService compute] (fn [lno [k v]]
(seq-from-immutable-set (.getNodesWithTag compute tag)))) ((list-nodes-map k) lno v)
lno)
(GetNodesOptions.) options)]
(seq-from-immutable-set (.getNodes compute-or-tag list-nodes-options)))
(nodes-with-tag compute-or-tag *compute*))))
(defn images (defn images
"Retrieve the available images for the compute context." "Retrieve the available images for the compute context."