From b8753e635960a5e36674782912a52b3bb9a23eb7 Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Wed, 21 Dec 2011 10:18:06 +0000 Subject: [PATCH 01/15] added AffinityType enum --- .../cloudsigma/domain/AffinityType.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/AffinityType.java diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/AffinityType.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/AffinityType.java new file mode 100644 index 0000000000..b3c24d8604 --- /dev/null +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/AffinityType.java @@ -0,0 +1,51 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.cloudsigma.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Option for the cloneDrive operation. + * 'HDD' to specifies a regular "spinning oxide" disk; 'SSD' specifies a solid-state drive. + * + * @author Alasdair Hodge + */ +public enum AffinityType { + HDD, + SSD, + UNRECOGNIZED; + + public String value() { + return name().toLowerCase(); + } + + @Override + public String toString() { + return value(); + } + + public static AffinityType fromValue(String affinity) { + try { + return valueOf(checkNotNull(affinity, "affinity").toUpperCase()); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + +} \ No newline at end of file From fd6a0779dd321df789f4f3c771236431de193b2c Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Wed, 21 Dec 2011 10:20:10 +0000 Subject: [PATCH 02/15] CloneDriveOptions now conveys affinity (in 'tags' option) --- .../cloudsigma/options/CloneDriveOptions.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java index d37c2f4a26..f9cce551bb 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java @@ -20,10 +20,17 @@ package org.jclouds.cloudsigma.options; import static com.google.common.base.Preconditions.checkArgument; +import java.util.HashSet; import java.util.Map; +import java.util.Set; +import org.jclouds.cloudsigma.domain.AffinityType; + +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; +import com.google.common.collect.Sets; /** * Contains options supported for clone drive operations.

@@ -53,6 +60,35 @@ public class CloneDriveOptions { return this; } + /** + * specifies whether the new drive has 'HDD' affinity (the default) or 'SSD' (for solid-state drives) + */ + public CloneDriveOptions affinity(AffinityType affinity) { + final String SSD_AFFINITY_TAG = "affinity:ssd"; + + // Affinity is conveyed using regular tags; make sure to avoid multiple affinity tags in the options. + String currentTagsString = options.remove("tags"); + Set tags = (currentTagsString == null) ? new HashSet() : + Sets.newHashSet(Splitter.on(' ').split(currentTagsString)); + + switch (affinity) { + // SSD affinity is conveyed as a special tag: "affinity:ssd". + case SSD: + tags.add(SSD_AFFINITY_TAG); + break; + + // HDD affinity (the default) is conveyed by the *absence* of the "affinity:ssd" tag. + case HDD: + tags.remove(SSD_AFFINITY_TAG); + break; + } + + if (!tags.isEmpty()) + options.put("tags", Joiner.on(' ').join(tags)); + + return this; + } + public static class Builder { /** @@ -63,6 +99,14 @@ public class CloneDriveOptions { return options.size(size); } + /** + * @see CloneDriveOptions#affinity + */ + public static CloneDriveOptions affinity(AffinityType affinity) { + CloneDriveOptions options = new CloneDriveOptions(); + return options.affinity(affinity); + } + } public Map getOptions() { From 933e64ecc62ee2c40f30abc9e5a90982c080e3da Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Wed, 21 Dec 2011 10:40:33 +0000 Subject: [PATCH 03/15] Add affinity attribute to Drive . add constructor arg and update all uses (inc subclasses) . update hashCode() and equals(), inc builder --- .../cloudsigma/domain/CreateDriveRequest.java | 8 +++--- .../org/jclouds/cloudsigma/domain/Drive.java | 27 ++++++++++++++++--- .../jclouds/cloudsigma/domain/DriveData.java | 6 ++--- .../jclouds/cloudsigma/domain/DriveInfo.java | 6 ++--- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java index 242973095d..4e8a507af4 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java @@ -89,7 +89,7 @@ public class CreateDriveRequest extends Drive { } public CreateDriveRequest build() { - return new CreateDriveRequest(name, size, claimType, readers, use, encryptionCipher, avoid); + return new CreateDriveRequest(name, size, claimType, affinity, readers, use, encryptionCipher, avoid); } } @@ -97,9 +97,9 @@ public class CreateDriveRequest extends Drive { @Nullable private final String encryptionCipher; - public CreateDriveRequest(String name, long size, @Nullable ClaimType claimType, Iterable readers, - Iterable use, @Nullable String encryptionCipher, Iterable avoid) { - super(null, name, size, claimType, readers, use); + public CreateDriveRequest(String name, long size, @Nullable ClaimType claimType, AffinityType affinity, + Iterable readers, Iterable use, @Nullable String encryptionCipher, Iterable avoid) { + super(null, name, size, claimType, affinity, readers, use); this.encryptionCipher = encryptionCipher; this.avoid = ImmutableSet.copyOf(checkNotNull(avoid, "avoid")); } diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java index ab53dab9ac..aadf281dba 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java @@ -34,6 +34,7 @@ public class Drive extends Item { public static class Builder extends Item.Builder { protected long size; protected ClaimType claimType = ClaimType.EXCLUSIVE; + protected AffinityType affinity = AffinityType.HDD; protected Set readers = ImmutableSet.of(); public Builder claimType(ClaimType claimType) { @@ -41,6 +42,11 @@ public class Drive extends Item { return this; } + public Builder affinity(AffinityType affinity) { + this.affinity = affinity; + return this; + } + public Builder readers(Iterable readers) { this.readers = ImmutableSet.copyOf(checkNotNull(readers, "readers")); return this; @@ -76,7 +82,7 @@ public class Drive extends Item { } public Drive build() { - return new Drive(uuid, name, size, claimType, readers, use); + return new Drive(uuid, name, size, claimType, affinity, readers, use); } @Override @@ -84,6 +90,7 @@ public class Drive extends Item { final int prime = 31; int result = super.hashCode(); result = prime * result + ((claimType == null) ? 0 : claimType.hashCode()); + result = prime * result + ((affinity == null) ? 0 : affinity.hashCode()); result = prime * result + ((readers == null) ? 0 : readers.hashCode()); result = prime * result + (int) (size ^ (size >>> 32)); return result; @@ -100,6 +107,8 @@ public class Drive extends Item { Builder other = (Builder) obj; if (claimType != other.claimType) return false; + if (affinity != other.affinity) + return false; if (readers == null) { if (other.readers != null) return false; @@ -113,13 +122,15 @@ public class Drive extends Item { protected final long size; protected final ClaimType claimType; + protected final AffinityType affinity; protected final Set readers; - public Drive(@Nullable String uuid, String name, long size, @Nullable ClaimType claimType, Iterable readers, - Iterable use) { + public Drive(@Nullable String uuid, String name, long size, @Nullable ClaimType claimType, + AffinityType affinity, Iterable readers, Iterable use) { super(uuid, name, use); this.size = size; this.claimType = checkNotNull(claimType, "set claimType to exclusive, not null"); + this.affinity = checkNotNull(affinity, "affinity"); this.readers = ImmutableSet.copyOf(checkNotNull(readers, "readers")); } @@ -133,6 +144,13 @@ public class Drive extends Item { return claimType; } + /** + * @return either 'HDD' (the default) or 'SSD' (for solid-state drives) + */ + public AffinityType getAffinity() { + return affinity; + } + /** * * @return list of users allowed to read from a drive or 'ffffffff-ffff-ffff-ffff-ffffffffffff' @@ -155,6 +173,7 @@ public class Drive extends Item { final int prime = 31; int result = 1; result = prime * result + ((claimType == null) ? 0 : claimType.hashCode()); + result = prime * result + ((affinity == null) ? 0 : affinity.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((readers == null) ? 0 : readers.hashCode()); result = prime * result + (int) (size ^ (size >>> 32)); @@ -173,6 +192,8 @@ public class Drive extends Item { Drive other = (Drive) obj; if (claimType != other.claimType) return false; + if (affinity != other.affinity) + return false; if (name == null) { if (other.name != null) return false; diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java index 2fc808e118..7a8e96d651 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java @@ -68,12 +68,12 @@ public class DriveData extends Drive { } public DriveData build() { - return new DriveData(uuid, name, size, claimType, readers, use); + return new DriveData(uuid, name, size, claimType, affinity, readers, use); } } public DriveData(@Nullable String uuid, String name, long size, @Nullable ClaimType claimType, - Iterable readers, Iterable use) { - super(uuid, name, size, claimType, readers, use); + AffinityType affinity, Iterable readers, Iterable use) { + super(uuid, name, size, claimType, affinity, readers, use); } } \ No newline at end of file diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java index 678de1d644..5c4b72fad7 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java @@ -195,7 +195,7 @@ public class DriveInfo extends Drive { */ @Override public DriveInfo build() { - return new DriveInfo(uuid, name, size, claimType, readers, use, status, user, claimed, encryptionCipher, + return new DriveInfo(uuid, name, size, claimType, affinity, readers, use, status, user, claimed, encryptionCipher, imaging, metrics, autoexpanding, bits, description, driveType, encryptionKey, free, installNotes, os, type, url); } @@ -221,12 +221,12 @@ public class DriveInfo extends Drive { private final DriveType type; private final URI url; - public DriveInfo(String uuid, String name, long size, ClaimType claimType, Iterable readers, + public DriveInfo(String uuid, String name, long size, ClaimType claimType, AffinityType affinity, Iterable readers, Iterable use, DriveStatus status, String user, Set claimed, String encryptionCipher, String imaging, DriveMetrics metrics, Boolean autoexpanding, Integer bits, String description, Iterable driveType, String encryptionKey, Boolean free, String installNotes, String os, DriveType type, URI url) { - super(uuid, name, size, claimType, readers, use); + super(uuid, name, size, claimType, affinity, readers, use); this.status = status; this.user = user; this.claimed = ImmutableSet.copyOf(checkNotNull(claimed, "claimed")); From e4eedf9b9939d326a72e1fdf17b34baf3623ee7a Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Wed, 21 Dec 2011 11:02:39 +0000 Subject: [PATCH 04/15] Add tags to CloneDriveOptions --- .../cloudsigma/options/CloneDriveOptions.java | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java index f9cce551bb..9cef0740ce 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java @@ -49,6 +49,7 @@ import com.google.common.collect.Sets; * */ public class CloneDriveOptions { + private final String SSD_AFFINITY_TAG = "affinity:ssd"; private final Map options = Maps.newLinkedHashMap(); /** @@ -60,12 +61,26 @@ public class CloneDriveOptions { return this; } + public CloneDriveOptions tags(Iterable tags) { + // Affinity is conveyed using regular tags; make sure to preserve any already-set affinity tag. + String currentTagsString = options.remove("tags"); + Set currentTags = (currentTagsString == null) ? new HashSet() : + Sets.newHashSet(Splitter.on(' ').split(currentTagsString)); + + Set newTags = Sets.newHashSet(tags); + if (currentTags.contains(SSD_AFFINITY_TAG)) { + newTags.add(SSD_AFFINITY_TAG); + } + + options.put("tags", Joiner.on(' ').join(newTags)); + return this; + } + /** - * specifies whether the new drive has 'HDD' affinity (the default) or 'SSD' (for solid-state drives) + * Specifies whether the new drive has 'HDD' affinity (the default) or 'SSD' (for solid-state drives). + * Affinity is conveyed via a special value among the drive's tags. */ public CloneDriveOptions affinity(AffinityType affinity) { - final String SSD_AFFINITY_TAG = "affinity:ssd"; - // Affinity is conveyed using regular tags; make sure to avoid multiple affinity tags in the options. String currentTagsString = options.remove("tags"); Set tags = (currentTagsString == null) ? new HashSet() : @@ -98,6 +113,14 @@ public class CloneDriveOptions { CloneDriveOptions options = new CloneDriveOptions(); return options.size(size); } + + /** + * @see CloneDriveOptions#tags + */ + public static CloneDriveOptions tags(Iterable tags) { + CloneDriveOptions options = new CloneDriveOptions(); + return options.tags(tags); + } /** * @see CloneDriveOptions#affinity From ede85e28f562c11e77a03b63a7a2708579389337 Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Wed, 21 Dec 2011 11:22:08 +0000 Subject: [PATCH 05/15] Drive domain object (and subclasses) refer to tags, and not explicitly to affinity --- .../cloudsigma/domain/CreateDriveRequest.java | 6 +-- .../org/jclouds/cloudsigma/domain/Drive.java | 50 ++++++++----------- .../jclouds/cloudsigma/domain/DriveData.java | 6 +-- .../jclouds/cloudsigma/domain/DriveInfo.java | 6 +-- 4 files changed, 30 insertions(+), 38 deletions(-) diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java index 4e8a507af4..30db029c76 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java @@ -89,7 +89,7 @@ public class CreateDriveRequest extends Drive { } public CreateDriveRequest build() { - return new CreateDriveRequest(name, size, claimType, affinity, readers, use, encryptionCipher, avoid); + return new CreateDriveRequest(name, size, claimType, tags, readers, use, encryptionCipher, avoid); } } @@ -97,9 +97,9 @@ public class CreateDriveRequest extends Drive { @Nullable private final String encryptionCipher; - public CreateDriveRequest(String name, long size, @Nullable ClaimType claimType, AffinityType affinity, + public CreateDriveRequest(String name, long size, @Nullable ClaimType claimType, Iterable tags, Iterable readers, Iterable use, @Nullable String encryptionCipher, Iterable avoid) { - super(null, name, size, claimType, affinity, readers, use); + super(null, name, size, claimType, tags, readers, use); this.encryptionCipher = encryptionCipher; this.avoid = ImmutableSet.copyOf(checkNotNull(avoid, "avoid")); } diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java index aadf281dba..5adcce61ca 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java @@ -24,6 +24,7 @@ import java.util.Set; import org.jclouds.javax.annotation.Nullable; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; /** @@ -34,7 +35,7 @@ public class Drive extends Item { public static class Builder extends Item.Builder { protected long size; protected ClaimType claimType = ClaimType.EXCLUSIVE; - protected AffinityType affinity = AffinityType.HDD; + protected Set tags = ImmutableSet.of(); protected Set readers = ImmutableSet.of(); public Builder claimType(ClaimType claimType) { @@ -42,8 +43,8 @@ public class Drive extends Item { return this; } - public Builder affinity(AffinityType affinity) { - this.affinity = affinity; + public Builder tags(Iterable tags) { + this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags")); return this; } @@ -82,7 +83,7 @@ public class Drive extends Item { } public Drive build() { - return new Drive(uuid, name, size, claimType, affinity, readers, use); + return new Drive(uuid, name, size, claimType, tags, readers, use); } @Override @@ -90,7 +91,7 @@ public class Drive extends Item { final int prime = 31; int result = super.hashCode(); result = prime * result + ((claimType == null) ? 0 : claimType.hashCode()); - result = prime * result + ((affinity == null) ? 0 : affinity.hashCode()); + result = prime * result + ((tags == null) ? 0 : tags.hashCode()); result = prime * result + ((readers == null) ? 0 : readers.hashCode()); result = prime * result + (int) (size ^ (size >>> 32)); return result; @@ -107,13 +108,10 @@ public class Drive extends Item { Builder other = (Builder) obj; if (claimType != other.claimType) return false; - if (affinity != other.affinity) + if (!Objects.equal(tags, other.tags)) + return false; + if (!Objects.equal(readers, other.readers)) return false; - if (readers == null) { - if (other.readers != null) - return false; - } else if (!readers.equals(other.readers)) - return false; if (size != other.size) return false; return true; @@ -122,15 +120,15 @@ public class Drive extends Item { protected final long size; protected final ClaimType claimType; - protected final AffinityType affinity; + protected final Set tags; protected final Set readers; public Drive(@Nullable String uuid, String name, long size, @Nullable ClaimType claimType, - AffinityType affinity, Iterable readers, Iterable use) { + Iterable tags, Iterable readers, Iterable use) { super(uuid, name, use); this.size = size; this.claimType = checkNotNull(claimType, "set claimType to exclusive, not null"); - this.affinity = checkNotNull(affinity, "affinity"); + this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags")); this.readers = ImmutableSet.copyOf(checkNotNull(readers, "readers")); } @@ -145,10 +143,10 @@ public class Drive extends Item { } /** - * @return either 'HDD' (the default) or 'SSD' (for solid-state drives) + * @return all tags associated with this drive, both user-specified and "system" tags (e.g. "affinity:ssd") */ - public AffinityType getAffinity() { - return affinity; + public Set getTags() { + return tags; } /** @@ -173,7 +171,7 @@ public class Drive extends Item { final int prime = 31; int result = 1; result = prime * result + ((claimType == null) ? 0 : claimType.hashCode()); - result = prime * result + ((affinity == null) ? 0 : affinity.hashCode()); + result = prime * result + ((tags == null) ? 0 : tags.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((readers == null) ? 0 : readers.hashCode()); result = prime * result + (int) (size ^ (size >>> 32)); @@ -192,18 +190,12 @@ public class Drive extends Item { Drive other = (Drive) obj; if (claimType != other.claimType) return false; - if (affinity != other.affinity) + if (!Objects.equal(tags, other.tags)) + return false; + if (!Objects.equal(name, other.name)) + return false; + if (!Objects.equal(readers, other.readers)) return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (readers == null) { - if (other.readers != null) - return false; - } else if (!readers.equals(other.readers)) - return false; if (size != other.size) return false; if (use == null) { diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java index 7a8e96d651..7d0a561195 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java @@ -68,12 +68,12 @@ public class DriveData extends Drive { } public DriveData build() { - return new DriveData(uuid, name, size, claimType, affinity, readers, use); + return new DriveData(uuid, name, size, claimType, tags, readers, use); } } public DriveData(@Nullable String uuid, String name, long size, @Nullable ClaimType claimType, - AffinityType affinity, Iterable readers, Iterable use) { - super(uuid, name, size, claimType, affinity, readers, use); + Iterable tags, Iterable readers, Iterable use) { + super(uuid, name, size, claimType, tags, readers, use); } } \ No newline at end of file diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java index 5c4b72fad7..0738d86727 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java @@ -195,7 +195,7 @@ public class DriveInfo extends Drive { */ @Override public DriveInfo build() { - return new DriveInfo(uuid, name, size, claimType, affinity, readers, use, status, user, claimed, encryptionCipher, + return new DriveInfo(uuid, name, size, claimType, tags, readers, use, status, user, claimed, encryptionCipher, imaging, metrics, autoexpanding, bits, description, driveType, encryptionKey, free, installNotes, os, type, url); } @@ -221,12 +221,12 @@ public class DriveInfo extends Drive { private final DriveType type; private final URI url; - public DriveInfo(String uuid, String name, long size, ClaimType claimType, AffinityType affinity, Iterable readers, + public DriveInfo(String uuid, String name, long size, ClaimType claimType, Iterable tags, Iterable readers, Iterable use, DriveStatus status, String user, Set claimed, String encryptionCipher, String imaging, DriveMetrics metrics, Boolean autoexpanding, Integer bits, String description, Iterable driveType, String encryptionKey, Boolean free, String installNotes, String os, DriveType type, URI url) { - super(uuid, name, size, claimType, affinity, readers, use); + super(uuid, name, size, claimType, tags, readers, use); this.status = status; this.user = user; this.claimed = ImmutableSet.copyOf(checkNotNull(claimed, "claimed")); From 3f0f782f9d9712f025a65dd9c32187d3e5582536 Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Wed, 21 Dec 2011 11:28:32 +0000 Subject: [PATCH 06/15] Include tags when converting between Map and Drive{Info,Data} --- .../java/org/jclouds/cloudsigma/functions/BaseDriveToMap.java | 2 ++ .../java/org/jclouds/cloudsigma/functions/MapToDriveInfo.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/BaseDriveToMap.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/BaseDriveToMap.java index 6555451cfc..0482e180cd 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/BaseDriveToMap.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/BaseDriveToMap.java @@ -45,6 +45,8 @@ public class BaseDriveToMap implements Function> { builder.put("size", from.getSize() + ""); if (from.getClaimType() != ClaimType.EXCLUSIVE) builder.put("claim:type", from.getClaimType().toString()); + if (from.getTags().size() != 0) + builder.put("tags", Joiner.on(' ').join(from.getTags())); if (from.getReaders().size() != 0) builder.put("readers", Joiner.on(' ').join(from.getReaders())); if (from.getUse().size() != 0) diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveInfo.java index 9732eabba1..9f9c3718a5 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveInfo.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveInfo.java @@ -48,8 +48,6 @@ public class MapToDriveInfo implements Function, DriveInfo> @Override public DriveInfo apply(Map from) { - if (from.size() == 0) - return null; if (from.size() == 0) return null; DriveInfo.Builder builder = new DriveInfo.Builder(); @@ -66,6 +64,8 @@ public class MapToDriveInfo implements Function, DriveInfo> builder.claimType(ClaimType.fromValue(from.get("claim:type"))); if (from.containsKey("claimed")) builder.claimed(Splitter.on(' ').split(from.get("claimed"))); + if (from.containsKey("tags")) + builder.tags(Splitter.on(' ').split(from.get("tags"))); if (from.containsKey("readers")) builder.readers(Splitter.on(' ').split(from.get("readers"))); if (from.containsKey("size")) From c13e6e20bc3d2fa82b7115cc5b08e46b9ce93285 Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Wed, 21 Dec 2011 12:59:59 +0000 Subject: [PATCH 07/15] Use varargs for tags() to make life easier for callers; preserve tag order for easier unit testing --- .../cloudsigma/options/CloneDriveOptions.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java index 9cef0740ce..fcb59d2cd5 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java @@ -21,6 +21,7 @@ package org.jclouds.cloudsigma.options; import static com.google.common.base.Preconditions.checkArgument; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; @@ -61,16 +62,18 @@ public class CloneDriveOptions { return this; } - public CloneDriveOptions tags(Iterable tags) { + public CloneDriveOptions tags(String... tags) { // Affinity is conveyed using regular tags; make sure to preserve any already-set affinity tag. String currentTagsString = options.remove("tags"); Set currentTags = (currentTagsString == null) ? new HashSet() : - Sets.newHashSet(Splitter.on(' ').split(currentTagsString)); + Sets.newLinkedHashSet(Splitter.on(' ').split(currentTagsString)); - Set newTags = Sets.newHashSet(tags); - if (currentTags.contains(SSD_AFFINITY_TAG)) { + Set newTags = new LinkedHashSet(); + for (String tag : tags) + newTags.add(tag); + + if (currentTags.contains(SSD_AFFINITY_TAG)) newTags.add(SSD_AFFINITY_TAG); - } options.put("tags", Joiner.on(' ').join(newTags)); return this; @@ -83,8 +86,8 @@ public class CloneDriveOptions { public CloneDriveOptions affinity(AffinityType affinity) { // Affinity is conveyed using regular tags; make sure to avoid multiple affinity tags in the options. String currentTagsString = options.remove("tags"); - Set tags = (currentTagsString == null) ? new HashSet() : - Sets.newHashSet(Splitter.on(' ').split(currentTagsString)); + Set tags = (currentTagsString == null) ? new LinkedHashSet() : + Sets.newLinkedHashSet(Splitter.on(' ').split(currentTagsString)); switch (affinity) { // SSD affinity is conveyed as a special tag: "affinity:ssd". @@ -117,7 +120,7 @@ public class CloneDriveOptions { /** * @see CloneDriveOptions#tags */ - public static CloneDriveOptions tags(Iterable tags) { + public static CloneDriveOptions tags(String... tags) { CloneDriveOptions options = new CloneDriveOptions(); return options.tags(tags); } From 5f63768d4df48d4f74a40a257e929131c7323d2f Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Wed, 21 Dec 2011 13:04:44 +0000 Subject: [PATCH 08/15] Update CloneDriveOptions unit test to include tags and affinity --- .../options/CloneDriveOptionsTest.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/options/CloneDriveOptionsTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/options/CloneDriveOptionsTest.java index c114f892b8..06175f999f 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/options/CloneDriveOptionsTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/options/CloneDriveOptionsTest.java @@ -19,9 +19,12 @@ package org.jclouds.cloudsigma.options; import static org.jclouds.cloudsigma.options.CloneDriveOptions.Builder.size; +import static org.jclouds.cloudsigma.options.CloneDriveOptions.Builder.tags; +import static org.jclouds.cloudsigma.options.CloneDriveOptions.Builder.affinity; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; +import org.jclouds.cloudsigma.domain.AffinityType; import org.testng.annotations.Test; /** @@ -54,5 +57,61 @@ public class CloneDriveOptionsTest { public void testSizeNegative() { size(-1); } + + @Test + public void testNullTags() { + CloneDriveOptions options = new CloneDriveOptions(); + assertNull(options.getOptions().get("tags")); + } + @Test + public void testTags() { + CloneDriveOptions options = new CloneDriveOptions().tags("foo", "bar", "baz"); + assertEquals(options.getOptions().get("tags"), "foo bar baz"); + } + + @Test + public void testTagsStatic() { + CloneDriveOptions options = tags("foo", "bar", "baz"); + assertEquals(options.getOptions().get("tags"), "foo bar baz"); + } + + @Test + public void testHddAffinity() { + CloneDriveOptions options = new CloneDriveOptions().affinity(AffinityType.HDD); + assertNull(options.getOptions().get("tags")); + } + + @Test + public void testHddAffinityStatic() { + CloneDriveOptions options = affinity(AffinityType.HDD); + assertNull(options.getOptions().get("tags")); + } + + @Test + public void testSsdAffinity() { + CloneDriveOptions options = new CloneDriveOptions().affinity(AffinityType.SSD); + assertEquals(options.getOptions().get("tags"), "affinity:ssd"); + } + + @Test + public void testSsdAffinityStatic() { + CloneDriveOptions options = affinity(AffinityType.SSD); + assertEquals(options.getOptions().get("tags"), "affinity:ssd"); + } + + @Test + public void testHddAffinityWithTags() { + CloneDriveOptions options = new CloneDriveOptions().affinity(AffinityType.HDD); + options.tags("foo", "bar", "baz"); + assertEquals(options.getOptions().get("tags"), "foo bar baz"); + } + + @Test + public void testSsdAffinityWithTags() { + CloneDriveOptions options = new CloneDriveOptions().affinity(AffinityType.SSD); + options.tags("foo", "bar", "baz"); + assertEquals(options.getOptions().get("tags"), "foo bar baz affinity:ssd"); + } + } From 422bf8371a00cade0e2241317676bc7cfd9d1c7a Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Wed, 21 Dec 2011 13:51:23 +0000 Subject: [PATCH 09/15] More thorough testing of tags/affintity interaction --- .../options/CloneDriveOptionsTest.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/options/CloneDriveOptionsTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/options/CloneDriveOptionsTest.java index 06175f999f..d8f733bedf 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/options/CloneDriveOptionsTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/options/CloneDriveOptionsTest.java @@ -101,17 +101,31 @@ public class CloneDriveOptionsTest { } @Test - public void testHddAffinityWithTags() { + public void testHddAffinityBeforeTags() { CloneDriveOptions options = new CloneDriveOptions().affinity(AffinityType.HDD); options.tags("foo", "bar", "baz"); assertEquals(options.getOptions().get("tags"), "foo bar baz"); } @Test - public void testSsdAffinityWithTags() { + public void testSsdAffinityBeforeTags() { CloneDriveOptions options = new CloneDriveOptions().affinity(AffinityType.SSD); options.tags("foo", "bar", "baz"); assertEquals(options.getOptions().get("tags"), "foo bar baz affinity:ssd"); } + @Test + public void testHddAffinityAfterTags() { + CloneDriveOptions options = new CloneDriveOptions().tags("foo", "bar", "baz"); + options.affinity(AffinityType.HDD); + assertEquals(options.getOptions().get("tags"), "foo bar baz"); + } + + @Test + public void testSsdAffinityAfterTags() { + CloneDriveOptions options = new CloneDriveOptions().tags("foo", "bar", "baz"); + options.affinity(AffinityType.SSD); + assertEquals(options.getOptions().get("tags"), "foo bar baz affinity:ssd"); + } + } From 5dedb8b81c0780d71bb4169c3f14577593ac0b5f Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Wed, 21 Dec 2011 14:09:12 +0000 Subject: [PATCH 10/15] builders perform necessary casting of return type when setting tags --- .../org/jclouds/cloudsigma/domain/CreateDriveRequest.java | 8 ++++++++ .../java/org/jclouds/cloudsigma/domain/DriveData.java | 8 ++++++++ .../java/org/jclouds/cloudsigma/domain/DriveInfo.java | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java index 30db029c76..f631823dcb 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java @@ -64,6 +64,14 @@ public class CreateDriveRequest extends Drive { return Builder.class.cast(super.name(name)); } + /** + * {@inheritDoc} + */ + @Override + public Builder tags(Iterable tags) { + return Builder.class.cast(super.tags(tags)); + } + /** * {@inheritDoc} */ diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java index 7d0a561195..4a01d831d1 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java @@ -43,6 +43,14 @@ public class DriveData extends Drive { return Builder.class.cast(super.name(name)); } + /** + * {@inheritDoc} + */ + @Override + public Builder tags(Iterable tags) { + return Builder.class.cast(super.tags(tags)); + } + /** * {@inheritDoc} */ diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java index 0738d86727..906f414cfc 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java @@ -141,6 +141,14 @@ public class DriveInfo extends Drive { return Builder.class.cast(super.claimType(claimType)); } + /** + * {@inheritDoc} + */ + @Override + public Builder tags(Iterable tags) { + return Builder.class.cast(super.tags(tags)); + } + /** * {@inheritDoc} */ From 7e0244edae5bb796dee73438b2b900f66b1ad825 Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Wed, 21 Dec 2011 14:10:36 +0000 Subject: [PATCH 11/15] Unit test tags as part of map <-> drive conversions --- .../cloudsigma/functions/BaseDriveToMapTest.java | 5 ++++- .../cloudsigma/functions/DriveDataToMapTest.java | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/BaseDriveToMapTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/BaseDriveToMapTest.java index 89ec601fb6..7d42de97e8 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/BaseDriveToMapTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/BaseDriveToMapTest.java @@ -48,13 +48,16 @@ public class BaseDriveToMapTest { // .size(8589934592l)// .claimType(ClaimType.SHARED)// + .tags(ImmutableSet.of("foo", "bar", "baz"))// .readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"))// .use(ImmutableSet.of("tag1", "tag2"))// .build(); assertEquals( BASEDRIVE_TO_MAP.apply(one), ImmutableMap.builder().put("name", "Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System") - .put("size", "8589934592").put("claim:type", "shared") + .put("size", "8589934592") + .put("claim:type", "shared") + .put("tags", "foo bar baz") .put("readers", "ffffffff-ffff-ffff-ffff-ffffffffffff").put("use", "tag1 tag2").build() ); diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/DriveDataToMapTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/DriveDataToMapTest.java index 2c2a49383c..7189048464 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/DriveDataToMapTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/DriveDataToMapTest.java @@ -49,14 +49,19 @@ public class DriveDataToMapTest { // .size(8589934592l)// .claimType(ClaimType.SHARED)// + .tags(ImmutableSet.of("foo", "bar", "baz"))// .readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"))// .use(ImmutableSet.of("tag1", "tag2"))// .build(); assertEquals( BASEDRIVE_TO_MAP.apply(one), - ImmutableMap.builder().put("name", "Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System") - .put("size", "8589934592").put("claim:type", "shared") - .put("readers", "ffffffff-ffff-ffff-ffff-ffffffffffff").put("use", "tag1 tag2").build() + ImmutableMap.builder() + .put("name", "Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System") + .put("size", "8589934592") + .put("claim:type", "shared") + .put("tags", "foo bar baz") + .put("readers", "ffffffff-ffff-ffff-ffff-ffffffffffff") + .put("use", "tag1 tag2").build() ); From 5ef0d044483d4ea3f6d110777d5171e6cb6e2c60 Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Wed, 21 Dec 2011 14:41:23 +0000 Subject: [PATCH 12/15] update resource-based drive <-> map tests --- .../cloudsigma/binders/BindDriveDataToPlainTextStringTest.java | 1 + .../org/jclouds/cloudsigma/functions/MapToDriveInfoTest.java | 1 + apis/cloudsigma/src/test/resources/drive.txt | 1 + apis/cloudsigma/src/test/resources/drive_data.txt | 1 + 4 files changed, 4 insertions(+) diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextStringTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextStringTest.java index e09eed7d35..d5027053c0 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextStringTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextStringTest.java @@ -72,6 +72,7 @@ public class BindDriveDataToPlainTextStringTest { // .size(8589934592l)// .claimType(ClaimType.SHARED)// + .tags(ImmutableSet.of("foo", "bar", "baz"))// .readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"))// .use(ImmutableSet.of("tag1", "tag2"))// .build(); diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToDriveInfoTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToDriveInfoTest.java index cfb3337580..a2bde54ee6 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToDriveInfoTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToDriveInfoTest.java @@ -54,6 +54,7 @@ public class MapToDriveInfoTest { .encryptionCipher("aes-xts-plain") .encryptionKey("ba6c2a4897072e9f25920ed73bd522e9c10d89f30a215158cccf8d0f654ac643") .description("The Ubuntu Linux distribution brings the spirit of Ubuntu to the software world.") + .tags(ImmutableSet.of("foo", "bar", "baz")) .uuid("b8171d28-755a-4271-b891-7998871a160e") .installNotes("first line\n\n") .os("linux") diff --git a/apis/cloudsigma/src/test/resources/drive.txt b/apis/cloudsigma/src/test/resources/drive.txt index 63abfc8f14..149c823e86 100644 --- a/apis/cloudsigma/src/test/resources/drive.txt +++ b/apis/cloudsigma/src/test/resources/drive.txt @@ -16,6 +16,7 @@ claim:type shared claimed 00109617-2c6b-424b-9cfa-5b572c17bafe:guest:692cd1c7-a863-4a22-8170-fc6e6feb68af:ide:0:0 00031836-a624-4b22-bc7d-41ff8977087b:guest:a1414360-7c24-4730-8c97-180bf7775a71:ide:0:0 0002c6df-a1d2-4d1d-96f0-f95405a28183:guest:386f1cc7-affc-49c1-82a5-2f8e412170e4:ide:0:0 00031836-a624-4b22-bc7d-41ff8977087b:guest:17b076be-430d-4a76-9df3-b9896fec82a5:ide:0:0 000663ee-9fb6-4461-90f6-01327a4aff07:guest:f83b519f-feab-42cf-859c-f61495681ada:ide:0:1 drive_type installcd,livecd autoexpanding false +tags foo bar baz readers ffffffff-ffff-ffff-ffff-ffffffffffff read:requests 1 free true diff --git a/apis/cloudsigma/src/test/resources/drive_data.txt b/apis/cloudsigma/src/test/resources/drive_data.txt index 44ce187567..74d7679ce6 100644 --- a/apis/cloudsigma/src/test/resources/drive_data.txt +++ b/apis/cloudsigma/src/test/resources/drive_data.txt @@ -1,5 +1,6 @@ name Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System size 8589934592 claim:type shared +tags foo bar baz readers ffffffff-ffff-ffff-ffff-ffffffffffff use tag1 tag2 \ No newline at end of file From df8d529235702616417d15a6d6692bf35200ca01 Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Thu, 22 Dec 2011 00:09:27 +0000 Subject: [PATCH 13/15] Include tags in existing toString() methods on Drive and subclasses --- .../org/jclouds/cloudsigma/domain/CreateDriveRequest.java | 5 +++-- .../src/main/java/org/jclouds/cloudsigma/domain/Drive.java | 2 +- .../main/java/org/jclouds/cloudsigma/domain/DriveInfo.java | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java index f631823dcb..cc77282f8b 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java @@ -163,7 +163,8 @@ public class CreateDriveRequest extends Drive { @Override public String toString() { - return "[name=" + name + ", size=" + size + ", claimType=" + claimType + ", readers=" + readers + ", use=" + use - + ", avoid=" + avoid + ", encryptionCipher=" + encryptionCipher + "]"; + return "[name=" + name + ", size=" + size + ", claimType=" + claimType + ", tags=" + tags + + ", readers=" + readers + ", use=" + use + ", avoid=" + avoid + + ", encryptionCipher=" + encryptionCipher + "]"; } } \ No newline at end of file diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java index 5adcce61ca..e9aa819080 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java @@ -209,7 +209,7 @@ public class Drive extends Item { @Override public String toString() { return "[uuid=" + uuid + ", name=" + name + ", use=" + use + ", size=" + size + ", claimType=" + claimType - + ", readers=" + readers + "]"; + + ", tags=" + tags + ", readers=" + readers + "]"; } } \ No newline at end of file diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java index 906f414cfc..8bc6537135 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java @@ -463,9 +463,10 @@ public class DriveInfo extends Drive { @Override public String toString() { - return "[size=" + size + ", claimType=" + claimType + ", readers=" + readers + ", uuid=" + uuid + ", name=" - + name + ", use=" + use + ", status=" + status + ", user=" + user + ", claimed=" + claimed - + ", encryptionCipher=" + encryptionCipher + ", imaging=" + imaging + ", metrics=" + metrics + "]"; + return "[size=" + size + ", claimType=" + claimType + ", tags=" + tags + ", readers=" + readers + + ", uuid=" + uuid + ", name=" + name + ", use=" + use + ", status=" + status + + ", user=" + user + ", claimed=" + claimed + ", encryptionCipher=" + encryptionCipher + + ", imaging=" + imaging + ", metrics=" + metrics + "]"; } } \ No newline at end of file From 91c0492e6a72c468a5ea3a63e8766f8226245ca5 Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Thu, 22 Dec 2011 00:58:15 +0000 Subject: [PATCH 14/15] Increase timeout on potentially-lengthy cloneDrive() operation --- .../src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java | 1 + 1 file changed, 1 insertion(+) diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java index dcd3f555a5..72c34c4a82 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java @@ -219,6 +219,7 @@ public interface CloudSigmaClient { * options to control size * @return new drive */ + @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) DriveInfo cloneDrive(String sourceUuid, String newName, CloneDriveOptions... options); /** From 601922a8e4c5d442b8a28341eebd744078395ee4 Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Thu, 22 Dec 2011 01:11:17 +0000 Subject: [PATCH 15/15] Specify tags to cloneDrive() and assert they are retrieved --- .../jclouds/cloudsigma/CloudSigmaClientLiveTest.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java index 1727e586e3..db98f21aba 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java @@ -446,9 +446,16 @@ public class CloudSigmaClientLiveTest { protected void prepareDrive() { client.destroyDrive(drive.getUuid()); drive = client.cloneDrive(bootDrive, drive.getName(), - new CloneDriveOptions().size(driveSize)); + new CloneDriveOptions() + .size(driveSize) + .tags("cat:mouse", "monkey:banana") + ); + // Block until the async clone operation has completed. assert driveNotClaimed.apply(drive) : client.getDriveInfo(drive.getUuid()); - System.err.println("after prepare" + client.getDriveInfo(drive.getUuid())); + + DriveInfo clonedDrive = client.getDriveInfo(drive.getUuid()); + System.err.println("after prepare" + clonedDrive); + assertEquals(clonedDrive.getTags(), ImmutableSet.of("cat:mouse", "monkey:banana")); } }