You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2017/04/06 06:35:37 UTC

[2/5] git commit: updated refs/heads/master to 5c0979f

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40225350/plugins/metrics/src/org/apache/cloudstack/response/ClusterMetricsResponse.java
----------------------------------------------------------------------
diff --git a/plugins/metrics/src/org/apache/cloudstack/response/ClusterMetricsResponse.java b/plugins/metrics/src/org/apache/cloudstack/response/ClusterMetricsResponse.java
new file mode 100644
index 0000000..dde1ab7
--- /dev/null
+++ b/plugins/metrics/src/org/apache/cloudstack/response/ClusterMetricsResponse.java
@@ -0,0 +1,211 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.response;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+import org.apache.cloudstack.api.response.ClusterResponse;
+
+public class ClusterMetricsResponse extends ClusterResponse {
+    @SerializedName("state")
+    @Param(description = "state of the cluster")
+    private String state;
+
+    @SerializedName("hosts")
+    @Param(description = "running / total hosts in the cluster")
+    private String resources;
+
+    @SerializedName("cputotal")
+    @Param(description = "the total cpu capacity in Ghz")
+    private String cpuTotal;
+
+    @SerializedName("cpuused")
+    @Param(description = "the total cpu used in Ghz")
+    private String cpuUsed;
+
+    @SerializedName("cpuallocated")
+    @Param(description = "the total cpu allocated in Ghz")
+    private String cpuAllocated;
+
+    @SerializedName("cpumaxdeviation")
+    @Param(description = "the maximum cpu deviation")
+    private String cpuMaxDeviation;
+
+    @SerializedName("memorytotal")
+    @Param(description = "the total cpu capacity in GiB")
+    private String memTotal;
+
+    @SerializedName("memoryused")
+    @Param(description = "the total cpu used in GiB")
+    private String memUsed;
+
+    @SerializedName("memoryallocated")
+    @Param(description = "the total cpu allocated in GiB")
+    private String memAllocated;
+
+    @SerializedName("memorymaxdeviation")
+    @Param(description = "the maximum memory deviation")
+    private String memMaxDeviation;
+
+    @SerializedName("cputhreshold")
+    @Param(description = "cpu usage notification threshold exceeded")
+    private Boolean cpuThresholdExceeded;
+
+    @SerializedName("cpudisablethreshold")
+    @Param(description = "cpu usage disable threshold exceeded")
+    private Boolean cpuDisableThresholdExceeded;
+
+    @SerializedName("cpuallocatedthreshold")
+    @Param(description = "cpu allocated notification threshold exceeded")
+    private Boolean cpuAllocatedThresholdExceeded;
+
+    @SerializedName("cpuallocateddisablethreshold")
+    @Param(description = "cpu allocated disable threshold exceeded")
+    private Boolean cpuAllocatedDisableThresholdExceeded;
+
+    @SerializedName("memorythreshold")
+    @Param(description = "memory usage notification threshold exceeded")
+    private Boolean memoryThresholdExceeded;
+
+    @SerializedName("memorydisablethreshold")
+    @Param(description = "memory usage disable threshold exceeded")
+    private Boolean memoryDisableThresholdExceeded;
+
+    @SerializedName("memoryallocatedthreshold")
+    @Param(description = "memory allocated notification threshold exceeded")
+    private Boolean memoryAllocatedThresholdExceeded;
+
+    @SerializedName("memoryallocateddisablethreshold")
+    @Param(description = "memory allocated disable threshold exceeded")
+    private Boolean memoryAllocatedDisableThresholdExceeded;
+
+    public void setState(final String allocationState, final String managedState) {
+        this.state = allocationState;
+        if (managedState.equals("Unmanaged")) {
+            this.state = managedState;
+        }
+        if (managedState.equals("Managed")) {
+            this.state = allocationState;
+        }
+    }
+
+    public void setResources(final Long upResources, final Long totalResources) {
+        if (upResources != null && totalResources != null) {
+            this.resources = String.format("%d / %d", upResources, totalResources);
+        }
+    }
+
+    public void setCpuTotal(final Long cpuTotal) {
+        if (cpuTotal != null) {
+            this.cpuTotal = String.format("%.2f Ghz", cpuTotal / 1000.0);
+        }
+    }
+
+    public void setCpuUsed(final Double cpuUsedPercentage, final Long totalHosts) {
+        if (cpuUsedPercentage != null && totalHosts != null && totalHosts != 0) {
+            this.cpuUsed = String.format("%.2f%%", 1.0 * cpuUsedPercentage / totalHosts);
+        }
+    }
+
+    public void setCpuAllocated(final Long cpuAllocated, final Long cpuTotal) {
+        if (cpuAllocated != null && cpuTotal != null && cpuTotal != 0) {
+            this.cpuAllocated = String.format("%.2f%%", cpuAllocated * 100.0 / cpuTotal);
+        }
+    }
+
+    public void setCpuMaxDeviation(final Double maxCpuDeviation, final Double totalCpuUsed, final Long totalHosts) {
+        if (maxCpuDeviation != null && totalCpuUsed != null && totalHosts != null && totalHosts != 0) {
+            final Double averageCpuUsage = totalCpuUsed / totalHosts;
+            this.cpuMaxDeviation = String.format("%.2f%%", (maxCpuDeviation - averageCpuUsage) * 100.0 / averageCpuUsage);
+        }
+    }
+
+    public void setMemTotal(final Long memTotal) {
+        if (memTotal != null) {
+            this.memTotal = String.format("%.2f GB", memTotal / (1024.0 * 1024.0 * 1024.0));
+        }
+    }
+
+    public void setMemUsed( final Long memUsed, final Long memTotal) {
+        if (memUsed != null && memTotal != null && memTotal != 0) {
+            this.memUsed = String.format("%.2f%%", memUsed * 100.0 / memTotal);
+        }
+    }
+
+    public void setMemAllocated(final Long memAllocated, final Long memTotal) {
+        if (memAllocated != null && memTotal != null && memTotal != 0) {
+            this.memAllocated = String.format("%.2f%%", memAllocated * 100.0 / memTotal);
+        }
+    }
+
+    public void setMemMaxDeviation(final Long maxMemoryUsage, final Long totalMemory, final Long totalHosts) {
+        if (maxMemoryUsage != null && totalMemory != null && totalHosts != null && totalHosts != 0) {
+            final Double averageMemoryUsage = 1.0 * totalMemory / totalHosts;
+            this.memMaxDeviation = String.format("%.2f%%", (maxMemoryUsage - averageMemoryUsage) * 100.0 / averageMemoryUsage);
+        }
+    }
+
+    public void setCpuUsageThreshold(final Double cpuUsed, final Long totalHosts, final Double threshold) {
+        if (cpuUsed != null && totalHosts != null && threshold != null && totalHosts != 0) {
+            this.cpuThresholdExceeded = (cpuUsed / (100.0 * totalHosts)) > threshold;
+        }
+    }
+
+    public void setCpuUsageDisableThreshold(final Double cpuUsed, final Long totalHosts, final Float threshold) {
+        if (cpuUsed != null && totalHosts != null && threshold != null && totalHosts != 0) {
+            this.cpuDisableThresholdExceeded = (cpuUsed / (100.0 * totalHosts)) > threshold;
+        }
+    }
+
+    public void setCpuAllocatedThreshold(final Long cpuAllocated, final Long cpuUsed, final Double overCommitRatio, final Double threshold) {
+        if (cpuAllocated != null && cpuUsed != null && overCommitRatio != null && threshold != null && cpuUsed != 0) {
+            this.cpuAllocatedThresholdExceeded = (1.0 * cpuAllocated * overCommitRatio / cpuUsed) > threshold;
+        }
+    }
+
+    public void setCpuAllocatedDisableThreshold(final Long cpuAllocated, final Long cpuUsed, final Double overCommitRatio, final Float threshold) {
+        if (cpuAllocated != null && cpuUsed != null && overCommitRatio != null && threshold != null && cpuUsed != 0) {
+            this.cpuAllocatedDisableThresholdExceeded = (1.0 * cpuAllocated * overCommitRatio / cpuUsed) > threshold;
+        }
+    }
+
+    public void setMemoryUsageThreshold(final Long memUsed, final Long memTotal, final Double threshold) {
+        if (memUsed != null && memTotal != null && threshold != null && memTotal != 0) {
+            this.memoryThresholdExceeded = (1.0 * memUsed / memTotal) > threshold;
+        }
+    }
+
+    public void setMemoryUsageDisableThreshold(final Long memUsed, final Long memTotal, final Float threshold) {
+        if (memUsed != null && memTotal != null && threshold != null && memTotal != 0) {
+            this.memoryDisableThresholdExceeded = (1.0 * memUsed / memTotal) > threshold;
+        }
+    }
+
+
+    public void setMemoryAllocatedThreshold(final Long memAllocated, final Long memTotal, final Double overCommitRatio, final Double threshold) {
+        if (memAllocated != null && memTotal != null && overCommitRatio != null && threshold != null && memTotal != 0) {
+            this.memoryAllocatedThresholdExceeded = (1.0 * memAllocated * overCommitRatio / memTotal) > threshold;
+        }
+    }
+
+    public void setMemoryAllocatedDisableThreshold(final Long memAllocated, final Long memTotal, final Double overCommitRatio, final Float threshold) {
+        if (memAllocated != null && memTotal != null && overCommitRatio != null && threshold != null && memTotal != 0) {
+            this.memoryAllocatedDisableThresholdExceeded = (1.0 * memAllocated * overCommitRatio / memTotal) > threshold;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40225350/plugins/metrics/src/org/apache/cloudstack/response/HostMetricsResponse.java
----------------------------------------------------------------------
diff --git a/plugins/metrics/src/org/apache/cloudstack/response/HostMetricsResponse.java b/plugins/metrics/src/org/apache/cloudstack/response/HostMetricsResponse.java
new file mode 100644
index 0000000..cdc9d16
--- /dev/null
+++ b/plugins/metrics/src/org/apache/cloudstack/response/HostMetricsResponse.java
@@ -0,0 +1,204 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.response;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+import org.apache.cloudstack.api.response.HostResponse;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
+
+public class HostMetricsResponse extends HostResponse {
+    @SerializedName("powerstate")
+    @Param(description = "out-of-band management power state")
+    private OutOfBandManagement.PowerState powerState;
+
+    @SerializedName("instances")
+    @Param(description = "instances on the host")
+    private String instances;
+
+    @SerializedName("cputotalghz")
+    @Param(description = "the total cpu capacity in Ghz")
+    private String cpuTotal;
+
+    @SerializedName("cpuusedghz")
+    @Param(description = "the total cpu used in Ghz")
+    private String cpuUsed;
+
+    @SerializedName("cpuallocatedghz")
+    @Param(description = "the total cpu allocated in Ghz")
+    private String cpuAllocated;
+
+    @SerializedName("memorytotalgb")
+    @Param(description = "the total cpu capacity in GiB")
+    private String memTotal;
+
+    @SerializedName("memoryusedgb")
+    @Param(description = "the total cpu used in GiB")
+    private String memUsed;
+
+    @SerializedName("memoryallocatedgb")
+    @Param(description = "the total cpu allocated in GiB")
+    private String memAllocated;
+
+    @SerializedName("networkread")
+    @Param(description = "network read in GiB")
+    private String networkRead;
+
+    @SerializedName("networkwrite")
+    @Param(description = "network write in GiB")
+    private String networkWrite;
+
+    @SerializedName("cputhreshold")
+    @Param(description = "cpu usage notification threshold exceeded")
+    private Boolean cpuThresholdExceeded;
+
+    @SerializedName("cpudisablethreshold")
+    @Param(description = "cpu usage disable threshold exceeded")
+    private Boolean cpuDisableThresholdExceeded;
+
+    @SerializedName("cpuallocatedthreshold")
+    @Param(description = "cpu allocated notification threshold exceeded")
+    private Boolean cpuAllocatedThresholdExceeded;
+
+    @SerializedName("cpuallocateddisablethreshold")
+    @Param(description = "cpu allocated disable threshold exceeded")
+    private Boolean cpuAllocatedDisableThresholdExceeded;
+
+    @SerializedName("memorythreshold")
+    @Param(description = "memory usage notification threshold exceeded")
+    private Boolean memoryThresholdExceeded;
+
+    @SerializedName("memorydisablethreshold")
+    @Param(description = "memory usage disable threshold exceeded")
+    private Boolean memoryDisableThresholdExceeded;
+
+    @SerializedName("memoryallocatedthreshold")
+    @Param(description = "memory allocated notification threshold exceeded")
+    private Boolean memoryAllocatedThresholdExceeded;
+
+    @SerializedName("memoryallocateddisablethreshold")
+    @Param(description = "memory allocated disable threshold exceeded")
+    private Boolean memoryAllocatedDisableThresholdExceeded;
+
+    public void setPowerState(final OutOfBandManagement.PowerState powerState) {
+        this.powerState = powerState;
+    }
+
+    public void setInstances(final Long running, final Long total) {
+        if (running != null && total != null) {
+            this.instances = String.format("%d / %d", running, total);
+        }
+    }
+
+    public void setCpuTotal(final Integer cpuNumber, final Long cpuSpeed, final Double overcommitRatio) {
+        if (cpuNumber != null && cpuSpeed != null && overcommitRatio != null) {
+            this.cpuTotal = String.format("%.2f Ghz (x %.1f)", cpuNumber * cpuSpeed / 1000.0, overcommitRatio);
+        }
+    }
+
+    public void setCpuUsed(final String cpuUsed, final Integer cpuNumber, final Long cpuSpeed) {
+        if (cpuUsed != null && cpuNumber != null && cpuSpeed != null) {
+            this.cpuUsed = String.format("%.2f Ghz", Double.valueOf(cpuUsed.replace("%", "")) * cpuNumber * cpuSpeed / (100.0 * 1000.0));
+        }
+    }
+
+    public void setCpuAllocated(final String cpuAllocated, final Integer cpuNumber, final Long cpuSpeed) {
+        if (cpuAllocated != null && cpuNumber != null && cpuSpeed != null) {
+            this.cpuAllocated = String.format("%.2f Ghz", Double.valueOf(cpuAllocated.replace("%", "")) * cpuNumber * cpuSpeed / (100.0 * 1000.0));
+        }
+    }
+
+    public void setMemTotal(final Long memTotal, final Double overcommitRatio) {
+        if (memTotal != null && overcommitRatio != null) {
+            this.memTotal = String.format("%.2f GB (x %.1f)", memTotal / (1024.0 * 1024.0 * 1024.0), overcommitRatio);
+        }
+    }
+
+    public void setMemUsed(final Long memUsed) {
+        if (memUsed != null) {
+            this.memUsed = String.format("%.2f GB", memUsed / (1024.0 * 1024.0 * 1024.0));
+        }
+    }
+
+    public void setMemAllocated(final Long memAllocated) {
+        if (memAllocated != null) {
+            this.memAllocated = String.format("%.2f GB", memAllocated / (1024.0 * 1024.0 * 1024.0));
+        }
+    }
+
+    public void setNetworkRead(final Long networkReadKbs) {
+        if (networkReadKbs != null) {
+            this.networkRead = String.format("%.2f GB", networkReadKbs / (1024.0 * 1024.0));
+        }
+    }
+
+    public void setNetworkWrite(final Long networkWriteKbs) {
+        if (networkWriteKbs != null) {
+            this.networkWrite = String.format("%.2f GB", networkWriteKbs / (1024.0 * 1024.0));
+        }
+    }
+
+    public void setCpuUsageThreshold(final String cpuUsed, final Double threshold) {
+        if (cpuUsed != null && threshold != null) {
+            this.cpuThresholdExceeded = Double.valueOf(cpuUsed.replace("%", "")) > (100.0 * threshold);
+        }
+    }
+
+    public void setCpuUsageDisableThreshold(final String cpuUsed, final Float threshold) {
+        if (cpuUsed != null && threshold != null) {
+            this.cpuDisableThresholdExceeded = Double.valueOf(cpuUsed.replace("%", "")) > (100.0 * threshold);
+        }
+    }
+
+    public void setCpuAllocatedThreshold(final String cpuAllocated, final Double overCommitRatio, final Double threshold) {
+        if (cpuAllocated != null && overCommitRatio != null && threshold != null) {
+            this.cpuAllocatedThresholdExceeded = (Double.valueOf(cpuAllocated.replace("%", "")) * overCommitRatio) > (100.0 * threshold);
+        }
+    }
+
+    public void setCpuAllocatedDisableThreshold(final String cpuAllocated, final Double overCommitRatio, final Float threshold) {
+        if (cpuAllocated != null && overCommitRatio != null && threshold != null) {
+            this.cpuAllocatedDisableThresholdExceeded = (Double.valueOf(cpuAllocated.replace("%", "")) * overCommitRatio) > (100.0 * threshold);
+        }
+    }
+
+    public void setMemoryUsageThreshold(final Long memUsed, final Long memTotal, final Double threshold) {
+        if (memUsed != null && memTotal != null && threshold != null) {
+            this.memoryThresholdExceeded = memUsed > (memTotal * threshold);
+        }
+    }
+
+    public void setMemoryUsageDisableThreshold(final Long memUsed, final Long memTotal, final Float threshold) {
+        if (memUsed != null && memTotal != null && threshold != null) {
+            this.memoryDisableThresholdExceeded = memUsed > (memTotal * threshold);
+        }
+    }
+
+    public void setMemoryAllocatedThreshold(final Long memAllocated, final Long memTotal, final Double overCommitRatio, final Double threshold) {
+        if (memAllocated != null && memTotal != null && overCommitRatio != null && threshold != null) {
+            this.memoryAllocatedThresholdExceeded = (memAllocated * overCommitRatio) > (memTotal * threshold);
+        }
+    }
+
+    public void setMemoryAllocatedDisableThreshold(final Long memAllocated, final Long memTotal, final Double overCommitRatio, final Float threshold) {
+        if (memAllocated != null && memTotal != null && overCommitRatio != null && threshold != null) {
+            this.memoryAllocatedDisableThresholdExceeded = (memAllocated * overCommitRatio) > (memTotal * threshold);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40225350/plugins/metrics/src/org/apache/cloudstack/response/InfrastructureResponse.java
----------------------------------------------------------------------
diff --git a/plugins/metrics/src/org/apache/cloudstack/response/InfrastructureResponse.java b/plugins/metrics/src/org/apache/cloudstack/response/InfrastructureResponse.java
new file mode 100644
index 0000000..a4db345
--- /dev/null
+++ b/plugins/metrics/src/org/apache/cloudstack/response/InfrastructureResponse.java
@@ -0,0 +1,101 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.response;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+import org.apache.cloudstack.api.BaseResponse;
+
+public class InfrastructureResponse extends BaseResponse {
+
+    @SerializedName("zones")
+    @Param(description = "Number of zones")
+    private Integer zones;
+
+    @SerializedName("pods")
+    @Param(description = "Number of pods")
+    private Integer pods;
+
+    @SerializedName("clusters")
+    @Param(description = "Number of clusters")
+    private Integer clusters;
+
+    @SerializedName("hosts")
+    @Param(description = "Number of hypervisor hosts")
+    private Integer hosts;
+
+    @SerializedName("storagepools")
+    @Param(description = "Number of storage pools")
+    private Integer storagePools;
+
+    @SerializedName("imagestores")
+    @Param(description = "Number of images stores")
+    private Integer imageStores;
+
+    @SerializedName("systemvms")
+    @Param(description = "Number of systemvms")
+    private Integer systemvms;
+
+    @SerializedName("routers")
+    @Param(description = "Number of routers")
+    private Integer routers;
+
+    @SerializedName("cpusockets")
+    @Param(description = "Number of cpu sockets")
+    private Integer cpuSockets;
+
+    public InfrastructureResponse() {
+        setObjectName("infrastructure");
+    }
+
+    public void setZones(final Integer zones) {
+        this.zones = zones;
+    }
+
+    public void setPods(final Integer pods) {
+        this.pods = pods;
+    }
+
+    public void setClusters(final Integer clusters) {
+        this.clusters = clusters;
+    }
+
+    public void setHosts(final Integer hosts) {
+        this.hosts = hosts;
+    }
+
+    public void setStoragePools(final Integer storagePools) {
+        this.storagePools = storagePools;
+    }
+
+    public void setImageStores(final Integer imageStores) {
+        this.imageStores = imageStores;
+    }
+
+    public void setSystemvms(final Integer systemvms) {
+        this.systemvms = systemvms;
+    }
+
+    public void setRouters(final Integer routers) {
+        this.routers = routers;
+    }
+
+    public void setCpuSockets(final Integer cpuSockets) {
+        this.cpuSockets = cpuSockets;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40225350/plugins/metrics/src/org/apache/cloudstack/response/StoragePoolMetricsResponse.java
----------------------------------------------------------------------
diff --git a/plugins/metrics/src/org/apache/cloudstack/response/StoragePoolMetricsResponse.java b/plugins/metrics/src/org/apache/cloudstack/response/StoragePoolMetricsResponse.java
new file mode 100644
index 0000000..f20f797
--- /dev/null
+++ b/plugins/metrics/src/org/apache/cloudstack/response/StoragePoolMetricsResponse.java
@@ -0,0 +1,105 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.response;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+import org.apache.cloudstack.api.response.StoragePoolResponse;
+
+public class StoragePoolMetricsResponse extends StoragePoolResponse {
+    @SerializedName("disksizeusedgb")
+    @Param(description = "disk size used in GiB")
+    private String diskSizeUsedGB;
+
+    @SerializedName("disksizetotalgb")
+    @Param(description = "disk size in GiB")
+    private String diskSizeTotalGB;
+
+    @SerializedName("disksizeallocatedgb")
+    @Param(description = "disk size allocated in GiB")
+    private String diskSizeAllocatedGB;
+
+    @SerializedName("disksizeunallocatedgb")
+    @Param(description = "disk size unallocated in GiB")
+    private String diskSizeUnallocatedGB;
+
+    @SerializedName("storageusagethreshold")
+    @Param(description = "storage usage notification threshold exceeded")
+    private Boolean storageUsedThreshold;
+
+    @SerializedName("storageusagedisablethreshold")
+    @Param(description = "storage usage disable threshold exceeded")
+    private Boolean storageUsedDisableThreshold;
+
+    @SerializedName("storageallocatedthreshold")
+    @Param(description = "storage allocated notification threshold exceeded")
+    private Boolean storageAllocatedThreshold;
+
+    @SerializedName("storageallocateddisablethreshold")
+    @Param(description = "storage allocated disable threshold exceeded")
+    private Boolean storageAllocatedDisableThreshold;
+
+    public void setDiskSizeUsedGB(final Long diskSizeUsed) {
+        if (diskSizeUsed != null) {
+            this.diskSizeUsedGB = String.format("%.2f GB", diskSizeUsed / (1024.0 * 1024.0 * 1024.0));
+        }
+    }
+
+    public void setDiskSizeTotalGB(final Long totalDiskSize, final String overProvisionFactor) {
+        if (totalDiskSize != null && overProvisionFactor != null) {
+            this.diskSizeTotalGB = String.format("%.2f GB (x%s)", totalDiskSize / (1024.0 * 1024.0 * 1024.0), overProvisionFactor);
+        }
+    }
+
+    public void setDiskSizeAllocatedGB(final Long diskSizeAllocated) {
+        if (diskSizeAllocated != null) {
+            this.diskSizeAllocatedGB = String.format("%.2f GB", diskSizeAllocated / (1024.0 * 1024.0 * 1024.0));
+
+        }
+    }
+
+    public void setDiskSizeUnallocatedGB(final Long totalDiskSize, final Long diskSizeAllocated, final String overProvisionFactor) {
+        if (totalDiskSize != null && diskSizeAllocated != null && overProvisionFactor != null) {
+            this.diskSizeUnallocatedGB = String.format("%.2f GB", ((Double.valueOf(overProvisionFactor) * totalDiskSize) - diskSizeAllocated) / (1024.0 * 1024.0 * 1024.0));
+        }
+    }
+
+    public void setStorageUsedThreshold(final Long totalDiskSize, final Long diskSizeUsed, final String overProvisionFactor, final Double threshold) {
+        if (totalDiskSize != null && diskSizeUsed != null && overProvisionFactor != null && threshold != null) {
+            this.storageUsedThreshold = diskSizeUsed > (totalDiskSize * Double.valueOf(overProvisionFactor) * threshold) ;
+        }
+    }
+
+    public void setStorageUsedDisableThreshold(final Long totalDiskSize, final Long diskSizeUsed, final String overProvisionFactor, final Double threshold) {
+        if (totalDiskSize != null && diskSizeUsed != null && overProvisionFactor != null && threshold != null) {
+            this.storageUsedDisableThreshold = diskSizeUsed > (totalDiskSize * Double.valueOf(overProvisionFactor) * threshold);
+        }
+    }
+
+    public void setStorageAllocatedThreshold(final Long totalDiskSize, final Long diskSizeAllocated, final String overProvisionFactor, final Double threshold) {
+        if (totalDiskSize != null && diskSizeAllocated != null && overProvisionFactor != null && threshold != null) {
+            this.storageAllocatedThreshold = diskSizeAllocated > (totalDiskSize * Double.valueOf(overProvisionFactor) * threshold);
+        }
+    }
+
+    public void setStorageAllocatedDisableThreshold(final Long totalDiskSize, final Long diskSizeAllocated, final String overProvisionFactor, final Double threshold) {
+        if (totalDiskSize != null && diskSizeAllocated != null && overProvisionFactor != null && threshold != null) {
+            this.storageAllocatedDisableThreshold = diskSizeAllocated > (totalDiskSize * Double.valueOf(overProvisionFactor) * threshold);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40225350/plugins/metrics/src/org/apache/cloudstack/response/VmMetricsResponse.java
----------------------------------------------------------------------
diff --git a/plugins/metrics/src/org/apache/cloudstack/response/VmMetricsResponse.java b/plugins/metrics/src/org/apache/cloudstack/response/VmMetricsResponse.java
new file mode 100644
index 0000000..a4057ae
--- /dev/null
+++ b/plugins/metrics/src/org/apache/cloudstack/response/VmMetricsResponse.java
@@ -0,0 +1,108 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.response;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.response.NicResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+
+import java.util.Set;
+
+public class VmMetricsResponse extends UserVmResponse {
+    @SerializedName(ApiConstants.IP_ADDRESS)
+    @Param(description = "the VM's primary IP address")
+    private String ipAddress;
+
+    @SerializedName("cputotal")
+    @Param(description = "the total cpu capacity in Ghz")
+    private String cpuTotal;
+
+    @SerializedName("memorytotal")
+    @Param(description = "the total memory capacity in GiB")
+    private String memTotal;
+
+    @SerializedName("networkread")
+    @Param(description = "network read in MiB")
+    private String networkRead;
+
+    @SerializedName("networkwrite")
+    @Param(description = "network write in MiB")
+    private String networkWrite;
+
+    @SerializedName("diskread")
+    @Param(description = "disk read in MiB")
+    private String diskRead;
+
+    @SerializedName("diskwrite")
+    @Param(description = "disk write in MiB")
+    private String diskWrite;
+
+    @SerializedName("diskiopstotal")
+    @Param(description = "the total disk iops")
+    private Long diskIopsTotal;
+
+    public void setIpAddress(final Set<NicResponse> nics) {
+        if (nics != null && nics.size() > 0) {
+            this.ipAddress = nics.iterator().next().getIpaddress();
+        }
+    }
+
+    public void setCpuTotal(final Integer cpuNumber, final Integer cpuSpeed) {
+        if (cpuNumber != null && cpuSpeed != null) {
+            this.cpuTotal = String.format("%.1f Ghz", cpuNumber * cpuSpeed / 1000.0);
+        }
+    }
+
+    public void setMemTotal(final Integer memory) {
+        if (memory != null) {
+            this.memTotal = String.format("%.2f GB", memory / 1024.0);
+        }
+    }
+
+    public void setNetworkRead(final Long networkReadKbs) {
+        if (networkReadKbs != null) {
+            this.networkRead = String.format("%.2f MB", networkReadKbs / 1024.0);
+        }
+    }
+
+    public void setNetworkWrite(final Long networkWriteKbs) {
+        if (networkWriteKbs != null) {
+            this.networkWrite = String.format("%.2f MB", networkWriteKbs / 1024.0);
+        }
+    }
+
+    public void setDiskRead(final Long diskReadKbs) {
+        if (diskReadKbs != null) {
+            this.networkRead = String.format("%.2f MB", diskReadKbs / 1024.0);
+        }
+    }
+
+    public void setDiskWrite(final Long diskWriteKbs) {
+        if (diskWriteKbs != null) {
+            this.networkWrite = String.format("%.2f MB", diskWriteKbs / 1024.0);
+        }
+    }
+
+    public void setDiskIopsTotal(final Long diskIoRead, final Long diskIoWrite) {
+        if (diskIoRead != null && diskIoWrite != null) {
+            this.diskIopsTotal = diskIoRead + diskIoWrite;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40225350/plugins/metrics/src/org/apache/cloudstack/response/VolumeMetricsResponse.java
----------------------------------------------------------------------
diff --git a/plugins/metrics/src/org/apache/cloudstack/response/VolumeMetricsResponse.java b/plugins/metrics/src/org/apache/cloudstack/response/VolumeMetricsResponse.java
new file mode 100644
index 0000000..ef8515f
--- /dev/null
+++ b/plugins/metrics/src/org/apache/cloudstack/response/VolumeMetricsResponse.java
@@ -0,0 +1,41 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.response;
+
+import com.cloud.serializer.Param;
+import com.google.common.base.Strings;
+import com.google.gson.annotations.SerializedName;
+import org.apache.cloudstack.api.response.VolumeResponse;
+
+public class VolumeMetricsResponse extends VolumeResponse {
+    @SerializedName("sizegb")
+    @Param(description = "disk size in GiB")
+    private String diskSizeGB;
+
+    public void setStorageType(final String storageType, final String volumeType) {
+        if (!Strings.isNullOrEmpty(storageType) && !Strings.isNullOrEmpty(volumeType)) {
+            this.setStorageType(String.format("%s (%s)", storageType.substring(0, 1).toUpperCase() + storageType.substring(1), volumeType));
+        }
+    }
+
+    public void setDiskSizeGB(final Long size) {
+        if (size != null) {
+            this.diskSizeGB = String.format("%.2f GB", size / (1024.0 * 1024.0 * 1024.0));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40225350/plugins/metrics/src/org/apache/cloudstack/response/ZoneMetricsResponse.java
----------------------------------------------------------------------
diff --git a/plugins/metrics/src/org/apache/cloudstack/response/ZoneMetricsResponse.java b/plugins/metrics/src/org/apache/cloudstack/response/ZoneMetricsResponse.java
new file mode 100644
index 0000000..7156017
--- /dev/null
+++ b/plugins/metrics/src/org/apache/cloudstack/response/ZoneMetricsResponse.java
@@ -0,0 +1,206 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.response;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+import org.apache.cloudstack.api.response.ZoneResponse;
+
+public class ZoneMetricsResponse extends ZoneResponse {
+    @SerializedName("state")
+    @Param(description = "state of the cluster")
+    private String state;
+
+    @SerializedName("clusters")
+    @Param(description = "healthy / total clusters in the zone")
+    private String resources;
+
+    @SerializedName("cputotal")
+    @Param(description = "the total cpu capacity in Ghz")
+    private String cpuTotal;
+
+    @SerializedName("cpuused")
+    @Param(description = "the total cpu used in Ghz")
+    private String cpuUsed;
+
+    @SerializedName("cpuallocated")
+    @Param(description = "the total cpu allocated in Ghz")
+    private String cpuAllocated;
+
+    @SerializedName("cpumaxdeviation")
+    @Param(description = "the maximum cpu deviation")
+    private String cpuMaxDeviation;
+
+    @SerializedName("memorytotal")
+    @Param(description = "the total cpu capacity in GiB")
+    private String memTotal;
+
+    @SerializedName("memoryused")
+    @Param(description = "the total cpu used in GiB")
+    private String memUsed;
+
+    @SerializedName("memoryallocated")
+    @Param(description = "the total cpu allocated in GiB")
+    private String memAllocated;
+
+    @SerializedName("memorymaxdeviation")
+    @Param(description = "the maximum memory deviation")
+    private String memMaxDeviation;
+
+    @SerializedName("cputhreshold")
+    @Param(description = "cpu usage notification threshold exceeded")
+    private Boolean cpuThresholdExceeded;
+
+    @SerializedName("cpudisablethreshold")
+    @Param(description = "cpu usage disable threshold exceeded")
+    private Boolean cpuDisableThresholdExceeded;
+
+    @SerializedName("cpuallocatedthreshold")
+    @Param(description = "cpu allocated notification threshold exceeded")
+    private Boolean cpuAllocatedThresholdExceeded;
+
+    @SerializedName("cpuallocateddisablethreshold")
+    @Param(description = "cpu allocated disable threshold exceeded")
+    private Boolean cpuAllocatedDisableThresholdExceeded;
+
+    @SerializedName("memorythreshold")
+    @Param(description = "memory usage notification threshold exceeded")
+    private Boolean memoryThresholdExceeded;
+
+    @SerializedName("memorydisablethreshold")
+    @Param(description = "memory usage disable threshold exceeded")
+    private Boolean memoryDisableThresholdExceeded;
+
+    @SerializedName("memoryallocatedthreshold")
+    @Param(description = "memory allocated notification threshold exceeded")
+    private Boolean memoryAllocatedThresholdExceeded;
+
+    @SerializedName("memoryallocateddisablethreshold")
+    @Param(description = "memory allocated disable threshold exceeded")
+    private Boolean memoryAllocatedDisableThresholdExceeded;
+
+
+    public void setState(final String allocationState) {
+        this.state = allocationState;
+    }
+
+    public void setResource(final Long upResources, final Long totalResources) {
+        if (upResources != null && totalResources != null) {
+            this.resources = String.format("%d / %d", upResources, totalResources);
+        }
+    }
+
+    public void setCpuTotal(final Long cpuTotal) {
+        if (cpuTotal != null) {
+            this.cpuTotal = String.format("%.2f Ghz", cpuTotal / 1000.0);
+        }
+    }
+
+    public void setCpuUsed(final Double cpuUsedPercentage, final Long totalHosts) {
+        if (cpuUsedPercentage != null && totalHosts != null && totalHosts != 0) {
+            this.cpuUsed = String.format("%.2f%%", 1.0 * cpuUsedPercentage / totalHosts);
+        }
+    }
+
+    public void setCpuAllocated(final Long cpuAllocated, final Long cpuTotal) {
+        if (cpuAllocated != null && cpuTotal != null && cpuTotal != 0) {
+            this.cpuAllocated = String.format("%.2f%%", cpuAllocated * 100.0 / cpuTotal);
+        }
+    }
+
+    public void setCpuMaxDeviation(final Double maxCpuDeviation, final Double totalCpuUsed, final Long totalHosts) {
+        if (maxCpuDeviation != null && totalCpuUsed != null && totalHosts != null && totalHosts != 0) {
+            final Double averageCpuUsage = totalCpuUsed / totalHosts;
+            this.cpuMaxDeviation = String.format("%.2f%%", (maxCpuDeviation - averageCpuUsage) * 100.0 / averageCpuUsage);
+        }
+    }
+
+    public void setMemTotal(final Long memTotal) {
+        if (memTotal != null) {
+            this.memTotal = String.format("%.2f GB", memTotal / (1024.0 * 1024.0 * 1024.0));
+        }
+    }
+
+    public void setMemUsed( final Long memUsed, final Long memTotal) {
+        if (memUsed != null && memTotal != null) {
+            this.memUsed = String.format("%.2f%%", memUsed * 100.0 / memTotal);
+        }
+    }
+
+    public void setMemAllocated(final Long memAllocated, final Long memTotal) {
+        if (memAllocated != null && memTotal != null && memTotal != 0) {
+            this.memAllocated = String.format("%.2f%%", memAllocated * 100.0 / memTotal);
+        }
+    }
+
+    public void setMemMaxDeviation(final Long maxMemoryUsage, final Long totalMemory, final Long totalHosts) {
+        if (maxMemoryUsage != null && totalMemory != null && totalHosts != null && totalHosts != 0) {
+            final Long averageMemoryUsage = totalMemory / totalHosts;
+            this.memMaxDeviation = String.format("%.2f%%", (maxMemoryUsage - averageMemoryUsage) * 100.0 / averageMemoryUsage);
+        }
+    }
+
+    public void setCpuUsageThreshold(final Double cpuUsed, final Long totalHosts, final Double threshold) {
+        if (cpuUsed != null && totalHosts != null && threshold != null && totalHosts != 0) {
+            this.cpuThresholdExceeded = (cpuUsed / (100.0 * totalHosts)) > threshold;
+        }
+    }
+
+    public void setCpuUsageDisableThreshold(final Double cpuUsed, final Long totalHosts, final Float threshold) {
+        if (cpuUsed != null && totalHosts != null && threshold != null && totalHosts != 0) {
+            this.cpuDisableThresholdExceeded = (cpuUsed / (100.0 * totalHosts)) > threshold;
+        }
+    }
+
+    public void setCpuAllocatedThreshold(final Long cpuAllocated, final Long cpuUsed, final Double threshold) {
+        if (cpuAllocated != null && cpuUsed != null && threshold != null && cpuUsed != 0) {
+            this.cpuAllocatedThresholdExceeded = (1.0 * cpuAllocated / cpuUsed) > threshold;
+        }
+    }
+
+    public void setCpuAllocatedDisableThreshold(final Long cpuAllocated, final Long cpuUsed, final Float threshold) {
+        if (cpuAllocated != null && cpuUsed != null && threshold != null && cpuUsed != 0) {
+            this.cpuAllocatedDisableThresholdExceeded = (1.0 * cpuAllocated / cpuUsed) > threshold;
+        }
+    }
+
+    public void setMemoryUsageThreshold(final Long memUsed, final Long memTotal, final Double threshold) {
+        if (memUsed != null && memTotal != null && threshold != null && memTotal != 0) {
+            this.memoryThresholdExceeded = (1.0 * memUsed / memTotal) > threshold;
+        }
+    }
+
+    public void setMemoryUsageDisableThreshold(final Long memUsed, final Long memTotal, final Float threshold) {
+        if (memUsed != null && memTotal != null && threshold != null && memTotal != 0) {
+            this.memoryDisableThresholdExceeded = (1.0 * memUsed / memTotal) > threshold;
+        }
+    }
+
+
+    public void setMemoryAllocatedThreshold(final Long memAllocated, final Long memTotal, final Double threshold) {
+        if (memAllocated != null && memTotal != null && threshold != null && memTotal != 0) {
+            this.memoryAllocatedThresholdExceeded = (1.0 * memAllocated / memTotal) > threshold;
+        }
+    }
+
+    public void setMemoryAllocatedDisableThreshold(final Long memAllocated, final Long memTotal, final Float threshold) {
+        if (memAllocated != null && memTotal != null && threshold != null && memTotal != 0) {
+            this.memoryAllocatedDisableThresholdExceeded = (1.0 * memAllocated / memTotal) > threshold;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40225350/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index 40cee26..72a7bc1 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -69,6 +69,7 @@
     <module>hypervisors/ucs</module>
     <module>hypervisors/hyperv</module>
     <module>hypervisors/ovm3</module>
+    <module>metrics</module>
     <module>network-elements/elastic-loadbalancer</module>
     <module>network-elements/ovs</module>
     <module>network-elements/juniper-contrail</module>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40225350/server/src/com/cloud/api/query/dao/HostJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/HostJoinDao.java b/server/src/com/cloud/api/query/dao/HostJoinDao.java
index f0ac183..e7dc5d5 100644
--- a/server/src/com/cloud/api/query/dao/HostJoinDao.java
+++ b/server/src/com/cloud/api/query/dao/HostJoinDao.java
@@ -41,4 +41,6 @@ public interface HostJoinDao extends GenericDao<HostJoinVO, Long> {
 
     List<HostJoinVO> searchByIds(Long... ids);
 
+    List<HostJoinVO> findByClusterId(Long clusterId, Host.Type type);
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40225350/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java
index 6c15a8b..58a0366 100644
--- a/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java
@@ -65,6 +65,8 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
 
     private final SearchBuilder<HostJoinVO> hostIdSearch;
 
+    private final SearchBuilder<HostJoinVO> ClusterSearch;
+
     protected HostJoinDaoImpl() {
 
         hostSearch = createSearchBuilder();
@@ -75,6 +77,11 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
         hostIdSearch.and("id", hostIdSearch.entity().getId(), SearchCriteria.Op.EQ);
         hostIdSearch.done();
 
+        ClusterSearch = createSearchBuilder();
+        ClusterSearch.and("clusterId", ClusterSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
+        ClusterSearch.and("type", ClusterSearch.entity().getType(), SearchCriteria.Op.EQ);
+        ClusterSearch.done();
+
         this._count = "select count(distinct id) from host_view WHERE ";
     }
 
@@ -432,4 +439,12 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
         return uvList;
     }
 
+    @Override
+    public List<HostJoinVO> findByClusterId(Long clusterId, Host.Type type) {
+        SearchCriteria<HostJoinVO> sc = ClusterSearch.create();
+        sc.setParameters("clusterId", clusterId);
+        sc.setParameters("type", type);
+        return listBy(sc);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40225350/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
index ef0ad19..80c417e 100644
--- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
+++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
@@ -588,7 +588,7 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
         List<Long> allDedicatedPods = _dedicatedDao.listAllPods();
         allPodsInDc.retainAll(allDedicatedPods);
 
-        List<Long> allClustersInDc = _clusterDao.listAllCusters(dc.getId());
+        List<Long> allClustersInDc = _clusterDao.listAllClusters(dc.getId());
         List<Long> allDedicatedClusters = _dedicatedDao.listAllClusters();
         allClustersInDc.retainAll(allDedicatedClusters);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40225350/test/integration/smoke/test_metrics_api.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_metrics_api.py b/test/integration/smoke/test_metrics_api.py
new file mode 100644
index 0000000..27c4a1b
--- /dev/null
+++ b/test/integration/smoke/test_metrics_api.py
@@ -0,0 +1,210 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import marvin
+from marvin.cloudstackTestCase import *
+from marvin.cloudstackAPI import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+from marvin.lib.utils import (random_gen)
+from nose.plugins.attrib import attr
+
+import time
+
+_multiprocess_shared_ = True
+
+class TestMetrics(cloudstackTestCase):
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.hypervisor = self.testClient.getHypervisorInfo()
+        self.dbclient = self.testClient.getDbConnection()
+        self.services = self.testClient.getParsedTestDataConfig()
+        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
+        self.pod = get_pod(self.apiclient, self.zone.id)
+        self.host = list_hosts(self.apiclient,
+            zoneid=self.zone.id,
+            type='Routing')[0]
+        self.cluster = self.apiclient.listClusters(listClusters.listClustersCmd())[0]
+        self.disk_offering = DiskOffering.create(
+                                    self.apiclient,
+                                    self.services["disk_offering"]
+                                    )
+        self.service_offering = ServiceOffering.create(
+            self.apiclient,
+            self.services["service_offering"]
+        )
+        self.template = get_template(
+            self.apiclient,
+            self.zone.id,
+            self.services["ostype"]
+        )
+
+        self.cleanup = []
+        self.cleanup.append(self.disk_offering)
+        self.cleanup.append(self.service_offering)
+
+    def tearDown(self):
+        try:
+            #Clean up
+            cleanup_resources(self.apiclient, self.cleanup)
+
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+    @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="false")
+    def test_list_hosts_metrics(self):
+
+        cmd = listHostsMetrics.listHostsMetricsCmd()
+        cmd.id = self.host.id
+        cmd.type = 'Routing'
+
+        host_metric = self.apiclient.listHostsMetrics(cmd)[0]
+
+        self.assertEqual(host_metric.cpuallocated, self.host.cpuallocated)
+        self.assertEqual(host_metric.memoryallocated, self.host.memoryallocated)
+
+    @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="false")
+    def test_list_clusters_metrics(self):
+
+        cmd = listClustersMetrics.listClustersMetricsCmd()
+        cmd.id = self.cluster.id
+
+        cluster_metric = self.apiclient.listClustersMetrics(cmd)[0]
+
+        self.assertEqual(cluster_metric.id, self.cluster.id)
+        self.assertTrue(hasattr(cluster_metric, 'cpuallocated'))
+        self.assertTrue(hasattr(cluster_metric, 'cpumaxdeviation'))
+        self.assertTrue(hasattr(cluster_metric, 'memoryallocated'))
+        self.assertTrue(hasattr(cluster_metric, 'memoryused'))
+        self.assertTrue(hasattr(cluster_metric, 'memorymaxdeviation'))
+
+    @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="false")
+    def test_list_zones_metrics(self):
+        cmd = listZonesMetrics.listZonesMetricsCmd()
+        cmd.id = self.zone.id
+
+        zone_metrics = self.apiclient.listZonesMetrics(cmd)[0]
+
+        self.assertTrue(hasattr(zone_metrics, 'cpuallocated'))
+        self.assertTrue(hasattr(zone_metrics, 'cpumaxdeviation'))
+        self.assertTrue(hasattr(zone_metrics, 'cputotal'))
+        self.assertTrue(hasattr(zone_metrics, 'cpuused'))
+        self.assertTrue(hasattr(zone_metrics, 'memoryallocated'))
+        self.assertTrue(hasattr(zone_metrics, 'memorymaxdeviation'))
+        self.assertTrue(hasattr(zone_metrics, 'memoryused'))
+
+    @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="false")
+    def test_list_vms_metrics(self):
+        #deploy VM
+        self.small_virtual_machine = VirtualMachine.create(
+                                        self.apiclient,
+                                        self.services["virtual_machine"],
+                                        serviceofferingid=self.service_offering.id,
+                                        templateid=self.template.id,
+                                        zoneid=self.zone.id
+                                        )
+        self.cleanup.append(self.small_virtual_machine)
+
+
+        cmd = listVirtualMachinesMetrics.listVirtualMachinesMetricsCmd()
+        cmd.id = self.small_virtual_machine.id
+
+        lvmm = self.apiclient.listVirtualMachinesMetrics(cmd)[0]
+
+        self.assertEqual(lvmm.id, self.small_virtual_machine.id)
+
+        self.assertTrue(hasattr(lvmm, 'cputotal'))
+        self.assertTrue(hasattr(lvmm, 'cpuused'))
+        self.assertTrue(hasattr(lvmm, 'diskiowrite'))
+        self.assertTrue(hasattr(lvmm, 'diskkbswrite'))
+        self.assertTrue(hasattr(lvmm, 'networkread'))
+        self.assertTrue(hasattr(lvmm, 'networkwrite'))
+
+        return
+
+    @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="false")
+    def test_list_pstorage_metrics(self):
+        #list StoragePools
+        sp = self.apiclient.listStoragePools(listStoragePools.listStoragePoolsCmd())[0]
+
+        #list StoragePoolsMetrics
+        cmd = listStoragePoolsMetrics.listStoragePoolsMetricsCmd()
+        cmd.id = sp.id
+
+        sp_metrics = self.apiclient.listStoragePoolsMetrics(cmd)[0]
+
+        self.assertEqual(sp_metrics.disksizeallocated, sp.disksizeallocated)
+        self.assertEqual(sp_metrics.state, sp.state)
+
+    @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="false")
+    def test_list_volumes_metrics(self):
+        volume = Volume.create(
+            self.apiclient,
+            self.services['volume'],
+            zoneid=self.zone.id,
+            diskofferingid=self.disk_offering.id
+        )
+        self.cleanup.append(volume)
+
+        cmd = listVolumes.listVolumesCmd()
+        cmd.id = volume.id
+
+        lv = self.apiclient.listVolumes(cmd)[0]
+
+        cmd = listVolumesMetrics.listVolumesMetricsCmd()
+        cmd.id = lv.id
+        lvm = self.apiclient.listVolumesMetrics(cmd)[0]
+
+        self.assertEqual(lv.size, lvm.size)
+        self.assertTrue(hasattr(lvm, 'diskBytesReadRate'))
+        self.assertTrue(hasattr(lvm, 'diskBytesWriteRate'))
+        self.assertTrue(hasattr(lvm, 'diskIopsReadRate'))
+        self.assertTrue(hasattr(lvm, 'diskIopsWriteRate'))
+
+        return
+
+    @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="false")
+    def test_list_infrastructure_metrics(self):
+        cmd = listInfrastructure.listInfrastructureCmd()
+        li = self.apiclient.listInfrastructure(cmd)
+
+        self.assertTrue(hasattr(li, 'clusters'))
+        self.assertEqual(li.clusters, len(self.apiclient.listClusters(listClusters.listClustersCmd())))
+        self.assertTrue(hasattr(li, 'hosts'))
+
+        self.assertEqual(li.hosts, len(list_hosts(self.apiclient,
+            zoneid=self.zone.id,
+            type='Routing')))
+
+        self.assertTrue(hasattr(li, 'imagestores'))
+        self.assertEqual(li.imagestores, len(self.apiclient.listImageStores(listImageStores.listImageStoresCmd())))
+
+        self.assertTrue(hasattr(li, 'pods'))
+        self.assertEqual(li.pods, len(self.apiclient.listPods(listPods.listPodsCmd())))
+
+        self.assertTrue(hasattr(li, 'routers'))
+
+        self.assertTrue(hasattr(li, 'storagepools'))
+        self.assertEqual(li.storagepools, len(self.apiclient.listStoragePools(listStoragePools.listStoragePoolsCmd())))
+
+        self.assertTrue(hasattr(li, 'zones'))
+        self.assertEqual(li.zones, len(self.apiclient.listZones(listZones.listZonesCmd())))
+
+        self.assertTrue(hasattr(li, 'systemvms'))
+        self.assertTrue(hasattr(li, 'cpusockets'))

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40225350/tools/apidoc/gen_toc.py
----------------------------------------------------------------------
diff --git a/tools/apidoc/gen_toc.py b/tools/apidoc/gen_toc.py
index e6ef674..0fd9775 100644
--- a/tools/apidoc/gen_toc.py
+++ b/tools/apidoc/gen_toc.py
@@ -168,7 +168,9 @@ known_categories = {
     'CacheStore' : 'Cache Store',
     'IAM' : 'IAM',
     'OvsElement' : 'Ovs Element',
-    'StratosphereSsp' : ' Stratosphere SSP'
+    'StratosphereSsp' : ' Stratosphere SSP',
+    'Metrics' : 'Metrics',
+    'Infrastructure' : 'Metrics',
     }