From e996fc57d5845f9701b88c69fd4706f37be8856e Mon Sep 17 00:00:00 2001 From: Richard Downer Date: Tue, 10 Jan 2012 17:36:43 +0200 Subject: [PATCH] Add Hosts API listClusters call; domain objects, options, tests, etc. --- .../jclouds/cloudstack/domain/Cluster.java | 248 ++++++++++++++++++ .../features/GlobalHostAsyncClient.java | 12 + .../cloudstack/features/GlobalHostClient.java | 9 + .../options/ListClustersOptions.java | 122 +++++++++ .../features/GlobalHostClientLiveTest.java | 28 ++ .../options/ListClustersOptionsTest.java | 126 +++++++++ .../parse/ListClustersResponseTest.java | 73 ++++++ .../test/resources/listclustersresponse.json | 1 + 8 files changed, 619 insertions(+) create mode 100644 apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Cluster.java create mode 100644 apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListClustersOptions.java create mode 100644 apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListClustersOptionsTest.java create mode 100644 apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListClustersResponseTest.java create mode 100644 apis/cloudstack/src/test/resources/listclustersresponse.json diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Cluster.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Cluster.java new file mode 100644 index 0000000000..edaf2ce520 --- /dev/null +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Cluster.java @@ -0,0 +1,248 @@ +/** + * 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.cloudstack.domain; + +import com.google.gson.annotations.SerializedName; + +import static com.google.common.base.CaseFormat.UPPER_CAMEL; +import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE; + +/** + * Represents a CloudStack Cluster. + * + * @author Richard Downer + */ +public class Cluster implements Comparable { + + public enum ManagedState { + MANAGED, + PREPARE_UNMANAGED, + UNMANAGED, + PREPARE_UNMANAGED_ERROR, + UNRECOGNIZED; + + public static ManagedState fromValue(String value) { + try{ + return valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, value)); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + + @Override + public String toString() { + return UPPER_UNDERSCORE.to(UPPER_CAMEL, name()); + } + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private long id; + private Host.AllocationState allocationState; + private Host.ClusterType clusterType; + private String hypervisor; + private ManagedState managedState; + private String name; + private long podId; + private String podName; + private long zoneId; + private String zoneName; + + public Builder id(long id) { + this.id = id; + return this; + } + + public Builder allocationState(Host.AllocationState allocationState) { + this.allocationState = allocationState; + return this; + } + + public Builder clusterType(Host.ClusterType clusterType) { + this.clusterType = clusterType; + return this; + } + + public Builder hypervisor(String hypervisor) { + this.hypervisor = hypervisor; + return this; + } + + public Builder managedState(ManagedState managedState) { + this.managedState = managedState; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder podId(long podId) { + this.podId = podId; + return this; + } + + public Builder podName(String podName) { + this.podName = podName; + return this; + } + + public Builder zoneId(long zoneId) { + this.zoneId = zoneId; + return this; + } + + public Builder zoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + public Cluster build() { + return new Cluster(id, allocationState, clusterType, hypervisor, managedState, name, podId, podName, zoneId, zoneName); + } + } + + private long id; + @SerializedName("allocationstate") private Host.AllocationState allocationState; + @SerializedName("clustertype") private Host.ClusterType clusterType; + @SerializedName("hypervisortype") private String hypervisor; + @SerializedName("managedstate") private ManagedState managedState; + private String name; + @SerializedName("podid") private long podId; + @SerializedName("podname") private String podName; + @SerializedName("zoneid") private long zoneId; + @SerializedName("zonename") private String zoneName; + + // Just for the serializer + Cluster() {} + + public Cluster(long id, Host.AllocationState allocationState, Host.ClusterType clusterType, String hypervisor, ManagedState managedState, String name, long podId, String podName, long zoneId, String zoneName) { + this.id = id; + this.allocationState = allocationState; + this.clusterType = clusterType; + this.hypervisor = hypervisor; + this.managedState = managedState; + this.name = name; + this.podId = podId; + this.podName = podName; + this.zoneId = zoneId; + this.zoneName = zoneName; + } + + public long getId() { + return id; + } + + public Host.AllocationState getAllocationState() { + return allocationState; + } + + public Host.ClusterType getClusterType() { + return clusterType; + } + + public String getHypervisor() { + return hypervisor; + } + + public ManagedState getManagedState() { + return managedState; + } + + public String getName() { + return name; + } + + public long getPodId() { + return podId; + } + + public String getPodName() { + return podName; + } + + public long getZoneId() { + return zoneId; + } + + public String getZoneName() { + return zoneName; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Cluster cluster = (Cluster) o; + + if (id != cluster.id) return false; + if (podId != cluster.podId) return false; + if (zoneId != cluster.zoneId) return false; + if (allocationState != cluster.allocationState) return false; + if (clusterType != cluster.clusterType) return false; + if (hypervisor != null ? !hypervisor.equals(cluster.hypervisor) : cluster.hypervisor != null) return false; + if (managedState != cluster.managedState) return false; + if (name != null ? !name.equals(cluster.name) : cluster.name != null) return false; + if (podName != null ? !podName.equals(cluster.podName) : cluster.podName != null) return false; + if (zoneName != null ? !zoneName.equals(cluster.zoneName) : cluster.zoneName != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = (int) (id ^ (id >>> 32)); + result = 31 * result + (allocationState != null ? allocationState.hashCode() : 0); + result = 31 * result + (clusterType != null ? clusterType.hashCode() : 0); + result = 31 * result + (hypervisor != null ? hypervisor.hashCode() : 0); + result = 31 * result + (managedState != null ? managedState.hashCode() : 0); + result = 31 * result + (name != null ? name.hashCode() : 0); + result = 31 * result + (int) (podId ^ (podId >>> 32)); + result = 31 * result + (podName != null ? podName.hashCode() : 0); + result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); + result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "Cluster{" + + "id=" + id + + ", allocationState=" + allocationState + + ", clusterType=" + clusterType + + ", hypervisor='" + hypervisor + '\'' + + ", managedState=" + managedState + + ", name='" + name + '\'' + + ", podId=" + podId + + ", podName='" + podName + '\'' + + ", zoneId=" + zoneId + + ", zoneName='" + zoneName + '\'' + + '}'; + } + + @Override + public int compareTo(Cluster other) { + return Long.valueOf(this.id).compareTo(other.id); + } +} diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java index 2a91b08802..a6fc4d05f0 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostAsyncClient.java @@ -19,8 +19,10 @@ package org.jclouds.cloudstack.features; import com.google.common.util.concurrent.ListenableFuture; +import org.jclouds.cloudstack.domain.Cluster; import org.jclouds.cloudstack.domain.Host; import org.jclouds.cloudstack.filters.QuerySigner; +import org.jclouds.cloudstack.options.ListClustersOptions; import org.jclouds.cloudstack.options.ListHostsOptions; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.QueryParams; @@ -54,4 +56,14 @@ public interface GlobalHostAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) ListenableFuture> listHosts(ListHostsOptions... options); + + /** + * @see GlobalHostClient#listClusters + */ + @GET + @QueryParams(keys = "command", values = "listClusters") + @SelectJson("cluster") + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listClusters(ListClustersOptions... options); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostClient.java index 6103fe45f8..414ce8b6fa 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/GlobalHostClient.java @@ -18,7 +18,9 @@ */ package org.jclouds.cloudstack.features; +import org.jclouds.cloudstack.domain.Cluster; import org.jclouds.cloudstack.domain.Host; +import org.jclouds.cloudstack.options.ListClustersOptions; import org.jclouds.cloudstack.options.ListHostsOptions; import org.jclouds.concurrent.Timeout; @@ -46,4 +48,11 @@ public interface GlobalHostClient { */ Set listHosts(ListHostsOptions... options); + /** + * Lists clusters + * + * @param options if present, how to constrain the list + * @return clusters matching query, or empty set if no clusters match + */ + Set listClusters(ListClustersOptions... options); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListClustersOptions.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListClustersOptions.java new file mode 100644 index 0000000000..667b403589 --- /dev/null +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListClustersOptions.java @@ -0,0 +1,122 @@ +/** + * 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.cloudstack.options; + +import com.google.common.collect.ImmutableSet; +import org.jclouds.cloudstack.domain.Cluster; +import org.jclouds.cloudstack.domain.Host; +import org.jclouds.http.options.BaseHttpRequestOptions; + +/** + * Options used to control what cluster information is returned + * + * @author Richard Downer + * @see + */ +public class ListClustersOptions extends BaseHttpRequestOptions { + + public static final ListHostsOptions NONE = new ListHostsOptions(); + + public ListClustersOptions allocationState(Host.AllocationState allocationState) { + this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString())); + return this; + } + + public ListClustersOptions clusterType(Host.ClusterType clusterType) { + this.queryParameters.replaceValues("clustertype", ImmutableSet.of(clusterType.toString())); + return this; + } + + public ListClustersOptions hypervisor(String hypervisor) { + this.queryParameters.replaceValues("hypervisor", ImmutableSet.of(hypervisor)); + return this; + } + + public ListClustersOptions id(long id) { + this.queryParameters.replaceValues("id", ImmutableSet.of(id + "")); + return this; + } + + public ListClustersOptions keyword(String keyword) { + this.queryParameters.replaceValues("keyword", ImmutableSet.of(keyword)); + return this; + } + + public ListClustersOptions managedState(Cluster.ManagedState managedState) { + this.queryParameters.replaceValues("managedstate", ImmutableSet.of(managedState.toString())); + return this; + } + + public ListClustersOptions name(String name) { + this.queryParameters.replaceValues("name", ImmutableSet.of(name)); + return this; + } + + public ListClustersOptions podId(long podId) { + this.queryParameters.replaceValues("podid", ImmutableSet.of(podId + "")); + return this; + } + + public ListClustersOptions zoneId(long zoneId) { + this.queryParameters.replaceValues("zoneid", ImmutableSet.of(zoneId + "")); + return this; + } + + public static class Builder { + + public static ListClustersOptions allocationState(Host.AllocationState allocationState) { + return new ListClustersOptions().allocationState(allocationState); + } + + public static ListClustersOptions clusterType(Host.ClusterType clusterType) { + return new ListClustersOptions().clusterType(clusterType); + } + + public static ListClustersOptions hypervisor(String hypervisor) { + return new ListClustersOptions().hypervisor(hypervisor); + } + + public static ListClustersOptions id(long id) { + return new ListClustersOptions().id(id); + } + + public static ListClustersOptions keyword(String keyword) { + return new ListClustersOptions().keyword(keyword); + } + + public static ListClustersOptions managedState(Cluster.ManagedState managedState) { + return new ListClustersOptions().managedState(managedState); + } + + public static ListClustersOptions name(String name) { + return new ListClustersOptions().name(name); + } + + public static ListClustersOptions podId(long podId) { + return new ListClustersOptions().podId(podId); + } + + public static ListClustersOptions zoneId(long zoneId) { + return new ListClustersOptions().zoneId(zoneId); + } + + } +} diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientLiveTest.java index 7764ca8a5f..cab4014391 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientLiveTest.java @@ -18,10 +18,13 @@ */ package org.jclouds.cloudstack.features; +import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import java.util.Set; +import com.google.common.base.Strings; +import org.jclouds.cloudstack.domain.Cluster; import org.jclouds.cloudstack.domain.Host; import org.testng.annotations.Test; @@ -61,4 +64,29 @@ public class GlobalHostClientLiveTest extends BaseCloudStackClientLiveTest { } } + @Test(groups = "live", enabled = true) + public void testListClusters() throws Exception { + assertTrue(globalAdminEnabled, "Test cannot run without global admin identity and credentials"); + + Set clusters = globalAdminClient.getHostClient().listClusters(); + assert clusters.size() > 0 : clusters; + + for(Cluster cluster : clusters) { + checkCluster(cluster); + } + } + + private void checkCluster(Cluster cluster) { + assertTrue(cluster.getId() > 0); + assertFalse(Strings.isNullOrEmpty(cluster.getName())); + assertTrue(cluster.getAllocationState() != Host.AllocationState.UNKNOWN); + assertTrue(cluster.getClusterType() != Host.ClusterType.UNKNOWN); + assertFalse(Strings.isNullOrEmpty(cluster.getHypervisor())); + assertTrue(cluster.getManagedState() != Cluster.ManagedState.UNRECOGNIZED); + assertTrue(cluster.getPodId() > 0); + assertFalse(Strings.isNullOrEmpty(cluster.getPodName())); + assertTrue(cluster.getZoneId() > 0); + assertFalse(Strings.isNullOrEmpty(cluster.getZoneName())); + } + } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListClustersOptionsTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListClustersOptionsTest.java new file mode 100644 index 0000000000..502fa6f218 --- /dev/null +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListClustersOptionsTest.java @@ -0,0 +1,126 @@ +/** + * 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.cloudstack.options; + +import com.google.common.collect.ImmutableList; +import org.jclouds.cloudstack.domain.Cluster; +import org.jclouds.cloudstack.domain.Host; +import org.testng.annotations.Test; + +import static org.jclouds.cloudstack.options.ListClustersOptions.Builder.*; +import static org.testng.Assert.assertEquals; + +/** + * Tests behavior of {@code ListClustersOptions} + * + * @author Richard Downer + */ +@Test(groups = "unit") +public class ListClustersOptionsTest { + + public void testAllocationState() { + ListClustersOptions options = new ListClustersOptions().allocationState(Host.AllocationState.ENABLED); + assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate")); + } + + public void testAllocationStateStatic() { + ListClustersOptions options = allocationState(Host.AllocationState.ENABLED); + assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate")); + } + + public void testClusterType() { + ListClustersOptions options = new ListClustersOptions().clusterType(Host.ClusterType.CLOUD_MANAGED); + assertEquals(ImmutableList.of("CloudManaged"), options.buildQueryParameters().get("clustertype")); + } + + public void testClusterTypeStatic() { + ListClustersOptions options = clusterType(Host.ClusterType.CLOUD_MANAGED); + assertEquals(ImmutableList.of("CloudManaged"), options.buildQueryParameters().get("clustertype")); + } + + public void testHypervisor() { + ListClustersOptions options = new ListClustersOptions().hypervisor("XenServer"); + assertEquals(ImmutableList.of("XenServer"), options.buildQueryParameters().get("hypervisor")); + } + + public void testHypervisorStatic() { + ListClustersOptions options = hypervisor("XenServer"); + assertEquals(ImmutableList.of("XenServer"), options.buildQueryParameters().get("hypervisor")); + } + + public void testId() { + ListClustersOptions options = new ListClustersOptions().id(42L); + assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("id")); + } + + public void testIdStatic() { + ListClustersOptions options = id(42L); + assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("id")); + } + + public void testKeyword() { + ListClustersOptions options = new ListClustersOptions().keyword("Enabled"); + assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("keyword")); + } + + public void testKeywordStatic() { + ListClustersOptions options = keyword("Enabled"); + assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("keyword")); + } + + public void testManagedState() { + ListClustersOptions options = new ListClustersOptions().managedState(Cluster.ManagedState.PREPARE_UNMANAGED); + assertEquals(ImmutableList.of("PrepareUnmanaged"), options.buildQueryParameters().get("managedstate")); + } + + public void testManagedStateStatic() { + ListClustersOptions options = managedState(Cluster.ManagedState.PREPARE_UNMANAGED); + assertEquals(ImmutableList.of("PrepareUnmanaged"), options.buildQueryParameters().get("managedstate")); + } + + public void testName() { + ListClustersOptions options = new ListClustersOptions().name("Host Name"); + assertEquals(ImmutableList.of("Host Name"), options.buildQueryParameters().get("name")); + } + + public void testNameStatic() { + ListClustersOptions options = name("Host Name"); + assertEquals(ImmutableList.of("Host Name"), options.buildQueryParameters().get("name")); + } + + public void testPodId() { + ListClustersOptions options = new ListClustersOptions().podId(42L); + assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("podid")); + } + + public void testPodIdStatic() { + ListClustersOptions options = podId(42L); + assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("podid")); + } + + public void testZoneId() { + ListClustersOptions options = new ListClustersOptions().zoneId(42L); + assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("zoneid")); + } + + public void testZoneIdStatic() { + ListClustersOptions options = zoneId(42L); + assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("zoneid")); + } +} diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListClustersResponseTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListClustersResponseTest.java new file mode 100644 index 0000000000..8f6354bf25 --- /dev/null +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListClustersResponseTest.java @@ -0,0 +1,73 @@ +/** + * 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.cloudstack.parse; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.jclouds.cloudstack.config.CloudStackParserModule; +import org.jclouds.cloudstack.domain.Cluster; +import org.jclouds.cloudstack.domain.Host; +import org.jclouds.date.internal.SimpleDateFormatDateService; +import org.jclouds.json.BaseSetParserTest; +import org.jclouds.json.config.GsonModule; +import org.jclouds.rest.annotations.SelectJson; +import org.testng.annotations.Test; + +import java.util.Set; + +/** + * @author Richard Downer + */ +@Test(groups = "unit") +public class ListClustersResponseTest extends BaseSetParserTest { + + @Override + public String resource() { + return "/listclustersresponse.json"; + } + + @Override + @SelectJson("cluster") + public Set expected() { + Cluster cluster1 = Cluster.builder() + .id(1) + .name("Xen Clust 1") + .podId(1).podName("Dev Pod 1") + .zoneId(1).zoneName("Dev Zone 1") + .hypervisor("XenServer") + .clusterType(Host.ClusterType.CLOUD_MANAGED) + .allocationState(Host.AllocationState.ENABLED) + .managedState(Cluster.ManagedState.MANAGED) + .build(); + Cluster cluster2 = Cluster.builder() + .id(2) + .name("Xen Clust 1") + .podId(2).podName("Dev Pod 2") + .zoneId(2).zoneName("Dev Zone 2") + .hypervisor("XenServer") + .clusterType(Host.ClusterType.CLOUD_MANAGED) + .allocationState(Host.AllocationState.ENABLED) + .managedState(Cluster.ManagedState.MANAGED) + .build(); + + return ImmutableSet.of(cluster1, cluster2); + } + +} diff --git a/apis/cloudstack/src/test/resources/listclustersresponse.json b/apis/cloudstack/src/test/resources/listclustersresponse.json new file mode 100644 index 0000000000..64dd052898 --- /dev/null +++ b/apis/cloudstack/src/test/resources/listclustersresponse.json @@ -0,0 +1 @@ +{ "listclustersresponse" : { "count":2 ,"cluster" : [ {"id":1,"name":"Xen Clust 1","podid":1,"podname":"Dev Pod 1","zoneid":1,"zonename":"Dev Zone 1","hypervisortype":"XenServer","clustertype":"CloudManaged","allocationstate":"Enabled","managedstate":"Managed"}, {"id":2,"name":"Xen Clust 1","podid":2,"podname":"Dev Pod 2","zoneid":2,"zonename":"Dev Zone 2","hypervisortype":"XenServer","clustertype":"CloudManaged","allocationstate":"Enabled","managedstate":"Managed"} ] } } \ No newline at end of file