mirror of https://github.com/apache/jclouds.git
Merge pull request #91 from ahgittin/704-clojure13
Issue 704: clojure13
This commit is contained in:
commit
04a5aa8f71
|
@ -22,7 +22,6 @@
|
|||
:doc "A clojure binding to the jclouds EBS service interface."}
|
||||
org.jclouds.ec2.ebs
|
||||
(:require (org.jclouds [compute :as compute]))
|
||||
(:use (clojure.contrib def core))
|
||||
(:import org.jclouds.aws.domain.Region
|
||||
org.jclouds.compute.domain.NodeMetadata
|
||||
(org.jclouds.ec2.domain Volume Volume$Status Snapshot Snapshot$Status AvailabilityZoneInfo)
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
:doc "A clojure binding to the jclouds EBS service interface."}
|
||||
org.jclouds.ec2.ebs2
|
||||
(:use [org.jclouds.compute2])
|
||||
(:use (clojure.contrib def core))
|
||||
(:import org.jclouds.aws.domain.Region
|
||||
org.jclouds.compute.domain.NodeMetadata
|
||||
(org.jclouds.ec2.domain Volume Volume$Status Snapshot Snapshot$Status AvailabilityZoneInfo)
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
org.jclouds.ec2.elastic-ip
|
||||
(:require (org.jclouds [compute :as compute])
|
||||
[org.jclouds.ec2.ebs :as ebs])
|
||||
(:use (clojure.contrib def core))
|
||||
(:import org.jclouds.compute.domain.NodeMetadata
|
||||
(org.jclouds.ec2.domain PublicIpInstanceIdPair)))
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
org.jclouds.ec2.elastic-ip2
|
||||
(:require (org.jclouds [compute2 :as compute])
|
||||
[org.jclouds.ec2.ebs :as ebs])
|
||||
(:use (clojure.contrib def core))
|
||||
(:import org.jclouds.compute.domain.NodeMetadata
|
||||
(org.jclouds.ec2.domain PublicIpInstanceIdPair)))
|
||||
|
||||
|
|
|
@ -53,11 +53,6 @@ See http://code.google.com/p/jclouds for details."
|
|||
[java.security DigestOutputStream MessageDigest]
|
||||
com.google.common.collect.ImmutableSet))
|
||||
|
||||
(try
|
||||
(require '[clojure.contrib.io :as io])
|
||||
(catch Exception e
|
||||
(require '[clojure.contrib.duck-streams :as io])))
|
||||
|
||||
(defn blobstore
|
||||
"Create a logged in context.
|
||||
Options for communication style
|
||||
|
|
|
@ -56,11 +56,6 @@ See http://code.google.com/p/jclouds for details."
|
|||
com.google.common.collect.ImmutableSet
|
||||
org.jclouds.encryption.internal.JCECrypto))
|
||||
|
||||
(try
|
||||
(require '[clojure.contrib.io :as io])
|
||||
(catch Exception e
|
||||
(require '[clojure.contrib.duck-streams :as io])))
|
||||
|
||||
(def ^{:private true}
|
||||
crypto-impl
|
||||
;; BouncyCastle might not be present. Try to load it, but fall back to
|
||||
|
@ -77,11 +72,6 @@ See http://code.google.com/p/jclouds for details."
|
|||
;; Payload support for creating Blobs.
|
||||
;;
|
||||
|
||||
(def ^{:doc "Type object for a Java primitive byte array, for use in the
|
||||
PayloadSource protocol."
|
||||
:private true}
|
||||
byte-array-type (class (make-array Byte/TYPE 0)))
|
||||
|
||||
(defprotocol PayloadSource
|
||||
"Various types can have PayloadSource extended onto them so that they are
|
||||
easily coerced into a Payload."
|
||||
|
@ -92,8 +82,6 @@ See http://code.google.com/p/jclouds for details."
|
|||
(payload [p] p)
|
||||
java.io.InputStream
|
||||
(payload [is] (Payloads/newInputStreamPayload is))
|
||||
byte-array-type
|
||||
(payload [ba] (Payloads/newByteArrayPayload ba))
|
||||
String
|
||||
(payload [s] (Payloads/newStringPayload s))
|
||||
java.io.File
|
||||
|
@ -106,6 +94,13 @@ See http://code.google.com/p/jclouds for details."
|
|||
(writeTo [this output-stream]
|
||||
(func output-stream))))))
|
||||
|
||||
;; something in clojure 1.3 (namespaces?) does not like a private type called byte-array-type,
|
||||
;; so we refer to (class (make-array ...)) directly; and it only parses if it is its own block,
|
||||
;; hence separating it from the above
|
||||
(extend-protocol PayloadSource
|
||||
(class (make-array Byte/TYPE 0))
|
||||
(payload [ba] (Payloads/newByteArrayPayload ba)))
|
||||
|
||||
(defn blobstore
|
||||
"Create a logged in context.
|
||||
Options for communication style
|
||||
|
|
|
@ -30,7 +30,6 @@ Current supported providers are:
|
|||
Here's an example of getting some compute configuration from rackspace:
|
||||
|
||||
(use 'org.jclouds.compute)
|
||||
(use 'clojure.contrib.pprint)
|
||||
|
||||
(def provider \"cloudservers\")
|
||||
(def provider-identity \"username\")
|
||||
|
@ -57,10 +56,7 @@ webserver:
|
|||
(create-node \"webserver\" compute)
|
||||
|
||||
See http://code.google.com/p/jclouds for details."
|
||||
(:use org.jclouds.core
|
||||
(clojure.contrib logging core))
|
||||
(:require
|
||||
[clojure.contrib.condition :as condition])
|
||||
(:use org.jclouds.core (clojure.core incubator))
|
||||
(:import java.io.File
|
||||
java.util.Properties
|
||||
[org.jclouds.domain Location]
|
||||
|
@ -74,13 +70,6 @@ See http://code.google.com/p/jclouds for details."
|
|||
NodePredicates]
|
||||
[com.google.common.collect ImmutableSet]))
|
||||
|
||||
(try
|
||||
(use '[clojure.contrib.reflect :only [get-field]])
|
||||
(catch Exception e
|
||||
(use '[clojure.contrib.java-utils
|
||||
:only [wall-hack-field]
|
||||
:rename {wall-hack-field get-field}])))
|
||||
|
||||
(defmacro deprecate-fwd [old-name new-name] `(defn ~old-name {:deprecated "beta-9"} [& args#] (apply ~new-name args#)))
|
||||
|
||||
(defn compute-service
|
||||
|
@ -455,19 +444,15 @@ Options correspond to TemplateBuilder methods."
|
|||
(let [builder (.. compute (templateBuilder))]
|
||||
(doseq [[option value] options]
|
||||
(when-not (known-template-options option)
|
||||
(condition/raise
|
||||
:type :invalid-template-builder-option
|
||||
:message (format "Invalid template builder option : %s" option)))
|
||||
(throw (Exception. (format "Invalid template builder option : %s" option))))
|
||||
;; apply template builder options
|
||||
(try
|
||||
(apply-option builder template-map option value)
|
||||
(catch Exception e
|
||||
(condition/raise
|
||||
:type :invalid-template-builder
|
||||
:message (format
|
||||
(throw (Exception. (format
|
||||
"Problem applying template builder %s with value %s: %s"
|
||||
option (pr-str value) (.getMessage e))
|
||||
:cause e))))
|
||||
e)))))
|
||||
(let [template (.build builder)
|
||||
template-options (.getOptions template)]
|
||||
(doseq [[option value] options]
|
||||
|
@ -475,10 +460,9 @@ Options correspond to TemplateBuilder methods."
|
|||
(try
|
||||
(apply-option template-options options-map option value)
|
||||
(catch Exception e
|
||||
(condition/raise
|
||||
:type :invalid-template-option
|
||||
:message (format
|
||||
(throw (Exception.
|
||||
(format
|
||||
"Problem applying template option %s with value %s: %s"
|
||||
option (pr-str value) (.getMessage e))
|
||||
:cause e))))
|
||||
e)))))
|
||||
template)))
|
||||
|
|
|
@ -60,10 +60,7 @@ Here's an example of creating and running a small linux node in the group webser
|
|||
See http://code.google.com/p/jclouds for details.
|
||||
"
|
||||
(:use org.jclouds.core
|
||||
(clojure.contrib logging core)
|
||||
(org.jclouds predicate))
|
||||
(:require
|
||||
[clojure.contrib.condition :as condition])
|
||||
(org.jclouds predicate) (clojure.core incubator))
|
||||
(:import java.io.File
|
||||
java.util.Properties
|
||||
[org.jclouds.domain Location]
|
||||
|
@ -79,13 +76,6 @@ Here's an example of creating and running a small linux node in the group webser
|
|||
[com.google.common.collect ImmutableSet])
|
||||
)
|
||||
|
||||
(try
|
||||
(use '[clojure.contrib.reflect :only [get-field]])
|
||||
(catch Exception e
|
||||
(use '[clojure.contrib.java-utils
|
||||
:only [wall-hack-field]
|
||||
:rename {wall-hack-field get-field}])))
|
||||
|
||||
(defn compute-service
|
||||
"Create a logged in context."
|
||||
([#^String provider #^String provider-identity #^String provider-credential
|
||||
|
@ -407,19 +397,16 @@ Options correspond to TemplateBuilder methods."
|
|||
(let [builder (.. compute (templateBuilder))]
|
||||
(doseq [[option value] options]
|
||||
(when-not (known-template-options option)
|
||||
(condition/raise
|
||||
:type :invalid-template-builder-option
|
||||
:message (format "Invalid template builder option : %s" option)))
|
||||
(throw (Exception. (format "Invalid template builder option : %s" option))))
|
||||
;; apply template builder options
|
||||
(try
|
||||
(apply-option builder template-map option value)
|
||||
(catch Exception e
|
||||
(condition/raise
|
||||
:type :invalid-template-builder
|
||||
:message (format
|
||||
"Problem applying template builder %s with value %s: %s"
|
||||
option (pr-str value) (.getMessage e))
|
||||
:cause e))))
|
||||
(throw (Exception.
|
||||
(format
|
||||
"Problem applying template builder %s with value %s: %s"
|
||||
option (pr-str value) (.getMessage e))
|
||||
e)))))
|
||||
(let [template (.build builder)
|
||||
template-options (.getOptions template)]
|
||||
(doseq [[option value] options]
|
||||
|
@ -427,10 +414,9 @@ Options correspond to TemplateBuilder methods."
|
|||
(try
|
||||
(apply-option template-options options-map option value)
|
||||
(catch Exception e
|
||||
(condition/raise
|
||||
:type :invalid-template-option
|
||||
:message (format
|
||||
"Problem applying template option %s with value %s: %s"
|
||||
option (pr-str value) (.getMessage e))
|
||||
:cause e))))
|
||||
(throw (Exception.
|
||||
(format
|
||||
"Problem applying template option %s with value %s: %s"
|
||||
option (pr-str value) (.getMessage e))
|
||||
e)))))
|
||||
template)))
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
(:require [org.jclouds.ssh-test :as ssh-test])
|
||||
(:import
|
||||
org.jclouds.compute.domain.OsFamily
|
||||
clojure.contrib.condition.Condition
|
||||
java.net.InetAddress
|
||||
org.jclouds.scriptbuilder.domain.Statements
|
||||
org.jclouds.compute.options.TemplateOptions
|
||||
|
@ -158,4 +157,4 @@ list, Alan Dipert and MeikelBrandmeyer."
|
|||
(-> (build-template service {:inbound-ports [22 8080]})
|
||||
bean :options bean :inboundPorts))))
|
||||
(testing "invalid"
|
||||
(is (thrown? Condition (build-template service {:xx :yy}))))))
|
||||
(is (thrown? Exception (build-template service {:xx :yy}))))))
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
(:use [org.jclouds.compute] :reload-all)
|
||||
(:use clojure.test)
|
||||
(:import
|
||||
org.jclouds.compute.domain.OsFamily
|
||||
clojure.contrib.condition.Condition))
|
||||
org.jclouds.compute.domain.OsFamily))
|
||||
|
||||
(defmacro with-private-vars [[ns fns] & tests]
|
||||
"Refers private fns from ns and runs tests in context. From users mailing
|
||||
|
@ -128,4 +127,4 @@ list, Alan Dipert and MeikelBrandmeyer."
|
|||
(-> (build-template service {:inbound-ports [22 8080]})
|
||||
bean :options bean :inboundPorts))))
|
||||
(testing "invalid"
|
||||
(is (thrown? Condition (build-template service {:xx :yy}))))))
|
||||
(is (thrown? Exception (build-template service {:xx :yy}))))))
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
(ns org.jclouds.ssh-test
|
||||
(:require
|
||||
[clojure.contrib.logging :as logging])
|
||||
[clojure.tools.logging :as logging])
|
||||
(:import
|
||||
org.jclouds.ssh.SshClient
|
||||
org.jclouds.domain.Credentials
|
||||
|
|
|
@ -19,14 +19,10 @@
|
|||
|
||||
(ns org.jclouds.core
|
||||
"Core functionality used across blobstore and compute."
|
||||
(:use clojure.contrib.logging)
|
||||
(:use clojure.tools.logging)
|
||||
(:import java.io.File
|
||||
(com.google.common.collect ImmutableSet)))
|
||||
|
||||
(try
|
||||
(require '[clojure.contrib.string :as string])
|
||||
(catch Exception e
|
||||
(require '[clojure.contrib.str-utils2 :as string])))
|
||||
(com.google.common.collect ImmutableSet))
|
||||
(:require [clojure.string :as string]))
|
||||
|
||||
(def module-lookup
|
||||
{:log4j 'org.jclouds.logging.log4j.config.Log4JLoggingModule
|
||||
|
@ -73,11 +69,17 @@ Ensure the module is on the classpath. You are maybe missing a dependency on
|
|||
(apply
|
||||
str (interpose "-" (map string/lower-case (re-seq #"[A-Z][^A-Z]*" a)))))
|
||||
|
||||
(defn ^String map-str
|
||||
"Apply f to each element of coll, concatenate all results into a
|
||||
String."
|
||||
[f coll]
|
||||
(apply str (map f coll)))
|
||||
|
||||
(defn camelize
|
||||
"Takes a string, or anything named, and converts it to camel case
|
||||
(capitalised initial component"
|
||||
[a]
|
||||
(string/map-str string/capitalize (.split (name a) "-")))
|
||||
(map-str string/capitalize (.split (name a) "-")))
|
||||
|
||||
(defn camelize-mixed
|
||||
"Takes a string, or anything named, and converts it to mixed camel case
|
||||
|
|
|
@ -236,8 +236,14 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.clojure</groupId>
|
||||
<artifactId>clojure-contrib</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<artifactId>tools.logging</artifactId>
|
||||
<version>0.2.3</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.clojure</groupId>
|
||||
<artifactId>core.incubator</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -689,23 +695,6 @@ pageTracker._trackPageview();
|
|||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>clojure-1.1</id>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.clojure</groupId>
|
||||
<artifactId>clojure</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.clojure</groupId>
|
||||
<artifactId>clojure-contrib</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>site</id>
|
||||
<build>
|
||||
|
|
Loading…
Reference in New Issue