cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [5/6] git commit: updated refs/heads/pr/689-review to af28a82
Date Mon, 31 Aug 2015 10:34:39 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/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
new file mode 100644
index 0000000..82d4af6
--- /dev/null
+++ b/framework/quota/src/org/apache/cloudstack/quota/dao/ServiceOfferingDaoImpl.java
@@ -0,0 +1,85 @@
+// 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.quota.dao;
+
+import java.util.Map;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+import org.apache.cloudstack.quota.vo.ServiceOfferingVO;
+
+import com.cloud.event.UsageEventVO;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.TransactionLegacy;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Component
+@Local(value = { ServiceOfferingDao.class })
+@DB()
+public class ServiceOfferingDaoImpl extends GenericDaoBase<ServiceOfferingVO, Long> implements ServiceOfferingDao {
+    protected static final Logger s_logger = Logger.getLogger(ServiceOfferingDaoImpl.class);
+
+    @Inject
+    UserVmDetailsDao userVmDetailsDao;
+
+    @Override
+    public ServiceOfferingVO findServiceOffering(final Long vmId, final long serviceOfferingId) {
+        final short opendb = TransactionLegacy.currentTxn().getDatabaseId();
+        TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
+        ServiceOfferingVO result;
+        try {
+            result = findById(vmId, serviceOfferingId);
+        } finally {
+            txn.close();
+        }
+        TransactionLegacy.open(opendb).close();
+        return result;
+    }
+
+    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");
+            }
+            Map<String, String> dynamicOffering = userVmDetailsDao.listDetailsKeyPairs(vmId);
+            return getcomputeOffering(offering, dynamicOffering);
+        }
+        return offering;
+    }
+
+    public ServiceOfferingVO getcomputeOffering(ServiceOfferingVO serviceOffering, Map<String, String> customParameters) {
+        ServiceOfferingVO dummyoffering = new ServiceOfferingVO(serviceOffering);
+        dummyoffering.setDynamicFlag(true);
+        if (customParameters.containsKey(UsageEventVO.DynamicParameters.cpuNumber.name())) {
+            dummyoffering.setCpu(Integer.parseInt(customParameters.get(UsageEventVO.DynamicParameters.cpuNumber.name())));
+        }
+        if (customParameters.containsKey(UsageEventVO.DynamicParameters.cpuSpeed.name())) {
+            dummyoffering.setSpeed(Integer.parseInt(customParameters.get(UsageEventVO.DynamicParameters.cpuSpeed.name())));
+        }
+        if (customParameters.containsKey(UsageEventVO.DynamicParameters.memory.name())) {
+            dummyoffering.setRamSize(Integer.parseInt(customParameters.get(UsageEventVO.DynamicParameters.memory.name())));
+        }
+        return dummyoffering;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/framework/quota/src/org/apache/cloudstack/quota/dao/UserVmDetailsDao.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/dao/UserVmDetailsDao.java b/framework/quota/src/org/apache/cloudstack/quota/dao/UserVmDetailsDao.java
new file mode 100644
index 0000000..f14ecf4
--- /dev/null
+++ b/framework/quota/src/org/apache/cloudstack/quota/dao/UserVmDetailsDao.java
@@ -0,0 +1,31 @@
+// 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.quota.dao;
+
+
+import java.util.Map;
+
+import com.cloud.utils.db.GenericDao;
+
+import org.apache.cloudstack.quota.vo.UserVmDetailVO;
+
+public interface UserVmDetailsDao extends GenericDao<UserVmDetailVO, Long> {
+
+    Map<String, String> listDetailsKeyPairs(long resourceId);
+
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/framework/quota/src/org/apache/cloudstack/quota/dao/UserVmDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/dao/UserVmDetailsDaoImpl.java b/framework/quota/src/org/apache/cloudstack/quota/dao/UserVmDetailsDaoImpl.java
new file mode 100644
index 0000000..7cc42e7
--- /dev/null
+++ b/framework/quota/src/org/apache/cloudstack/quota/dao/UserVmDetailsDaoImpl.java
@@ -0,0 +1,62 @@
+// 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.quota.dao;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+import org.apache.cloudstack.quota.vo.UserVmDetailVO;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value = UserVmDetailsDao.class)
+public class UserVmDetailsDaoImpl extends GenericDaoBase<UserVmDetailVO, Long> implements UserVmDetailsDao {
+    private SearchBuilder<UserVmDetailVO> AllFieldsSearch;
+
+    public UserVmDetailsDaoImpl() {
+        AllFieldsSearch = createSearchBuilder();
+        AllFieldsSearch.and("resourceId", AllFieldsSearch.entity().getResourceId(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("value", AllFieldsSearch.entity().getValue(), SearchCriteria.Op.EQ);
+        // FIXME SnapshotDetailsVO doesn't have a display field
+        if (_allAttributes.containsKey("display")) {
+            AllFieldsSearch.and("display", AllFieldsSearch.entity().isDisplay(), SearchCriteria.Op.EQ);
+        }
+        AllFieldsSearch.done();
+    }
+
+    @Override
+    public Map<String, String> listDetailsKeyPairs(long resourceId) {
+        SearchCriteria<UserVmDetailVO> sc = AllFieldsSearch.create();
+        sc.setParameters("resourceId", resourceId);
+
+        List<UserVmDetailVO> results = search(sc, null);
+        Map<String, String> details = new HashMap<String, String>(results.size());
+        for (UserVmDetailVO result : results) {
+            details.put(result.getName(), result.getValue());
+        }
+        return details;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaAccountVO.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaAccountVO.java b/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaAccountVO.java
new file mode 100644
index 0000000..eee790d
--- /dev/null
+++ b/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaAccountVO.java
@@ -0,0 +1,142 @@
+//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.quota.vo;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Entity
+@Table(name = "quota_account")
+public class QuotaAccountVO implements InternalIdentity {
+
+    private static final long serialVersionUID = -7112846845287653210L;
+
+    @Id
+    @Column(name = "account_id")
+    private Long accountId = null;
+
+    @Column(name = "quota_enforce")
+    private Integer quotaEnforce = null;
+
+    @Column(name = "quota_balance")
+    private BigDecimal quotaBalance;
+
+    @Column(name = "quota_balance_date")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    private Date quotaBalanceDate = null;
+
+    @Column(name = "quota_min_balance")
+    private BigDecimal quotaMinBalance;
+
+    @Column(name = "quota_alert_type")
+    private Integer quotaAlertType = null;
+
+    @Column(name = "quota_alert_date")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    private Date quotaAlertDate = null;
+
+    @Column(name = "last_statement_date")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    private Date lastStatementDate = null;
+
+    public QuotaAccountVO() {
+    }
+
+    public QuotaAccountVO(Long accountId) {
+        super();
+        this.accountId = accountId;
+    }
+
+    @Override
+    public long getId() {
+        return accountId;
+    }
+
+    public Long getAccountId() {
+        return accountId;
+    }
+
+    public void setAccountId(Long accountId) {
+        this.accountId = accountId;
+    }
+
+    public Integer getQuotaEnforce() {
+        return quotaEnforce == null ? 0 : quotaEnforce;
+    }
+
+    public void setQuotaEnforce(Integer quotaEnforce) {
+        this.quotaEnforce = quotaEnforce;
+    }
+
+    public BigDecimal getQuotaBalance() {
+        return quotaBalance;
+    }
+
+    public void setQuotaBalance(BigDecimal quotaBalance) {
+        this.quotaBalance = quotaBalance;
+    }
+
+    public BigDecimal getQuotaMinBalance() {
+        return quotaMinBalance == null ? new BigDecimal(0) : quotaMinBalance;
+    }
+
+    public void setQuotaMinBalance(BigDecimal quotaMinBalance) {
+        this.quotaMinBalance = quotaMinBalance;
+    }
+
+    public Integer getQuotaAlertType() {
+        return quotaAlertType;
+    }
+
+    public void setQuotaAlertType(Integer quotaAlertType) {
+        this.quotaAlertType = quotaAlertType;
+    }
+
+    public Date getQuotaAlertDate() {
+        return quotaAlertDate;
+    }
+
+    public void setQuotaAlertDate(Date quotaAlertDate) {
+        this.quotaAlertDate = quotaAlertDate;
+    }
+
+    public Date getQuotaBalanceDate() {
+        return quotaBalanceDate;
+    }
+
+    public void setQuotaBalanceDate(Date quotaBalanceDate) {
+        this.quotaBalanceDate = quotaBalanceDate;
+    }
+
+    public Date getLastStatementDate() {
+        return lastStatementDate;
+    }
+
+    public void setLastStatementDate(Date lastStatementDate) {
+        this.lastStatementDate = lastStatementDate;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaBalanceVO.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaBalanceVO.java b/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaBalanceVO.java
new file mode 100644
index 0000000..d46b949
--- /dev/null
+++ b/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaBalanceVO.java
@@ -0,0 +1,127 @@
+//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.quota.vo;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Entity
+@Table(name = "quota_balance")
+public class QuotaBalanceVO implements InternalIdentity {
+
+    private static final long serialVersionUID = -7112846845287653210L;
+
+    @Id
+    @Column(name = "id")
+    private Long id;
+
+    @Column(name = "account_id")
+    private Long accountId = null;
+
+    @Column(name = "domain_id")
+    private Long domainId = null;
+
+    @Column(name = "credit_balance")
+    private BigDecimal creditBalance;
+
+    @Column(name = "credits_id")
+    private Long creditsId;
+
+    @Column(name = "updated_on")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    private Date updatedOn = null;
+
+    public QuotaBalanceVO() {
+        super();
+    }
+
+    public QuotaBalanceVO(QuotaCreditsVO credit) {
+        super();
+        this.accountId = credit.getAccountId();
+        this.domainId = credit.getDomainId();
+        this.creditBalance = credit.getCredit();
+        this.updatedOn = credit.getUpdatedOn();
+        this.creditsId = credit.getId();
+    }
+
+    public QuotaBalanceVO(Long accountId, Long domainId, BigDecimal creditBalance, Date updatedOn) {
+        super();
+        this.accountId = accountId;
+        this.domainId = domainId;
+        this.creditBalance = creditBalance;
+        this.creditsId=0L;
+        this.updatedOn = updatedOn;
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getAccountId() {
+        return accountId;
+    }
+
+    public void setAccountId(Long accountId) {
+        this.accountId = accountId;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(Long domainId) {
+        this.domainId = domainId;
+    }
+
+    public Long getCreditsId() {
+        return creditsId;
+    }
+
+    public void setCreditsId(Long creditsId) {
+        this.creditsId = creditsId;
+    }
+
+    public BigDecimal getCreditBalance() {
+        return creditBalance;
+    }
+
+    public void setCreditBalance(BigDecimal creditBalance) {
+        this.creditBalance = creditBalance;
+    }
+
+    public Date getUpdatedOn() {
+        return updatedOn;
+    }
+
+    public void setUpdatedOn(Date updatedOn) {
+        this.updatedOn = updatedOn;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaCreditsVO.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaCreditsVO.java b/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaCreditsVO.java
new file mode 100644
index 0000000..55205bd
--- /dev/null
+++ b/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaCreditsVO.java
@@ -0,0 +1,117 @@
+//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.quota.vo;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Entity
+@Table(name = "quota_credits")
+public class QuotaCreditsVO implements InternalIdentity {
+
+    private static final long serialVersionUID = -3576833845287653210L;
+
+    @Id
+    @Column(name = "id")
+    private Long id;
+
+    @Column(name = "account_id")
+    private Long accountId = null;
+
+    @Column(name = "domain_id")
+    private Long domainId = null;
+
+    @Column(name = "credit")
+    private BigDecimal credit;
+
+    @Column(name = "updated_on")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    private Date updatedOn = null;
+
+    public QuotaCreditsVO() {
+    }
+
+    public QuotaCreditsVO(long accountId, long domainId, BigDecimal credit, long updatedBy) {
+        super();
+        this.accountId = accountId;
+        this.domainId = domainId;
+        this.credit = credit;
+        this.updatedBy = updatedBy;
+    }
+
+    public Long getAccountId() {
+        return accountId;
+    }
+
+    public void setAccountId(Long accountId) {
+        this.accountId = accountId;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(Long domainId) {
+        this.domainId = domainId;
+    }
+
+    public BigDecimal getCredit() {
+        return credit;
+    }
+
+    public void setCredit(BigDecimal credit) {
+        this.credit = credit;
+    }
+
+    public Date getUpdatedOn() {
+        return updatedOn;
+    }
+
+    public void setUpdatedOn(Date updatedOn) {
+        this.updatedOn = updatedOn;
+    }
+
+    public Long getUpdatedBy() {
+        return updatedBy;
+    }
+
+    public void setUpdatedBy(Long updatedBy) {
+        this.updatedBy = updatedBy;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    // User ID of the creditor
+    @Column(name = "updated_by")
+    private Long updatedBy = null;
+
+    @Override
+    public long getId() {
+        // TODO Auto-generated method stub
+        return this.id;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaEmailTemplatesVO.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaEmailTemplatesVO.java b/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaEmailTemplatesVO.java
new file mode 100644
index 0000000..54013fc
--- /dev/null
+++ b/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaEmailTemplatesVO.java
@@ -0,0 +1,109 @@
+//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.quota.vo;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import java.util.Date;
+
+@Entity
+@Table(name = "quota_email_templates")
+public class QuotaEmailTemplatesVO implements InternalIdentity {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private Long id;
+
+    @Column(name = "template_name")
+    private String templateName;
+
+    @Column(name = "template_subject")
+    private String templateSubject;
+
+    @Column(name = "template_body")
+    private String templateBody;
+
+    @Column(name = "locale")
+    private String locale;
+
+    @Column(name = "updated")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    private Date lastUpdated = null;
+
+    public QuotaEmailTemplatesVO() {
+    }
+
+    public QuotaEmailTemplatesVO(String templateName, String templateSubject, String templateBody) {
+        super();
+        this.templateName = templateName;
+        this.templateSubject = templateSubject;
+        this.templateBody = templateBody;
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    public String getTemplateName() {
+        return templateName;
+    }
+
+    public void setTemplateName(String templateName) {
+        this.templateName = templateName;
+    }
+
+    public String getTemplateSubject() {
+        return templateSubject;
+    }
+
+    public void setTemplateSubject(String templateSubject) {
+        this.templateSubject = templateSubject;
+    }
+
+    public String getTemplateBody() {
+        return templateBody;
+    }
+
+    public void setTemplateBody(String templateBody) {
+        this.templateBody = templateBody;
+    }
+
+    public Date getLastUpdated() {
+        return lastUpdated;
+    }
+
+    public void setLastUpdated(Date lastUpdated) {
+        this.lastUpdated = lastUpdated;
+    }
+
+    public String getLocale() {
+        return locale;
+    }
+
+    public void setLocale(String locale) {
+        this.locale = locale;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaTariffVO.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaTariffVO.java b/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaTariffVO.java
new file mode 100644
index 0000000..38a26b7
--- /dev/null
+++ b/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaTariffVO.java
@@ -0,0 +1,162 @@
+//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.quota.vo;
+
+import org.apache.cloudstack.api.InternalIdentity;
+import org.apache.cloudstack.quota.constant.QuotaTypes;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Entity
+@Table(name = "quota_tariff")
+public class QuotaTariffVO implements InternalIdentity {
+    private static final long serialVersionUID = -7117933766387653203L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private Long id;
+
+    @Column(name = "usage_type")
+    private int usageType;
+
+    @Column(name = "usage_name")
+    private String usageName;
+
+    @Column(name = "usage_unit")
+    private String usageUnit;
+
+    @Column(name = "usage_discriminator")
+    private String usageDiscriminator;
+
+    @Column(name = "currency_value")
+    private BigDecimal currencyValue;
+
+    @Column(name = "effective_on")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    private Date effectiveOn = null;
+
+    @Column(name = "updated_on")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    private Date updatedOn = null;
+
+    @Column(name = "updated_by")
+    private Long updatedBy = null;
+
+    public QuotaTariffVO() {
+    }
+
+    public QuotaTariffVO(final int usagetype, final String usagename, final String usageunit, final String usagediscriminator, final BigDecimal currencyvalue,
+            final Date effectiveOn, final Date updatedOn, final long updatedBy) {
+        this.usageType = usagetype;
+        this.usageName = usagename;
+        this.usageUnit = usageunit;
+        this.usageDiscriminator = usagediscriminator;
+        this.currencyValue = currencyvalue;
+        this.effectiveOn = effectiveOn;
+        this.updatedOn = updatedOn;
+        this.updatedBy = updatedBy;
+    }
+
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Date getEffectiveOn() {
+        return effectiveOn;
+    }
+
+    public void setEffectiveOn(Date effectiveOn) {
+        this.effectiveOn = effectiveOn;
+    }
+
+    public Date getUpdatedOn() {
+        return updatedOn;
+    }
+
+    public void setUpdatedOn(Date updatedOn) {
+        this.updatedOn = updatedOn;
+    }
+
+    public Long getUpdatedBy() {
+        return updatedBy;
+    }
+
+    public void setUpdatedBy(Long updatedBy) {
+        this.updatedBy = updatedBy;
+    }
+
+    public int getUsageType() {
+        return usageType;
+    }
+
+    public void setUsageType(int usageType) {
+        this.usageType = usageType;
+    }
+
+    public String getUsageName() {
+        return usageName;
+    }
+
+    public void setUsageName(String usageName) {
+        this.usageName = usageName;
+    }
+
+    public String getUsageUnit() {
+        return usageUnit;
+    }
+
+    public void setUsageUnit(String usageUnit) {
+        this.usageUnit = usageUnit;
+    }
+
+    public String getUsageDiscriminator() {
+        return usageDiscriminator;
+    }
+
+    public void setUsageDiscriminator(String usageDiscriminator) {
+        this.usageDiscriminator = usageDiscriminator;
+    }
+
+    public BigDecimal getCurrencyValue() {
+        return currencyValue;
+    }
+
+    public void setCurrencyValue(BigDecimal currencyValue) {
+        this.currencyValue = currencyValue;
+    }
+
+    public String getDescription() {
+        return QuotaTypes.getDescription(usageType);
+    }
+
+    @Override
+    public long getId() {
+        return this.id;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaUsageVO.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaUsageVO.java b/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaUsageVO.java
new file mode 100644
index 0000000..a82b309
--- /dev/null
+++ b/framework/quota/src/org/apache/cloudstack/quota/vo/QuotaUsageVO.java
@@ -0,0 +1,172 @@
+//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.quota.vo;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name = "quota_usage")
+public class QuotaUsageVO implements InternalIdentity {
+
+    private static final long serialVersionUID = -7117933845287204781L;
+
+    @Id
+    @Column(name = "id")
+    private Long id;
+
+    @Column(name = "zone_id")
+    private Long zoneId = null;
+
+    @Column(name = "account_id")
+    private Long accountId = null;
+
+    @Column(name = "domain_id")
+    private Long domainId = null;
+
+    @Column(name = "usage_item_id")
+    private Long usageItemId;
+
+    @Column(name = "usage_type")
+    private int usageType;
+
+    @Column(name = "quota_used")
+    private BigDecimal quotaUsed;
+
+    @Column(name = "start_date")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    private Date startDate = null;
+
+    @Column(name = "end_date")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    private Date endDate = null;
+
+    public QuotaUsageVO() {
+        usageType=-1;
+        quotaUsed = new BigDecimal(0);
+        endDate =  new Date();
+        startDate = new Date();
+    }
+
+    public QuotaUsageVO(Long usageItemId,  Long zoneId, Long accountId, Long domainId, int usageType, BigDecimal quotaUsed, Date startDate, Date endDate) {
+        super();
+        this.usageItemId = usageItemId;
+        this.zoneId = zoneId;
+        this.accountId = accountId;
+        this.domainId = domainId;
+        this.usageType = usageType;
+        this.quotaUsed = quotaUsed;
+        this.startDate = startDate;
+        this.endDate = endDate;
+    }
+
+    public QuotaUsageVO(QuotaUsageVO toclone) {
+        super();
+        this.usageItemId = toclone.usageItemId;
+        this.zoneId = toclone.zoneId;
+        this.accountId = toclone.accountId;
+        this.domainId = toclone.domainId;
+        this.usageType = toclone.usageType;
+        this.quotaUsed = toclone.quotaUsed;
+        this.startDate = toclone.startDate;
+        this.endDate = toclone.endDate;
+    }
+
+    public Long getZoneId() {
+        return zoneId;
+    }
+
+    public void setZoneId(Long zoneId) {
+        this.zoneId = zoneId;
+    }
+
+    public Long getAccountId() {
+        return accountId;
+    }
+
+    public void setAccountId(Long accountId) {
+        this.accountId = accountId;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(Long domainId) {
+        this.domainId = domainId;
+    }
+
+    @Override
+    public long getId() {
+        // TODO Auto-generated method stub
+        return id;
+    }
+
+    public Long getUsageItemId() {
+        return usageItemId;
+    }
+
+    public void setUsageItemId(Long usageItemId) {
+        this.usageItemId = usageItemId;
+    }
+
+    public int getUsageType() {
+        return usageType;
+    }
+
+    public void setUsageType(int usageType) {
+        this.usageType = usageType;
+    }
+
+    public BigDecimal getQuotaUsed() {
+        return quotaUsed;
+    }
+
+    public void setQuotaUsed(BigDecimal quotaUsed) {
+        this.quotaUsed = quotaUsed;
+    }
+
+    public Date getStartDate() {
+        return startDate;
+    }
+
+    public void setStartDate(Date startDate) {
+        this.startDate = startDate;
+    }
+
+    public Date getEndDate() {
+        return endDate;
+    }
+
+    public void setEndDate(Date endDate) {
+        this.endDate = endDate;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/framework/quota/src/org/apache/cloudstack/quota/vo/ServiceOfferingVO.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/vo/ServiceOfferingVO.java b/framework/quota/src/org/apache/cloudstack/quota/vo/ServiceOfferingVO.java
new file mode 100644
index 0000000..2883fbc
--- /dev/null
+++ b/framework/quota/src/org/apache/cloudstack/quota/vo/ServiceOfferingVO.java
@@ -0,0 +1,336 @@
+//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.quota.vo;
+
+import java.util.Map;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import com.cloud.offering.ServiceOffering;
+import com.cloud.storage.DiskOfferingVO;
+import com.cloud.storage.Storage.ProvisioningType;
+import com.cloud.vm.VirtualMachine;
+
+@Entity
+@Table(name = "service_offering")
+@DiscriminatorValue(value = "Service")
+@PrimaryKeyJoinColumn(name = "id")
+public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering {
+ @Column(name = "cpu")
+ private Integer cpu;
+
+ @Column(name = "speed")
+ private Integer speed;
+
+ @Column(name = "ram_size")
+ private Integer ramSize;
+
+ @Column(name = "nw_rate")
+ private Integer rateMbps;
+
+ @Column(name = "mc_rate")
+ private Integer multicastRateMbps;
+
+ @Column(name = "ha_enabled")
+ private boolean offerHA;
+
+ @Column(name = "limit_cpu_use")
+ private boolean limitCpuUse;
+
+ @Column(name = "is_volatile")
+ private boolean volatileVm;
+
+ @Column(name = "host_tag")
+ private String hostTag;
+
+ @Column(name = "default_use")
+ private boolean defaultUse;
+
+ @Column(name = "vm_type")
+ private String vmType;
+
+ @Column(name = "sort_key")
+ int sortKey;
+
+ @Column(name = "deployment_planner")
+ private String deploymentPlanner = null;
+
+ // This is a delayed load value.  If the value is null,
+ // then this field has not been loaded yet.
+ // Call service offering dao to load it.
+ @Transient
+ Map<String, String> details;
+
+ // This flag is required to tell if the offering is dynamic once the cpu, memory and speed are set.
+ // In some cases cpu, memory and speed are set to non-null values even if the offering is dynamic.
+ @Transient
+ boolean isDynamic;
+
+ protected ServiceOfferingVO() {
+     super();
+ }
+
+ public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText,
+         ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vmType, boolean defaultUse) {
+     super(name, displayText, provisioningType, false, tags, recreatable, useLocalStorage, systemUse, true);
+     this.cpu = cpu;
+     this.ramSize = ramSize;
+     this.speed = speed;
+     this.rateMbps = rateMbps;
+     this.multicastRateMbps = multicastRateMbps;
+     this.offerHA = offerHA;
+     limitCpuUse = false;
+     volatileVm = false;
+     this.defaultUse = defaultUse;
+     this.vmType = vmType == null ? null : vmType.toString().toLowerCase();
+ }
+
+ public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, boolean limitCpuUse,
+         boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vmType, Long domainId) {
+     super(name, displayText, provisioningType, false, tags, recreatable, useLocalStorage, systemUse, true, domainId);
+     this.cpu = cpu;
+     this.ramSize = ramSize;
+     this.speed = speed;
+     this.rateMbps = rateMbps;
+     this.multicastRateMbps = multicastRateMbps;
+     this.offerHA = offerHA;
+     this.limitCpuUse = limitCpuUse;
+     this.volatileVm = volatileVm;
+     this.vmType = vmType == null ? null : vmType.toString().toLowerCase();
+ }
+
+ public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA,
+         boolean limitResourceUse, boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse,
+         VirtualMachine.Type vmType, Long domainId, String hostTag) {
+     this(name,
+         cpu,
+         ramSize,
+         speed,
+         rateMbps,
+         multicastRateMbps,
+         offerHA,
+         limitResourceUse,
+         volatileVm,
+         displayText,
+         provisioningType,
+         useLocalStorage,
+         recreatable,
+         tags,
+         systemUse,
+         vmType,
+         domainId);
+     this.hostTag = hostTag;
+ }
+
+ public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA,
+         boolean limitResourceUse, boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse,
+         VirtualMachine.Type vmType, Long domainId, String hostTag, String deploymentPlanner) {
+     this(name,
+         cpu,
+         ramSize,
+         speed,
+         rateMbps,
+         multicastRateMbps,
+         offerHA,
+         limitResourceUse,
+         volatileVm,
+         displayText,
+         provisioningType,
+         useLocalStorage,
+         recreatable,
+         tags,
+         systemUse,
+         vmType,
+         domainId,
+         hostTag);
+     this.deploymentPlanner = deploymentPlanner;
+ }
+
+ public ServiceOfferingVO(ServiceOfferingVO offering) {
+     super(offering.getId(),
+         offering.getName(),
+         offering.getDisplayText(),
+         offering.getProvisioningType(),
+         false,
+         offering.getTags(),
+         offering.isRecreatable(),
+         offering.getUseLocalStorage(),
+         offering.getSystemUse(),
+         true,
+         offering.isCustomizedIops()== null ? false:offering.isCustomizedIops(),
+         offering.getDomainId(),
+         offering.getMinIops(),
+         offering.getMaxIops());
+     cpu = offering.getCpu();
+     ramSize = offering.getRamSize();
+     speed = offering.getSpeed();
+     rateMbps = offering.getRateMbps();
+     multicastRateMbps = offering.getMulticastRateMbps();
+     offerHA = offering.getOfferHA();
+     limitCpuUse = offering.getLimitCpuUse();
+     volatileVm = offering.getVolatileVm();
+     hostTag = offering.getHostTag();
+     vmType = offering.getSystemVmType();
+ }
+
+ @Override
+ public boolean getOfferHA() {
+     return offerHA;
+ }
+
+ public void setOfferHA(boolean offerHA) {
+     this.offerHA = offerHA;
+ }
+
+ @Override
+ public boolean getLimitCpuUse() {
+     return limitCpuUse;
+ }
+
+ public void setLimitResourceUse(boolean limitCpuUse) {
+     this.limitCpuUse = limitCpuUse;
+ }
+
+ @Override
+ public boolean getDefaultUse() {
+     return defaultUse;
+ }
+
+ @Override
+ @Transient
+ public String[] getTagsArray() {
+     String tags = getTags();
+     if (tags == null || tags.length() == 0) {
+         return new String[0];
+     }
+
+     return tags.split(",");
+ }
+
+ @Override
+ public Integer getCpu() {
+     return cpu;
+ }
+
+ public void setCpu(int cpu) {
+     this.cpu = cpu;
+ }
+
+ public void setSpeed(int speed) {
+     this.speed = speed;
+ }
+
+ public void setRamSize(int ramSize) {
+     this.ramSize = ramSize;
+ }
+
+ @Override
+ public Integer getSpeed() {
+     return speed;
+ }
+
+ @Override
+ public Integer getRamSize() {
+     return ramSize;
+ }
+
+ public void setRateMbps(Integer rateMbps) {
+     this.rateMbps = rateMbps;
+ }
+
+ @Override
+ public Integer getRateMbps() {
+     return rateMbps;
+ }
+
+ public void setMulticastRateMbps(Integer multicastRateMbps) {
+     this.multicastRateMbps = multicastRateMbps;
+ }
+
+ @Override
+ public Integer getMulticastRateMbps() {
+     return multicastRateMbps;
+ }
+
+ public void setHostTag(String hostTag) {
+     this.hostTag = hostTag;
+ }
+
+ @Override
+ public String getHostTag() {
+     return hostTag;
+ }
+
+ @Override
+ public String getSystemVmType() {
+     return vmType;
+ }
+
+ @Override
+ public void setSortKey(int key) {
+     sortKey = key;
+ }
+
+ @Override
+ public int getSortKey() {
+     return sortKey;
+ }
+
+ @Override
+ public boolean getVolatileVm() {
+     return volatileVm;
+ }
+
+ @Override
+ public String getDeploymentPlanner() {
+     return deploymentPlanner;
+ }
+
+ public Map<String, String> getDetails() {
+     return details;
+ }
+
+ public String getDetail(String name) {
+     assert (details != null) : "Did you forget to load the details?";
+
+     return details != null ? details.get(name) : null;
+ }
+
+ public void setDetail(String name, String value) {
+     assert (details != null) : "Did you forget to load the details?";
+
+     details.put(name, value);
+ }
+
+ public void setDetails(Map<String, String> details) {
+     this.details = details;
+ }
+
+ @Override
+ public boolean isDynamic() {
+     return cpu == null || speed == null || ramSize == null || isDynamic;
+ }
+
+ public void setDynamicFlag(boolean isdynamic) {
+     isDynamic = isdynamic;
+ }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/framework/quota/src/org/apache/cloudstack/quota/vo/UserVmDetailVO.java
----------------------------------------------------------------------
diff --git a/framework/quota/src/org/apache/cloudstack/quota/vo/UserVmDetailVO.java b/framework/quota/src/org/apache/cloudstack/quota/vo/UserVmDetailVO.java
new file mode 100644
index 0000000..debec6c
--- /dev/null
+++ b/framework/quota/src/org/apache/cloudstack/quota/vo/UserVmDetailVO.java
@@ -0,0 +1,83 @@
+//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.quota.vo;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.ResourceDetail;
+
+@Entity
+@Table(name = "user_vm_details")
+public class UserVmDetailVO implements ResourceDetail {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private long id;
+
+ @Column(name = "vm_id")
+ private long resourceId;
+
+ @Column(name = "name")
+ private String name;
+
+ @Column(name = "value", length = 5120)
+ private String value;
+
+ @Column(name = "display")
+ private boolean display = true;
+
+ public UserVmDetailVO() {
+ }
+
+ public UserVmDetailVO(long vmId, String name, String value, boolean display) {
+     this.resourceId = vmId;
+     this.name = name;
+     this.value = value;
+     this.display = display;
+ }
+
+ @Override
+ public long getId() {
+     return id;
+ }
+
+ @Override
+ public String getName() {
+     return name;
+ }
+
+ @Override
+ public String getValue() {
+     return value;
+ }
+
+ @Override
+ public long getResourceId() {
+     return resourceId;
+ }
+
+ @Override
+ public boolean isDisplay() {
+     return display;
+ }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/plugins/database/quota/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/database/quota/pom.xml b/plugins/database/quota/pom.xml
new file mode 100644
index 0000000..bd1ee43
--- /dev/null
+++ b/plugins/database/quota/pom.xml
@@ -0,0 +1,58 @@
+<!-- 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. -->
+<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>
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/plugins/database/quota/resources/META-INF/cloudstack/quota/module.properties
----------------------------------------------------------------------
diff --git a/plugins/database/quota/resources/META-INF/cloudstack/quota/module.properties b/plugins/database/quota/resources/META-INF/cloudstack/quota/module.properties
new file mode 100644
index 0000000..7332f15
--- /dev/null
+++ b/plugins/database/quota/resources/META-INF/cloudstack/quota/module.properties
@@ -0,0 +1,18 @@
+# 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.
+name=quota
+parent=api

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/plugins/database/quota/resources/META-INF/cloudstack/quota/spring-quota-context.xml
----------------------------------------------------------------------
diff --git a/plugins/database/quota/resources/META-INF/cloudstack/quota/spring-quota-context.xml b/plugins/database/quota/resources/META-INF/cloudstack/quota/spring-quota-context.xml
new file mode 100644
index 0000000..15bc144
--- /dev/null
+++ b/plugins/database/quota/resources/META-INF/cloudstack/quota/spring-quota-context.xml
@@ -0,0 +1,31 @@
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
+    xmlns:aop="http://www.springframework.org/schema/aop"
+    xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+                      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+                      http://www.springframework.org/schema/context
+                      http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+    <bean id="QuotaService" class="org.apache.cloudstack.quota.QuotaServiceImpl" />
+    <bean id="QuotaResponseBuilder" class="org.apache.cloudstack.api.response.QuotaResponseBuilderImpl"/>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/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
new file mode 100644
index 0000000..ddf6f05
--- /dev/null
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java
@@ -0,0 +1,136 @@
+//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.api.command;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.AccountResponse;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.QuotaBalanceResponse;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
+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)
+public class QuotaBalanceCmd extends BaseCmd {
+
+    public static final Logger s_logger = Logger.getLogger(QuotaBalanceCmd.class.getName());
+
+    private static final String s_name = "quotabalanceresponse";
+
+    @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = true, description = "Optional, Account Id for which statement needs to be generated")
+    private String accountName;
+
+    @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, required = true, entityType = DomainResponse.class, description = "Optional, If domain Id is given and the caller is domain admin then the statement is generated for domain.")
+    private Long domainId;
+
+    @Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, description = "End date range for quota query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-03.")
+    private Date endDate;
+
+    @Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, description = "Start date range quota query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-01.")
+    private Date startDate;
+
+    @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "List usage records for the specified account")
+    private Long accountId;
+
+    @Inject
+    QuotaResponseBuilder _responseBuilder;
+
+    public Long getAccountId() {
+        return accountId;
+    }
+
+    public void setAccountId(Long accountId) {
+        this.accountId = accountId;
+    }
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    public void setAccountName(String accountName) {
+        this.accountName = accountName;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(Long domainId) {
+        this.domainId = domainId;
+    }
+
+    public Date getEndDate() {
+        return endDate == null ? null : _responseBuilder.startOfNextDay(endDate);
+    }
+
+    public void setEndDate(Date endDate) {
+        this.endDate = endDate;
+    }
+
+    public Date getStartDate() {
+        return startDate;
+    }
+
+    public void setStartDate(Date startDate) {
+        this.startDate = startDate;
+    }
+
+    public QuotaBalanceCmd() {
+        super();
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Long accountId = _accountService.getActiveAccountByName(accountName, domainId).getAccountId();
+        if (accountId == null) {
+            return CallContext.current().getCallingAccount().getId();
+        }
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute() {
+        List<QuotaBalanceVO> quotaUsage = _responseBuilder.getQuotaBalance(this);
+
+        QuotaBalanceResponse response;
+        if (getEndDate() == null) {
+            response = _responseBuilder.createQuotaLastBalanceResponse(quotaUsage, startDate);
+        } else {
+            response = _responseBuilder.createQuotaBalanceResponse(quotaUsage, startDate, endDate);
+        }
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/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
new file mode 100644
index 0000000..1a7db81
--- /dev/null
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaCreditsCmd.java
@@ -0,0 +1,143 @@
+//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.api.command;
+
+import com.cloud.user.Account;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.QuotaCreditsResponse;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.quota.QuotaService;
+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)
+public class QuotaCreditsCmd extends BaseCmd {
+
+    @Inject
+    QuotaResponseBuilder _responseBuilder;
+
+    @Inject
+    QuotaService _quotaService;
+
+    public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class.getName());
+
+    private static final String s_name = "quotacreditsresponse";
+
+    @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = true, description = "Account Id for which quota credits need to be added")
+    private String accountName;
+
+    @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, required = true, entityType = DomainResponse.class, description = "Domain for which quota credits need to be added")
+    private Long domainId;
+
+    @Parameter(name = ApiConstants.VALUE, type = CommandType.DOUBLE, required = true, description = "Value of the credits to be added+, subtracted-")
+    private Double value;
+
+    @Parameter(name = "min_balance", type = CommandType.DOUBLE, required = false, description = "Minimum balance threshold of the account")
+    private Double minBalance;
+
+    @Parameter(name = "quota_enforce", type = CommandType.BOOLEAN, required = false, description = "Account for which quota enforce is set to false will not be locked when there is no credit balance")
+    private Boolean quotaEnforce;
+
+    public Double getMinBalance() {
+        return minBalance;
+    }
+
+    public void setMinBalance(Double minBalance) {
+        this.minBalance = minBalance;
+    }
+
+    public Boolean getQuotaEnforce() {
+        return quotaEnforce;
+    }
+
+    public void setQuotaEnforce(Boolean quotaEnforce) {
+        this.quotaEnforce = quotaEnforce;
+    }
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    public void setAccountName(String accountName) {
+        this.accountName = accountName;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(Long domainId) {
+        this.domainId = domainId;
+    }
+
+    public Double getValue() {
+        return value;
+    }
+
+    public void setValue(Double value) {
+        this.value = value;
+    }
+
+    public QuotaCreditsCmd() {
+        super();
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute() {
+        Long accountId = _accountService.getActiveAccountByName(accountName, domainId).getAccountId();
+        if (accountId == null) {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "The account does not exists or has been removed/disabled");
+        }
+        if (value == null) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Please send a valid non-empty quota value");
+        }
+        if (getQuotaEnforce() != null) {
+            _quotaService.setLockAccount(accountId, getQuotaEnforce());
+        }
+        if (getMinBalance() != null) {
+            _quotaService.setMinBalance(accountId, getMinBalance());
+        }
+        else {
+            _quotaService.setMinBalance(accountId, 0.2 * value);
+        }
+
+        final QuotaCreditsResponse response = _responseBuilder.addQuotaCredits(accountId, domainId, value, CallContext.current().getCallingUserId());
+        response.setResponseName(getCommandName());
+        response.setObjectName("quotacredits");
+        setResponseObject(response);
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateListCmd.java
----------------------------------------------------------------------
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateListCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateListCmd.java
new file mode 100644
index 0000000..e2985fe
--- /dev/null
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateListCmd.java
@@ -0,0 +1,56 @@
+//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.api.command;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.QuotaEmailTemplateResponse;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+
+@APICommand(name = "quotaEmailTemplateList", responseObject = QuotaEmailTemplateResponse.class, description = "Lists all quota email templates", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class QuotaEmailTemplateListCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(QuotaEmailTemplateListCmd.class.getName());
+    private static final String s_name = "quotaemailtemplatelistresponse";
+
+    @Inject
+    QuotaResponseBuilder _quotaResponseBuilder;
+
+    @Parameter(name = "templatetype", type = CommandType.STRING, description = "List by type of the quota email template, allowed types: QUOTA_LOW, QUOTA_EMPTY")
+    private String templateName;
+
+    public String getTemplateName() {
+        return templateName;
+    }
+
+    @Override
+    public void execute() {
+        final ListResponse<QuotaEmailTemplateResponse> response = new ListResponse<QuotaEmailTemplateResponse>();
+        response.setResponses(_quotaResponseBuilder.listQuotaEmailTemplates(this));
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/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
new file mode 100644
index 0000000..df08d91
--- /dev/null
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateUpdateCmd.java
@@ -0,0 +1,111 @@
+//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.api.command;
+
+import com.cloud.user.Account;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.quota.constant.QuotaConfig;
+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)
+public class QuotaEmailTemplateUpdateCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(QuotaEmailTemplateUpdateCmd.class.getName());
+    private static final String s_name = "quotaemailtemplateupdateresponse";
+
+    @Inject
+    QuotaResponseBuilder _quotaResponseBuilder;
+
+    @Parameter(name = "templatetype", type = CommandType.STRING, required=true, description = "Type of the quota email template, allowed types: QUOTA_LOW, QUOTA_EMPTY")
+    private String templateName;
+
+    @Parameter(name = "templatesubject", type = CommandType.STRING, required=true, description = "The quota email template subject, max: 77 characters", length = 77)
+    private String templateSubject;
+
+    @Parameter(name = "templatebody", type = CommandType.STRING, required=true, description = "The quota email template body, max: 500k characters", length = 512000)
+    private String templateBody;
+
+    @Parameter(name = "locale", type = CommandType.STRING, description = "The locale of the email text")
+    private String locale;
+
+    @Override
+    public void execute() {
+        final String templateName = getTemplateName();
+        if (templateName == null || getTemplateSubject() == null || getTemplateBody() == null) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Failed to update quota email template due to empty or invalid template name or text");
+        }
+
+        boolean isValidTemplateName = false;
+        for (QuotaConfig.QuotaEmailTemplateTypes e: QuotaConfig.QuotaEmailTemplateTypes.values()) {
+            if (e.toString().equalsIgnoreCase(templateName)) {
+                isValidTemplateName = true;
+                setTemplateName(e.toString());
+                break;
+            }
+        }
+        if (!isValidTemplateName) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid quota email template type, allowed values are: " + Arrays.toString(QuotaConfig.QuotaEmailTemplateTypes.values()));
+        }
+
+        if (!_quotaResponseBuilder.updateQuotaEmailTemplate(this)) {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to update quota email template due to an internal error");
+        }
+        final SuccessResponse response = new SuccessResponse();
+        response.setResponseName(getCommandName());
+        response.setSuccess(true);
+        setResponseObject(response);
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    private void setTemplateName(String templateName) {
+        this.templateName = templateName;
+    }
+
+    public String getTemplateName() {
+        return templateName;
+    }
+
+    public String getTemplateSubject() {
+        return templateSubject;
+    }
+
+    public String getTemplateBody() {
+        return templateBody;
+    }
+
+    public String getLocale() {
+        return locale;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/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
new file mode 100644
index 0000000..5d38d3d
--- /dev/null
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java
@@ -0,0 +1,143 @@
+//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.api.command;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.AccountResponse;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.api.response.QuotaStatementResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.quota.vo.QuotaUsageVO;
+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)
+public class QuotaStatementCmd extends BaseCmd {
+
+    public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class.getName());
+
+    private static final String s_name = "quotastatementresponse";
+
+    @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = true, description = "Optional, Account Id for which statement needs to be generated")
+    private String accountName;
+
+    @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, required = true, entityType = DomainResponse.class, description = "Optional, If domain Id is given and the caller is domain admin then the statement is generated for domain.")
+    private Long domainId;
+
+    @Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, required = true, description = "End date range for quota query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-03.")
+    private Date endDate;
+
+    @Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, required = true, description = "Start date range quota query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-01.")
+    private Date startDate;
+
+    @Parameter(name = ApiConstants.TYPE, type = CommandType.INTEGER, description = "List quota usage records for the specified usage type")
+    private Integer usageType;
+
+    @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "List usage records for the specified account")
+    private Long accountId;
+
+    @Inject
+    QuotaResponseBuilder _responseBuilder;
+
+    public Long getAccountId() {
+        return accountId;
+    }
+
+    public void setAccountId(Long accountId) {
+        this.accountId = accountId;
+    }
+
+    public Integer getUsageType() {
+        return usageType;
+    }
+
+    public void setUsageType(Integer usageType) {
+        this.usageType = usageType;
+    }
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    public void setAccountName(String accountName) {
+        this.accountName = accountName;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(Long domainId) {
+        this.domainId = domainId;
+    }
+
+    public Date getEndDate() {
+        return _responseBuilder.startOfNextDay(endDate == null ? new Date() : endDate);
+    }
+
+    public void setEndDate(Date endDate) {
+        this.endDate = endDate;
+    }
+
+    public Date getStartDate() {
+        return startDate;
+    }
+
+    public void setStartDate(Date startDate) {
+        this.startDate = startDate;
+    }
+
+    public QuotaStatementCmd() {
+        super();
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Long accountId = _accountService.getActiveAccountByName(accountName, domainId).getAccountId();
+        if (accountId == null) {
+            return CallContext.current().getCallingAccount().getId();
+        }
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute() {
+        List<QuotaUsageVO> quotaUsage = _responseBuilder.getQuotaUsage(this);
+
+        QuotaStatementResponse response = _responseBuilder.createQuotaStatementResponse(quotaUsage);
+
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/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
new file mode 100644
index 0000000..121873f
--- /dev/null
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffListCmd.java
@@ -0,0 +1,93 @@
+//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.api.command;
+
+import com.cloud.user.Account;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.api.response.QuotaTariffResponse;
+import org.apache.cloudstack.quota.vo.QuotaTariffVO;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@APICommand(name = "quotaTariffList", responseObject = QuotaTariffResponse.class, description = "Lists all quota tariff plans", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class QuotaTariffListCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(QuotaTariffListCmd.class.getName());
+    private static final String s_name = "quotatarifflistresponse";
+
+    @Inject
+    QuotaResponseBuilder _responseBuilder;
+
+    @Parameter(name = ApiConstants.USAGE_TYPE, type = CommandType.INTEGER, required = false, description = "Usage type of the resource")
+    private Integer usageType;
+
+    @Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, required = false, description = "The effective start date on/after which the quota tariff is effective and older tariffs are no longer used for the usage type. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-03.")
+    private Date effectiveDate;
+
+    public QuotaTariffListCmd() {
+        super();
+    }
+
+    @Override
+    public void execute() {
+        final List<QuotaTariffVO> result = _responseBuilder.listQuotaTariffPlans(this);
+
+        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());
+            responses.add(_responseBuilder.createQuotaTariffResponse(resource));
+        }
+
+        final ListResponse<QuotaTariffResponse> response = new ListResponse<QuotaTariffResponse>();
+        response.setResponses(responses);
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    public Date getEffectiveDate() {
+        return effectiveDate;
+    }
+
+    public Integer getUsageType() {
+        return usageType;
+    }
+
+    public void setUsageType(Integer usageType) {
+        this.usageType = usageType;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dedb351f/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffUpdateCmd.java
----------------------------------------------------------------------
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffUpdateCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffUpdateCmd.java
new file mode 100644
index 0000000..0af3ab8
--- /dev/null
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffUpdateCmd.java
@@ -0,0 +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.
+package org.apache.cloudstack.api.command;
+
+import com.cloud.user.Account;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.api.response.QuotaTariffResponse;
+import org.apache.cloudstack.quota.vo.QuotaTariffVO;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+
+import java.util.Date;
+
+@APICommand(name = "quotaTariffUpdate", responseObject = QuotaTariffResponse.class, description = "Update the tariff plan for a resource", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class QuotaTariffUpdateCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(QuotaTariffUpdateCmd.class.getName());
+    private static final String s_name = "quotatariffupdateresponse";
+
+    @Inject
+    QuotaResponseBuilder _responseBuilder;
+
+    @Parameter(name = ApiConstants.USAGE_TYPE, type = CommandType.INTEGER, required = true, description = "Integer value for the usage type of the resource")
+    private Integer usageType;
+
+    @Parameter(name = "value", type = CommandType.DOUBLE, required = true,  description = "The quota tariff value of the resource as per the default unit")
+    private Double value;
+
+    @Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, required = true, description = "The effective start date on/after which the quota tariff is effective and older tariffs are no longer used for the usage type. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-03.")
+    private Date startDate;
+
+    public int getUsageType() {
+        return usageType;
+    }
+
+    public void setUsageType(int usageType) {
+        this.usageType = usageType;
+    }
+
+    public Double getValue() {
+        return value;
+    }
+
+    public void setValue(Double value) {
+        this.value = value;
+    }
+
+    public Date getStartDate() {
+        return startDate;
+    }
+
+    public void setStartDate(Date startDate) {
+        this.startDate = startDate;
+    }
+
+    public QuotaTariffUpdateCmd() {
+        super();
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute() {
+        final QuotaTariffVO result = _responseBuilder.updateQuotaTariffPlan(this);
+        if (result == null) {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update quota tariff plan");
+        }
+        final QuotaTariffResponse response = _responseBuilder.createQuotaTariffResponse(result);
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+}


Mime
View raw message