fix references to Region.DEFAULT, using nil as default region now

This commit is contained in:
Chas Emerick 2010-04-27 17:02:37 -04:00
parent e3a816e6cd
commit 56f6246d8c
1 changed files with 24 additions and 13 deletions

View File

@ -27,6 +27,16 @@
(org.jclouds.aws.ec2.domain Volume Snapshot AvailabilityZone)
(org.jclouds.aws.ec2.options DescribeSnapshotsOptions DetachVolumeOptions CreateSnapshotOptions)))
(defn snapshot?
"Returns true iff the argument is a org.jclouds.aws.ec2.domain.Snapshot."
[s]
(instance? Snapshot s))
(defn volume?
"Returns true iff the argument is a org.jclouds.aws.ec2.domain.Volume."
[v]
(instance? Volume v))
(defn #^org.jclouds.aws.ec2.services.ElasticBlockStoreClient
ebs-service
"Returns the synchronous ElasticBlockStoreClient associated with
@ -40,7 +50,8 @@
keyword or already a Region instance. An optional second argument
is returned if the first cannot be coerced into a Region.
Returns nil otherwise."
[v & [default-region]]
([v] (get-region v nil))
([v default-region]
(cond
(keyword? v) (Region/fromValue (name v))
(instance? Region v) v
@ -49,7 +60,7 @@
(Region/fromValue (if (> (.indexOf zone "-") -1)
(subs zone 0 (-> zone count dec))
zone)))
:else default-region))
:else default-region)))
(defn get-volume-id
"Returns a string volume ID taken from the given string, keyword, or Volume argument."
@ -70,7 +81,7 @@
[& [region & volume-ids]]
(set
(.describeVolumesInRegion (ebs-service)
(get-region region Region/DEFAULT)
(get-region region)
(into-array String (map get-volume-id
(if (get-region region)
volume-ids
@ -124,7 +135,7 @@
options (snapshot-options (dissoc options :region))]
(set
(.describeSnapshotsInRegion (ebs-service)
(get-region region Region/DEFAULT)
(get-region region)
(into-array DescribeSnapshotsOptions [options])))))
(defn create-snapshot