Merge pull request #230 from andreisavu/list-hosts

Implement the Cloudstack global admin listHosts API call
This commit is contained in:
Adrian Cole 2011-12-11 11:14:14 -08:00
commit ed9e4c8232
12 changed files with 1619 additions and 0 deletions

View File

@ -21,6 +21,7 @@ package org.jclouds.cloudstack;
import org.jclouds.cloudstack.features.GlobalAccountAsyncClient; import org.jclouds.cloudstack.features.GlobalAccountAsyncClient;
import org.jclouds.cloudstack.features.GlobalAlertAsyncClient; import org.jclouds.cloudstack.features.GlobalAlertAsyncClient;
import org.jclouds.cloudstack.features.GlobalCapacityAsyncClient; import org.jclouds.cloudstack.features.GlobalCapacityAsyncClient;
import org.jclouds.cloudstack.features.GlobalHostAsyncClient;
import org.jclouds.cloudstack.features.GlobalOfferingAsyncClient; import org.jclouds.cloudstack.features.GlobalOfferingAsyncClient;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
@ -62,4 +63,10 @@ public interface CloudStackGlobalAsyncClient extends CloudStackDomainAsyncClient
@Override @Override
GlobalOfferingAsyncClient getOfferingClient(); GlobalOfferingAsyncClient getOfferingClient();
/**
* Provides asynchronous access to Hosts
*/
@Delegate
GlobalHostAsyncClient getHostClient();
} }

View File

@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.cloudstack.features.GlobalAccountClient; import org.jclouds.cloudstack.features.GlobalAccountClient;
import org.jclouds.cloudstack.features.GlobalAlertClient; import org.jclouds.cloudstack.features.GlobalAlertClient;
import org.jclouds.cloudstack.features.GlobalCapacityClient; import org.jclouds.cloudstack.features.GlobalCapacityClient;
import org.jclouds.cloudstack.features.GlobalHostClient;
import org.jclouds.cloudstack.features.GlobalOfferingClient; import org.jclouds.cloudstack.features.GlobalOfferingClient;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
@ -66,4 +67,10 @@ public interface CloudStackGlobalClient extends CloudStackDomainClient {
@Override @Override
GlobalOfferingClient getOfferingClient(); GlobalOfferingClient getOfferingClient();
/**
* Provides synchronous access to Hosts
*/
@Delegate
GlobalHostClient getHostClient();
} }

View File

@ -48,6 +48,8 @@ import org.jclouds.cloudstack.features.GlobalAlertAsyncClient;
import org.jclouds.cloudstack.features.GlobalAlertClient; import org.jclouds.cloudstack.features.GlobalAlertClient;
import org.jclouds.cloudstack.features.GlobalCapacityAsyncClient; import org.jclouds.cloudstack.features.GlobalCapacityAsyncClient;
import org.jclouds.cloudstack.features.GlobalCapacityClient; import org.jclouds.cloudstack.features.GlobalCapacityClient;
import org.jclouds.cloudstack.features.GlobalHostAsyncClient;
import org.jclouds.cloudstack.features.GlobalHostClient;
import org.jclouds.cloudstack.features.GlobalOfferingAsyncClient; import org.jclouds.cloudstack.features.GlobalOfferingAsyncClient;
import org.jclouds.cloudstack.features.GlobalOfferingClient; import org.jclouds.cloudstack.features.GlobalOfferingClient;
import org.jclouds.cloudstack.features.GuestOSAsyncClient; import org.jclouds.cloudstack.features.GuestOSAsyncClient;
@ -136,6 +138,7 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
.put(GlobalAlertClient.class, GlobalAlertAsyncClient.class)// .put(GlobalAlertClient.class, GlobalAlertAsyncClient.class)//
.put(GlobalCapacityClient.class, GlobalCapacityAsyncClient.class)// .put(GlobalCapacityClient.class, GlobalCapacityAsyncClient.class)//
.put(GlobalOfferingClient.class, GlobalOfferingAsyncClient.class)// .put(GlobalOfferingClient.class, GlobalOfferingAsyncClient.class)//
.put(GlobalHostClient.class, GlobalHostAsyncClient.class)//
.build(); .build();
@Override @Override

View File

@ -0,0 +1,774 @@
/**
* 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 java.util.Date;
/**
* Represents a host issued by Cloudstack
*
* @author Andrei Savu
*/
public class Host implements Comparable<Host> {
public static Builder builder() {
return new Builder();
}
public static class Builder {
private long id;
private String allocationState;
private int averageLoad;
private String capabilities;
private long clusterId;
private String clusterName;
private String clusterType;
private String cpuAllocated;
private int cpuNumber;
private int cpuSpeed;
private String cpuUsed;
private float cpuWithOverProvisioning;
private Date created;
private Date disconnected;
private long diskSizeAllocated;
private long diskSizeTotal;
private String events;
private boolean hasEnoughCapacity;
private String hostTags;
private String hypervisor;
private String ipAddress;
private boolean localStorageActive;
private long jobId;
private AsyncJob.Status jobStatus;
private Date lastPinged;
private long managementServerId;
private long memoryAllocated;
private long memoryTotal;
private long memoryUsed;
private String name;
private long networkKbsRead;
private long networkKbsWrite;
private long osCategoryId;
private long osCategoryName;
private long podId;
private String podName;
private Date removed;
private String state;
private String type;
private String version;
private long zoneId;
private String zoneName;
public Builder id(long id) {
this.id = id;
return this;
}
public Builder allocationState(String allocationState) {
this.allocationState = allocationState;
return this;
}
public Builder averageLoad(int averageLoad) {
this.averageLoad = averageLoad;
return this;
}
public Builder capabilities(String capabilities) {
this.capabilities = capabilities;
return this;
}
public Builder clusterId(long clusterId) {
this.clusterId = clusterId;
return this;
}
public Builder clusterName(String clusterName) {
this.clusterName = clusterName;
return this;
}
public Builder clusterType(String clusterType) {
this.clusterType = clusterType;
return this;
}
public Builder cpuAllocated(String cpuAllocated) {
this.cpuAllocated = cpuAllocated;
return this;
}
public Builder cpuNumber(int cpuNumber) {
this.cpuNumber = cpuNumber;
return this;
}
public Builder cpuSpeed(int cpuSpeed) {
this.cpuSpeed = cpuSpeed;
return this;
}
public Builder cpuUsed(String cpuUsed) {
this.cpuUsed = cpuUsed;
return this;
}
public Builder cpuWithOverProvisioning(float cpuWithOverProvisioning) {
this.cpuWithOverProvisioning = cpuWithOverProvisioning;
return this;
}
public Builder created(Date created) {
this.created = created;
return this;
}
public Builder disconnected(Date disconnected) {
this.disconnected = disconnected;
return this;
}
public Builder diskSizeAllocated(long diskSizeAllocated) {
this.diskSizeAllocated = diskSizeAllocated;
return this;
}
public Builder diskSizeTotal(long diskSizeTotal) {
this.diskSizeTotal = diskSizeTotal;
return this;
}
public Builder events(String events) {
this.events = events;
return this;
}
public Builder hasEnoughCapacity(boolean hasEnoughCapacity) {
this.hasEnoughCapacity = hasEnoughCapacity;
return this;
}
public Builder hostTags(String hostTags) {
this.hostTags = hostTags;
return this;
}
public Builder hypervisor(String hypervisor) {
this.hypervisor = hypervisor;
return this;
}
public Builder ipAddress(String ipAddress) {
this.ipAddress = ipAddress;
return this;
}
public Builder localStorageActive(boolean localStorageActive) {
this.localStorageActive = localStorageActive;
return this;
}
public Builder jobId(long jobId) {
this.jobId = jobId;
return this;
}
public Builder jobStatus(AsyncJob.Status jobStatus) {
this.jobStatus = jobStatus;
return this;
}
public Builder lastPinged(Date lastPinged) {
this.lastPinged = lastPinged;
return this;
}
public Builder managementServerId(long managementServerId) {
this.managementServerId = managementServerId;
return this;
}
public Builder memoryAllocated(long memoryAllocated) {
this.memoryAllocated = memoryAllocated;
return this;
}
public Builder memoryTotal(long memoryTotal) {
this.memoryTotal = memoryTotal;
return this;
}
public Builder memoryUsed(long memoryUsed) {
this.memoryUsed = memoryUsed;
return this;
}
public Builder name(String name) {
this.name = name;
return this;
}
public Builder networkKbsRead(long networkKbsRead) {
this.networkKbsRead = networkKbsRead;
return this;
}
public Builder networkKbsWrite(long networkKbsWrite) {
this.networkKbsWrite = networkKbsWrite;
return this;
}
public Builder osCategoryId(long osCategoryId) {
this.osCategoryId = osCategoryId;
return this;
}
public Builder osCategoryName(long osCategoryName) {
this.osCategoryName = osCategoryName;
return this;
}
public Builder podId(long podId) {
this.podId = podId;
return this;
}
public Builder podName(String podName) {
this.podName = podName;
return this;
}
public Builder removed(Date removed) {
this.removed = removed;
return this;
}
public Builder state(String state) {
this.state = state;
return this;
}
public Builder type(String type) {
this.type = type;
return this;
}
public Builder version(String version) {
this.version = version;
return this;
}
public Builder zoneId(long zoneId) {
this.zoneId = zoneId;
return this;
}
public Builder zoneName(String zoneName) {
this.zoneName = zoneName;
return this;
}
public Host build() {
return new Host(id, allocationState, averageLoad, capabilities,
clusterId, clusterName, clusterType, cpuAllocated,
cpuNumber, cpuSpeed, cpuUsed, cpuWithOverProvisioning,
created, disconnected, diskSizeAllocated, diskSizeTotal,
events, hasEnoughCapacity, hostTags, hypervisor,
ipAddress, localStorageActive, jobId, jobStatus,
lastPinged, managementServerId, memoryAllocated, memoryTotal,
memoryUsed, name, networkKbsRead, networkKbsWrite,
osCategoryId, osCategoryName, podId, podName, removed,
state, type, version, zoneId, zoneName);
}
}
private long id;
@SerializedName("allocationstate")
private String allocationState;
@SerializedName("averageload")
private int averageLoad;
@SerializedName("capabilities")
private String capabilities;
@SerializedName("clusterid")
private long clusterId;
@SerializedName("clustername")
private String clusterName;
@SerializedName("clustertype")
private String clusterType;
@SerializedName("cpuallocated")
private String cpuAllocated;
@SerializedName("cpunumber")
private int cpuNumber;
@SerializedName("cpuspeed")
private int cpuSpeed;
@SerializedName("cpuused")
private String cpuUsed;
@SerializedName("cpuwithoverprovisioning")
private float cpuWithOverProvisioning;
private Date created;
private Date disconnected;
@SerializedName("disksizeallocated")
private long diskSizeAllocated;
@SerializedName("disksizetotal")
private long diskSizeTotal;
private String events;
@SerializedName("hasenoughcapacity")
private boolean hasEnoughCapacity;
@SerializedName("hosttags")
private String hostTags;
private String hypervisor;
@SerializedName("ipaddress")
private String ipAddress;
@SerializedName("islocalstorageactive")
private boolean localStorageActive;
@SerializedName("jobid")
private long jobId;
@SerializedName("jobstatus")
private AsyncJob.Status jobStatus;
@SerializedName("lastpinged")
private Date lastPinged;
@SerializedName("managementserverid")
private long managementServerId;
@SerializedName("memoryallocated")
private long memoryAllocated;
@SerializedName("memorytotal")
private long memoryTotal;
@SerializedName("memoryused")
private long memoryUsed;
private String name;
@SerializedName("networkkbsread")
private long networkKbsRead;
@SerializedName("networkkbswrite")
private long networkKbsWrite;
@SerializedName("oscategoryid")
private long osCategoryId;
@SerializedName("oscategoryname")
private long osCategoryName;
@SerializedName("podid")
private long podId;
@SerializedName("podname")
private String podName;
private Date removed;
private String state;
private String type;
private String version;
@SerializedName("zoneid")
private long zoneId;
@SerializedName("zonename")
private String zoneName;
/* exists for the deserializer, only */
Host() {
}
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, 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,
long memoryUsed, String name, long networkKbsRead, long networkKbsWrite,
long osCategoryId, long osCategoryName, long podId, String podName, Date removed,
String state, String type, String version, long zoneId, String zoneName) {
this.id = id;
this.allocationState = allocationState;
this.averageLoad = averageLoad;
this.capabilities = capabilities;
this.clusterId = clusterId;
this.clusterName = clusterName;
this.clusterType = clusterType;
this.cpuAllocated = cpuAllocated;
this.cpuNumber = cpuNumber;
this.cpuSpeed = cpuSpeed;
this.cpuUsed = cpuUsed;
this.cpuWithOverProvisioning = cpuWithOverProvisioning;
this.created = created;
this.disconnected = disconnected;
this.diskSizeAllocated = diskSizeAllocated;
this.diskSizeTotal = diskSizeTotal;
this.events = events;
this.hasEnoughCapacity = hasEnoughCapacity;
this.hostTags = hostTags;
this.hypervisor = hypervisor;
this.ipAddress = ipAddress;
this.localStorageActive = localStorageActive;
this.jobId = jobId;
this.jobStatus = jobStatus;
this.lastPinged = lastPinged;
this.managementServerId = managementServerId;
this.memoryAllocated = memoryAllocated;
this.memoryTotal = memoryTotal;
this.memoryUsed = memoryUsed;
this.name = name;
this.networkKbsRead = networkKbsRead;
this.networkKbsWrite = networkKbsWrite;
this.osCategoryId = osCategoryId;
this.osCategoryName = osCategoryName;
this.podId = podId;
this.podName = podName;
this.removed = removed;
this.state = state;
this.type = type;
this.version = version;
this.zoneId = zoneId;
this.zoneName = zoneName;
}
public long getId() {
return id;
}
public String getAllocationState() {
return allocationState;
}
public int getAverageLoad() {
return averageLoad;
}
public String getCapabilities() {
return capabilities;
}
public long getClusterId() {
return clusterId;
}
public String getClusterName() {
return clusterName;
}
public String getClusterType() {
return clusterType;
}
public String getCpuAllocated() {
return cpuAllocated;
}
public int getCpuNumber() {
return cpuNumber;
}
public int getCpuSpeed() {
return cpuSpeed;
}
public String getCpuUsed() {
return cpuUsed;
}
public float getCpuWithOverProvisioning() {
return cpuWithOverProvisioning;
}
public Date getCreated() {
return created;
}
public Date getDisconnected() {
return disconnected;
}
public long getDiskSizeAllocated() {
return diskSizeAllocated;
}
public long getDiskSizeTotal() {
return diskSizeTotal;
}
public String getEvents() {
return events;
}
public boolean isHasEnoughCapacity() {
return hasEnoughCapacity;
}
public String getHostTags() {
return hostTags;
}
public String getHypervisor() {
return hypervisor;
}
public String getIpAddress() {
return ipAddress;
}
public boolean isLocalStorageActive() {
return localStorageActive;
}
public long getJobId() {
return jobId;
}
public AsyncJob.Status getJobStatus() {
return jobStatus;
}
public Date getLastPinged() {
return lastPinged;
}
public long getManagementServerId() {
return managementServerId;
}
public long getMemoryAllocated() {
return memoryAllocated;
}
public long getMemoryTotal() {
return memoryTotal;
}
public long getMemoryUsed() {
return memoryUsed;
}
public String getName() {
return name;
}
public long getNetworkKbsRead() {
return networkKbsRead;
}
public long getNetworkKbsWrite() {
return networkKbsWrite;
}
public long getOsCategoryId() {
return osCategoryId;
}
public long getOsCategoryName() {
return osCategoryName;
}
public long getPodId() {
return podId;
}
public String getPodName() {
return podName;
}
public Date getRemoved() {
return removed;
}
public String getState() {
return state;
}
public String getType() {
return type;
}
public String getVersion() {
return version;
}
public long getZoneId() {
return zoneId;
}
public String getZoneName() {
return zoneName;
}
@Override
public int hashCode() {
int result = (int) (id ^ (id >>> 32));
result = 31 * result + (allocationState != null ? allocationState.hashCode() : 0);
result = 31 * result + averageLoad;
result = 31 * result + (capabilities != null ? capabilities.hashCode() : 0);
result = 31 * result + (int) (clusterId ^ (clusterId >>> 32));
result = 31 * result + (clusterName != null ? clusterName.hashCode() : 0);
result = 31 * result + (clusterType != null ? clusterType.hashCode() : 0);
result = 31 * result + (cpuAllocated != null ? cpuAllocated.hashCode() : 0);
result = 31 * result + cpuNumber;
result = 31 * result + cpuSpeed;
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 != 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);
result = 31 * result + (hasEnoughCapacity ? 1 : 0);
result = 31 * result + (hostTags != null ? hostTags.hashCode() : 0);
result = 31 * result + (hypervisor != null ? hypervisor.hashCode() : 0);
result = 31 * result + (ipAddress != null ? ipAddress.hashCode() : 0);
result = 31 * result + (localStorageActive ? 1 : 0);
result = 31 * result + (int) (jobId ^ (jobId >>> 32));
result = 31 * result + (jobStatus != null ? jobStatus.hashCode() : 0);
result = 31 * result + (lastPinged != null ? lastPinged.hashCode() : 0);
result = 31 * result + (int) (managementServerId ^ (managementServerId >>> 32));
result = 31 * result + (int) (memoryAllocated ^ (memoryAllocated >>> 32));
result = 31 * result + (int) (memoryTotal ^ (memoryTotal >>> 32));
result = 31 * result + (int) (memoryUsed ^ (memoryUsed >>> 32));
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (int) (networkKbsRead ^ (networkKbsRead >>> 32));
result = 31 * result + (int) (networkKbsWrite ^ (networkKbsWrite >>> 32));
result = 31 * result + (int) (osCategoryId ^ (osCategoryId >>> 32));
result = 31 * result + (int) (osCategoryName ^ (osCategoryName >>> 32));
result = 31 * result + (int) (podId ^ (podId >>> 32));
result = 31 * result + (podName != null ? podName.hashCode() : 0);
result = 31 * result + (removed != null ? removed.hashCode() : 0);
result = 31 * result + (state != null ? state.hashCode() : 0);
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (version != null ? version.hashCode() : 0);
result = 31 * result + (int) (zoneId ^ (zoneId >>> 32));
result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0);
return result;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Host host = (Host) o;
if (averageLoad != host.averageLoad) return false;
if (clusterId != host.clusterId) return false;
if (cpuAllocated != host.cpuAllocated) return false;
if (cpuNumber != host.cpuNumber) return false;
if (cpuSpeed != host.cpuSpeed) return false;
if (cpuUsed != host.cpuUsed) return false;
if (cpuWithOverProvisioning != host.cpuWithOverProvisioning) return false;
if (disconnected != host.disconnected) return false;
if (diskSizeAllocated != host.diskSizeAllocated) return false;
if (diskSizeTotal != host.diskSizeTotal) return false;
if (hasEnoughCapacity != host.hasEnoughCapacity) return false;
if (id != host.id) return false;
if (localStorageActive != host.localStorageActive) return false;
if (jobId != host.jobId) return false;
if (managementServerId != host.managementServerId) return false;
if (memoryAllocated != host.memoryAllocated) return false;
if (memoryTotal != host.memoryTotal) return false;
if (memoryUsed != host.memoryUsed) return false;
if (networkKbsRead != host.networkKbsRead) return false;
if (networkKbsWrite != host.networkKbsWrite) return false;
if (osCategoryId != host.osCategoryId) return false;
if (osCategoryName != host.osCategoryName) return false;
if (podId != host.podId) return false;
if (zoneId != host.zoneId) return false;
if (allocationState != null ? !allocationState.equals(host.allocationState) : host.allocationState != null)
return false;
if (capabilities != null ? !capabilities.equals(host.capabilities) : host.capabilities != null)
return false;
if (clusterName != null ? !clusterName.equals(host.clusterName) : host.clusterName != null)
return false;
if (clusterType != null ? !clusterType.equals(host.clusterType) : host.clusterType != null)
return false;
if (created != null ? !created.equals(host.created) : host.created != null)
return false;
if (events != null ? !events.equals(host.events) : host.events != null)
return false;
if (hostTags != null ? !hostTags.equals(host.hostTags) : host.hostTags != null)
return false;
if (hypervisor != null ? !hypervisor.equals(host.hypervisor) : host.hypervisor != null)
return false;
if (ipAddress != null ? !ipAddress.equals(host.ipAddress) : host.ipAddress != null)
return false;
if (jobStatus != host.jobStatus) return false;
if (lastPinged != null ? !lastPinged.equals(host.lastPinged) : host.lastPinged != null)
return false;
if (name != null ? !name.equals(host.name) : host.name != null)
return false;
if (podName != null ? !podName.equals(host.podName) : host.podName != null)
return false;
if (removed != null ? !removed.equals(host.removed) : host.removed != null)
return false;
if (state != null ? !state.equals(host.state) : host.state != null)
return false;
if (type != null ? !type.equals(host.type) : host.type != null)
return false;
if (version != null ? !version.equals(host.version) : host.version != null)
return false;
if (zoneName != null ? !zoneName.equals(host.zoneName) : host.zoneName != null)
return false;
return true;
}
@Override
public String toString() {
return "Host{" +
"id=" + id +
", allocationState='" + allocationState + '\'' +
", averageLoad=" + averageLoad +
", capabilities='" + capabilities + '\'' +
", clusterId=" + clusterId +
", clusterName='" + clusterName + '\'' +
", clusterType='" + clusterType + '\'' +
", cpuAllocated=" + cpuAllocated +
", cpuNumber=" + cpuNumber +
", cpuSpeed=" + cpuSpeed +
", cpuUsed=" + cpuUsed +
", cpuWithOverProvisioning=" + cpuWithOverProvisioning +
", created=" + created +
", disconnected=" + disconnected +
", diskSizeAllocated=" + diskSizeAllocated +
", diskSizeTotal=" + diskSizeTotal +
", events='" + events + '\'' +
", hasEnoughCapacity=" + hasEnoughCapacity +
", hostTags='" + hostTags + '\'' +
", hypervisor='" + hypervisor + '\'' +
", ipAddress='" + ipAddress + '\'' +
", localStorageActive=" + localStorageActive +
", jobId=" + jobId +
", jobStatus=" + jobStatus +
", lastPinged=" + lastPinged +
", managementServerId=" + managementServerId +
", memoryAllocated=" + memoryAllocated +
", memoryTotal=" + memoryTotal +
", memoryUsed=" + memoryUsed +
", name='" + name + '\'' +
", networkKbsRead=" + networkKbsRead +
", networkKbsWrite=" + networkKbsWrite +
", osCategoryId=" + osCategoryId +
", osCategoryName=" + osCategoryName +
", podId=" + podId +
", podName='" + podName + '\'' +
", removed=" + removed +
", state='" + state + '\'' +
", type='" + type + '\'' +
", version='" + version + '\'' +
", zoneId=" + zoneId +
", zoneName='" + zoneName + '\'' +
'}';
}
@Override
public int compareTo(Host other) {
return Long.valueOf(this.getId()).compareTo(other.getId());
}
}

View File

@ -0,0 +1,57 @@
/**
* 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.features;
import com.google.common.util.concurrent.ListenableFuture;
import org.jclouds.cloudstack.domain.Host;
import org.jclouds.cloudstack.filters.QuerySigner;
import org.jclouds.cloudstack.options.ListHostsOptions;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.core.MediaType;
import java.util.Set;
/**
* Provides asynchronous access to cloudstack via their REST API.
* <p/>
*
* @see GlobalHostClient
* @see <a href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_Global_Admin.html" />
* @author Andrei Savu
*/
@RequestFilters(QuerySigner.class)
@QueryParams(keys = "response", values = "json")
public interface GlobalHostAsyncClient {
/**
* @see GlobalHostClient#listHosts
*/
@GET
@QueryParams(keys = "command", values = "listHosts")
@SelectJson("host")
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Host>> listHosts(ListHostsOptions... options);
}

View File

@ -0,0 +1,49 @@
/**
* 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.features;
import org.jclouds.cloudstack.domain.Host;
import org.jclouds.cloudstack.options.ListHostsOptions;
import org.jclouds.concurrent.Timeout;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
* Provides synchronous access to CloudStack host features.
* <p/>
*
* @see org.jclouds.cloudstack.features.GlobalOfferingAsyncClient
* @see <a href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_Global_Admin.html" />
* @author Andrei Savu
*/
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
public interface GlobalHostClient {
/**
* Lists hosts
*
* @param options
* if present, how to constrain the list.
* @return hosts matching query, or empty set, if no service
* offerings are found
*/
Set<Host> listHosts(ListHostsOptions... options);
}

View File

@ -0,0 +1,264 @@
/**
* 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.NetworkType;
import org.jclouds.cloudstack.domain.TrafficType;
/**
* Options used to control what hosts information is returned
*
* @author Andrei Savu
* @see <a
* href="http://download.cloud.com/releases/2.2.0/api_2.2.12/global_admin/listHosts.html"
* />
*/
public class ListHostsOptions extends AccountInDomainOptions {
public static final ListHostsOptions NONE = new ListHostsOptions();
/**
* @param id the id of the host
*/
public ListHostsOptions id(long id) {
this.queryParameters.replaceValues("id", ImmutableSet.of(id + ""));
return this;
}
/**
* @param allocationState list hosts by allocation state
*/
public ListHostsOptions allocationState(String allocationState) {
this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState));
return this;
}
/**
* @param clusterId lists hosts existing in particular cluster
*/
public ListHostsOptions clusterId(long clusterId) {
this.queryParameters.replaceValues("clusterid", ImmutableSet.of(clusterId + ""));
return this;
}
/**
* @param keyword List by keyword
*/
public ListHostsOptions keyword(String keyword) {
this.queryParameters.replaceValues("keyword", ImmutableSet.of(keyword));
return this;
}
/**
* @param name List by name
*/
public ListHostsOptions name(String name) {
this.queryParameters.replaceValues("name", ImmutableSet.of(name));
return this;
}
/**
* @param page
*/
public ListHostsOptions page(long page) {
this.queryParameters.replaceValues("page", ImmutableSet.of(page + ""));
return this;
}
/**
* @param pageSize the page size
*/
public ListHostsOptions pageSize(long pageSize) {
this.queryParameters.replaceValues("pagesize", ImmutableSet.of(pageSize + ""));
return this;
}
/**
* @param podId the Pod ID for the host
*/
public ListHostsOptions podId(long podId) {
this.queryParameters.replaceValues("podid", ImmutableSet.of(podId + ""));
return this;
}
/**
* @param state the state of the host
*/
public ListHostsOptions state(String state) {
this.queryParameters.replaceValues("state", ImmutableSet.of(state));
return this;
}
/**
* @param type the type of the host
*/
public ListHostsOptions type(String type) {
this.queryParameters.replaceValues("type", ImmutableSet.of(type));
return this;
}
/**
* @param virtualMachineId lists hosts in the same cluster as this VM and flag hosts with
* enough CPU/RAm to host this VM
*/
public ListHostsOptions virtualMachineId(long virtualMachineId) {
this.queryParameters.replaceValues("virtualmachineid", ImmutableSet.of(virtualMachineId + ""));
return this;
}
/**
* @param zoneId the Zone ID for the host
*/
public ListHostsOptions zoneId(long zoneId) {
this.queryParameters.replaceValues("zoneid", ImmutableSet.of(zoneId + ""));
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ListHostsOptions accountInDomain(String account, long domain) {
return ListHostsOptions.class.cast(super.accountInDomain(account, domain));
}
/**
* {@inheritDoc}
*/
@Override
public ListHostsOptions domainId(long domainId) {
return ListHostsOptions.class.cast(super.domainId(domainId));
}
public static class Builder {
/**
* @see ListHostsOptions#id
*/
public static ListHostsOptions id(long id) {
ListHostsOptions options = new ListHostsOptions();
return options.id(id);
}
/**
* @see ListHostsOptions#allocationState
*/
public static ListHostsOptions allocationState(String allocationState) {
ListHostsOptions options = new ListHostsOptions();
return options.allocationState(allocationState);
}
/**
* @see ListHostsOptions#clusterId
*/
public static ListHostsOptions clusterId(long clusterId) {
ListHostsOptions options = new ListHostsOptions();
return options.clusterId(clusterId);
}
/**
* @see ListHostsOptions#keyword(String)
*/
public static ListHostsOptions keyword(String keyword) {
ListHostsOptions options = new ListHostsOptions();
return options.keyword(keyword);
}
/**
* @see ListHostsOptions#name(String)
*/
public static ListHostsOptions name(String name) {
ListHostsOptions options = new ListHostsOptions();
return options.name(name);
}
/**
* @see ListHostsOptions#page
*/
public static ListHostsOptions page(long page) {
ListHostsOptions options = new ListHostsOptions();
return options.page(page);
}
/**
* @see ListHostsOptions#pageSize
*/
public static ListHostsOptions pageSize(long pageSize) {
ListHostsOptions options = new ListHostsOptions();
return options.pageSize(pageSize);
}
/**
* @see ListHostsOptions#podId
*/
public static ListHostsOptions podId(long podId) {
ListHostsOptions options = new ListHostsOptions();
return options.podId(podId);
}
/**
* @see ListHostsOptions#state
*/
public static ListHostsOptions state(String state) {
ListHostsOptions options = new ListHostsOptions();
return options.state(state);
}
/**
* @see ListHostsOptions#type
*/
public static ListHostsOptions type(String type) {
ListHostsOptions options = new ListHostsOptions();
return options.type(type);
}
/**
* @see ListHostsOptions#virtualMachineId
*/
public static ListHostsOptions virtualMachineId(long virtualMachineId) {
ListHostsOptions options = new ListHostsOptions();
return options.virtualMachineId(virtualMachineId);
}
/**
* @see ListHostsOptions#zoneId
*/
public static ListHostsOptions zoneId(long zoneId) {
ListHostsOptions options = new ListHostsOptions();
return options.zoneId(zoneId);
}
/**
* @see ListHostsOptions#accountInDomain
*/
public static ListHostsOptions accountInDomain(String account, long domain) {
ListHostsOptions options = new ListHostsOptions();
return options.accountInDomain(account, domain);
}
/**
* @see ListHostsOptions#domainId
*/
public static ListHostsOptions domainId(long domainId) {
ListHostsOptions options = new ListHostsOptions();
return options.domainId(domainId);
}
}
}

View File

@ -0,0 +1,61 @@
/**
* 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.features;
import com.google.inject.TypeLiteral;
import org.jclouds.cloudstack.options.ListHostsOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
import java.io.IOException;
import java.lang.reflect.Method;
/**
* Tests behavior of {@code GlobalHostAsyncClient}
*
* @author Andrei Savu
*/
@Test(groups = "unit", testName = "GlobalHostAsyncClientTest")
public class GlobalHostAsyncClientTest extends BaseCloudStackAsyncClientTest<GlobalHostAsyncClient> {
public void testListHosts() throws Exception {
Method method =GlobalHostAsyncClient.class.getMethod("listHosts", ListHostsOptions[].class);
HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listHosts HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
checkFilters(httpRequest);
}
@Override
protected TypeLiteral<RestAnnotationProcessor<GlobalHostAsyncClient>> createTypeLiteral() {
return new TypeLiteral<RestAnnotationProcessor<GlobalHostAsyncClient>>() {
};
}
}

View File

@ -0,0 +1,66 @@
/**
* 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.features;
import org.jclouds.cloudstack.domain.Host;
import org.jclouds.logging.Logger;
import org.testng.annotations.Test;
import java.util.Set;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
/**
* Tests behavior of {@code GlobalHostClient}
*
* @author Andrei Savu
*/
@Test(groups = "live", singleThreaded = true, testName = "GlobalHostClientLiveTest")
public class GlobalHostClientLiveTest extends BaseCloudStackClientLiveTest {
@Test(groups = "live", enabled = true)
public void testListHosts() throws Exception {
assertTrue(globalAdminEnabled, "Test cannot run without global admin identity and credentials");
Set<Host> hosts = globalAdminClient.getHostClient().listHosts();
assert hosts.size() > 0 : hosts;
for(Host host : hosts) {
checkHost(host);
}
}
private void checkHost(Host host) {
if (host.getType().equals("Routing")) {
assert host.getCpuNumber() > 0;
assert host.getAverageLoad() >= 0;
assert host.getHypervisor() != null;
}
assert host.getAllocationState() != null;
assert host.getEvents() != null;
if (host.getType().equals("SecondaryStorageVM")) {
assert host.getName().startsWith("s-");
}
if (host.getType().equals("ConsoleProxy")) {
assert host.getName().startsWith("v-");
}
}
}

View File

@ -0,0 +1,166 @@
/**
* 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.testng.annotations.Test;
import static org.jclouds.cloudstack.options.ListHostsOptions.Builder.allocationState;
import static org.jclouds.cloudstack.options.ListHostsOptions.Builder.clusterId;
import static org.jclouds.cloudstack.options.ListHostsOptions.Builder.id;
import static org.jclouds.cloudstack.options.ListHostsOptions.Builder.keyword;
import static org.jclouds.cloudstack.options.ListHostsOptions.Builder.name;
import static org.jclouds.cloudstack.options.ListHostsOptions.Builder.page;
import static org.jclouds.cloudstack.options.ListHostsOptions.Builder.pageSize;
import static org.jclouds.cloudstack.options.ListHostsOptions.Builder.podId;
import static org.jclouds.cloudstack.options.ListHostsOptions.Builder.state;
import static org.jclouds.cloudstack.options.ListHostsOptions.Builder.type;
import static org.jclouds.cloudstack.options.ListHostsOptions.Builder.virtualMachineId;
import static org.jclouds.cloudstack.options.ListHostsOptions.Builder.zoneId;
import static org.testng.Assert.assertEquals;
/**
* Tests behavior of {@code ListHostsOptions}
*
* @author Andrei Savu
*/
@Test(groups = "unit")
public class ListHostsOptionsTest {
public void testId() {
ListHostsOptions options = new ListHostsOptions().id(42L);
assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("id"));
}
public void testIdStatic() {
ListHostsOptions options = id(42L);
assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("id"));
}
public void testAllocationState() {
ListHostsOptions options = new ListHostsOptions().allocationState("Enabled");
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
}
public void testAllocationStateStatic() {
ListHostsOptions options = allocationState("Enabled");
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("allocationstate"));
}
public void testClusterId() {
ListHostsOptions options = new ListHostsOptions().clusterId(42L);
assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("clusterid"));
}
public void testClusterIdStatic() {
ListHostsOptions options = clusterId(42L);
assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("clusterid"));
}
public void testKeyword() {
ListHostsOptions options = new ListHostsOptions().keyword("Enabled");
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("keyword"));
}
public void testKeywordStatic() {
ListHostsOptions options = keyword("Enabled");
assertEquals(ImmutableList.of("Enabled"), options.buildQueryParameters().get("keyword"));
}
public void testName() {
ListHostsOptions options = new ListHostsOptions().name("Host Name");
assertEquals(ImmutableList.of("Host Name"), options.buildQueryParameters().get("name"));
}
public void testNameStatic() {
ListHostsOptions options = name("Host Name");
assertEquals(ImmutableList.of("Host Name"), options.buildQueryParameters().get("name"));
}
public void testPage() {
ListHostsOptions options = new ListHostsOptions().page(42L);
assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("page"));
}
public void testPageStatic() {
ListHostsOptions options = page(42L);
assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("page"));
}
public void testPageSize() {
ListHostsOptions options = new ListHostsOptions().pageSize(42L);
assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("pagesize"));
}
public void testPageSizeStatic() {
ListHostsOptions options = pageSize(42L);
assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("pagesize"));
}
public void testPodId() {
ListHostsOptions options = new ListHostsOptions().podId(42L);
assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("podid"));
}
public void testPodIdStatic() {
ListHostsOptions options = podId(42L);
assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("podid"));
}
public void testState() {
ListHostsOptions options = new ListHostsOptions().state("Up");
assertEquals(ImmutableList.of("Up"), options.buildQueryParameters().get("state"));
}
public void testStateStatic() {
ListHostsOptions options = state("Up");
assertEquals(ImmutableList.of("Up"), options.buildQueryParameters().get("state"));
}
public void testType() {
ListHostsOptions options = new ListHostsOptions().type("Routing");
assertEquals(ImmutableList.of("Routing"), options.buildQueryParameters().get("type"));
}
public void testTypeStatic() {
ListHostsOptions options = type("Routing");
assertEquals(ImmutableList.of("Routing"), options.buildQueryParameters().get("type"));
}
public void testVirtualMachineId() {
ListHostsOptions options = new ListHostsOptions().virtualMachineId(42L);
assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("virtualmachineid"));
}
public void testVirtualMachineIdStatic() {
ListHostsOptions options = virtualMachineId(42L);
assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("virtualmachineid"));
}
public void testZoneId() {
ListHostsOptions options = new ListHostsOptions().zoneId(42L);
assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("zoneid"));
}
public void testZoneIdStatic() {
ListHostsOptions options = zoneId(42L);
assertEquals(ImmutableList.of("42"), options.buildQueryParameters().get("zoneid"));
}
}

View File

@ -0,0 +1,160 @@
/**
* 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.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 Andrei Savu
*/
@Test(groups = "unit")
public class ListHostsResponseTest extends BaseSetParserTest<Host> {
@Override
protected Injector injector() {
return Guice.createInjector(new CloudStackParserModule(), new GsonModule() {
@Override
protected void configure() {
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
super.configure();
}
});
}
@Override
public String resource() {
return "/listhostsresponse.json";
}
@Override
@SelectJson("host")
public Set<Host> expected() {
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()
);
}
}

View File

@ -0,0 +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"} ] } }