Implementing Dimension Data ServerImageApi.
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/3b6dbe51 Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/3b6dbe51 Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/3b6dbe51 Branch: refs/heads/2.0.x Commit: 3b6dbe51cbbbfb6b72883e762f9529d3f5b9306c Parents: f477118 Author: Trevor Flanagan <[email protected]> Authored: Tue Apr 11 13:57:24 2017 +0100 Committer: Ignasi Barrera <[email protected]> Committed: Tue Apr 11 16:11:47 2017 +0200 ---------------------------------------------------------------------- .../DimensionDataCloudControlApi.java | 4 + .../DimensionDataCloudControlParserModule.java | 2 + .../cloudcontrol/domain/Account.java | 17 + .../cloudcontrol/domain/BaseImage.java | 26 +- .../cloudcontrol/domain/Cluster.java | 51 +++ .../cloudcontrol/domain/CustomerImage.java | 234 +++++++++++ .../cloudcontrol/domain/CustomerImages.java | 32 ++ .../cloudcontrol/domain/Guest.java | 60 +++ .../cloudcontrol/domain/ImageNic.java | 53 +++ .../cloudcontrol/domain/OsImage.java | 65 ++- .../cloudcontrol/domain/VmTools.java | 77 ++++ .../cloudcontrol/features/ServerImageApi.java | 162 ++++++++ .../filters/DatacenterIdFilter.java | 49 +++ .../features/ServerImageApiLiveTest.java | 52 +++ .../features/ServerImageApiMockTest.java | 154 +++++++ .../BaseDimensionDataCloudControlMockTest.java | 4 +- .../BaseDimensionDataCloudControlParseTest.java | 39 ++ .../parse/CustomerImagesParseTest.java | 76 ++++ .../cloudcontrol/parse/OsImagesParseTest.java | 63 +++ .../src/test/resources/customerImage.json | 80 ++++ .../src/test/resources/customerImages.json | 77 ++++ .../test/resources/customerImages_page1.json | 333 +++++++++++++++ .../test/resources/customerImages_page2.json | 402 +++++++++++++++++++ dimensiondata/src/test/resources/osImage.json | 61 +++ dimensiondata/src/test/resources/osImages.json | 50 +++ .../src/test/resources/osImages_page1.json | 50 +++ .../src/test/resources/osImages_page2.json | 50 +++ 27 files changed, 2278 insertions(+), 45 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/DimensionDataCloudControlApi.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/DimensionDataCloudControlApi.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/DimensionDataCloudControlApi.java index a3b81c8..7e21571 100644 --- a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/DimensionDataCloudControlApi.java +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/DimensionDataCloudControlApi.java @@ -18,6 +18,7 @@ package org.jclouds.dimensiondata.cloudcontrol; import org.jclouds.dimensiondata.cloudcontrol.features.AccountApi; import org.jclouds.dimensiondata.cloudcontrol.features.InfrastructureApi; +import org.jclouds.dimensiondata.cloudcontrol.features.ServerImageApi; import org.jclouds.rest.annotations.Delegate; import java.io.Closeable; @@ -29,4 +30,7 @@ public interface DimensionDataCloudControlApi extends Closeable { @Delegate InfrastructureApi getInfrastructureApi(); + + @Delegate + ServerImageApi getServerImageApi(); } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/config/DimensionDataCloudControlParserModule.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/config/DimensionDataCloudControlParserModule.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/config/DimensionDataCloudControlParserModule.java index f5023da..99d7063 100644 --- a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/config/DimensionDataCloudControlParserModule.java +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/config/DimensionDataCloudControlParserModule.java @@ -17,11 +17,13 @@ package org.jclouds.dimensiondata.cloudcontrol.config; import com.google.inject.AbstractModule; +import org.jclouds.json.config.GsonModule; public class DimensionDataCloudControlParserModule extends AbstractModule { @Override protected void configure() { + bind(GsonModule.DateAdapter.class).to(GsonModule.Iso8601DateAdapter.class); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Account.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Account.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Account.java index 323dbcb..0f257ef 100644 --- a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Account.java +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Account.java @@ -69,6 +69,8 @@ public abstract class Account { .customDefined2(customDefined2).organization(organization).state(state).build(); } + public abstract Builder toBuilder(); + public static Builder builder() { return new AutoValue_Account.Builder(); } @@ -113,6 +115,9 @@ public abstract class Account { @AutoValue public abstract static class AccountOrganization { + AccountOrganization() { + } + public abstract String id(); public abstract String name(); @@ -130,6 +135,8 @@ public abstract class Account { .build(); } + public abstract Builder toBuilder(); + public static Builder builder() { return new AutoValue_Account_AccountOrganization.Builder(); } @@ -153,6 +160,9 @@ public abstract class Account { @AutoValue public abstract static class AccountPhoneNumber { + AccountPhoneNumber() { + } + public abstract String countryCode(); public abstract String number(); @@ -162,6 +172,8 @@ public abstract class Account { return builder().countryCode(countryCode).number(number).build(); } + public abstract Builder toBuilder(); + public static Builder builder() { return new AutoValue_Account_AccountPhoneNumber.Builder(); } @@ -180,6 +192,9 @@ public abstract class Account { @AutoValue public abstract static class RoleType { + RoleType() { + } + public abstract String name(); @SerializedNames({ "role" }) @@ -187,6 +202,8 @@ public abstract class Account { return builder().name(name).build(); } + public abstract Builder toBuilder(); + public static Builder builder() { return new AutoValue_Account_RoleType.Builder(); } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/BaseImage.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/BaseImage.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/BaseImage.java index fc3c57b..1f0d143 100644 --- a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/BaseImage.java +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/BaseImage.java @@ -16,9 +16,12 @@ */ package org.jclouds.dimensiondata.cloudcontrol.domain; +import org.jclouds.javax.annotation.Nullable; + import java.util.Date; import java.util.List; + public abstract class BaseImage { public static final String IMAGE_TYPE_METADATA_KEY = "IMAGE_TYPE"; public static final String OS_FAMILY_METADATA_KEY = "OS_FAMILY"; @@ -30,21 +33,32 @@ public abstract class BaseImage { public abstract String id(); - public abstract String datacenterId(); - public abstract String name(); + @Nullable public abstract String description(); - public abstract OperatingSystem operatingSystem(); + @Nullable + public abstract Cluster cluster(); + + /** + * optional on CustomerImage, mandatory on OsImage + */ + @Nullable + public abstract Guest guest(); + + public abstract String datacenterId(); public abstract CPU cpu(); - public abstract Integer memoryGb(); + public abstract int memoryGb(); - public abstract List<Disk> disk(); + public abstract List<ImageNic> nics(); - public abstract List<Object> softwareLabel(); + public abstract List<Disk> disks(); + + public abstract List<String> softwareLabels(); public abstract Date createTime(); + } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Cluster.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Cluster.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Cluster.java new file mode 100644 index 0000000..1e442d1 --- /dev/null +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Cluster.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.dimensiondata.cloudcontrol.domain; + +import com.google.auto.value.AutoValue; +import org.jclouds.json.SerializedNames; + +@AutoValue +public abstract class Cluster { + + Cluster() { + } + + public abstract String id(); + + public abstract String name(); + + @SerializedNames({ "id", "name" }) + public static Cluster create(String id, String name) { + return builder().id(id).name(name).build(); + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_Cluster.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(String id); + + public abstract Builder name(String name); + + public abstract Cluster build(); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/CustomerImage.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/CustomerImage.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/CustomerImage.java new file mode 100644 index 0000000..a549ef7 --- /dev/null +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/CustomerImage.java @@ -0,0 +1,234 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.dimensiondata.cloudcontrol.domain; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import java.util.Date; +import java.util.List; + +@AutoValue +public abstract class CustomerImage extends BaseImage { + + public static final String TYPE = "CUSTOMER_IMAGE"; + + CustomerImage() { + type = TYPE; + } + + public static Builder builder() { + return new AutoValue_CustomerImage.Builder(); + } + + @SerializedNames({ "id", "name", "description", "cluster", "guest", "datacenterId", "cpu", "memoryGb", "nic", "disk", + "softwareLabel", "createTime", "state", "tag", "progress", "virtualHardware", "source" }) + public static CustomerImage create(String id, String name, String description, Cluster cluster, Guest guest, + String datacenterId, CPU cpu, int memoryGb, List<ImageNic> nics, List<Disk> disk, List<String> softwareLabel, + Date createTime, String state, List<TagWithIdAndName> tags, Progress progress, VirtualHardware virtualHardware, + Source source) { + return builder().id(id).datacenterId(datacenterId).name(name).description(description).cluster(cluster) + .guest(guest).cpu(cpu).memoryGb(memoryGb).nics(nics).disks(disk).softwareLabels(softwareLabel) + .createTime(createTime).state(state).tags(tags).progress(progress).virtualHardware(virtualHardware) + .source(source).build(); + } + + public abstract String state(); + + @Nullable + public abstract List<TagWithIdAndName> tags(); + + @Nullable + public abstract Progress progress(); + + @Nullable + public abstract VirtualHardware virtualHardware(); + + public abstract Source source(); + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(String id); + + public abstract Builder datacenterId(String datacenterId); + + public abstract Builder name(String name); + + public abstract Builder description(String description); + + public abstract Builder cluster(Cluster cluster); + + public abstract Builder guest(Guest guest); + + public abstract Builder cpu(CPU cpu); + + public abstract Builder memoryGb(int memoryGb); + + public abstract Builder nics(List<ImageNic> nics); + + public abstract Builder disks(List<Disk> disks); + + public abstract Builder tags(List<TagWithIdAndName> tags); + + public abstract Builder softwareLabels(List<String> softwareLabels); + + public abstract Builder virtualHardware(VirtualHardware virtualHardware); + + public abstract Builder source(Source source); + + public abstract Builder createTime(Date createTime); + + public abstract Builder state(String state); + + public abstract Builder progress(Progress progress); + + abstract CustomerImage autoBuild(); + + abstract List<Disk> disks(); + + abstract List<String> softwareLabels(); + + abstract List<ImageNic> nics(); + + abstract List<TagWithIdAndName> tags(); + + public CustomerImage build() { + disks(disks() != null ? ImmutableList.copyOf(disks()) : ImmutableList.<Disk>of()); + softwareLabels(softwareLabels() != null ? ImmutableList.copyOf(softwareLabels()) : ImmutableList.<String>of()); + nics(nics() != null ? ImmutableList.copyOf(nics()) : ImmutableList.<ImageNic>of()); + tags(tags() != null ? ImmutableList.copyOf(tags()) : null); + return autoBuild(); + } + } + + @AutoValue + public abstract static class TagWithIdAndName { + + TagWithIdAndName() { + } + + public abstract String tagKeyName(); + + @Nullable + public abstract String value(); + + public abstract String tagKeyId(); + + public abstract Builder toBuilder(); + + @SerializedNames({ "tagKeyName", "value", "tagKeyId" }) + public static TagWithIdAndName create(String tagKeyName, String value, String tagKeyId) { + return builder().tagKeyName(tagKeyName).value(value).tagKeyId(tagKeyId).build(); + } + + public static Builder builder() { + return new AutoValue_CustomerImage_TagWithIdAndName.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder tagKeyName(String tagKeyName); + + public abstract Builder value(String value); + + public abstract Builder tagKeyId(String tagKeyId); + + public abstract TagWithIdAndName build(); + } + } + + @AutoValue + public abstract static class Source { + + public enum Type { + BASE, CLONE, IMPORT, COPY + } + + public abstract List<Artifact> artifacts(); + + public abstract Type type(); + + @SerializedNames({ "artifact", "type" }) + public static Source create(List<Artifact> artifact, Type type) { + return builder().artifacts(artifact).type(type).build(); + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_CustomerImage_Source.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder type(Type type); + + public abstract Builder artifacts(List<Artifact> artifact); + + abstract List<Artifact> artifacts(); + + abstract Source autoBuild(); + + public Source build() { + artifacts(artifacts() != null ? ImmutableList.copyOf(artifacts()) : ImmutableList.<Artifact>of()); + return autoBuild(); + } + } + } + + @AutoValue + public abstract static class Artifact { + + public enum Type { + MF, OVF, VMDK, REFERENCE, SERVER_ID, LEGACY_IMPORT_ID, IMAGE_ID, OVF_PACKAGE_PREFIX + } + + public abstract Type type(); + + public abstract String value(); + + @Nullable + public abstract Date date(); + + @SerializedNames({ "type", "value", "date" }) + public static Artifact create(Type type, String value, Date date) { + return builder().type(type).value(value).date(date).build(); + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_CustomerImage_Artifact.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder type(Type type); + + public abstract Builder value(String value); + + public abstract Builder date(Date date); + + public abstract Artifact build(); + } + } +} + http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/CustomerImages.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/CustomerImages.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/CustomerImages.java new file mode 100644 index 0000000..ad66623 --- /dev/null +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/CustomerImages.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.dimensiondata.cloudcontrol.domain; + +import java.beans.ConstructorProperties; +import java.util.List; + +/** + * A collection of CustomerImage + */ +public class CustomerImages extends PaginatedCollection<CustomerImage> { + + @ConstructorProperties({ "customerImage", "pageNumber", "pageCount", "totalCount", "pageSize" }) + public CustomerImages(List<CustomerImage> content, Integer pageNumber, Integer pageCount, Integer totalCount, + Integer pageSize) { + super(content, pageNumber, pageCount, totalCount, pageSize); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Guest.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Guest.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Guest.java new file mode 100644 index 0000000..cc07b71 --- /dev/null +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/Guest.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.dimensiondata.cloudcontrol.domain; + +import com.google.auto.value.AutoValue; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +@AutoValue +public abstract class Guest { + + Guest() { + } + + public abstract boolean osCustomization(); + + public abstract OperatingSystem operatingSystem(); + + /** + * always null for OSImage, optional for CustomerImage and Server + */ + @Nullable + public abstract VmTools vmTools(); + + public static Builder builder() { + return new AutoValue_Guest.Builder(); + } + + @SerializedNames({ "osCustomization", "operatingSystem", "vmTools" }) + public static Guest create(boolean osCustomization, OperatingSystem operatingSystem, VmTools vmTools) { + return builder().osCustomization(osCustomization).operatingSystem(operatingSystem).vmTools(vmTools).build(); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder osCustomization(boolean osCustomization); + + public abstract Builder operatingSystem(OperatingSystem operatingSystem); + + public abstract Builder vmTools(VmTools vmTools); + + public abstract Guest build(); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/ImageNic.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/ImageNic.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/ImageNic.java new file mode 100644 index 0000000..59bdec2 --- /dev/null +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/ImageNic.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.dimensiondata.cloudcontrol.domain; + +import com.google.auto.value.AutoValue; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +@AutoValue +public abstract class ImageNic { + + ImageNic() { + } + + public abstract String networkAdapter(); + + @Nullable + public abstract Integer key(); + + @SerializedNames({ "networkAdapter", "key" }) + public static ImageNic create(String networkAdapter, Integer key) { + return builder().networkAdapter(networkAdapter).key(key).build(); + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_ImageNic.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder networkAdapter(String networkAdapter); + + public abstract Builder key(Integer key); + + public abstract ImageNic build(); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/OsImage.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/OsImage.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/OsImage.java index 3d8cdae..7b179e5 100644 --- a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/OsImage.java +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/OsImage.java @@ -24,49 +24,31 @@ import java.util.Date; import java.util.List; @AutoValue -public abstract class OsImage { +public abstract class OsImage extends BaseImage { + public static final String TYPE = "OS_IMAGE"; OsImage() { + type = TYPE; } - public static Builder builder() { - return new AutoValue_OsImage.Builder(); - } - - public abstract String id(); - - public abstract String name(); - - public abstract String description(); - - public abstract String datacenterId(); - public abstract String osImageKey(); - public abstract Date createTime(); - - public abstract OperatingSystem operatingSystem(); - - public abstract CPU cpu(); - - public abstract int memoryGb(); - - public abstract List<Disk> disks(); - - public abstract List<Object> softwareLabels(); - - @SerializedNames({ "id", "name", "description", "datacenterId", "osImageKey", "createTime", "operatingSystem", "cpu", - "memoryGb", "disk", "softwareLabel" }) - public static OsImage create(String id, String name, String description, String datacenterId, String osImageKey, - Date createTime, OperatingSystem operatingSystem, CPU cpu, int memoryGb, List<Disk> disks, - List<Object> softwareLabels) { - return builder().id(id).name(name).datacenterId(datacenterId).description(description).osImageKey(osImageKey) - .createTime(createTime).operatingSystem(operatingSystem).cpu(cpu).memoryGb(memoryGb).disks(disks) - .softwareLabels(softwareLabels).build(); + @SerializedNames({ "id", "name", "description", "cluster", "guest", "datacenterId", "cpu", "memoryGb", "nic", "disk", + "softwareLabel", "createTime", "osImageKey" }) + public static OsImage create(String id, String name, String description, Cluster cluster, Guest guest, + String datacenterId, CPU cpu, int memoryGb, List<ImageNic> nics, List<Disk> disks, List<String> softwareLabels, + Date createTime, String osImageKey) { + return builder().id(id).name(name).description(description).cluster(cluster).guest(guest) + .datacenterId(datacenterId).osImageKey(osImageKey).createTime(createTime).cpu(cpu).memoryGb(memoryGb) + .nics(nics).disks(disks).softwareLabels(softwareLabels).build(); } public abstract Builder toBuilder(); + public static Builder builder() { + return new AutoValue_OsImage.Builder(); + } + @AutoValue.Builder public abstract static class Builder { public abstract Builder id(String id); @@ -75,31 +57,38 @@ public abstract class OsImage { public abstract Builder description(String description); + public abstract Builder cluster(Cluster cluster); + + public abstract Builder guest(Guest guest); + public abstract Builder datacenterId(String datacenterId); public abstract Builder osImageKey(String osImageKey); public abstract Builder createTime(Date createTime); - public abstract Builder operatingSystem(OperatingSystem operatingSystem); - public abstract Builder cpu(CPU cpu); public abstract Builder memoryGb(int memoryGb); + public abstract Builder nics(List<ImageNic> nics); + public abstract Builder disks(List<Disk> disks); - public abstract Builder softwareLabels(List<Object> softwareLabels); + public abstract Builder softwareLabels(List<String> softwareLabels); abstract OsImage autoBuild(); abstract List<Disk> disks(); - abstract List<Object> softwareLabels(); + abstract List<String> softwareLabels(); + + abstract List<ImageNic> nics(); public OsImage build() { disks(disks() != null ? ImmutableList.copyOf(disks()) : ImmutableList.<Disk>of()); - softwareLabels(softwareLabels() != null ? ImmutableList.copyOf(softwareLabels()) : ImmutableList.of()); + softwareLabels(softwareLabels() != null ? ImmutableList.copyOf(softwareLabels()) : ImmutableList.<String>of()); + nics(nics() != null ? ImmutableList.copyOf(nics()) : ImmutableList.<ImageNic>of()); return autoBuild(); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/VmTools.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/VmTools.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/VmTools.java new file mode 100644 index 0000000..5078c26 --- /dev/null +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/domain/VmTools.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.dimensiondata.cloudcontrol.domain; + +import com.google.auto.value.AutoValue; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +@AutoValue +public abstract class VmTools { + + public enum Type { + VMWARE_TOOLS, OPEN_VM_TOOLS + } + + public enum RunningStatus { + STARTING, NOT_RUNNING, RUNNING + } + + public enum VersionStatus { + CURRENT, NEED_UPGRADE, NOT_INSTALLED, UNMANAGED + } + + VmTools() { + } + + public abstract Type type(); + + @Nullable + public abstract VersionStatus versionStatus(); + + @Nullable + public abstract RunningStatus runningStatus(); + + @Nullable + public abstract Integer apiVersion(); + + @SerializedNames({ "type", "versionStatus", "runningStatus", "apiVersion" }) + public static VmTools create(Type type, VersionStatus versionStatus, RunningStatus runningStatus, + Integer apiVersion) { + return builder().type(type).versionStatus(versionStatus).runningStatus(runningStatus).apiVersion(apiVersion) + .build(); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder versionStatus(VersionStatus versionStatus); + + public abstract Builder runningStatus(RunningStatus runningStatus); + + public abstract Builder apiVersion(Integer apiVersion); + + public abstract Builder type(Type type); + + public abstract VmTools build(); + } + + public static Builder builder() { + return new AutoValue_VmTools.Builder(); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerImageApi.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerImageApi.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerImageApi.java new file mode 100644 index 0000000..22db3a2 --- /dev/null +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerImageApi.java @@ -0,0 +1,162 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.dimensiondata.cloudcontrol.features; + +import com.google.common.base.Function; +import com.google.inject.TypeLiteral; +import org.jclouds.Fallbacks; +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.PagedIterable; +import org.jclouds.collect.internal.ArgsToPagedIterable; +import org.jclouds.dimensiondata.cloudcontrol.DimensionDataCloudControlApi; +import org.jclouds.dimensiondata.cloudcontrol.domain.CustomerImage; +import org.jclouds.dimensiondata.cloudcontrol.domain.CustomerImages; +import org.jclouds.dimensiondata.cloudcontrol.domain.OsImage; +import org.jclouds.dimensiondata.cloudcontrol.domain.OsImages; +import org.jclouds.dimensiondata.cloudcontrol.domain.PaginatedCollection; +import org.jclouds.dimensiondata.cloudcontrol.filters.DatacenterIdFilter; +import org.jclouds.dimensiondata.cloudcontrol.filters.OrganisationIdFilter; +import org.jclouds.dimensiondata.cloudcontrol.options.PaginationOptions; +import org.jclouds.http.filters.BasicAuthentication; +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.Transform; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; +import java.util.List; + +@RequestFilters({ BasicAuthentication.class, OrganisationIdFilter.class }) +@Consumes(MediaType.APPLICATION_JSON) +@Path("/{jclouds.api-version}/image") +public interface ServerImageApi { + + @Named("image:listOsImages") + @GET + @Path("/osImage") + @ResponseParser(ParseOsImages.class) + @RequestFilters(DatacenterIdFilter.class) + @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) + PaginatedCollection<OsImage> listOsImages(PaginationOptions options); + + @Named("image:listOsImages") + @GET + @Path("/osImage") + @Transform(ParseOsImages.ToPagedIterable.class) + @ResponseParser(ParseOsImages.class) + @RequestFilters(DatacenterIdFilter.class) + @Fallback(Fallbacks.EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<OsImage> listOsImages(); + + @Named("image:listCustomerImages") + @GET + @Path("/customerImage") + @ResponseParser(ParseCustomerImages.class) + @RequestFilters(DatacenterIdFilter.class) + @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) + PaginatedCollection<CustomerImage> listCustomerImages(PaginationOptions options); + + @Named("image:listCustomerImages") + @GET + @Path("/customerImage") + @Transform(ParseCustomerImages.ToPagedIterable.class) + @ResponseParser(ParseCustomerImages.class) + @RequestFilters(DatacenterIdFilter.class) + @Fallback(Fallbacks.EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<CustomerImage> listCustomerImages(); + + @Named("image:getOsImage") + @GET + @Path("/osImage/{id}") + @Fallback(Fallbacks.NullOnNotFoundOr404.class) + OsImage getOsImage(@PathParam("id") String id); + + @Named("image:getCustomerImage") + @GET + @Path("/customerImage/{id}") + @Fallback(Fallbacks.NullOnNotFoundOr404.class) + CustomerImage getCustomerImage(@PathParam("id") String id); + + final class ParseOsImages extends ParseJson<OsImages> { + + @Inject + ParseOsImages(Json json) { + super(json, TypeLiteral.get(OsImages.class)); + } + + private static class ToPagedIterable extends ArgsToPagedIterable<OsImage, ToPagedIterable> { + + private DimensionDataCloudControlApi api; + + @Inject + ToPagedIterable(DimensionDataCloudControlApi api) { + this.api = api; + } + + @Override + protected Function<Object, IterableWithMarker<OsImage>> markerToNextForArgs(List<Object> args) { + return new Function<Object, IterableWithMarker<OsImage>>() { + @Override + public IterableWithMarker<OsImage> apply(Object input) { + PaginationOptions paginationOptions = PaginationOptions.class.cast(input); + return api.getServerImageApi().listOsImages(paginationOptions); + } + }; + } + } + } + + final class ParseCustomerImages extends ParseJson<CustomerImages> { + + @Inject + ParseCustomerImages(Json json) { + super(json, TypeLiteral.get(CustomerImages.class)); + } + + private static class ToPagedIterable extends ArgsToPagedIterable<CustomerImage, ToPagedIterable> { + + private DimensionDataCloudControlApi api; + + @Inject + ToPagedIterable(DimensionDataCloudControlApi api) { + this.api = api; + } + + @Override + protected Function<Object, IterableWithMarker<CustomerImage>> markerToNextForArgs(List<Object> args) { + return new Function<Object, IterableWithMarker<CustomerImage>>() { + @Override + public IterableWithMarker<CustomerImage> apply(Object input) { + PaginationOptions paginationOptions = PaginationOptions.class.cast(input); + return api.getServerImageApi().listCustomerImages(paginationOptions); + } + }; + } + } + } + +} + + http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/filters/DatacenterIdFilter.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/filters/DatacenterIdFilter.java b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/filters/DatacenterIdFilter.java new file mode 100644 index 0000000..436cd67 --- /dev/null +++ b/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/filters/DatacenterIdFilter.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.dimensiondata.cloudcontrol.filters; + +import com.google.common.base.Supplier; +import org.jclouds.http.HttpException; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpRequestFilter; +import org.jclouds.location.Zone; + +import javax.inject.Inject; +import java.util.Set; + +/** + * Adds set of Datacenter IDs as set in jclouds.zones JVM property. + */ +public class DatacenterIdFilter implements HttpRequestFilter { + + protected final Supplier<Set<String>> datacenterIdsSupplier; + + @Inject + DatacenterIdFilter(@Zone Supplier<Set<String>> datacenterIdsSupplier) { + this.datacenterIdsSupplier = datacenterIdsSupplier; + } + + @Override + public HttpRequest filter(HttpRequest request) throws HttpException { + Set<String> datacenterIds = datacenterIdsSupplier.get(); + if (datacenterIds != null && !datacenterIds.isEmpty()) { + return request.toBuilder().addQueryParam("datacenterId", datacenterIds).build(); + } else { + return request; + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerImageApiLiveTest.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerImageApiLiveTest.java b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerImageApiLiveTest.java new file mode 100644 index 0000000..ba60e96 --- /dev/null +++ b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerImageApiLiveTest.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.dimensiondata.cloudcontrol.features; + +import com.google.common.collect.FluentIterable; +import org.jclouds.dimensiondata.cloudcontrol.domain.CustomerImage; +import org.jclouds.dimensiondata.cloudcontrol.domain.OsImage; +import org.jclouds.dimensiondata.cloudcontrol.internal.BaseDimensionDataCloudControlApiLiveTest; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertNotNull; + +@Test(groups = "live", testName = "ServerImageApiLiveTest", singleThreaded = true) +public class ServerImageApiLiveTest extends BaseDimensionDataCloudControlApiLiveTest { + + @Test + public void testListOsImages() { + FluentIterable<OsImage> osImages = api().listOsImages().concat(); + assertNotNull(osImages); + for (OsImage osImage : osImages) { + assertNotNull(osImage); + } + } + + @Test + public void testListCustomerImages() { + FluentIterable<CustomerImage> customerImages = api().listCustomerImages().concat(); + assertNotNull(customerImages); + for (CustomerImage customerImage : customerImages) { + assertNotNull(customerImage); + } + } + + private ServerImageApi api() { + return api.getServerImageApi(); + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerImageApiMockTest.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerImageApiMockTest.java b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerImageApiMockTest.java new file mode 100644 index 0000000..a7e3f29 --- /dev/null +++ b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerImageApiMockTest.java @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.dimensiondata.cloudcontrol.features; + +import org.jclouds.dimensiondata.cloudcontrol.domain.CustomerImage; +import org.jclouds.dimensiondata.cloudcontrol.domain.OsImage; +import org.jclouds.dimensiondata.cloudcontrol.internal.BaseAccountAwareCloudControlMockTest; +import org.jclouds.http.Uris; +import org.jclouds.location.suppliers.ZoneIdsSupplier; +import org.testng.annotations.Test; + +import javax.ws.rs.HttpMethod; +import java.util.Set; + +import static com.google.common.collect.Iterables.size; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +/** + * Mock tests for the {@link ServerImageApi} class. + */ +@Test(groups = "unit", testName = "ServerImageApiMockTest", singleThreaded = true) +public class ServerImageApiMockTest extends BaseAccountAwareCloudControlMockTest { + + public void testGetOsImage() throws Exception { + server.enqueue(jsonResponse("/osImage.json")); + OsImage osImage = api.getServerImageApi().getOsImage("id"); + assertNotNull(osImage); + assertSent(HttpMethod.GET, getOsImageUrl().appendPath("/id").toString()); + } + + public void testGetOsImage_404() throws Exception { + server.enqueue(response404()); + OsImage osImage = api.getServerImageApi().getOsImage("id"); + assertNull(osImage); + assertSent(HttpMethod.GET, getOsImageUrl().appendPath("/id").toString()); + } + + public void testListOsImage() throws Exception { + server.enqueue(jsonResponse("/osImages.json")); + Iterable<OsImage> osImages = api.getServerImageApi().listOsImages().concat(); + assertEquals(size(osImages), 1); + assertEquals(server.getRequestCount(), 2); + + assertSent(HttpMethod.GET, getListOsImageUrl().toString()); + } + + public void testListOsImageWithPagination() throws Exception { + server.enqueue(jsonResponse("/osImages_page1.json")); + server.enqueue(jsonResponse("/osImages_page2.json")); + Iterable<OsImage> osImages = api.getServerImageApi().listOsImages().concat(); + assertNotNull(osImages); + consumeIterableAndAssertAdditionalPagesRequested(osImages, 2, 1); + + Uris.UriBuilder uriBuilder = getListOsImageUrl(); + assertSent(HttpMethod.GET, uriBuilder.toString()); + assertSent(HttpMethod.GET, addPageNumberToUriBuilder(uriBuilder, 2).toString()); + } + + public void testListOsImage_404() throws Exception { + server.enqueue(response404()); + assertTrue(api.getServerImageApi().listOsImages().concat().isEmpty()); + assertSent(HttpMethod.GET, getListOsImageUrl().toString()); + } + + private Uris.UriBuilder getListOsImageUrl() { + Uris.UriBuilder uriBuilder = getOsImageUrl(); + Set<String> zones = ctx.utils().injector().getInstance(ZoneIdsSupplier.class).get(); + for (String zone : zones) { + uriBuilder.addQuery("datacanterId", zone); + } + return uriBuilder; + } + + public void testGetCustomerImage() throws Exception { + server.enqueue(jsonResponse("/customerImage.json")); + CustomerImage customerImage = api.getServerImageApi().getCustomerImage("id"); + assertNotNull(customerImage); + assertSent(HttpMethod.GET, getCustomerImageUrl().appendPath("/id").toString()); + } + + public void testGetCustomerImage_404() throws Exception { + server.enqueue(response404()); + CustomerImage customerImage = api.getServerImageApi().getCustomerImage("id"); + assertNull(customerImage); + assertSent(HttpMethod.GET, getCustomerImageUrl().appendPath("/id").toString()); + } + + public void testListCustomerImage() throws Exception { + server.enqueue(jsonResponse("/customerImages.json")); + Iterable<CustomerImage> customerImages = api.getServerImageApi().listCustomerImages().concat(); + assertEquals(size(customerImages), 1); + assertEquals(server.getRequestCount(), 2); + + assertSent(HttpMethod.GET, getListCustomerImageUrl().toString()); + } + + public void testListCustomerImageWithPagination() throws Exception { + server.enqueue(jsonResponse("/customerImages_page1.json")); + server.enqueue(jsonResponse("/customerImages_page2.json")); + Iterable<CustomerImage> customerImages = api.getServerImageApi().listCustomerImages().concat(); + assertNotNull(customerImages); + consumeIterableAndAssertAdditionalPagesRequested(customerImages, 10, 1); + + Uris.UriBuilder uriBuilder = getListCustomerImageUrl(); + + assertSent(HttpMethod.GET, uriBuilder.toString()); + assertSent(HttpMethod.GET, addPageNumberToUriBuilder(uriBuilder, 2).toString()); + } + + public void testListCustomerImage_404() throws Exception { + server.enqueue(response404()); + assertTrue(api.getServerImageApi().listCustomerImages().concat().isEmpty()); + assertSent(HttpMethod.GET, getListCustomerImageUrl().toString()); + } + + private Uris.UriBuilder getListCustomerImageUrl() { + Uris.UriBuilder uriBuilder = getCustomerImageUrl(); + Set<String> zones = ctx.utils().injector().getInstance(ZoneIdsSupplier.class).get(); + for (String zone : zones) { + uriBuilder.addQuery("datacanterId", zone); + } + return uriBuilder; + } + + private Uris.UriBuilder getOsImageUrl() { + Uris.UriBuilder uriBuilder = Uris + .uriBuilder("/" + VERSION + "/6ac1e746-b1ea-4da5-a24e-caf1a978789d/image/osImage"); + return uriBuilder; + } + + private Uris.UriBuilder getCustomerImageUrl() { + Uris.UriBuilder uriBuilder = Uris + .uriBuilder("/" + VERSION + "/6ac1e746-b1ea-4da5-a24e-caf1a978789d/image/customerImage"); + return uriBuilder; + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/internal/BaseDimensionDataCloudControlMockTest.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/internal/BaseDimensionDataCloudControlMockTest.java b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/internal/BaseDimensionDataCloudControlMockTest.java index 85a8b9d..8c38085 100644 --- a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/internal/BaseDimensionDataCloudControlMockTest.java +++ b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/internal/BaseDimensionDataCloudControlMockTest.java @@ -91,7 +91,9 @@ public class BaseDimensionDataCloudControlMockTest implements IHookable { @Override public void run(IHookCallBack callBack, ITestResult testResult) { callBack.runTestMethod(testResult); - ensureAllRequestsWereAsserted(); + if (testResult.isSuccess()) { + ensureAllRequestsWereAsserted(); + } } private void ensureAllRequestsWereAsserted() { http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/internal/BaseDimensionDataCloudControlParseTest.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/internal/BaseDimensionDataCloudControlParseTest.java b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/internal/BaseDimensionDataCloudControlParseTest.java new file mode 100644 index 0000000..a3c807b --- /dev/null +++ b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/internal/BaseDimensionDataCloudControlParseTest.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.dimensiondata.cloudcontrol.internal; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.jclouds.dimensiondata.cloudcontrol.config.DimensionDataCloudControlParserModule; +import org.jclouds.json.BaseItemParserTest; +import org.jclouds.json.config.GsonModule; + +import javax.xml.bind.DatatypeConverter; +import java.util.Date; + +public abstract class BaseDimensionDataCloudControlParseTest<T> extends BaseItemParserTest<T> { + + @Override + protected Injector injector() { + return Guice.createInjector(new GsonModule(), new DimensionDataCloudControlParserModule()); + } + + protected Date parseDate(final String dateString) { + return DatatypeConverter.parseDateTime(dateString).getTime(); + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/CustomerImagesParseTest.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/CustomerImagesParseTest.java b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/CustomerImagesParseTest.java new file mode 100644 index 0000000..7b8e0ae --- /dev/null +++ b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/CustomerImagesParseTest.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.dimensiondata.cloudcontrol.parse; + +import com.google.common.collect.ImmutableList; +import org.jclouds.date.internal.SimpleDateFormatDateService; +import org.jclouds.dimensiondata.cloudcontrol.domain.CPU; +import org.jclouds.dimensiondata.cloudcontrol.domain.Cluster; +import org.jclouds.dimensiondata.cloudcontrol.domain.CustomerImage; +import org.jclouds.dimensiondata.cloudcontrol.domain.CustomerImages; +import org.jclouds.dimensiondata.cloudcontrol.domain.Disk; +import org.jclouds.dimensiondata.cloudcontrol.domain.Guest; +import org.jclouds.dimensiondata.cloudcontrol.domain.ImageNic; +import org.jclouds.dimensiondata.cloudcontrol.domain.OperatingSystem; +import org.jclouds.dimensiondata.cloudcontrol.domain.VirtualHardware; +import org.jclouds.dimensiondata.cloudcontrol.domain.VmTools; +import org.jclouds.dimensiondata.cloudcontrol.internal.BaseDimensionDataCloudControlParseTest; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; +import java.util.List; + +import static org.testng.Assert.assertEquals; + +public class CustomerImagesParseTest extends BaseDimensionDataCloudControlParseTest<CustomerImages> { + + @Override + public String resource() { + return "/customerImages.json"; + } + + @Override + @Consumes(MediaType.APPLICATION_JSON) + public CustomerImages expected() { + final CustomerImage customerImage = CustomerImage.builder().id("f27b7ead-9cdc-4cee-be50-8f8e6cec8534") + .name("CloneForDrs").cluster(Cluster.builder().id("QA1_N2_VMWARE_1-01").name("QA1_N2_VMWARE_1-01").build()) + .cpu(CPU.builder().count(2).speed("STANDARD").coresPerSocket(1).build()).memoryGb(4).disks(ImmutableList + .of(Disk.builder().id("1bddd4ed-67dc-4e5e-a0d5-b5a6c012ec14").scsiId(0).sizeGb(50) + .speed("HIGHPERFORMANCE").build())) + .createTime(new SimpleDateFormatDateService().iso8601DateParse("2016-07-17T23:53:48.000Z")) + .datacenterId("QA1_N2_VMWARE_1").state("FAILED_ADD").guest(Guest.builder().operatingSystem( + OperatingSystem.builder().id("WIN2012DC64").displayName("WIN2012DC/64").family("WINDOWS").build()) + .vmTools(VmTools.builder().versionStatus(VmTools.VersionStatus.CURRENT) + .runningStatus(VmTools.RunningStatus.NOT_RUNNING).apiVersion(9354) + .type(VmTools.Type.VMWARE_TOOLS).build()).osCustomization(true).build()) + .virtualHardware(VirtualHardware.builder().version("vmx-08").upToDate(false).build()).tags(ImmutableList + .of(CustomerImage.TagWithIdAndName.builder().tagKeyName("DdTest3") + .tagKeyId("ee58176e-305b-4ec2-85e0-330a33729a94").build(), + CustomerImage.TagWithIdAndName.builder().tagKeyName("Lukas11") + .tagKeyId("c5480364-d3cd-4391-9536-5c1af683a8f1").value("j").build(), + CustomerImage.TagWithIdAndName.builder().tagKeyName("Lukas5") + .tagKeyId("a3e869df-6427-404f-99c2-b50f526369aa").build())) + .softwareLabels(ImmutableList.<String>of()).nics(ImmutableList.<ImageNic>of()).source( + CustomerImage.Source.builder().artifacts(ImmutableList + .of(CustomerImage.Artifact.builder().value("cb4b8674-09a4-4194-9593-9cdc81489de1") + .type(CustomerImage.Artifact.Type.SERVER_ID).build())) + .type(CustomerImage.Source.Type.CLONE).build()).build(); + assertEquals(customerImage.type, CustomerImage.TYPE, "CustomerImage type is no CUSTOMER_IMAGE"); + List<CustomerImage> customerImages = ImmutableList.of(customerImage); + return new CustomerImages(customerImages, 1, 2, 2, 250); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/OsImagesParseTest.java ---------------------------------------------------------------------- diff --git a/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/OsImagesParseTest.java b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/OsImagesParseTest.java new file mode 100644 index 0000000..ca17363 --- /dev/null +++ b/dimensiondata/src/test/java/org/jclouds/dimensiondata/cloudcontrol/parse/OsImagesParseTest.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.dimensiondata.cloudcontrol.parse; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import org.jclouds.dimensiondata.cloudcontrol.domain.CPU; +import org.jclouds.dimensiondata.cloudcontrol.domain.Cluster; +import org.jclouds.dimensiondata.cloudcontrol.domain.Disk; +import org.jclouds.dimensiondata.cloudcontrol.domain.Guest; +import org.jclouds.dimensiondata.cloudcontrol.domain.ImageNic; +import org.jclouds.dimensiondata.cloudcontrol.domain.OperatingSystem; +import org.jclouds.dimensiondata.cloudcontrol.domain.OsImage; +import org.jclouds.dimensiondata.cloudcontrol.domain.OsImages; +import org.jclouds.dimensiondata.cloudcontrol.internal.BaseDimensionDataCloudControlParseTest; +import org.testng.annotations.Test; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; +import java.util.List; + +import static org.testng.Assert.assertEquals; + +@Test(groups = "unit") +public class OsImagesParseTest extends BaseDimensionDataCloudControlParseTest<OsImages> { + + @Override + public String resource() { + return "/osImages.json"; + } + + @Override + @Consumes(MediaType.APPLICATION_JSON) + public OsImages expected() { + final OsImage osImage = OsImage.builder().id("12ea8472-6e4e-4068-b2cb-f04ecacd3962").name("CentOS 5 64-bit") + .description("DRaaS CentOS Release 5.9 64-bit").guest(Guest.builder().osCustomization(false) + .operatingSystem( + OperatingSystem.builder().id("CENTOS564").displayName("CENTOS5/64").family("UNIX").build()) + .build()).cpu(CPU.builder().count(2).speed("STANDARD").coresPerSocket(1).build()).memoryGb(4) + .nics(ImmutableList.of(ImageNic.builder().networkAdapter("E1000").key(4040).build())).disks(ImmutableList + .of(Disk.builder().id("98299851-37a3-4ebe-9cf1-090da9ae42a0").scsiId(0).sizeGb(20).speed("STANDARD") + .build())).softwareLabels(Lists.<String>newArrayList()).osImageKey("T-CENT-5-64-2-4-10") + .createTime(parseDate("2016-06-09T17:36:31.000Z")).datacenterId("NA1") + .cluster(Cluster.builder().id("NA12-01").name("my cluster name").build()).build(); + assertEquals(osImage.type, OsImage.TYPE, "OsImage type is not OS_IMAGE"); + List<OsImage> osImages = ImmutableList.of(osImage); + return new OsImages(osImages, 1, 2, 2, 250); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/test/resources/customerImage.json ---------------------------------------------------------------------- diff --git a/dimensiondata/src/test/resources/customerImage.json b/dimensiondata/src/test/resources/customerImage.json new file mode 100644 index 0000000..85105a7 --- /dev/null +++ b/dimensiondata/src/test/resources/customerImage.json @@ -0,0 +1,80 @@ +{ + "name": "CloneForDrs", + "cluster": { + "id": "QA1_N2_VMWARE_1-01", + "name": "QA1_N2_VMWARE_1-01" + }, + "cpu": { + "count": 2, + "speed": "STANDARD", + "coresPerSocket": 1 + }, + "memoryGb": 4, + "disk": [ + { + "id": "1bddd4ed-67dc-4e5e-a0d5-b5a6c012ec14", + "scsiId": 0, + "sizeGb": 50, + "speed": "HIGHPERFORMANCE" + } + ], + "nic": [ + { + "networkAdapter": "E1000", + "key": 4000 + } + ], + "softwareLabel": [], + "createTime": "2016-07-17T23:53:48.000Z", + "id": "f27b7ead-9cdc-4cee-be50-8f8e6cec8534", + "datacenterId": "QA1_N2_VMWARE_1", + "state": "FAILED_ADD", + "guest": { + "operatingSystem": { + "id": "WIN2012DC64", + "displayName": "WIN2012DC/64", + "family": "WINDOWS" + }, + "vmTools": { + "type": "VMWARE_TOOLS", + "versionStatus": "CURRENT", + "runningStatus": "NOT_RUNNING", + "apiVersion": 9354 + }, + "osCustomization": true + }, + "virtualHardware": { + "version": "vmx-08", + "upToDate": false + }, + "source": { + "artifact": [ + { + "type": "SERVER_ID", + "value": "cb4b8674-09a4-4194-9593-9cdc81489de1" + } + ], + "type": "CLONE" + }, + "tag": [ + { + "tagKeyName": "DdTest3", + "tagKeyId": "ee58176e-305b-4ec2-85e0-330a33729a94" + }, + { + "tagKeyName": "Lukas11", + "value": "j", + "tagKeyId": "c5480364-d3cd-4391-9536-5c1af683a8f1" + }, + { + "tagKeyName": "Lukas5", + "tagKeyId": "a3e869df-6427-404f-99c2-b50f526369aa" + } + ], + "progress": { + "action": "DELETE_SERVER_IMAGE", + "requestTime": "2017-03-15T07:47:26.000Z", + "userName": "QA1Tester", + "failureReason": "Failed to delete the virtual machine, '/vmfs/volumes/57fdddc0-5d9a80e5-2b30-1005ca0a6c1a/atestCloneServer3/atestCloneServer3.vmx'.An error occurred while deleting the virtual machine: Error.: Failed to delete the virtual machine, '/vmfs/volumes/57fdddc0-5d9a80e5-2b30-1005ca0a6c1a/atestCloneServer3/atestCloneServer3.vmx'." + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/test/resources/customerImages.json ---------------------------------------------------------------------- diff --git a/dimensiondata/src/test/resources/customerImages.json b/dimensiondata/src/test/resources/customerImages.json new file mode 100644 index 0000000..6aabc37 --- /dev/null +++ b/dimensiondata/src/test/resources/customerImages.json @@ -0,0 +1,77 @@ +{ + "customerImage": [ + { + "name": "CloneForDrs", + "cluster": { + "id": "QA1_N2_VMWARE_1-01", + "name": "QA1_N2_VMWARE_1-01" + }, + "cpu": { + "count": 2, + "speed": "STANDARD", + "coresPerSocket": 1 + }, + "memoryGb": 4, + "disk": [ + { + "id": "1bddd4ed-67dc-4e5e-a0d5-b5a6c012ec14", + "scsiId": 0, + "sizeGb": 50, + "speed": "HIGHPERFORMANCE" + } + ], + "nic": [], + "softwareLabel": [], + "createTime": "2016-07-17T23:53:48.000Z", + "id": "f27b7ead-9cdc-4cee-be50-8f8e6cec8534", + "datacenterId": "QA1_N2_VMWARE_1", + "state": "FAILED_ADD", + "guest": { + "operatingSystem": { + "id": "WIN2012DC64", + "displayName": "WIN2012DC/64", + "family": "WINDOWS" + }, + "vmTools": { + "type": "VMWARE_TOOLS", + "versionStatus": "CURRENT", + "runningStatus": "NOT_RUNNING", + "apiVersion": 9354 + }, + "osCustomization": true + }, + "virtualHardware": { + "version": "vmx-08", + "upToDate": false + }, + "source": { + "artifact": [ + { + "type": "SERVER_ID", + "value": "cb4b8674-09a4-4194-9593-9cdc81489de1" + } + ], + "type": "CLONE" + }, + "tag": [ + { + "tagKeyName": "DdTest3", + "tagKeyId": "ee58176e-305b-4ec2-85e0-330a33729a94" + }, + { + "tagKeyName": "Lukas11", + "value": "j", + "tagKeyId": "c5480364-d3cd-4391-9536-5c1af683a8f1" + }, + { + "tagKeyName": "Lukas5", + "tagKeyId": "a3e869df-6427-404f-99c2-b50f526369aa" + } + ] + } + ], + "pageNumber": 1, + "pageCount": 1, + "totalCount": 1, + "pageSize": 1 +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b6dbe51/dimensiondata/src/test/resources/customerImages_page1.json ---------------------------------------------------------------------- diff --git a/dimensiondata/src/test/resources/customerImages_page1.json b/dimensiondata/src/test/resources/customerImages_page1.json new file mode 100644 index 0000000..fc4affc --- /dev/null +++ b/dimensiondata/src/test/resources/customerImages_page1.json @@ -0,0 +1,333 @@ +{ + "customerImage": [ + { + "name": "CloneForDrs", + "cluster": { + "id": "QA1_N2_VMWARE_1-01", + "name": "QA1_N2_VMWARE_1-01" + }, + "cpu": { + "count": 2, + "speed": "STANDARD", + "coresPerSocket": 1 + }, + "memoryGb": 4, + "disk": [ + { + "id": "1bddd4ed-67dc-4e5e-a0d5-b5a6c012ec14", + "scsiId": 0, + "sizeGb": 50, + "speed": "HIGHPERFORMANCE" + } + ], + "nic": [], + "softwareLabel": [], + "createTime": "2016-07-17T23:53:48.000Z", + "id": "f27b7ead-9cdc-4cee-be50-8f8e6cec8534", + "datacenterId": "QA1_N2_VMWARE_1", + "state": "FAILED_ADD", + "guest": { + "operatingSystem": { + "id": "WIN2012DC64", + "displayName": "WIN2012DC/64", + "family": "WINDOWS" + }, + "vmTools": { + "type": "VMWARE_TOOLS", + "versionStatus": "CURRENT", + "runningStatus": "NOT_RUNNING", + "apiVersion": 9354 + }, + "osCustomization": true + }, + "virtualHardware": { + "version": "vmx-08", + "upToDate": false + }, + "source": { + "artifact": [ + { + "type": "SERVER_ID", + "value": "cb4b8674-09a4-4194-9593-9cdc81489de1" + } + ], + "type": "CLONE" + }, + "tag": [ + { + "tagKeyName": "DdTest3", + "tagKeyId": "ee58176e-305b-4ec2-85e0-330a33729a94" + }, + { + "tagKeyName": "Lukas11", + "value": "j", + "tagKeyId": "c5480364-d3cd-4391-9536-5c1af683a8f1" + }, + { + "tagKeyName": "Lukas5", + "tagKeyId": "a3e869df-6427-404f-99c2-b50f526369aa" + } + ] + }, + { + "name": "atestCloneServer3", + "description": "This is a description", + "cluster": { + "id": "QA1_N2_VMWARE_1-01", + "name": "QA1_N2_VMWARE_1-01" + }, + "cpu": { + "count": 5, + "speed": "HIGHPERFORMANCE", + "coresPerSocket": 5 + }, + "memoryGb": 6, + "disk": [ + { + "id": "ac7f0180-ec20-46b8-8f89-534a67c97551", + "scsiId": 0, + "sizeGb": 52, + "speed": "STANDARD" + } + ], + "nic": [ + { + "networkAdapter": "VMXNET3", + "key": 4000 + } + ], + "softwareLabel": [], + "createTime": "2016-10-27T23:31:30.000Z", + "id": "12b1a94b-d126-4a93-8d87-c19df263fac8", + "datacenterId": "QA1_N2_VMWARE_1", + "state": "PENDING_DELETE", + "guest": { + "operatingSystem": { + "id": "REDHAT664", + "displayName": "REDHAT6/64", + "family": "UNIX" + }, + "vmTools": { + "type": "OPEN_VM_TOOLS", + "versionStatus": "UNMANAGED", + "runningStatus": "NOT_RUNNING", + "apiVersion": 2147483647 + }, + "osCustomization": true + }, + "virtualHardware": { + "version": "vmx-09", + "upToDate": false + }, + "source": { + "artifact": [ + { + "type": "SERVER_ID", + "value": "b3a86189-3901-4ec6-b03f-8921d26b6128" + } + ], + "type": "CLONE" + }, + "tag": [ + { + "tagKeyName": "CAAS3985_Test", + "value": "VLANs", + "tagKeyId": "cc552b40-3058-4834-b5c7-02b8803db249" + }, + { + "tagKeyName": "DDTEst", + "value": "Test", + "tagKeyId": "37c0c90c-b74f-4062-8d29-3c1c051ea0a7" + }, + { + "tagKeyName": "Lukas3", + "value": "Test", + "tagKeyId": "669879d5-26bc-42fb-bcff-761e817187a7" + } + ], + "progress": { + "action": "DELETE_SERVER_IMAGE", + "requestTime": "2017-03-15T07:47:26.000Z", + "userName": "QA1Tester", + "failureReason": "Failed to delete the virtual machine, '/vmfs/volumes/57fdddc0-5d9a80e5-2b30-1005ca0a6c1a/atestCloneServer3/atestCloneServer3.vmx'.An error occurred while deleting the virtual machine: Error.: Failed to delete the virtual machine, '/vmfs/volumes/57fdddc0-5d9a80e5-2b30-1005ca0a6c1a/atestCloneServer3/atestCloneServer3.vmx'." + } + }, + { + "name": "postManGocToNGoc", + "description": "This is a description", + "cluster": { + "id": "QA1_N2_VMWARE_1-01", + "name": "QA1_N2_VMWARE_1-01" + }, + "cpu": { + "count": 4, + "speed": "HIGHPERFORMANCE", + "coresPerSocket": 1 + }, + "memoryGb": 2, + "disk": [ + { + "id": "1e41aa5f-d393-4b35-b5a8-c9af6cde5b87", + "scsiId": 0, + "sizeGb": 10, + "speed": "STANDARD" + }, + { + "id": "9bcdbd4e-c1e1-49f2-afd1-9984e0c7f60f", + "scsiId": 1, + "sizeGb": 20, + "speed": "STANDARD" + } + ], + "nic": [ + { + "networkAdapter": "E1000", + "key": 4000 + } + ], + "softwareLabel": [], + "createTime": "2016-10-30T22:30:03.000Z", + "id": "87bfab7b-088a-44f9-aef1-a5f5e53026a9", + "datacenterId": "QA1_N2_VMWARE_1", + "state": "NORMAL", + "guest": { + "operatingSystem": { + "id": "SUSE1164", + "displayName": "SUSE11/64", + "family": "UNIX" + }, + "vmTools": { + "type": "VMWARE_TOOLS", + "versionStatus": "CURRENT", + "runningStatus": "NOT_RUNNING", + "apiVersion": 9354 + }, + "osCustomization": true + }, + "virtualHardware": { + "version": "vmx-08", + "upToDate": false + }, + "source": { + "artifact": [ + { + "type": "SERVER_ID", + "value": "4eb1a1ae-2836-4850-981e-ab9603c83e33" + } + ], + "type": "CLONE" + }, + "tag": [] + }, + { + "name": "gocTestImage", + "description": "", + "cpu": { + "count": 5, + "speed": "HIGHPERFORMANCE", + "coresPerSocket": 1 + }, + "memoryGb": 8, + "disk": [ + { + "id": "422bf38e-b639-4203-b14f-3a9eac56768d", + "scsiId": 0, + "sizeGb": 10, + "speed": "STANDARD" + }, + { + "id": "42da7303-a5c8-4cf0-b1f8-56fe27b4a895", + "scsiId": 1, + "sizeGb": 20, + "speed": "STANDARD" + } + ], + "nic": [], + "softwareLabel": [], + "createTime": "2016-10-31T04:08:26.000Z", + "id": "7c6afe65-03b8-4d13-b273-527079840390", + "datacenterId": "QA1_N2_VF5", + "state": "REQUIRES_SUPPORT", + "guest": { + "operatingSystem": { + "id": "SUSE1164", + "displayName": "SUSE11/64", + "family": "UNIX" + }, + "osCustomization": true + }, + "source": { + "artifact": [ + { + "type": "IMAGE_ID", + "value": "32de886a-9754-4494-8e4c-1e6d72102078" + } + ], + "type": "COPY" + }, + "tag": [], + "progress": { + "action": "CLEAN_SERVER_IMAGE", + "requestTime": "2016-10-31T04:09:09.000Z", + "userName": "NR_test1", + "failureReason": "Unable to find the target VM - this will need to be checked by support.Could not locate the folder for the VM" + } + }, + { + "name": "NGOC_Image", + "description": "test image", + "cpu": { + "count": 3, + "speed": "HIGHPERFORMANCE", + "coresPerSocket": 3 + }, + "memoryGb": 3, + "disk": [ + { + "id": "4060cda4-e02e-454f-a8d0-912aa81c345d", + "scsiId": 0, + "sizeGb": 52, + "speed": "STANDARD" + } + ], + "nic": [], + "softwareLabel": [], + "createTime": "2016-10-31T22:41:57.000Z", + "id": "5c15d056-7d73-42ff-8959-e2e7a019fdd9", + "datacenterId": "QA1_N2_VF5", + "state": "REQUIRES_SUPPORT", + "guest": { + "operatingSystem": { + "id": "REDHAT664", + "displayName": "REDHAT6/64", + "family": "UNIX" + }, + "osCustomization": true + }, + "source": { + "artifact": [ + { + "type": "IMAGE_ID", + "value": "ca811be3-d70b-4ea9-af72-3a95e7249298" + }, + { + "type": "OVF_PACKAGE_PREFIX", + "value": "Test_NGOC_Image" + } + ], + "type": "COPY" + }, + "tag": [], + "progress": { + "action": "CLEAN_SERVER_IMAGE", + "requestTime": "2016-11-24T09:44:08.000Z", + "userName": "QA1Tester", + "failureReason": "Unable to find the target VM - this will need to be checked by support.Could not locate the folder for the VM" + } + } + ], + "pageNumber": 1, + "pageCount": 5, + "totalCount": 10, + "pageSize": 5 +} \ No newline at end of file
