cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [1/6] git commit: updated refs/heads/pr/689-review to af28a82
Date Mon, 31 Aug 2015 10:34:35 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/pr/689-review [created] af28a8269


 CLOUDSTACK-8592: Add changes from review

- added marvin test for quota plugin API
- removed unused commented code
- debug messages in debug enabled check
- checks for nulls, fixed access to member variables and feature
- changes based on PR comments


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/af28a826
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/af28a826
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/af28a826

Branch: refs/heads/pr/689-review
Commit: af28a8269fd9e80ff08193238e7c94d4a2321312
Parents: 04267f4
Author: Abhinandan Prateek <abhinandan.prateek@shapeblue.com>
Authored: Mon Aug 17 14:58:19 2015 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Mon Aug 31 15:38:53 2015 +0530

----------------------------------------------------------------------
 .../src/com/cloud/usage/dao/UsageDaoImpl.java   |   8 +-
 .../cloudstack/quota/constant/QuotaTypes.java   |  59 +++---
 .../cloudstack/quota/dao/QuotaBalanceDao.java   |   6 +-
 .../quota/dao/QuotaBalanceDaoImpl.java          |   6 +-
 .../quota/dao/QuotaTariffDaoImpl.java           |   8 +-
 .../cloudstack/quota/dao/QuotaUsageDaoImpl.java |  11 -
 .../quota/dao/ServiceOfferingDaoImpl.java       |   2 +-
 plugins/database/quota/pom.xml                  | 154 +++++++++-----
 .../cloudstack/api/command/QuotaBalanceCmd.java |   6 +-
 .../cloudstack/api/command/QuotaCreditsCmd.java |   2 +-
 .../command/QuotaEmailTemplateUpdateCmd.java    |   2 +-
 .../api/command/QuotaStatementCmd.java          |   2 +-
 .../api/command/QuotaTariffListCmd.java         |   4 +-
 .../api/response/QuotaResponseBuilder.java      |   2 +-
 .../api/response/QuotaResponseBuilderImpl.java  |  42 ++--
 .../cloudstack/quota/QuotaServiceImpl.java      |  20 +-
 test/integration/smoke/test_quota.py            | 204 +++++++++++++++++++
 .../cloudstack/quota/QuotaAlertManagerImpl.java |  33 +--
 .../cloudstack/quota/QuotaManagerImpl.java      |  54 ++---
 19 files changed, 436 insertions(+), 189 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java b/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
index 287843e..c37b9a1 100644
--- a/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
+++ b/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
@@ -483,7 +483,9 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage
     public Pair<List<? extends UsageVO>, Integer> getUsageRecordsPendingQuotaAggregation(final long accountId, final long domainId) {
         final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
         TransactionLegacy.open(TransactionLegacy.USAGE_DB).close();
-        s_logger.debug("getting usage records for account: " + accountId + ", domainId: " + domainId);
+        if (s_logger.isDebugEnabled()){
+            s_logger.debug("getting usage records for account: " + accountId + ", domainId: " + domainId);
+        }
         Filter usageFilter = new Filter(UsageVO.class, "startDate", true, 0L, 10000L);
         SearchCriteria<UsageVO> sc = createSearchCriteria();
         if (accountId != -1) {
@@ -494,7 +496,9 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage
         }
         sc.addAnd("quotaCalculated", SearchCriteria.Op.NULL);
         sc.addOr("quotaCalculated", SearchCriteria.Op.EQ, 0);
-        s_logger.debug("Getting usage records" + usageFilter.getOrderBy());
+        if (s_logger.isDebugEnabled()){
+            s_logger.debug("Getting usage records" + usageFilter.getOrderBy());
+        }
         Pair<List<UsageVO>, Integer> usageRecords = searchAndCountAllRecords(sc, usageFilter);
         TransactionLegacy.open(opendb).close();
         return new Pair<List<? extends UsageVO>, Integer>(usageRecords.first(), usageRecords.second());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/framework/quota/src/org/apache/cloudstack/quota/constant/QuotaTypes.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/constant/QuotaTypes.java b/framework/quota/src/org/apache/cloudstack/quota/constant/QuotaTypes.java
index 483ecef..c60436d 100644
--- a/framework/quota/src/org/apache/cloudstack/quota/constant/QuotaTypes.java
+++ b/framework/quota/src/org/apache/cloudstack/quota/constant/QuotaTypes.java
@@ -25,11 +25,37 @@ public class QuotaTypes extends UsageTypes {
     public static final int CPU_NUMBER = 16;
     public static final int MEMORY = 17;
 
-    private Integer quotaType;
-    private String quotaName;
-    private String quotaUnit;
-    private String description;
-    private String discriminator;
+    private final Integer quotaType;
+    private final String quotaName;
+    private final String quotaUnit;
+    private final String description;
+    private final String discriminator;
+    private static final HashMap<Integer, QuotaTypes> quotaTypeList = new HashMap<Integer, QuotaTypes>();
+
+    static {
+        quotaTypeList.put(Integer.valueOf(RUNNING_VM), new QuotaTypes(Integer.valueOf(RUNNING_VM), "RUNNING_VM", "Compute-Month", "Running Vm Usage"));
+        quotaTypeList.put(Integer.valueOf(ALLOCATED_VM), new QuotaTypes(Integer.valueOf(ALLOCATED_VM), "ALLOCATED_VM", "Compute-Month", "Allocated Vm Usage"));
+        quotaTypeList.put(Integer.valueOf(IP_ADDRESS), new QuotaTypes(Integer.valueOf(IP_ADDRESS), "IP_ADDRESS", "IP-Month", "IP Address Usage"));
+        quotaTypeList.put(Integer.valueOf(NETWORK_BYTES_SENT), new QuotaTypes(Integer.valueOf(NETWORK_BYTES_SENT), "NETWORK_BYTES_SENT", "GB", "Network Usage (Bytes Sent)"));
+        quotaTypeList.put(Integer.valueOf(NETWORK_BYTES_RECEIVED), new QuotaTypes(Integer.valueOf(NETWORK_BYTES_RECEIVED), "NETWORK_BYTES_RECEIVED", "GB", "Network Usage (Bytes Received)"));
+        quotaTypeList.put(Integer.valueOf(VOLUME), new QuotaTypes(Integer.valueOf(VOLUME), "VOLUME", "GB-Month", "Volume Usage"));
+        quotaTypeList.put(Integer.valueOf(TEMPLATE), new QuotaTypes(Integer.valueOf(TEMPLATE), "TEMPLATE", "GB-Month", "Template Usage"));
+        quotaTypeList.put(Integer.valueOf(ISO), new QuotaTypes(Integer.valueOf(ISO), "ISO", "GB-Month", "ISO Usage"));
+        quotaTypeList.put(Integer.valueOf(SNAPSHOT), new QuotaTypes(Integer.valueOf(SNAPSHOT), "SNAPSHOT", "GB-Month", "Snapshot Usage"));
+        quotaTypeList.put(Integer.valueOf(SECURITY_GROUP), new QuotaTypes(Integer.valueOf(SECURITY_GROUP), "SECURITY_GROUP", "Policy-Month", "Security Group Usage"));
+        quotaTypeList.put(Integer.valueOf(LOAD_BALANCER_POLICY), new QuotaTypes(Integer.valueOf(LOAD_BALANCER_POLICY), "LOAD_BALANCER_POLICY", "Policy-Month", "Load Balancer Usage"));
+        quotaTypeList.put(Integer.valueOf(PORT_FORWARDING_RULE), new QuotaTypes(Integer.valueOf(PORT_FORWARDING_RULE), "PORT_FORWARDING_RULE", "Policy-Month", "Port Forwarding Usage"));
+        quotaTypeList.put(Integer.valueOf(NETWORK_OFFERING), new QuotaTypes(Integer.valueOf(NETWORK_OFFERING), "NETWORK_OFFERING", "Policy-Month", "Network Offering Usage"));
+        quotaTypeList.put(Integer.valueOf(VPN_USERS), new QuotaTypes(Integer.valueOf(VPN_USERS), "VPN_USERS", "Policy-Month", "VPN users usage"));
+        quotaTypeList.put(Integer.valueOf(VM_DISK_IO_READ), new QuotaTypes(Integer.valueOf(VM_DISK_IO_READ), "VM_DISK_IO_READ", "GB", "VM Disk usage(I/O Read)"));
+        quotaTypeList.put(Integer.valueOf(VM_DISK_IO_WRITE), new QuotaTypes(Integer.valueOf(VM_DISK_IO_WRITE), "VM_DISK_IO_WRITE", "GB", "VM Disk usage(I/O Write)"));
+        quotaTypeList.put(Integer.valueOf(VM_DISK_BYTES_READ), new QuotaTypes(Integer.valueOf(VM_DISK_BYTES_READ), "VM_DISK_BYTES_READ", "GB", "VM Disk usage(Bytes Read)"));
+        quotaTypeList.put(Integer.valueOf(VM_DISK_BYTES_WRITE), new QuotaTypes(Integer.valueOf(VM_DISK_BYTES_WRITE), "VPN_USERS", "GB", "VM Disk usage(Bytes Write)"));
+        quotaTypeList.put(Integer.valueOf(VM_SNAPSHOT), new QuotaTypes(Integer.valueOf(VM_SNAPSHOT), "VM_SNAPSHOT", "GB-Month", "VM Snapshot storage usage"));
+        quotaTypeList.put(Integer.valueOf(CPU_CLOCK_RATE), new QuotaTypes(Integer.valueOf(CPU_CLOCK_RATE), "CPU_CLOCK_RATE", "Compute-Month", "Quota tariff for using 1 CPU of clock rate 100MHz"));
+        quotaTypeList.put(Integer.valueOf(CPU_NUMBER), new QuotaTypes(Integer.valueOf(CPU_NUMBER), "CPU_NUMBER", "Compute-Month", "Quota tariff for running VM that has 1vCPU"));
+        quotaTypeList.put(Integer.valueOf(MEMORY), new QuotaTypes(Integer.valueOf(MEMORY), "MEMORY", "Compute-Month", "Quota tariff for using 1MB or RAM for 1 hour"));
+    }
 
     public QuotaTypes(Integer quotaType, String name, String unit, String description) {
         this.quotaType = quotaType;
@@ -40,29 +66,6 @@ public class QuotaTypes extends UsageTypes {
     }
 
     public static HashMap<Integer, QuotaTypes> listQuotaTypes() {
-        final HashMap<Integer, QuotaTypes> quotaTypeList = new HashMap<Integer, QuotaTypes>();
-        quotaTypeList.put(new Integer(RUNNING_VM), new QuotaTypes(new Integer(RUNNING_VM), "RUNNING_VM", "Compute-Month", "Running Vm Usage"));
-        quotaTypeList.put(new Integer(ALLOCATED_VM), new QuotaTypes(new Integer(ALLOCATED_VM), "ALLOCATED_VM", "Compute-Month", "Allocated Vm Usage"));
-        quotaTypeList.put(new Integer(IP_ADDRESS), new QuotaTypes(new Integer(IP_ADDRESS), "IP_ADDRESS", "IP-Month", "IP Address Usage"));
-        quotaTypeList.put(new Integer(NETWORK_BYTES_SENT), new QuotaTypes(new Integer(NETWORK_BYTES_SENT), "NETWORK_BYTES_SENT", "GB", "Network Usage (Bytes Sent)"));
-        quotaTypeList.put(new Integer(NETWORK_BYTES_RECEIVED), new QuotaTypes(new Integer(NETWORK_BYTES_RECEIVED), "NETWORK_BYTES_RECEIVED", "GB", "Network Usage (Bytes Received)"));
-        quotaTypeList.put(new Integer(VOLUME), new QuotaTypes(new Integer(VOLUME), "VOLUME", "GB-Month", "Volume Usage"));
-        quotaTypeList.put(new Integer(TEMPLATE), new QuotaTypes(new Integer(TEMPLATE), "TEMPLATE", "GB-Month", "Template Usage"));
-        quotaTypeList.put(new Integer(ISO), new QuotaTypes(new Integer(ISO), "ISO", "GB-Month", "ISO Usage"));
-        quotaTypeList.put(new Integer(SNAPSHOT), new QuotaTypes(new Integer(SNAPSHOT), "SNAPSHOT", "GB-Month", "Snapshot Usage"));
-        quotaTypeList.put(new Integer(SECURITY_GROUP), new QuotaTypes(new Integer(SECURITY_GROUP), "SECURITY_GROUP", "Policy-Month", "Security Group Usage"));
-        quotaTypeList.put(new Integer(LOAD_BALANCER_POLICY), new QuotaTypes(new Integer(LOAD_BALANCER_POLICY), "LOAD_BALANCER_POLICY", "Policy-Month", "Load Balancer Usage"));
-        quotaTypeList.put(new Integer(PORT_FORWARDING_RULE), new QuotaTypes(new Integer(PORT_FORWARDING_RULE), "PORT_FORWARDING_RULE", "Policy-Month", "Port Forwarding Usage"));
-        quotaTypeList.put(new Integer(NETWORK_OFFERING), new QuotaTypes(new Integer(NETWORK_OFFERING), "NETWORK_OFFERING", "Policy-Month", "Network Offering Usage"));
-        quotaTypeList.put(new Integer(VPN_USERS), new QuotaTypes(new Integer(VPN_USERS), "VPN_USERS", "Policy-Month", "VPN users usage"));
-        quotaTypeList.put(new Integer(VM_DISK_IO_READ), new QuotaTypes(new Integer(VM_DISK_IO_READ), "VM_DISK_IO_READ", "GB", "VM Disk usage(I/O Read)"));
-        quotaTypeList.put(new Integer(VM_DISK_IO_WRITE), new QuotaTypes(new Integer(VM_DISK_IO_WRITE), "VM_DISK_IO_WRITE", "GB", "VM Disk usage(I/O Write)"));
-        quotaTypeList.put(new Integer(VM_DISK_BYTES_READ), new QuotaTypes(new Integer(VM_DISK_BYTES_READ), "VM_DISK_BYTES_READ", "GB", "VM Disk usage(Bytes Read)"));
-        quotaTypeList.put(new Integer(VM_DISK_BYTES_WRITE), new QuotaTypes(new Integer(VM_DISK_BYTES_WRITE), "VPN_USERS", "GB", "VM Disk usage(Bytes Write)"));
-        quotaTypeList.put(new Integer(VM_SNAPSHOT), new QuotaTypes(new Integer(VM_SNAPSHOT), "VM_SNAPSHOT", "GB-Month", "VM Snapshot storage usage"));
-        quotaTypeList.put(new Integer(CPU_CLOCK_RATE), new QuotaTypes(new Integer(CPU_CLOCK_RATE), "CPU_CLOCK_RATE", "Compute-Month", "Quota tariff for using 1 CPU of clock rate 100MHz"));
-        quotaTypeList.put(new Integer(CPU_NUMBER), new QuotaTypes(new Integer(CPU_NUMBER), "CPU_NUMBER", "Compute-Month", "Quota tariff for running VM that has 1vCPU"));
-        quotaTypeList.put(new Integer(MEMORY), new QuotaTypes(new Integer(MEMORY), "MEMORY", "Compute-Month", "Quota tariff for using 1MB or RAM for 1 hour"));
         return quotaTypeList;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDao.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDao.java b/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDao.java
index 8bf07ec..e203367 100644
--- a/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDao.java
+++ b/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDao.java
@@ -28,11 +28,11 @@ public interface QuotaBalanceDao extends GenericDao<QuotaBalanceVO, Long> {
 
     void saveQuotaBalance(List<QuotaBalanceVO> credits);
 
-    List<QuotaBalanceVO> findCreditBalance(long accountId, long domainId, Date startDate, Date endDate);
+    List<QuotaBalanceVO> findCreditBalance(Long accountId, Long domainId, Date startDate, Date endDate);
 
-    QuotaBalanceVO findLastBalanceEntry(long accountId, long domainId, Date beforeThis);
+    QuotaBalanceVO findLastBalanceEntry(Long accountId, Long domainId, Date beforeThis);
 
-    QuotaBalanceVO findLaterBalanceEntry(long accountId, long domainId, Date afterThis);
+    QuotaBalanceVO findLaterBalanceEntry(Long accountId, Long domainId, Date afterThis);
 
     List<QuotaBalanceVO> findQuotaBalance(Long accountId, Long domainId, Date startDate, Date endDate);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDaoImpl.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDaoImpl.java b/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDaoImpl.java
index 628777e..a0cd1ac 100644
--- a/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDaoImpl.java
+++ b/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDaoImpl.java
@@ -41,7 +41,7 @@ public class QuotaBalanceDaoImpl extends GenericDaoBase<QuotaBalanceVO, Long> im
 
     @SuppressWarnings("deprecation")
     @Override
-    public QuotaBalanceVO findLastBalanceEntry(final long accountId, final long domainId, final Date beforeThis) {
+    public QuotaBalanceVO findLastBalanceEntry(final Long accountId, final Long domainId, final Date beforeThis) {
         final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
         TransactionLegacy.open(TransactionLegacy.USAGE_DB).close();
         Filter filter = new Filter(QuotaBalanceVO.class, "updatedOn", false, 0L, 1L);
@@ -57,7 +57,7 @@ public class QuotaBalanceDaoImpl extends GenericDaoBase<QuotaBalanceVO, Long> im
 
     @SuppressWarnings("deprecation")
     @Override
-    public QuotaBalanceVO findLaterBalanceEntry(final long accountId, final long domainId, final Date afterThis) {
+    public QuotaBalanceVO findLaterBalanceEntry(final Long accountId, final Long domainId, final Date afterThis) {
         final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
         TransactionLegacy.open(TransactionLegacy.USAGE_DB).close();
         Filter filter = new Filter(QuotaBalanceVO.class, "updatedOn", true, 0L, 1L);
@@ -87,7 +87,7 @@ public class QuotaBalanceDaoImpl extends GenericDaoBase<QuotaBalanceVO, Long> im
 
     @SuppressWarnings("deprecation")
     @Override
-    public List<QuotaBalanceVO> findCreditBalance(final long accountId, final long domainId, final Date lastbalancedate, final Date beforeThis) {
+    public List<QuotaBalanceVO> findCreditBalance(final Long accountId, final Long domainId, final Date lastbalancedate, final Date beforeThis) {
         final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
         TransactionLegacy.open(TransactionLegacy.USAGE_DB).close();
         Filter filter = new Filter(QuotaBalanceVO.class, "updatedOn", true, 0L, Long.MAX_VALUE);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaTariffDaoImpl.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaTariffDaoImpl.java b/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaTariffDaoImpl.java
index 38aad15..0b3b9f1 100644
--- a/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaTariffDaoImpl.java
+++ b/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaTariffDaoImpl.java
@@ -70,10 +70,14 @@ public class QuotaTariffDaoImpl extends GenericDaoBase<QuotaTariffVO, Long> impl
         // Switch back
         TransactionLegacy.open(opendb).close();
         if (result.size() > 0) {
-            //s_logger.info("findTariffPlanByUsageType: " + effectiveDate + "quota type " + quotaType  + " val=" + result.get(0).getCurrencyValue());
+            if (s_logger.isDebugEnabled()){
+                s_logger.debug("findTariffPlanByUsageType: " + effectiveDate + "quota type " + quotaType  + " val=" + result.get(0).getCurrencyValue());
+            }
             return result.get(0);
         } else {
-            //s_logger.info("Missing quota type " + quotaType);
+            if (s_logger.isDebugEnabled()){
+                s_logger.info("Missing quota type " + quotaType);
+            }
             return null;
         }
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDaoImpl.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDaoImpl.java b/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDaoImpl.java
index bff43d0..4604aa1 100644
--- a/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDaoImpl.java
+++ b/framework/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDaoImpl.java
@@ -71,17 +71,6 @@ public class QuotaUsageDaoImpl extends GenericDaoBase<QuotaUsageVO, Long> implem
             if (accountId != null) {
                 sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
             }
-            /*
-             * if (isDomainAdmin) { SearchCriteria<DomainVO> sdc =
-             * _domainDao.createSearchCriteria(); sdc.addOr("path",
-             * SearchCriteria.Op.LIKE,
-             * _domainDao.findById(caller.getDomainId()).getPath() + "%");
-             * List<DomainVO> domains = _domainDao.search(sdc, null); List<Long>
-             * domainIds = new ArrayList<Long>(); for (DomainVO domain :
-             * domains) domainIds.add(domain.getId()); sc.addAnd("domainId",
-             * SearchCriteria.Op.IN, domainIds.toArray());
-             * s_logger.debug("Account ID=" + accountId); }
-             */
             if (domainId != null) {
                 sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId);
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/framework/quota/src/org/apache/cloudstack/quota/dao/ServiceOfferingDaoImpl.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/dao/ServiceOfferingDaoImpl.java b/framework/quota/src/org/apache/cloudstack/quota/dao/ServiceOfferingDaoImpl.java
index 82d4af6..763e905 100644
--- a/framework/quota/src/org/apache/cloudstack/quota/dao/ServiceOfferingDaoImpl.java
+++ b/framework/quota/src/org/apache/cloudstack/quota/dao/ServiceOfferingDaoImpl.java
@@ -57,10 +57,10 @@ public class ServiceOfferingDaoImpl extends GenericDaoBase<ServiceOfferingVO, Lo
     public ServiceOfferingVO findById(Long vmId, long serviceOfferingId) {
         ServiceOfferingVO offering = super.findById(serviceOfferingId);
         if (offering.isDynamic()) {
-            offering.setDynamicFlag(true);
             if (vmId == null) {
                 throw new CloudRuntimeException("missing argument vmId");
             }
+            offering.setDynamicFlag(true);
             Map<String, String> dynamicOffering = userVmDetailsDao.listDetailsKeyPairs(vmId);
             return getcomputeOffering(offering, dynamicOffering);
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/plugins/database/quota/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/database/quota/pom.xml b/plugins/database/quota/pom.xml
index bd1ee43..0330dc8 100644
--- a/plugins/database/quota/pom.xml
+++ b/plugins/database/quota/pom.xml
@@ -1,58 +1,102 @@
 <!-- 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. -->
+	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. -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <artifactId>cloud-plugin-database-quota</artifactId>
-  <name>Apache CloudStack Plugin - Quota Service</name>
-  <parent>
-    <groupId>org.apache.cloudstack</groupId>
-    <artifactId>cloudstack-plugins</artifactId>
-    <version>4.6.0-SNAPSHOT</version>
-    <relativePath>../../pom.xml</relativePath>
-  </parent>
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.cloudstack</groupId>
-      <artifactId>cloud-api</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.cloudstack</groupId>
-      <artifactId>cloud-engine-schema</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.cloudstack</groupId>
-      <artifactId>cloud-utils</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-        <groupId>org.apache.cloudstack</groupId>
-        <artifactId>cloud-framework-quota</artifactId>
-        <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>mysql</groupId>
-      <artifactId>mysql-connector-java</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-lang3</artifactId>
-      <version>${cs.commons-lang3.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>joda-time</groupId>
-      <artifactId>joda-time</artifactId>
-      <version>${cs.joda-time.version}</version>
-    </dependency>
-  </dependencies>
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>cloud-plugin-database-quota</artifactId>
+	<name>Apache CloudStack Plugin - Quota Service</name>
+	<parent>
+		<groupId>org.apache.cloudstack</groupId>
+		<artifactId>cloudstack-plugins</artifactId>
+		<version>4.6.0-SNAPSHOT</version>
+		<relativePath>../../pom.xml</relativePath>
+	</parent>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.cloudstack</groupId>
+			<artifactId>cloud-api</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cloudstack</groupId>
+			<artifactId>cloud-engine-schema</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cloudstack</groupId>
+			<artifactId>cloud-utils</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cloudstack</groupId>
+			<artifactId>cloud-framework-quota</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.commons</groupId>
+			<artifactId>commons-lang3</artifactId>
+			<version>${cs.commons-lang3.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>joda-time</groupId>
+			<artifactId>joda-time</artifactId>
+			<version>${cs.joda-time.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${cs.junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.hamcrest</groupId>
+			<artifactId>hamcrest-library</artifactId>
+			<version>${cs.hamcrest.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-all</artifactId>
+			<version>${cs.mockito.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.powermock</groupId>
+			<artifactId>powermock-module-junit4</artifactId>
+			<version>${cs.powermock.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.powermock</groupId>
+			<artifactId>powermock-api-mockito</artifactId>
+			<version>${cs.powermock.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${org.springframework.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>javax.inject</groupId>
+			<artifactId>javax.inject</artifactId>
+			<version>1</version>
+		</dependency>
+
+
+	</dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java
index ddf6f05..349dbea 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java
@@ -36,7 +36,7 @@ import org.apache.cloudstack.api.response.QuotaStatementItemResponse;
 
 import com.cloud.user.Account;
 
-@APICommand(name = "quotaBalance", responseObject = QuotaStatementItemResponse.class, description = "Create a quota balance statement", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+@APICommand(name = "quotaBalance", responseObject = QuotaStatementItemResponse.class, description = "Create a quota balance statement", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
 public class QuotaBalanceCmd extends BaseCmd {
 
     public static final Logger s_logger = Logger.getLogger(QuotaBalanceCmd.class.getName());
@@ -125,9 +125,9 @@ public class QuotaBalanceCmd extends BaseCmd {
 
         QuotaBalanceResponse response;
         if (getEndDate() == null) {
-            response = _responseBuilder.createQuotaLastBalanceResponse(quotaUsage, startDate);
+            response = _responseBuilder.createQuotaLastBalanceResponse(quotaUsage, getStartDate());
         } else {
-            response = _responseBuilder.createQuotaBalanceResponse(quotaUsage, startDate, endDate);
+            response = _responseBuilder.createQuotaBalanceResponse(quotaUsage, getStartDate(), getEndDate());
         }
         response.setResponseName(getCommandName());
         setResponseObject(response);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaCreditsCmd.java
----------------------------------------------------------------------
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaCreditsCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaCreditsCmd.java
index 1a7db81..f2a7532 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaCreditsCmd.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaCreditsCmd.java
@@ -33,7 +33,7 @@ import org.apache.log4j.Logger;
 
 import javax.inject.Inject;
 
-@APICommand(name = "quotaCredits", responseObject = QuotaCreditsResponse.class, description = "Add +-credits to an account", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+@APICommand(name = "quotaCredits", responseObject = QuotaCreditsResponse.class, description = "Add +-credits to an account", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
 public class QuotaCreditsCmd extends BaseCmd {
 
     @Inject

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateUpdateCmd.java
----------------------------------------------------------------------
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateUpdateCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateUpdateCmd.java
index df08d91..b34bd29 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateUpdateCmd.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateUpdateCmd.java
@@ -30,7 +30,7 @@ import org.apache.log4j.Logger;
 import javax.inject.Inject;
 import java.util.Arrays;
 
-@APICommand(name = "quotaEmailTemplateUpdate", responseObject = SuccessResponse.class, description = "Updates existing email templates for quota alerts", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+@APICommand(name = "quotaEmailTemplateUpdate", responseObject = SuccessResponse.class, description = "Updates existing email templates for quota alerts", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
 public class QuotaEmailTemplateUpdateCmd extends BaseCmd {
     public static final Logger s_logger = Logger.getLogger(QuotaEmailTemplateUpdateCmd.class.getName());
     private static final String s_name = "quotaemailtemplateupdateresponse";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java
----------------------------------------------------------------------
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java
index 5d38d3d..5c52fb6 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java
@@ -36,7 +36,7 @@ import org.apache.cloudstack.api.response.QuotaStatementItemResponse;
 
 import com.cloud.user.Account;
 
-@APICommand(name = "quotaStatement", responseObject = QuotaStatementItemResponse.class, description = "Create a quota statement", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+@APICommand(name = "quotaStatement", responseObject = QuotaStatementItemResponse.class, description = "Create a quota statement", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
 public class QuotaStatementCmd extends BaseCmd {
 
     public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class.getName());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffListCmd.java
----------------------------------------------------------------------
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffListCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffListCmd.java
index 121873f..f82ba30 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffListCmd.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffListCmd.java
@@ -58,7 +58,9 @@ public class QuotaTariffListCmd extends BaseListCmd {
 
         final List<QuotaTariffResponse> responses = new ArrayList<QuotaTariffResponse>();
         for (final QuotaTariffVO resource : result) {
-            s_logger.info("Result desc=" + resource.getDescription() + " date=" + resource.getEffectiveOn() + " val=" + resource.getCurrencyValue());
+            if (s_logger.isDebugEnabled()){
+                s_logger.debug("Result desc=" + resource.getDescription() + " date=" + resource.getEffectiveOn() + " val=" + resource.getCurrencyValue());
+            }
             responses.add(_responseBuilder.createQuotaTariffResponse(resource));
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilder.java
----------------------------------------------------------------------
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilder.java b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilder.java
index e9bb611..eb97198 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilder.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilder.java
@@ -46,7 +46,7 @@ public interface QuotaResponseBuilder {
 
     QuotaCreditsResponse addQuotaCredits(Long accountId, Long domainId, Double amount, Long updatedBy, Date despositedOn);
 
-    public List<QuotaUsageVO> getQuotaUsage(QuotaStatementCmd cmd);
+    List<QuotaUsageVO> getQuotaUsage(QuotaStatementCmd cmd);
 
     List<QuotaBalanceVO> getQuotaBalance(QuotaBalanceCmd cmd);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
----------------------------------------------------------------------
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
index de082ee..3da648f 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
@@ -99,7 +99,7 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
 
     @Override
     public QuotaBalanceResponse createQuotaBalanceResponse(List<QuotaBalanceVO> quotaBalance, Date startDate, Date endDate) {
-        if (quotaBalance.size() == 0) {
+        if (quotaBalance == null || quotaBalance.size() == 0) {
             new InvalidParameterValueException("The request period does not contain balance entries.");
         }
         Collections.sort(quotaBalance, new Comparator<QuotaBalanceVO>() {
@@ -108,12 +108,15 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
             }
         });
 
+        int quota_activity = quotaBalance.size();
         QuotaBalanceResponse resp = new QuotaBalanceResponse();
         BigDecimal lastCredits = new BigDecimal(0);
         boolean consecutive = true;
         for (Iterator<QuotaBalanceVO> it = quotaBalance.iterator(); it.hasNext();) {
             QuotaBalanceVO entry = it.next();
-            s_logger.info("createQuotaBalanceResponse: Date=" + entry.getUpdatedOn().toGMTString() + " balance=" + entry.getCreditBalance() + " credit=" + entry.getCreditsId());
+            if (s_logger.isDebugEnabled()){
+                s_logger.debug("createQuotaBalanceResponse: Date=" + entry.getUpdatedOn().toGMTString() + " balance=" + entry.getCreditBalance() + " credit=" + entry.getCreditsId());
+            }
             if (entry.getCreditsId() > 0) {
                 if (consecutive) {
                     lastCredits = lastCredits.add(entry.getCreditBalance());
@@ -125,7 +128,7 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
             }
         }
 
-        if (quotaBalance.size() > 0) {
+        if (quota_activity > 0 && quotaBalance.size() > 0) {
             // order is desc last item is the start item
             QuotaBalanceVO startItem = quotaBalance.get(quotaBalance.size() - 1);
             QuotaBalanceVO endItem = quotaBalance.get(0);
@@ -133,6 +136,12 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
             resp.setStartQuota(startItem.getCreditBalance());
             resp.setEndDate(endDate);
             resp.setEndQuota(endItem.getCreditBalance().add(lastCredits));
+        } else if (quota_activity > 0) {
+            // order is desc last item is the start item
+            resp.setStartDate(startDate);
+            resp.setStartQuota(new BigDecimal(0));
+            resp.setEndDate(endDate);
+            resp.setEndQuota(new BigDecimal(0).add(lastCredits));
         } else {
             resp.setStartQuota(new BigDecimal(0));
             resp.setEndQuota(new BigDecimal(0));
@@ -178,9 +187,13 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
         BigDecimal totalUsage = new BigDecimal(0);
         quotaUsage.add(new QuotaUsageVO());// boundary
         QuotaUsageVO prev = quotaUsage.get(0);
-        //s_logger.info("createQuotaStatementResponse record count=" + quotaUsage.size());
+        if (s_logger.isDebugEnabled()){
+            s_logger.debug("createQuotaStatementResponse record count=" + quotaUsage.size());
+        }
         for (final QuotaUsageVO quotaRecord : quotaUsage) {
-            //s_logger.info("createQuotaStatementResponse Type=" + quotaRecord.getUsageType() + " usage=" + usage + " name" + quotaRecord.getUsageItemId());
+            if (s_logger.isDebugEnabled()){
+                s_logger.debug("createQuotaStatementResponse Type=" + quotaRecord.getUsageType() + " usage=" + usage + " name" + quotaRecord.getUsageItemId());
+            }
             if (type != quotaRecord.getUsageType()) {
                 if (type != -1) {
                     lineitem = new QuotaStatementItemResponse();
@@ -216,7 +229,9 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
         List<QuotaTariffVO> result = new ArrayList<QuotaTariffVO>();
         Date effectiveDate = cmd.getEffectiveDate() == null ? new Date() : cmd.getEffectiveDate();
         Date adjustedEffectiveDate = _quotaService.computeAdjustedTime(effectiveDate);
-        s_logger.info("Effective datec=" + effectiveDate + " quotatype=" + cmd.getUsageType() + " Adjusted date=" + adjustedEffectiveDate);
+        if (s_logger.isDebugEnabled()){
+            s_logger.debug("Effective datec=" + effectiveDate + " quotatype=" + cmd.getUsageType() + " Adjusted date=" + adjustedEffectiveDate);
+        }
         if (cmd.getUsageType() != null) {
             QuotaTariffVO tariffPlan = _quotaTariffDao.findTariffPlanByUsageType(cmd.getUsageType(), adjustedEffectiveDate);
             if (tariffPlan != null) {
@@ -294,16 +309,11 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
         }
         TransactionLegacy.open(TransactionLegacy.CLOUD_DB).close();
         final AccountVO account = _accountDao.findById(accountId);
-        final boolean lockAccountEnforcement = QuotaConfig.QuotaEnableEnforcement.value().equalsIgnoreCase("true");
+        final boolean lockAccountEnforcement = "true".equalsIgnoreCase(QuotaConfig.QuotaEnableEnforcement.value());
         final BigDecimal currentAccountBalance = _quotaBalanceDao.lastQuotaBalance(accountId, domainId, startOfNextDay(despositedOn));
         if (lockAccountEnforcement && (currentAccountBalance.compareTo(new BigDecimal(0)) >= 0)) {
             if (account.getState() == Account.State.locked) {
-                try {
-                    _regionMgr.enableAccount(account.getAccountName(), domainId, accountId);
-                    //_quotaMgr.sendQuotaAlert(account, currentAccountBalance, QuotaConfig.QuotaEmailTemplateTypes.QUOTA_UNLOCK_ACCOUNT);
-                } catch (Exception e) {
-                    s_logger.error(String.format("Unable to unlock account %s after getting enough quota credits", account.getAccountName()));
-                }
+                _regionMgr.enableAccount(account.getAccountName(), domainId, accountId);
             }
         }
 
@@ -361,7 +371,7 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
 
     @Override
     public QuotaBalanceResponse createQuotaLastBalanceResponse(List<QuotaBalanceVO> quotaBalance, Date startDate) {
-        if (quotaBalance.size() == 0) {
+        if (quotaBalance == null || quotaBalance.size() == 0) {
             new InvalidParameterValueException("There are no balance entries on or before the requested date.");
         }
         if (startDate == null) {
@@ -371,7 +381,9 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
         BigDecimal lastCredits = new BigDecimal(0);
         for (Iterator<QuotaBalanceVO> it = quotaBalance.iterator(); it.hasNext();) {
             QuotaBalanceVO entry = it.next();
-            s_logger.info("createQuotaLastBalanceResponse Date=" + entry.getUpdatedOn() + " balance=" + entry.getCreditBalance() + " credit=" + entry.getCreditsId());
+            if (s_logger.isDebugEnabled()){
+                s_logger.info("createQuotaLastBalanceResponse Date=" + entry.getUpdatedOn() + " balance=" + entry.getCreditBalance() + " credit=" + entry.getCreditsId());
+            }
             lastCredits = lastCredits.add(entry.getCreditBalance());
         }
         resp.setStartQuota(lastCredits);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java
----------------------------------------------------------------------
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java
index e13512a..3704098 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java
@@ -108,7 +108,9 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi
             s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + UsageUtils.USAGE_AGGREGATION_RANGE_MIN);
             _aggregationDuration = UsageUtils.USAGE_AGGREGATION_RANGE_MIN;
         }
-        s_logger.info("Usage timezone = " + _usageTimezone + " AggregationDuration=" + _aggregationDuration);
+        if (s_logger.isDebugEnabled()){
+            s_logger.debug("Usage timezone = " + _usageTimezone + " AggregationDuration=" + _aggregationDuration);
+        }
         return true;
     }
 
@@ -175,9 +177,13 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi
         if (endDate == null) {
             // adjust start date to end of day as there is no end date
             Date adjustedStartDate = computeAdjustedTime(_respBldr.startOfNextDay(startDate));
-            s_logger.debug("getQuotaBalance1: Getting quota balance records for account: " + accountId + ", domainId: " + domainId + ", on or before " + adjustedStartDate);
+            if (s_logger.isDebugEnabled()){
+                s_logger.debug("getQuotaBalance1: Getting quota balance records for account: " + accountId + ", domainId: " + domainId + ", on or before " + adjustedStartDate);
+            }
             List<QuotaBalanceVO> qbrecords = _quotaBalanceDao.lastQuotaBalanceVO(accountId, domainId, adjustedStartDate);
-            s_logger.info("Found records size=" + qbrecords.size());
+            if (s_logger.isDebugEnabled()){
+                s_logger.debug("Found records size=" + qbrecords.size());
+            }
             if (qbrecords.size() == 0) {
                 throw new InvalidParameterValueException("Incorrect Date there are no quota records before this date " + adjustedStartDate);
             } else {
@@ -189,9 +195,13 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi
                 throw new InvalidParameterValueException("Incorrect Date Range. End date:" + endDate + " should not be in future. ");
             } else if (startDate.before(endDate)) {
                 Date adjustedEndDate = computeAdjustedTime(endDate);
-                s_logger.debug("getQuotaBalance2: Getting quota balance records for account: " + accountId + ", domainId: " + domainId + ", between " + adjustedStartDate + " and " + adjustedEndDate);
+                if (s_logger.isDebugEnabled()){
+                    s_logger.debug("getQuotaBalance2: Getting quota balance records for account: " + accountId + ", domainId: " + domainId + ", between " + adjustedStartDate + " and " + adjustedEndDate);
+                }
                 List<QuotaBalanceVO> qbrecords = _quotaBalanceDao.findQuotaBalance(accountId, domainId, adjustedStartDate, adjustedEndDate);
-                s_logger.info("getQuotaBalance3: Found records size=" + qbrecords.size());
+                if (s_logger.isDebugEnabled()){
+                    s_logger.debug("getQuotaBalance3: Found records size=" + qbrecords.size());
+                }
                 if (qbrecords.size() == 0) {
                     throw new InvalidParameterValueException("Incorrect Date range there are no quota records between these dates start date " + adjustedStartDate + " and end date:" + endDate);
                 } else {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/test/integration/smoke/test_quota.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_quota.py b/test/integration/smoke/test_quota.py
new file mode 100644
index 0000000..d4e4323
--- /dev/null
+++ b/test/integration/smoke/test_quota.py
@@ -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.
+""" Test cases for checking quota API
+"""
+
+#Import Local Modules
+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 System modules
+import time
+
+#ENABLE THE QUOTA PLUGIN AND RESTART THE MANAGEMENT SERVER TO RUN QUOTA TESTS
+
+class TestQuota(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.cleanup = []
+        return
+
+    def tearDown(self):
+        try:
+            #Clean up, terminate the created templates
+            cleanup_resources(self.apiclient, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    #Check quotaTariffList API returning 22 items
+    @attr(tags=["smoke", "advanced"], required_hardware="false")
+    def test_01_quota(self):
+        cmd = quotaTariffList.quotaTariffListCmd()
+        response = self.apiclient.quotaTariffList(cmd)
+
+        self.debug("Number of quota usage types: %s" % len(response))
+        self.assertEqual(
+                         len(response), 22
+                         )
+        for quota in response:
+            self.debug("Usage Name: %s" % quota.usageName)
+            self.assertEqual(
+                hasattr(quota, 'usageName'),
+                True,
+                "Check whether usgaeName field is there"
+            )
+
+        return
+
+    #Check quota tariff on a particualr day
+    @attr(tags=["smoke", "advanced"], required_hardware="false")
+    def test_02_quota(self):
+        cmd = quotaTariffList.quotaTariffListCmd()
+        cmd.startdate='2015-07-06'
+        response = self.apiclient.quotaTariffList(cmd)
+
+        self.debug("Number of quota usage types: %s" % len(response))
+        self.assertEqual(
+                         len(response), 22
+                         )
+
+        return
+
+    #check quota tariff of a particular item
+    @attr(tags=["smoke", "advanced"], required_hardware="false")
+    def test_03_quota(self):
+        cmd = quotaTariffList.quotaTariffListCmd()
+        cmd.startdate='2015-07-06'
+        cmd.usagetype='10'
+        response = self.apiclient.quotaTariffList(cmd)
+
+        self.debug("Number of quota usage types: %s" % len(response))
+        self.assertEqual(
+                         len(response), 1
+                         )
+        return
+
+
+    #check quota tariff
+    #Change it
+    #Check on affective date the new tariff should be applicable
+    #check the old tariff it should be same
+    @attr(tags=["smoke", "advanced"], required_hardware="false")
+    def test_04_quota(self):
+        cmd = quotaTariffList.quotaTariffListCmd()
+        cmd.startdate='2015-07-06'
+        cmd.usagetype='10'
+        response = self.apiclient.quotaTariffList(cmd)
+
+        self.debug("Number of quota usage types: %s" % len(response))
+        self.assertEqual(
+                         len(response), 1
+                         )
+        quota = response[0]
+        self.debug("Tariff Value for 10: %s" % quota.tariffValue)
+
+        cmd = quotaTariffUpdate.quotaTariffUpdateCmd()
+        tomorrow = datetime.date.today() + datetime.timedelta(days=1)
+        cmd.startdate=tomorrow
+        cmd.usagetype='10'
+        cmd.value='2.9'
+        response = self.apiclient.quotaTariffUpdate(cmd)
+
+        cmd = quotaTariffList.quotaTariffListCmd()
+        cmd.startdate=tomorrow
+        cmd.usagetype='10'
+        response = self.apiclient.quotaTariffList(cmd)
+        self.assertEqual(
+                         len(response), 1
+                         )
+        quota = response[0]
+        self.debug("Tariff Value for 10: %s" % quota.tariffValue)
+
+        self.assertEqual( quota.tariffValue, 2.9)
+
+
+        cmd = quotaTariffList.quotaTariffListCmd()
+        cmd.startdate='2015-07-07'
+        cmd.usagetype='10'
+        response = self.apiclient.quotaTariffList(cmd)
+        self.assertEqual(
+                         len(response), 1
+                         )
+        quota = response[0]
+        self.debug("Tariff Value for 10: %s" % quota.tariffValue)
+
+        self.assertEqual( quota.tariffValue, 0)
+
+        return
+
+
+    #Make credit deposit
+    @attr(tags=["smoke", "advanced"], required_hardware="false")
+    def test_05_quota(self):
+        cmd = quotaCredits.quotaCreditsCmd()
+        cmd.domainid = '1'
+        cmd.account = 'admin'
+        cmd.value = '10'
+        cmd.quota_enforce = '1'
+        cmd.min_balance = '9'
+        response = self.apiclient.quotaCredits(cmd)
+
+        self.debug("Credit response update on: %s" % response.updated_on)
+
+        return
+
+
+    #Make credit deposit and check today balance
+    @attr(tags=["smoke", "advanced"], required_hardware="false")
+    def test_06_quota(self):
+        cmd = quotaBalance.quotaBalanceCmd()
+        today = datetime.date.today()
+        cmd.domainid = '1'
+        cmd.account = 'admin'
+        cmd.startdate = today
+        response = self.apiclient.quotaBalance(cmd)
+
+        self.debug("Quota Balance on: %s" % response.startdate)
+        self.debug("is: %s" % response.startquota)
+
+        self.assertGreater( response.startquota, 9)
+        return
+
+    #make credit deposit and check start and end date balances
+    @attr(tags=["smoke", "advanced"], required_hardware="false")
+    def test_07_quota(self):
+        cmd = quotaBalance.quotaBalanceCmd()
+        today = datetime.date.today()
+        cmd.domainid = '1'
+        cmd.account = 'admin'
+        cmd.startdate = today - datetime.timedelta(days=2)
+        cmd.enddate = today
+        response = self.apiclient.quotaBalance(cmd)
+
+        self.debug("Quota Balance on: %s" % response.startdate)
+        self.debug("is: %s" % response.startquota)
+
+        self.assertGreater( response.endquota, 9)
+        return

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
----------------------------------------------------------------------
diff --git a/usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java b/usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
index 6112514..703ee63 100644
--- a/usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
+++ b/usage/src/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
@@ -19,7 +19,6 @@ package org.apache.cloudstack.quota;
 import com.cloud.domain.DomainVO;
 import com.cloud.domain.dao.DomainDao;
 import com.cloud.user.Account;
-//import com.cloud.user.AccountManager;
 import com.cloud.user.AccountVO;
 import com.cloud.user.UserVO;
 import com.cloud.user.Account.State;
@@ -126,7 +125,7 @@ public class QuotaAlertManagerImpl extends ManagerBase implements QuotaAlertMana
         String smtpUsername = configs.get(QuotaConfig.QuotaSmtpUser.key());
         String smtpPassword = configs.get(QuotaConfig.QuotaSmtpPassword.key());
         String emailSender = configs.get(QuotaConfig.QuotaSmtpSender.key());
-        _lockAccountEnforcement = configs.get(QuotaConfig.QuotaEnableEnforcement.key()).equalsIgnoreCase("true");
+        _lockAccountEnforcement = "true".equalsIgnoreCase(configs.get(QuotaConfig.QuotaEnableEnforcement.key()));
         _emailQuotaAlert = new EmailQuotaAlert(smtpHost, smtpPort, useAuth, smtpUsername, smtpPassword, emailSender, _smtpDebug);
 
         return true;
@@ -162,11 +161,12 @@ public class QuotaAlertManagerImpl extends ManagerBase implements QuotaAlertMana
         Date firstDateOfPreviousMonth = aCalendar.getTime();
         aCalendar.set(Calendar.DATE, aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
         Date lastDateOfPreviousMonth = aCalendar.getTime(); // actually the first day of this month
-        //s_logger.info("firstDateOfPreviousMonth" + firstDateOfPreviousMonth + " lastDateOfPreviousMonth" + lastDateOfPreviousMonth);
 
         List<DeferredQuotaEmail> deferredQuotaEmailList = new ArrayList<DeferredQuotaEmail>();
         for (final QuotaAccountVO quotaAccount : _quotaAcc.listAll()) {
-            if (quotaAccount.getQuotaBalance() == null) continue; // no quota usage for this account ever, ignore
+            if (quotaAccount.getQuotaBalance() == null) {
+                continue; // no quota usage for this account ever, ignore
+            }
             Date lastStatementDate = quotaAccount.getLastStatementDate();
             if (now.getDate() < 6) {
                 AccountVO account = _accountDao.findById(quotaAccount.getId());
@@ -208,7 +208,9 @@ public class QuotaAlertManagerImpl extends ManagerBase implements QuotaAlertMana
             BigDecimal thresholdBalance = quotaAccount.getQuotaMinBalance();
             if (accountBalance != null) {
                 AccountVO account = _accountDao.findById(quotaAccount.getId());
-                // s_logger.info("Check id " + account.getId() + " bal="+ accountBalance + " alertDate"+ alertDate + " diff" + getDifferenceDays(alertDate, new Date()));
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Check id " + account.getId() + " bal=" + accountBalance + " alertDate" + alertDate + " diff" + getDifferenceDays(alertDate, new Date()));
+                }
                 if (accountBalance.compareTo(zeroBalance) <= 0) {
                     if (_lockAccountEnforcement && (lockable == 1)) {
                         if (account.getType() == Account.ACCOUNT_TYPE_NORMAL) {
@@ -266,8 +268,10 @@ public class QuotaAlertManagerImpl extends ManagerBase implements QuotaAlertMana
                 optionMap.put("quotaUsage", QuotaConfig.QuotaCurrencySymbol.value() + " " + usage.toString());
             }
 
-            // s_logger.info("accountName" + account.getAccountName() + "accountID" + account.getUuid() + "accountUsers" + userNames + "domainName" + accountDomain.getName() + "domainID"
-            // + accountDomain.getUuid());
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("accountName" + account.getAccountName() + "accountID" + account.getUuid() + "accountUsers" + userNames + "domainName" + accountDomain.getName() + "domainID"
+                        + accountDomain.getUuid());
+            }
 
             final StrSubstitutor templateEngine = new StrSubstitutor(optionMap);
             final String subject = templateEngine.replace(emailTemplate.getTemplateSubject());
@@ -285,10 +289,10 @@ public class QuotaAlertManagerImpl extends ManagerBase implements QuotaAlertMana
     }
 
     class DeferredQuotaEmail {
-        AccountVO account;
-        QuotaAccountVO quotaAccount;
-        QuotaConfig.QuotaEmailTemplateTypes emailTemplateType;
-        BigDecimal quotaUsage;
+        private AccountVO account;
+        private QuotaAccountVO quotaAccount;
+        private QuotaConfig.QuotaEmailTemplateTypes emailTemplateType;
+        private BigDecimal quotaUsage;
 
         public DeferredQuotaEmail(AccountVO account, QuotaAccountVO quotaAccount, BigDecimal quotaUsage, QuotaConfig.QuotaEmailTemplateTypes emailTemplateType) {
             this.account = account;
@@ -324,8 +328,7 @@ public class QuotaAlertManagerImpl extends ManagerBase implements QuotaAlertMana
             if (emailTemplateType == QuotaEmailTemplateTypes.QUOTA_STATEMENT) {
                 quotaAccount.setLastStatementDate(new Date());
                 _quotaAcc.update(quotaAccount.getAccountId(), quotaAccount);
-            }
-            else {
+            } else {
                 quotaAccount.setQuotaAlertDate(new Date());
                 quotaAccount.setQuotaAlertType(emailTemplateType.ordinal());
                 _quotaAcc.update(quotaAccount.getAccountId(), quotaAccount);
@@ -336,8 +339,8 @@ public class QuotaAlertManagerImpl extends ManagerBase implements QuotaAlertMana
     class EmailQuotaAlert {
         private Session _smtpSession;
         private final String _smtpHost;
-        private int _smtpPort = -1;
-        private boolean _smtpUseAuth = false;
+        private final int _smtpPort;
+        private final boolean _smtpUseAuth;
         private final String _smtpUsername;
         private final String _smtpPassword;
         private final String _emailSender;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af28a826/usage/src/org/apache/cloudstack/quota/QuotaManagerImpl.java
----------------------------------------------------------------------
diff --git a/usage/src/org/apache/cloudstack/quota/QuotaManagerImpl.java b/usage/src/org/apache/cloudstack/quota/QuotaManagerImpl.java
index 75ac015..568a50d 100644
--- a/usage/src/org/apache/cloudstack/quota/QuotaManagerImpl.java
+++ b/usage/src/org/apache/cloudstack/quota/QuotaManagerImpl.java
@@ -19,7 +19,6 @@ package org.apache.cloudstack.quota;
 import com.cloud.usage.UsageVO;
 import com.cloud.usage.dao.UsageDao;
 import com.cloud.user.Account;
-//import com.cloud.user.AccountManager;
 import com.cloud.user.AccountVO;
 import com.cloud.user.Account.State;
 import com.cloud.user.dao.AccountDao;
@@ -162,49 +161,27 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
                         BigDecimal aggregationRatio = new BigDecimal(_aggregationDuration).divide(s_minutesInMonth, 8, RoundingMode.HALF_EVEN);
                         switch (usageRecord.getUsageType()) {
                         case QuotaTypes.RUNNING_VM:
-                            quotalistforaccount.addAll(updateQuotaRunningVMUsage(usageRecord, aggregationRatio));
-                            break;
                         case QuotaTypes.ALLOCATED_VM:
                             quotalistforaccount.add(updateQuotaAllocatedVMUsage(usageRecord, aggregationRatio));
                             break;
                         case QuotaTypes.SNAPSHOT:
-                            quotalistforaccount.add(updateQuotaDiskUsage(usageRecord, aggregationRatio, QuotaTypes.SNAPSHOT));
-                            break;
                         case QuotaTypes.TEMPLATE:
-                            quotalistforaccount.add(updateQuotaDiskUsage(usageRecord, aggregationRatio, QuotaTypes.TEMPLATE));
-                            break;
                         case QuotaTypes.ISO:
-                            quotalistforaccount.add(updateQuotaDiskUsage(usageRecord, aggregationRatio, QuotaTypes.ISO));
-                            break;
                         case QuotaTypes.VOLUME:
-                            quotalistforaccount.add(updateQuotaDiskUsage(usageRecord, aggregationRatio, QuotaTypes.VOLUME));
-                            break;
                         case QuotaTypes.VM_SNAPSHOT:
-                            quotalistforaccount.add(updateQuotaDiskUsage(usageRecord, aggregationRatio, QuotaTypes.VM_SNAPSHOT));
+                            quotalistforaccount.add(updateQuotaDiskUsage(usageRecord, aggregationRatio, usageRecord.getUsageType()));
                             break;
                         case QuotaTypes.LOAD_BALANCER_POLICY:
-                            quotalistforaccount.add(updateQuotaRaw(usageRecord, aggregationRatio, QuotaTypes.LOAD_BALANCER_POLICY));
-                            break;
                         case QuotaTypes.PORT_FORWARDING_RULE:
-                            quotalistforaccount.add(updateQuotaRaw(usageRecord, aggregationRatio, QuotaTypes.PORT_FORWARDING_RULE));
-                            break;
                         case QuotaTypes.IP_ADDRESS:
-                            quotalistforaccount.add(updateQuotaRaw(usageRecord, aggregationRatio, QuotaTypes.IP_ADDRESS));
-                            break;
                         case QuotaTypes.NETWORK_OFFERING:
-                            quotalistforaccount.add(updateQuotaRaw(usageRecord, aggregationRatio, QuotaTypes.NETWORK_OFFERING));
-                            break;
                         case QuotaTypes.SECURITY_GROUP:
-                            quotalistforaccount.add(updateQuotaRaw(usageRecord, aggregationRatio, QuotaTypes.SECURITY_GROUP));
-                            break;
                         case QuotaTypes.VPN_USERS:
-                            quotalistforaccount.add(updateQuotaRaw(usageRecord, aggregationRatio, QuotaTypes.VPN_USERS));
+                            quotalistforaccount.add(updateQuotaRaw(usageRecord, aggregationRatio, usageRecord.getUsageType()));
                             break;
                         case QuotaTypes.NETWORK_BYTES_RECEIVED:
-                            quotalistforaccount.add(updateQuotaNetwork(usageRecord, QuotaTypes.NETWORK_BYTES_RECEIVED));
-                            break;
                         case QuotaTypes.NETWORK_BYTES_SENT:
-                            quotalistforaccount.add(updateQuotaNetwork(usageRecord, QuotaTypes.NETWORK_BYTES_SENT));
+                            quotalistforaccount.add(updateQuotaNetwork(usageRecord, usageRecord.getUsageType()));
                             break;
                         case QuotaTypes.VM_DISK_IO_READ:
                         case QuotaTypes.VM_DISK_IO_WRITE:
@@ -216,7 +193,9 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
                     }
                 } while ((usageRecords != null) && !usageRecords.first().isEmpty());
                 // list of quotas for this account
-                s_logger.info("Quota entries size = " + quotalistforaccount.size() + ", accId" + account.getAccountId() + ", domId" + account.getDomainId());
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Quota entries size = " + quotalistforaccount.size() + ", accId" + account.getAccountId() + ", domId" + account.getDomainId());
+                }
                 if (quotalistforaccount.size() > 0) { // balance to be processed
                     quotalistforaccount.add(new QuotaUsageVO());
                     Date startDate = quotalistforaccount.get(0).getStartDate();
@@ -239,7 +218,10 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
                             }
 
                             QuotaBalanceVO newbalance = new QuotaBalanceVO(account.getAccountId(), account.getDomainId(), aggrUsage, endDate);
-                            // s_logger.info("Balance entry=" + aggrUsage + " on Date=" + endDate);
+
+                            if (s_logger.isDebugEnabled()) {
+                                s_logger.debug("Balance entry=" + aggrUsage + " on Date=" + endDate);
+                            }
                             _quotaBalanceDao.persist(newbalance);
                             aggrUsage = new BigDecimal(0);
                         }
@@ -249,7 +231,9 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
                     }
                     // update is quota_accounts
                     QuotaAccountVO quota_account = _quotaAcc.findById(account.getAccountId());
-                    s_logger.info("Updating quota account bal=" + aggrUsage + " date=" + endDate);
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("Updating quota account bal=" + aggrUsage + " date=" + endDate);
+                    }
                     if (quota_account == null) {
                         quota_account = new QuotaAccountVO(account.getAccountId());
                         quota_account.setQuotaBalance(aggrUsage);
@@ -265,7 +249,6 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
             jobResult = true;
         } catch (Exception e) {
             s_logger.error("Quota Manager error", e);
-            e.printStackTrace();
         } finally {
             txn.close();
         }
@@ -273,7 +256,6 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
         return jobResult;
     }
 
-
     @DB
     private QuotaUsageVO updateQuotaDiskUsage(UsageVO usageRecord, final BigDecimal aggregationRatio, final int quotaType) {
         QuotaUsageVO quota_usage = null;
@@ -285,8 +267,6 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
             onehourcostpergb = tariff.getCurrencyValue().multiply(aggregationRatio);
             noofgbinuse = new BigDecimal(usageRecord.getSize()).divide(s_gb, 8, RoundingMode.HALF_EVEN);
             quotaUsgage = new BigDecimal(usageRecord.getRawUsage()).multiply(onehourcostpergb).multiply(noofgbinuse);
-            // s_logger.info(" No of GB In use = " + noofgbinuse +
-            // " onehour cost=" + onehourcostpergb);
             quota_usage = new QuotaUsageVO(usageRecord.getId(), usageRecord.getZoneId(), usageRecord.getAccountId(), usageRecord.getDomainId(), usageRecord.getUsageType(), quotaUsgage,
                     usageRecord.getStartDate(), usageRecord.getEndDate());
             _quotaUsageDao.persist(quota_usage);
@@ -303,10 +283,6 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
         BigDecimal cpuquotausgage, speedquotausage, memoryquotausage, vmusage;
         BigDecimal onehourcostpercpu, onehourcostper100mhz, onehourcostper1mb, onehourcostforvmusage;
         BigDecimal rawusage;
-        // s_logger.info(usageRecord.getDescription() + ", " +
-        // usageRecord.getType() + ", " + usageRecord.getOfferingId() + ", " +
-        // usageRecord.getVmInstanceId() + ", " + usageRecord.getUsageDisplay()
-        // + ", aggrR=" + aggregationRatio);
         // get service offering details
         ServiceOfferingVO serviceoffering = _serviceOfferingDao.findServiceOffering(usageRecord.getVmInstanceId(), usageRecord.getOfferingId());
         rawusage = new BigDecimal(usageRecord.getRawUsage());
@@ -364,8 +340,6 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
             BigDecimal vmusage;
             BigDecimal onehourcostforvmusage;
             onehourcostforvmusage = tariff.getCurrencyValue().multiply(aggregationRatio);
-            // s_logger.info("Quotatariff onehourcostforvmusage=" +
-            // onehourcostforvmusage);
             vmusage = new BigDecimal(usageRecord.getRawUsage()).multiply(onehourcostforvmusage);
             quota_usage = new QuotaUsageVO(usageRecord.getId(), usageRecord.getZoneId(), usageRecord.getAccountId(), usageRecord.getDomainId(), QuotaTypes.ALLOCATED_VM, vmusage,
                     usageRecord.getStartDate(), usageRecord.getEndDate());
@@ -385,7 +359,6 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
             BigDecimal ruleusage;
             BigDecimal onehourcost;
             onehourcost = tariff.getCurrencyValue().multiply(aggregationRatio);
-            // s_logger.info("Quotatariff onehourcost=" + onehourcost);
             ruleusage = new BigDecimal(usageRecord.getRawUsage()).multiply(onehourcost);
             quota_usage = new QuotaUsageVO(usageRecord.getId(), usageRecord.getZoneId(), usageRecord.getAccountId(), usageRecord.getDomainId(), ruleType, ruleusage, usageRecord.getStartDate(),
                     usageRecord.getEndDate());
@@ -406,7 +379,6 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
             BigDecimal rawusageingb;
             BigDecimal networkusage;
             onegbcost = tariff.getCurrencyValue();
-            // s_logger.info("Quotatariff onegbcost=" + onegbcost);
             rawusageingb = new BigDecimal(usageRecord.getRawUsage()).divide(s_gb, 8, RoundingMode.HALF_EVEN);
             networkusage = rawusageingb.multiply(onegbcost);
             quota_usage = new QuotaUsageVO(usageRecord.getId(), usageRecord.getZoneId(), usageRecord.getAccountId(), usageRecord.getDomainId(), transferType, networkusage, usageRecord.getStartDate(),


Mime
View raw message