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
:in-direcory path
:max-results n
:with-details true
:recursive true"
[blobstore & args]
(if (blobstore? blobstore)

View File

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