mirror of https://github.com/apache/jclouds.git
Refactor Host and Zone to share a common AllocationState enum type
This commit is contained in:
parent
2680460b9a
commit
2e8757af9c
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* 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 static com.google.common.base.CaseFormat.UPPER_CAMEL;
|
||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||
|
||||
/**
|
||||
* Represents the allocationstate field used in several CloudStack domain objects.
|
||||
*/
|
||||
public enum AllocationState {
|
||||
DISABLED,
|
||||
ENABLED,
|
||||
UNKNOWN;
|
||||
|
||||
public static AllocationState fromValue(String value) {
|
||||
try{
|
||||
return valueOf(value.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return UPPER_UNDERSCORE.to(UPPER_CAMEL, name());
|
||||
}
|
||||
}
|
|
@ -57,7 +57,7 @@ public class Cluster implements Comparable<Cluster> {
|
|||
|
||||
public static class Builder {
|
||||
private long id;
|
||||
private Host.AllocationState allocationState;
|
||||
private AllocationState allocationState;
|
||||
private Host.ClusterType clusterType;
|
||||
private String hypervisor;
|
||||
private ManagedState managedState;
|
||||
|
@ -72,7 +72,7 @@ public class Cluster implements Comparable<Cluster> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder allocationState(Host.AllocationState allocationState) {
|
||||
public Builder allocationState(AllocationState allocationState) {
|
||||
this.allocationState = allocationState;
|
||||
return this;
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public class Cluster implements Comparable<Cluster> {
|
|||
}
|
||||
|
||||
private long id;
|
||||
@SerializedName("allocationstate") private Host.AllocationState allocationState;
|
||||
@SerializedName("allocationstate") private AllocationState allocationState;
|
||||
@SerializedName("clustertype") private Host.ClusterType clusterType;
|
||||
@SerializedName("hypervisortype") private String hypervisor;
|
||||
@SerializedName("managedstate") private ManagedState managedState;
|
||||
|
@ -136,7 +136,7 @@ public class Cluster implements Comparable<Cluster> {
|
|||
// 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) {
|
||||
public Cluster(long id, 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;
|
||||
|
@ -153,7 +153,7 @@ public class Cluster implements Comparable<Cluster> {
|
|||
return id;
|
||||
}
|
||||
|
||||
public Host.AllocationState getAllocationState() {
|
||||
public AllocationState getAllocationState() {
|
||||
return allocationState;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,25 +32,6 @@ import com.google.gson.annotations.SerializedName;
|
|||
*/
|
||||
public class Host implements Comparable<Host> {
|
||||
|
||||
public static enum AllocationState {
|
||||
DISABLED,
|
||||
ENABLED,
|
||||
UNKNOWN;
|
||||
|
||||
public static AllocationState fromValue(String value) {
|
||||
try{
|
||||
return valueOf(value.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return UPPER_UNDERSCORE.to(UPPER_CAMEL, name());
|
||||
}
|
||||
}
|
||||
|
||||
public static enum ClusterType {
|
||||
CLOUD_MANAGED,
|
||||
EXTERNAL_MANAGED,
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
|
||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -33,25 +31,6 @@ import com.google.gson.annotations.SerializedName;
|
|||
*/
|
||||
public class Zone implements Comparable<Zone> {
|
||||
|
||||
public static enum AllocationState {
|
||||
DISABLED,
|
||||
ENABLED,
|
||||
UNKNOWN;
|
||||
|
||||
public static AllocationState fromValue(String value) {
|
||||
try{
|
||||
return valueOf(value.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return UPPER_UNDERSCORE.to(UPPER_CAMEL, name());
|
||||
}
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
|
|
@ -19,12 +19,9 @@
|
|||
package org.jclouds.cloudstack.options;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.jclouds.functions.JoinOnComma;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Options to the GlobalHostClient.addHost() API call
|
||||
*
|
||||
|
@ -37,7 +34,7 @@ public class AddClusterOptions extends BaseHttpRequestOptions {
|
|||
/**
|
||||
* @param allocationState Allocation state of this Host for allocation of new resources
|
||||
*/
|
||||
public AddClusterOptions allocationState(Host.AllocationState allocationState) {
|
||||
public AddClusterOptions allocationState(AllocationState allocationState) {
|
||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||
return this;
|
||||
}
|
||||
|
@ -79,7 +76,7 @@ public class AddClusterOptions extends BaseHttpRequestOptions {
|
|||
/**
|
||||
* @param allocationState Allocation state of this Host for allocation of new resources
|
||||
*/
|
||||
public static AddClusterOptions allocationState(Host.AllocationState allocationState) {
|
||||
public static AddClusterOptions allocationState(AllocationState allocationState) {
|
||||
return new AddClusterOptions().allocationState(allocationState);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.cloudstack.options;
|
|||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -37,7 +37,7 @@ public class AddHostOptions extends BaseHttpRequestOptions {
|
|||
/**
|
||||
* @param allocationState Allocation state of this Host for allocation of new resources
|
||||
*/
|
||||
public AddHostOptions allocationState(Host.AllocationState allocationState) {
|
||||
public AddHostOptions allocationState(AllocationState allocationState) {
|
||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||
return this;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public class AddHostOptions extends BaseHttpRequestOptions {
|
|||
/**
|
||||
* @param allocationState Allocation state of this Host for allocation of new resources
|
||||
*/
|
||||
public static AddHostOptions allocationState(Host.AllocationState allocationState) {
|
||||
public static AddHostOptions allocationState(AllocationState allocationState) {
|
||||
return new AddHostOptions().allocationState(allocationState);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.jclouds.cloudstack.options;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.jclouds.cloudstack.domain.Zone;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class CreateZoneOptions extends BaseHttpRequestOptions {
|
|||
* @param allocationState
|
||||
* allocation state of this Zone for allocation of new resources
|
||||
*/
|
||||
public CreateZoneOptions allocationState(Zone.AllocationState allocationState) {
|
||||
public CreateZoneOptions allocationState(AllocationState allocationState) {
|
||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||
return this;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class CreateZoneOptions extends BaseHttpRequestOptions {
|
|||
/**
|
||||
* @see CreateZoneOptions#allocationState
|
||||
*/
|
||||
public static CreateZoneOptions allocationState(Zone.AllocationState allocationState) {
|
||||
public static CreateZoneOptions allocationState(AllocationState allocationState) {
|
||||
CreateZoneOptions options = new CreateZoneOptions();
|
||||
return options.allocationState(allocationState);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.cloudstack.options;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.cloudstack.domain.Cluster;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
|
@ -35,7 +36,7 @@ public class ListClustersOptions extends BaseHttpRequestOptions {
|
|||
|
||||
public static final ListHostsOptions NONE = new ListHostsOptions();
|
||||
|
||||
public ListClustersOptions allocationState(Host.AllocationState allocationState) {
|
||||
public ListClustersOptions allocationState(AllocationState allocationState) {
|
||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||
return this;
|
||||
}
|
||||
|
@ -82,7 +83,7 @@ public class ListClustersOptions extends BaseHttpRequestOptions {
|
|||
|
||||
public static class Builder {
|
||||
|
||||
public static ListClustersOptions allocationState(Host.AllocationState allocationState) {
|
||||
public static ListClustersOptions allocationState(AllocationState allocationState) {
|
||||
return new ListClustersOptions().allocationState(allocationState);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.options;
|
||||
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -45,7 +46,7 @@ public class ListHostsOptions extends AccountInDomainOptions {
|
|||
/**
|
||||
* @param allocationState list hosts by allocation state
|
||||
*/
|
||||
public ListHostsOptions allocationState(Host.AllocationState allocationState) {
|
||||
public ListHostsOptions allocationState(AllocationState allocationState) {
|
||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||
return this;
|
||||
}
|
||||
|
@ -159,7 +160,7 @@ public class ListHostsOptions extends AccountInDomainOptions {
|
|||
/**
|
||||
* @see ListHostsOptions#allocationState
|
||||
*/
|
||||
public static ListHostsOptions allocationState(Host.AllocationState allocationState) {
|
||||
public static ListHostsOptions allocationState(AllocationState allocationState) {
|
||||
ListHostsOptions options = new ListHostsOptions();
|
||||
return options.allocationState(allocationState);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.cloudstack.options;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.cloudstack.domain.Cluster;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
|
@ -35,7 +36,7 @@ public class UpdateClusterOptions extends BaseHttpRequestOptions {
|
|||
/**
|
||||
* @param allocationState Allocation state of this cluster for allocation of new resources
|
||||
*/
|
||||
public UpdateClusterOptions allocationState(Host.AllocationState allocationState) {
|
||||
public UpdateClusterOptions allocationState(AllocationState allocationState) {
|
||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.<String>of(allocationState.toString()));
|
||||
return this;
|
||||
}
|
||||
|
@ -77,7 +78,7 @@ public class UpdateClusterOptions extends BaseHttpRequestOptions {
|
|||
/**
|
||||
* @param allocationState Allocation state of this cluster for allocation of new resources
|
||||
*/
|
||||
public static UpdateClusterOptions allocationState(Host.AllocationState allocationState) {
|
||||
public static UpdateClusterOptions allocationState(AllocationState allocationState) {
|
||||
return new UpdateClusterOptions().allocationState(allocationState);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,7 @@ package org.jclouds.cloudstack.options;
|
|||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.jclouds.functions.JoinOnComma;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -39,7 +38,7 @@ public class UpdateHostOptions extends BaseHttpRequestOptions {
|
|||
/**
|
||||
* @param allocationState Allocation state of this Host for allocation of new resources
|
||||
*/
|
||||
public UpdateHostOptions allocationState(Host.AllocationState allocationState) {
|
||||
public UpdateHostOptions allocationState(AllocationState allocationState) {
|
||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||
return this;
|
||||
}
|
||||
|
@ -65,7 +64,7 @@ public class UpdateHostOptions extends BaseHttpRequestOptions {
|
|||
/**
|
||||
* @param allocationState Allocation state of this Host for allocation of new resources
|
||||
*/
|
||||
public static UpdateHostOptions allocationState(Host.AllocationState allocationState) {
|
||||
public static UpdateHostOptions allocationState(AllocationState allocationState) {
|
||||
return new UpdateHostOptions().allocationState(allocationState);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.jclouds.cloudstack.options;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.jclouds.cloudstack.domain.Zone;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -42,7 +42,7 @@ public class UpdateZoneOptions extends BaseHttpRequestOptions {
|
|||
* @param allocationState
|
||||
* allocation state of this Zone for allocation of new resources
|
||||
*/
|
||||
public UpdateZoneOptions allocationState(Zone.AllocationState allocationState) {
|
||||
public UpdateZoneOptions allocationState(AllocationState allocationState) {
|
||||
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString()));
|
||||
return this;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ public class UpdateZoneOptions extends BaseHttpRequestOptions {
|
|||
/**
|
||||
* @see UpdateZoneOptions#allocationState
|
||||
*/
|
||||
public static UpdateZoneOptions allocationState(Zone.AllocationState allocationState) {
|
||||
public static UpdateZoneOptions allocationState(AllocationState allocationState) {
|
||||
UpdateZoneOptions options = new UpdateZoneOptions();
|
||||
return options.allocationState(allocationState);
|
||||
}
|
||||
|
|
|
@ -18,12 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.cloudstack.domain.Cluster;
|
||||
import org.jclouds.cloudstack.domain.ConfigurationEntry;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.jclouds.cloudstack.options.AddClusterOptions;
|
||||
import org.jclouds.cloudstack.options.AddHostOptions;
|
||||
|
@ -68,20 +67,20 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
|||
|
||||
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
||||
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "UTC");
|
||||
Host host1 = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(Host.AllocationState.ENABLED).build();
|
||||
Host host1 = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||
|
||||
Date disconnected = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
||||
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 42, 30, "UTC");
|
||||
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
||||
Host host2 = Host.builder().id(2).name("nfs://10.26.26.165/mnt/nfs/cs_sec").state(Host.State.ALERT).disconnected(disconnected).type(Host.Type.SECONDARY_STORAGE).ipAddress("nfs").zoneId(1).zoneName("Dev Zone 1").version("2.2.12.20110928142833").hypervisor("None").lastPinged(lastPinged).localStorageActive(false).created(created).events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping").hasEnoughCapacity(false).allocationState(Host.AllocationState.ENABLED).build();
|
||||
Host host2 = Host.builder().id(2).name("nfs://10.26.26.165/mnt/nfs/cs_sec").state(Host.State.ALERT).disconnected(disconnected).type(Host.Type.SECONDARY_STORAGE).ipAddress("nfs").zoneId(1).zoneName("Dev Zone 1").version("2.2.12.20110928142833").hypervisor("None").lastPinged(lastPinged).localStorageActive(false).created(created).events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||
|
||||
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
||||
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 35, 51, "UTC");
|
||||
Host host3 = Host.builder().id(3).name("s-1-VM").state(Host.State.UP).type(Host.Type.SECONDARY_STORAGE_VM).ipAddress("10.26.26.81").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").lastPinged(lastPinged).managementServerId(223098941760041L).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(Host.AllocationState.ENABLED).build();
|
||||
Host host3 = Host.builder().id(3).name("s-1-VM").state(Host.State.UP).type(Host.Type.SECONDARY_STORAGE_VM).ipAddress("10.26.26.81").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").lastPinged(lastPinged).managementServerId(223098941760041L).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||
|
||||
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
||||
created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 36, 46, "UTC");
|
||||
Host host4 = Host.builder().id(4).name("v-2-VM").state(Host.State.UP).type(Host.Type.CONSOLE_PROXY).ipAddress("10.26.26.96").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").lastPinged(lastPinged).managementServerId(223098941760041L).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(Host.AllocationState.ENABLED).build();
|
||||
Host host4 = Host.builder().id(4).name("v-2-VM").state(Host.State.UP).type(Host.Type.CONSOLE_PROXY).ipAddress("10.26.26.96").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").lastPinged(lastPinged).managementServerId(223098941760041L).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||
|
||||
Set<Host> expected = ImmutableSet.of(host1, host2, host3, host4);
|
||||
|
||||
|
@ -114,10 +113,10 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
|||
|
||||
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
||||
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "UTC");
|
||||
Host expected = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(Host.AllocationState.ENABLED).build();
|
||||
Host expected = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||
|
||||
Host actual = requestSendsResponse(request, response).addHost(1, "http://example.com", "XenServer", "fred", "sekrit",
|
||||
AddHostOptions.Builder.hostTags(Collections.<String>emptySet()).allocationState(Host.AllocationState.ENABLED).clusterId(1).clusterName("Xen Clust 1").podId(1));
|
||||
AddHostOptions.Builder.hostTags(Collections.<String>emptySet()).allocationState(AllocationState.ENABLED).clusterId(1).clusterName("Xen Clust 1").podId(1));
|
||||
|
||||
assertEquals(actual, expected);
|
||||
}
|
||||
|
@ -135,9 +134,9 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
|||
|
||||
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "UTC");
|
||||
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "UTC");
|
||||
Host expected = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(Host.AllocationState.ENABLED).build();
|
||||
Host expected = Host.builder().id(1).name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId(1).zoneName("Dev Zone 1").podId(1).podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId(223098941760041L).clusterId(1).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||
|
||||
Host actual = requestSendsResponse(request, response).updateHost(1, UpdateHostOptions.Builder.allocationState(Host.AllocationState.ENABLED).hostTags(Collections.<String>emptySet()).osCategoryId(5));
|
||||
Host actual = requestSendsResponse(request, response).updateHost(1, UpdateHostOptions.Builder.allocationState(AllocationState.ENABLED).hostTags(Collections.<String>emptySet()).osCategoryId(5));
|
||||
|
||||
assertEquals(actual, expected);
|
||||
}
|
||||
|
@ -227,7 +226,7 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
|||
Date disconnected = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
||||
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 42, 30, "UTC");
|
||||
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "UTC");
|
||||
Host expected = Host.builder().id(2).name("nfs://10.26.26.165/mnt/nfs/cs_sec").state(Host.State.ALERT).disconnected(disconnected).type(Host.Type.SECONDARY_STORAGE).ipAddress("nfs").zoneId(1).zoneName("Dev Zone 1").version("2.2.12.20110928142833").hypervisor("None").lastPinged(lastPinged).localStorageActive(false).created(created).events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping").hasEnoughCapacity(false).allocationState(Host.AllocationState.ENABLED).build();
|
||||
Host expected = Host.builder().id(2).name("nfs://10.26.26.165/mnt/nfs/cs_sec").state(Host.State.ALERT).disconnected(disconnected).type(Host.Type.SECONDARY_STORAGE).ipAddress("nfs").zoneId(1).zoneName("Dev Zone 1").version("2.2.12.20110928142833").hypervisor("None").lastPinged(lastPinged).localStorageActive(false).created(created).events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
|
||||
|
||||
Host actual = requestSendsResponse(request, response).addSecondaryStorage("nfs://10.26.26.165/mnt/nfs/cs_sec", AddSecondaryStorageOptions.Builder.zoneId(1));
|
||||
|
||||
|
@ -247,8 +246,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
|||
|
||||
Set<Cluster> actual = requestSendsResponse(request, response).listClusters();
|
||||
|
||||
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();
|
||||
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(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(AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build();
|
||||
ImmutableSet<Cluster> expected = ImmutableSet.of(cluster1, cluster2);
|
||||
|
||||
assertEquals(actual, expected);
|
||||
|
@ -278,9 +277,9 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
|||
.payload(payloadFromResource("/addclusterresponse.json"))
|
||||
.statusCode(200).build();
|
||||
|
||||
Cluster expected = 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 expected = 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(AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build();
|
||||
|
||||
Cluster actual = requestSendsResponse(request, response).addCluster(1, "Xen Clust 1", Host.ClusterType.CLOUD_MANAGED, "XenServer", AddClusterOptions.Builder.allocationState(Host.AllocationState.ENABLED).podId(1).url("http://example.com/cluster").username("fred").password("sekrit"));
|
||||
Cluster actual = requestSendsResponse(request, response).addCluster(1, "Xen Clust 1", Host.ClusterType.CLOUD_MANAGED, "XenServer", AddClusterOptions.Builder.allocationState(AllocationState.ENABLED).podId(1).url("http://example.com/cluster").username("fred").password("sekrit"));
|
||||
|
||||
assertEquals(actual, expected);
|
||||
}
|
||||
|
@ -296,9 +295,9 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
|||
.payload(payloadFromResource("/updateclusterresponse.json"))
|
||||
.statusCode(200).build();
|
||||
|
||||
Cluster expected = 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 expected = 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(AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build();
|
||||
|
||||
Cluster actual = requestSendsResponse(request, response).updateCluster(1, UpdateClusterOptions.Builder.allocationState(Host.AllocationState.ENABLED).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).hypervisor("XenServer").managedState(Cluster.ManagedState.MANAGED));
|
||||
Cluster actual = requestSendsResponse(request, response).updateCluster(1, UpdateClusterOptions.Builder.allocationState(AllocationState.ENABLED).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).hypervisor("XenServer").managedState(Cluster.ManagedState.MANAGED));
|
||||
|
||||
assertEquals(actual, expected);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import static org.testng.Assert.assertTrue;
|
|||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.cloudstack.domain.Cluster;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -79,7 +80,7 @@ public class GlobalHostClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
private void checkCluster(Cluster cluster) {
|
||||
assertTrue(cluster.getId() > 0);
|
||||
assertFalse(Strings.isNullOrEmpty(cluster.getName()));
|
||||
assertTrue(cluster.getAllocationState() != Host.AllocationState.UNKNOWN);
|
||||
assertTrue(cluster.getAllocationState() != AllocationState.UNKNOWN);
|
||||
assertTrue(cluster.getClusterType() != Host.ClusterType.UNKNOWN);
|
||||
assertFalse(Strings.isNullOrEmpty(cluster.getHypervisor()));
|
||||
assertTrue(cluster.getManagedState() != Cluster.ManagedState.UNRECOGNIZED);
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.cloudstack.features;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.cloudstack.domain.NetworkType;
|
||||
import org.jclouds.cloudstack.domain.Zone;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -68,7 +69,7 @@ public class GlobalZoneClientExpectTest extends BaseCloudStackRestClientExpectTe
|
|||
.internalDNS(ImmutableList.of("10.10.10.10"))
|
||||
.networkType(NetworkType.BASIC)
|
||||
.securityGroupsEnabled(true)
|
||||
.allocationState(Zone.AllocationState.ENABLED)
|
||||
.allocationState(AllocationState.ENABLED)
|
||||
.zoneToken("7b6e27df-30a6-3024-9d8b-7971a3127f64")
|
||||
.dhcpProvider("DhcpServer").build());
|
||||
|
||||
|
@ -102,7 +103,7 @@ public class GlobalZoneClientExpectTest extends BaseCloudStackRestClientExpectTe
|
|||
.internalDNS(ImmutableList.of("10.10.10.10"))
|
||||
.networkType(NetworkType.BASIC)
|
||||
.securityGroupsEnabled(true)
|
||||
.allocationState(Zone.AllocationState.ENABLED)
|
||||
.allocationState(AllocationState.ENABLED)
|
||||
.zoneToken("7b6e27df-30a6-3024-9d8b-7971a3127f64")
|
||||
.dhcpProvider("DhcpServer").build());
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.jclouds.cloudstack.options;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.jclouds.cloudstack.options.AddClusterOptions.Builder.*;
|
||||
|
@ -34,12 +34,12 @@ import static org.testng.Assert.assertEquals;
|
|||
public class AddClusterOptionsTest {
|
||||
|
||||
public void testAllocationState() {
|
||||
AddClusterOptions options = new AddClusterOptions().allocationState(Host.AllocationState.ENABLED);
|
||||
AddClusterOptions options = new AddClusterOptions().allocationState(AllocationState.ENABLED);
|
||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||
}
|
||||
|
||||
public void testAllocationStateStatic() {
|
||||
AddClusterOptions options = allocationState(Host.AllocationState.ENABLED);
|
||||
AddClusterOptions options = allocationState(AllocationState.ENABLED);
|
||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.cloudstack.options;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.jclouds.cloudstack.options.AddHostOptions.Builder.*;
|
||||
|
@ -35,12 +35,12 @@ import static org.testng.Assert.assertEquals;
|
|||
public class AddHostOptionsTest {
|
||||
|
||||
public void testAllocationState() {
|
||||
AddHostOptions options = new AddHostOptions().allocationState(Host.AllocationState.ENABLED);
|
||||
AddHostOptions options = new AddHostOptions().allocationState(AllocationState.ENABLED);
|
||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||
}
|
||||
|
||||
public void testAllocationStateStatic() {
|
||||
AddHostOptions options = allocationState(Host.AllocationState.ENABLED);
|
||||
AddHostOptions options = allocationState(AllocationState.ENABLED);
|
||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.cloudstack.options;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.cloudstack.domain.Cluster;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -35,12 +36,12 @@ import static org.testng.Assert.assertEquals;
|
|||
public class ListClustersOptionsTest {
|
||||
|
||||
public void testAllocationState() {
|
||||
ListClustersOptions options = new ListClustersOptions().allocationState(Host.AllocationState.ENABLED);
|
||||
ListClustersOptions options = new ListClustersOptions().allocationState(AllocationState.ENABLED);
|
||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||
}
|
||||
|
||||
public void testAllocationStateStatic() {
|
||||
ListClustersOptions options = allocationState(Host.AllocationState.ENABLED);
|
||||
ListClustersOptions options = allocationState(AllocationState.ENABLED);
|
||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.cloudstack.options;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -55,12 +56,12 @@ public class ListHostsOptionsTest {
|
|||
}
|
||||
|
||||
public void testAllocationState() {
|
||||
ListHostsOptions options = new ListHostsOptions().allocationState(Host.AllocationState.ENABLED);
|
||||
ListHostsOptions options = new ListHostsOptions().allocationState(AllocationState.ENABLED);
|
||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||
}
|
||||
|
||||
public void testAllocationStateStatic() {
|
||||
ListHostsOptions options = allocationState(Host.AllocationState.ENABLED);
|
||||
ListHostsOptions options = allocationState(AllocationState.ENABLED);
|
||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.cloudstack.options;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.cloudstack.domain.Cluster;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -35,12 +36,12 @@ import static org.testng.Assert.assertEquals;
|
|||
public class UpdateClusterOptionsTest {
|
||||
|
||||
public void testAllocationState() {
|
||||
UpdateClusterOptions options = new UpdateClusterOptions().allocationState(Host.AllocationState.ENABLED);
|
||||
UpdateClusterOptions options = new UpdateClusterOptions().allocationState(AllocationState.ENABLED);
|
||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||
}
|
||||
|
||||
public void testAllocationStateStatic() {
|
||||
UpdateClusterOptions options = allocationState(Host.AllocationState.ENABLED);
|
||||
UpdateClusterOptions options = allocationState(AllocationState.ENABLED);
|
||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.cloudstack.options;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.jclouds.cloudstack.options.UpdateHostOptions.Builder.*;
|
||||
|
@ -35,12 +35,12 @@ import static org.testng.Assert.assertEquals;
|
|||
public class UpdateHostOptionsTest {
|
||||
|
||||
public void testAllocationState() {
|
||||
UpdateHostOptions options = new UpdateHostOptions().allocationState(Host.AllocationState.ENABLED);
|
||||
UpdateHostOptions options = new UpdateHostOptions().allocationState(AllocationState.ENABLED);
|
||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||
}
|
||||
|
||||
public void testAllocationStateStatic() {
|
||||
UpdateHostOptions options = allocationState(Host.AllocationState.ENABLED);
|
||||
UpdateHostOptions options = allocationState(AllocationState.ENABLED);
|
||||
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,14 +19,10 @@
|
|||
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.AllocationState;
|
||||
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;
|
||||
|
||||
|
@ -53,7 +49,7 @@ public class ListClustersResponseTest extends BaseSetParserTest<Cluster> {
|
|||
.zoneId(1).zoneName("Dev Zone 1")
|
||||
.hypervisor("XenServer")
|
||||
.clusterType(Host.ClusterType.CLOUD_MANAGED)
|
||||
.allocationState(Host.AllocationState.ENABLED)
|
||||
.allocationState(AllocationState.ENABLED)
|
||||
.managedState(Cluster.ManagedState.MANAGED)
|
||||
.build();
|
||||
Cluster cluster2 = Cluster.builder()
|
||||
|
@ -63,7 +59,7 @@ public class ListClustersResponseTest extends BaseSetParserTest<Cluster> {
|
|||
.zoneId(2).zoneName("Dev Zone 2")
|
||||
.hypervisor("XenServer")
|
||||
.clusterType(Host.ClusterType.CLOUD_MANAGED)
|
||||
.allocationState(Host.AllocationState.ENABLED)
|
||||
.allocationState(AllocationState.ENABLED)
|
||||
.managedState(Cluster.ManagedState.MANAGED)
|
||||
.build();
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ 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.AllocationState;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.json.BaseSetParserTest;
|
||||
|
@ -95,7 +96,7 @@ public class ListHostsResponseTest extends BaseSetParserTest<Host> {
|
|||
"AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping")
|
||||
.hostTags("")
|
||||
.hasEnoughCapacity(false)
|
||||
.allocationState(Host.AllocationState.ENABLED).build(),
|
||||
.allocationState(AllocationState.ENABLED).build(),
|
||||
|
||||
Host.builder()
|
||||
.id(2)
|
||||
|
@ -113,7 +114,7 @@ public class ListHostsResponseTest extends BaseSetParserTest<Host> {
|
|||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-11-26T23:33:38+0200"))
|
||||
.events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping")
|
||||
.hasEnoughCapacity(false)
|
||||
.allocationState(Host.AllocationState.ENABLED).build(),
|
||||
.allocationState(AllocationState.ENABLED).build(),
|
||||
|
||||
Host.builder()
|
||||
.id(3)
|
||||
|
@ -133,7 +134,7 @@ public class ListHostsResponseTest extends BaseSetParserTest<Host> {
|
|||
.events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; " +
|
||||
"AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping")
|
||||
.hasEnoughCapacity(false)
|
||||
.allocationState(Host.AllocationState.ENABLED).build(),
|
||||
.allocationState(AllocationState.ENABLED).build(),
|
||||
|
||||
Host.builder()
|
||||
.id(4)
|
||||
|
@ -153,7 +154,7 @@ public class ListHostsResponseTest extends BaseSetParserTest<Host> {
|
|||
.events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; " +
|
||||
"AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping")
|
||||
.hasEnoughCapacity(false)
|
||||
.allocationState(Host.AllocationState.ENABLED).build()
|
||||
.allocationState(AllocationState.ENABLED).build()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue