More doc for compute2.clj. Added example to ns-doc.

This commit is contained in:
Mattias Holmqvist 2011-04-29 11:12:41 +02:00
parent a70c672d6a
commit fbe02ae4d8
1 changed files with 32 additions and 4 deletions

View File

@ -27,11 +27,39 @@
slicehost, elastichosts-lon-p, elastichosts-sat-p, elastichosts, slicehost, elastichosts-lon-p, elastichosts-sat-p, elastichosts,
openhosting-east1, serverlove-z1-man, skalicloud-sdg-my, deltacloud] openhosting-east1, serverlove-z1-man, skalicloud-sdg-my, deltacloud]
Here's an example of getting some compute configuration from rackspace:" Here's an example of getting some compute configuration from rackspace:
(use 'org.jclouds.compute2)
(use 'clojure.pprint)
(def provider \"cloudservers\")
(def provider-identity \"username\")
(def provider-credential \"password\")
;; create a compute service
(def compute
(compute-service provider provider-identity provider-credential))
(pprint (locations compute))
(pprint (images compute))
(pprint (nodes compute))
(pprint (hardware-profiles compute)))
Here's an example of creating and running a small linux node in the group webserver:
;; create a compute service using ssh and log4j extensions
(def compute
(compute-service
provider provider-identity provider-credential :ssh :log4j))
(create-node \"webserver\" compute)
See http://code.google.com/p/jclouds for details.
"
(:use org.jclouds.core (:use org.jclouds.core
(clojure.contrib logging core)) (clojure.contrib logging core))
(:require (:require
[clojure.contrib.condition :as condition]) [clojure.contrib.condition :as condition])
(:import java.io.File (:import java.io.File
java.util.Properties java.util.Properties
[org.jclouds.domain Location] [org.jclouds.domain Location]
@ -129,8 +157,8 @@
;; Note that this will actually add another 2 nodes to the set called ;; Note that this will actually add another 2 nodes to the set called
;; \"webserver\"" ;; \"webserver\""
([group count compute] ([group count compute]
(create-nodes (create-nodes
group count (default-template compute) compute)) group count (default-template compute) compute))
([group count template #^ComputeService compute] ([group count template #^ComputeService compute]
(seq (seq
(.createNodesInGroup compute group count template)))) (.createNodesInGroup compute group count template))))