diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java index 48f72738fe..af077ec472 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java @@ -47,7 +47,7 @@ public class Host implements Comparable { private String cpuUsed; private float cpuWithOverProvisioning; private Date created; - private boolean disconnected; + private Date disconnected; private long diskSizeAllocated; private long diskSizeTotal; private String events; @@ -142,7 +142,7 @@ public class Host implements Comparable { return this; } - public Builder disconnected(boolean disconnected) { + public Builder disconnected(Date disconnected) { this.disconnected = disconnected; return this; } @@ -325,7 +325,7 @@ public class Host implements Comparable { @SerializedName("cpuwithoverprovisioning") private float cpuWithOverProvisioning; private Date created; - private boolean disconnected; + private Date disconnected; @SerializedName("disksizeallocated") private long diskSizeAllocated; @SerializedName("disksizetotal") @@ -383,7 +383,7 @@ public class Host implements Comparable { public Host(long id, String allocationState, int averageLoad, String capabilities, long clusterId, String clusterName, String clusterType, String cpuAllocated, int cpuNumber, int cpuSpeed, String cpuUsed, float cpuWithOverProvisioning, - Date created, boolean disconnected, long diskSizeAllocated, long diskSizeTotal, + Date created, Date disconnected, long diskSizeAllocated, long diskSizeTotal, String events, boolean hasEnoughCapacity, String hostTags, String hypervisor, String ipAddress, boolean localStorageActive, long jobId, AsyncJob.Status jobStatus, Date lastPinged, long managementServerId, long memoryAllocated, long memoryTotal, @@ -486,7 +486,7 @@ public class Host implements Comparable { return created; } - public boolean isDisconnected() { + public Date getDisconnected() { return disconnected; } @@ -617,7 +617,7 @@ public class Host implements Comparable { result = 31 * result + (cpuUsed != null ? cpuUsed.hashCode() : 0); result = 31 * result + (int) cpuWithOverProvisioning; result = 31 * result + (created != null ? created.hashCode() : 0); - result = 31 * result + (disconnected ? 1 : 0); + result = 31 * result + (disconnected != null ? disconnected.hashCode() : 0); result = 31 * result + (int) (diskSizeAllocated ^ (diskSizeAllocated >>> 32)); result = 31 * result + (int) (diskSizeTotal ^ (diskSizeTotal >>> 32)); result = 31 * result + (events != null ? events.hashCode() : 0); 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 0a70997718..2827e6e675 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 @@ -48,8 +48,8 @@ public class GlobalHostClientLiveTest extends BaseCloudStackClientLiveTest { } private void checkHost(Host host) { - // assert host.getCpuNumber() > 0; - // assert host.getAverageLoad() >= 0; + assert host.getCpuNumber() > 0; + assert host.getAverageLoad() >= 0; } } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListHostsResponseTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListHostsResponseTest.java index 4ab325f08b..85e8c9ce03 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListHostsResponseTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListHostsResponseTest.java @@ -23,6 +23,7 @@ import com.google.inject.Guice; import com.google.inject.Injector; import org.jclouds.cloudstack.config.CloudStackParserModule; 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; @@ -31,7 +32,6 @@ import org.testng.annotations.Test; import java.util.Set; /** - * * @author Andrei Savu */ @Test(groups = "unit") @@ -59,7 +59,102 @@ public class ListHostsResponseTest extends BaseSetParserTest { @Override @SelectJson("host") public Set expected() { - return ImmutableSet.of(); + return ImmutableSet.of( + + Host.builder() + .id(1L) + .name("cs2-xevsrv.alucloud.local") + .state("Up") + .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(4443L) + .networkKbsWrite(15048L) + .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(new SimpleDateFormatDateService().iso8601SecondsDateParse("1970-01-16T00:54:43+0200")) + .managementServerId(223098941760041L) + .clusterId(1) + .clusterName("Xen Clust 1") + .clusterType("CloudManaged") + .localStorageActive(false) + .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-11-26T23:28:36+0200")) + .events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; " + + "AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping") + .hostTags("") + .hasEnoughCapacity(false) + .allocationState("Enabled").build(), + + Host.builder() + .id(2) + .name("nfs://10.26.26.165/mnt/nfs/cs_sec") + .state("Alert") + .disconnected(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-11-26T23:33:38+0200")) + .type("SecondaryStorage") + .ipAddress("nfs") + .zoneId(1L) + .zoneName("Dev Zone 1") + .version("2.2.12.20110928142833") + .hypervisor("None") + .lastPinged(new SimpleDateFormatDateService().iso8601SecondsDateParse("1970-01-16T00:42:30+0200")) + .localStorageActive(false) + .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-11-26T23:33:38+0200")) + .events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping") + .hasEnoughCapacity(false) + .allocationState("Enabled").build(), + + Host.builder() + .id(3) + .name("s-1-VM") + .state("Up") + .type("SecondaryStorageVM") + .ipAddress("10.26.26.81") + .zoneId(1) + .zoneName("Dev Zone 1") + .podId(1) + .podName("Dev Pod 1") + .version("2.2.12.20110928142833") + .lastPinged(new SimpleDateFormatDateService().iso8601SecondsDateParse("1970-01-16T00:54:43+0200")) + .managementServerId(223098941760041L) + .localStorageActive(false) + .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-11-26T23:35:51+0200")) + .events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; " + + "AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping") + .hasEnoughCapacity(false) + .allocationState("Enabled").build(), + + Host.builder() + .id(4) + .name("v-2-VM") + .state("Up") + .type("ConsoleProxy") + .ipAddress("10.26.26.96") + .zoneId(1) + .zoneName("Dev Zone 1") + .podId(1) + .podName("Dev Pod 1") + .version("2.2.12.20110928142833") + .lastPinged(new SimpleDateFormatDateService().iso8601SecondsDateParse("1970-01-16T00:54:43+0200")) + .managementServerId(223098941760041L) + .localStorageActive(false) + .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-11-26T23:36:46+0200")) + .events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; " + + "AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping") + .hasEnoughCapacity(false) + .allocationState("Enabled").build() + ); } } diff --git a/apis/cloudstack/src/test/resources/listhostsresponse.json b/apis/cloudstack/src/test/resources/listhostsresponse.json index 8f20c1a639..5d1fcf3541 100644 --- a/apis/cloudstack/src/test/resources/listhostsresponse.json +++ b/apis/cloudstack/src/test/resources/listhostsresponse.json @@ -1 +1,5 @@ -{ "listhostsresponse" : { "count":4 ,"host" : [ {"id":1,"name":"cs2-xevsrv.alucloud.local","state":"Up","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.0","networkkbsread":4443,"networkkbswrite":15048,"memorytotal":100549733760,"memoryallocated":3623878656,"memoryused":3623878656,"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":"1970-01-16T00:54:43+0200","managementserverid":223098941760041,"clusterid":1,"clustername":"Xen Clust 1","clustertype":"CloudManaged","islocalstorageactive":false,"created":"2011-11-26T23:28:36+0200","events":"PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping","hosttags":"","hasEnoughCapacity":false,"allocationstate":"Enabled"}, {"id":2,"name":"nfs://10.26.26.165/mnt/nfs/cs_sec","state":"Alert","disconnected":"2011-11-26T23:33:38+0200","type":"SecondaryStorage","ipaddress":"nfs","zoneid":1,"zonename":"Dev Zone 1","version":"2.2.12.20110928142833","hypervisor":"None","lastpinged":"1970-01-16T00:42:30+0200","islocalstorageactive":false,"created":"2011-11-26T23:33:38+0200","events":"ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping","hasEnoughCapacity":false,"allocationstate":"Enabled"}, {"id":3,"name":"s-1-VM","state":"Up","type":"SecondaryStorageVM","ipaddress":"10.26.26.81","zoneid":1,"zonename":"Dev Zone 1","podid":1,"podname":"Dev Pod 1","version":"2.2.12.20110928142833","lastpinged":"1970-01-16T00:54:43+0200","managementserverid":223098941760041,"islocalstorageactive":false,"created":"2011-11-26T23:35:51+0200","events":"PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping","hasEnoughCapacity":false,"allocationstate":"Enabled"}, {"id":4,"name":"v-2-VM","state":"Up","type":"ConsoleProxy","ipaddress":"10.26.26.96","zoneid":1,"zonename":"Dev Zone 1","podid":1,"podname":"Dev Pod 1","version":"2.2.12.20110928142833","lastpinged":"1970-01-16T00:54:43+0200","managementserverid":223098941760041,"islocalstorageactive":false,"created":"2011-11-26T23:36:46+0200","events":"PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping","hasEnoughCapacity":false,"allocationstate":"Enabled"} ] } } \ No newline at end of file +{ "listhostsresponse" : { "count":4 ,"host" : [ + {"id":1,"name":"cs2-xevsrv.alucloud.local","state":"Up","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.0","networkkbsread":4443,"networkkbswrite":15048,"memorytotal":100549733760,"memoryallocated":3623878656,"memoryused":3623878656,"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":"1970-01-16T00:54:43+0200","managementserverid":223098941760041,"clusterid":1,"clustername":"Xen Clust 1","clustertype":"CloudManaged","islocalstorageactive":false,"created":"2011-11-26T23:28:36+0200","events":"PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping","hosttags":"","hasEnoughCapacity":false,"allocationstate":"Enabled"}, + {"id":2,"name":"nfs://10.26.26.165/mnt/nfs/cs_sec","state":"Alert","disconnected":"2011-11-26T23:33:38+0200","type":"SecondaryStorage","ipaddress":"nfs","zoneid":1,"zonename":"Dev Zone 1","version":"2.2.12.20110928142833","hypervisor":"None","lastpinged":"1970-01-16T00:42:30+0200","islocalstorageactive":false,"created":"2011-11-26T23:33:38+0200","events":"ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping","hasEnoughCapacity":false,"allocationstate":"Enabled"}, + {"id":3,"name":"s-1-VM","state":"Up","type":"SecondaryStorageVM","ipaddress":"10.26.26.81","zoneid":1,"zonename":"Dev Zone 1","podid":1,"podname":"Dev Pod 1","version":"2.2.12.20110928142833","lastpinged":"1970-01-16T00:54:43+0200","managementserverid":223098941760041,"islocalstorageactive":false,"created":"2011-11-26T23:35:51+0200","events":"PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping","hasEnoughCapacity":false,"allocationstate":"Enabled"}, + {"id":4,"name":"v-2-VM","state":"Up","type":"ConsoleProxy","ipaddress":"10.26.26.96","zoneid":1,"zonename":"Dev Zone 1","podid":1,"podname":"Dev Pod 1","version":"2.2.12.20110928142833","lastpinged":"1970-01-16T00:54:43+0200","managementserverid":223098941760041,"islocalstorageactive":false,"created":"2011-11-26T23:36:46+0200","events":"PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping","hasEnoughCapacity":false,"allocationstate":"Enabled"} ] } } \ No newline at end of file