diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 637950261c6..c817cb9d271 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -783,8 +783,9 @@ listOpenDaylightControllers=1
addGloboDnsHost=1
### Quota Service
-listQuotaConfigurations=15
-quotaEditResourceMapping=15
+quotaTypes=15
+quotaMapping=15
+quotaEditMapping=15
quotaRefresh=15
quotaCredits=15
quotaStatement=15
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
index 18318c6fabf..628324c67be 100644
--- 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
@@ -26,6 +26,7 @@
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
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 6b408d3519a..812b5481aa4 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
@@ -28,21 +28,21 @@ import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.QuotaCreditsResponse;
import org.apache.cloudstack.context.CallContext;
-import org.apache.cloudstack.quota.QuotaManager;
+import org.apache.cloudstack.quota.QuotaDBUtilsImpl;
import com.cloud.user.Account;
@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
+ QuotaDBUtilsImpl _quotaDBUtils;
+
public static final Logger s_logger = Logger
.getLogger(QuotaStatementCmd.class.getName());
private static final String s_name = "quotacreditsresponse";
- @Inject
- private QuotaManager _quotaManager;
-
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "Account Id for which quota credits need to be added")
private String accountName;
@@ -80,9 +80,9 @@ public class QuotaCreditsCmd extends BaseCmd {
super();
}
- public QuotaCreditsCmd(final QuotaManager quotaManager) {
+ public QuotaCreditsCmd(final QuotaDBUtilsImpl quotaDBUtils) {
super();
- _quotaManager = quotaManager;
+ _quotaDBUtils = quotaDBUtils;
}
@Override
@@ -99,7 +99,7 @@ public class QuotaCreditsCmd extends BaseCmd {
"The account does not exists or has been removed/disabled");
}
- final QuotaCreditsResponse credit_response = _quotaManager
+ final QuotaCreditsResponse credit_response = _quotaDBUtils
.addQuotaCredits(accountId, domainId, value, CallContext
.current().getCallingAccount().getId());
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEditMappingCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEditMappingCmd.java
new file mode 100644
index 00000000000..73a66aa74e7
--- /dev/null
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEditMappingCmd.java
@@ -0,0 +1,106 @@
+//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.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
+import org.apache.cloudstack.api.response.QuotaCreditsResponse;
+import org.apache.cloudstack.quota.QuotaConfigurationVO;
+import org.apache.cloudstack.quota.QuotaDBUtilsImpl;
+
+import com.cloud.user.Account;
+import com.cloud.utils.Pair;
+
+@APICommand(name = "quotaEditMapping", responseObject = QuotaCreditsResponse.class, description = "Edit the mapping for a resource", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class QuotaEditMappingCmd extends BaseCmd {
+
+ public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class.getName());
+
+ private static final String s_name = "quotaconfigurationresponse";
+
+ @Inject
+ QuotaDBUtilsImpl _quotaDBUtils;
+
+ @Parameter(name = "type", type = CommandType.STRING, required = false, description = "Usage type of the resource")
+ private String usageType;
+
+ @Parameter(name = "value", type = CommandType.INTEGER, entityType = DomainResponse.class, description = "The quota vale of the resource as per the default unit")
+ private Integer value;
+
+ public String getUsageType() {
+ return usageType;
+ }
+
+ public void setUsageType(String usageType) {
+ this.usageType = usageType;
+ }
+
+ public Integer getValue() {
+ return value;
+ }
+
+ public void setValue(Integer value) {
+ this.value = value;
+ }
+
+ public QuotaEditMappingCmd() {
+ super();
+ }
+
+ public QuotaEditMappingCmd(final QuotaDBUtilsImpl quotaDBUtils) {
+ super();
+ _quotaDBUtils = quotaDBUtils;
+ }
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public void execute() {
+ final Pair, Integer> result = _quotaDBUtils.editQuotaMapping(this);
+
+ final List responses = new ArrayList();
+ for (final QuotaConfigurationVO resource : result.first()) {
+ final QuotaConfigurationResponse configurationResponse = _quotaDBUtils.createQuotaConfigurationResponse(resource);
+ configurationResponse.setObjectName("QuotaConfiguration");
+ responses.add(configurationResponse);
+ }
+
+ final ListResponse response = new ListResponse();
+ response.setResponses(responses, responses.size());
+ response.setResponseName(getCommandName());
+ setResponseObject(response);
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEditResourceMappingCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEditResourceMappingCmd.java
deleted file mode 100644
index f257dc9e379..00000000000
--- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEditResourceMappingCmd.java
+++ /dev/null
@@ -1,112 +0,0 @@
-//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.ArrayList;
-import java.util.List;
-
-import javax.inject.Inject;
-
-import org.apache.log4j.Logger;
-import org.apache.cloudstack.api.APICommand;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.response.DomainResponse;
-import org.apache.cloudstack.api.response.ListResponse;
-import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
-import org.apache.cloudstack.api.response.QuotaCreditsResponse;
-import org.apache.cloudstack.quota.QuotaConfigurationVO;
-import org.apache.cloudstack.quota.QuotaManager;
-
-import com.cloud.user.Account;
-import com.cloud.utils.Pair;
-
-@APICommand(name = "quotaEditResourceMapping", responseObject = QuotaCreditsResponse.class, description = "Edit the mapping for a resource", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
-public class QuotaEditResourceMappingCmd extends BaseCmd {
-
-
-public static final Logger s_logger = Logger
- .getLogger(QuotaStatementCmd.class.getName());
-
- private static final String s_name = "quotaconfigurationresponse";
-
-
- @Parameter(name = "type", type = CommandType.STRING, required = false, description = "Usage type of the resource")
- private String usageType;
-
- @Parameter(name = "value", type = CommandType.INTEGER, entityType = DomainResponse.class, description = "The quota vale of the resource as per the default unit")
- private Integer value;
-
- @Inject
- private QuotaManager _quotaManager;
-
-
- public String getUsageType() {
- return usageType;
- }
-
- public void setUsageType(String usageType) {
- this.usageType = usageType;
- }
-
- public Integer getValue() {
- return value;
- }
-
- public void setValue(Integer value) {
- this.value = value;
- }
-
-
- public QuotaEditResourceMappingCmd() {
- super();
- }
-
- public QuotaEditResourceMappingCmd(final QuotaManager quotaManager) {
- super();
- _quotaManager = quotaManager;
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public void execute() {
- final Pair, Integer> result = _quotaManager.editQuotaMapping(this);
-
- final List responses = new ArrayList();
- for (final QuotaConfigurationVO resource : result.first()) {
- final QuotaConfigurationResponse configurationResponse = _quotaManager.createQuotaConfigurationResponse(resource);
- configurationResponse.setObjectName("QuotaConfiguration");
- responses.add(configurationResponse);
- }
-
- final ListResponse response = new ListResponse();
- response.setResponses(responses, responses.size());
- response.setResponseName(getCommandName());
- setResponseObject(response);
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
-
-}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateAddCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateAddCmd.java
index a66510cce6b..17458e7a1c7 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateAddCmd.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateAddCmd.java
@@ -16,91 +16,67 @@
//under the License.
package org.apache.cloudstack.api.command;
-import javax.inject.Inject;
-
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.quota.QuotaManager;
import org.apache.cloudstack.api.response.QuotaEmailTemplateResponse;
@APICommand(name = "quotaEmailTemplateAdd", responseObject = QuotaEmailTemplateResponse.class, description = "Add a new email template", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class QuotaEmailTemplateAddCmd extends BaseListCmd {
-public static final Logger s_logger = Logger
- .getLogger(QuotaEmailTemplateAddCmd.class.getName());
+ public static final Logger s_logger = Logger.getLogger(QuotaEmailTemplateAddCmd.class.getName());
-private static final String s_name = "quotaemailtemplateresponse";
+ private static final String s_name = "quotaemailtemplateresponse";
-@Inject
-private QuotaManager _quotaManager;
+ @Parameter(name = "templatename", type = CommandType.STRING, description = "The name of email template")
+ private String templateName;
-@Parameter(name = "templatename", type = CommandType.STRING, description = "The name of email template")
-private String templateName;
+ @Parameter(name = "templatetext", type = CommandType.STRING, description = "The text of the email")
+ private Long templateText;
-@Parameter(name = "templatetext", type = CommandType.STRING, description = "The text of the email")
-private Long templateText;
+ @Parameter(name = "locale", type = CommandType.STRING, description = "The locale of the email text")
+ private Integer locale;
-@Parameter(name = "locale", type = CommandType.STRING, description = "The locale of the email text")
-private Integer locale;
+ public QuotaEmailTemplateAddCmd() {
+ super();
+ }
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+ @Override
+ public void execute() {
-public QuotaEmailTemplateAddCmd() {
- super();
-}
+ final QuotaEmailTemplateResponse templResponse = null;
+ setResponseObject(templResponse);
+ }
-public QuotaEmailTemplateAddCmd(final QuotaManager quotaManager) {
- super();
- _quotaManager = quotaManager;
-}
+ public String getTemplateName() {
+ return templateName;
+ }
+ public void setTemplateName(String templateName) {
+ this.templateName = templateName;
+ }
-@Override
-public String getCommandName() {
- return s_name;
-}
+ public Long getTemplateText() {
+ return templateText;
+ }
+ public void setTemplateText(Long templateText) {
+ this.templateText = templateText;
+ }
-@Override
-public void execute() {
-
- final QuotaEmailTemplateResponse templResponse = null;
-
- setResponseObject(templResponse);
-}
-
-
-public String getTemplateName() {
- return templateName;
-}
-
-
-public void setTemplateName(String templateName) {
- this.templateName = templateName;
-}
-
-
-public Long getTemplateText() {
- return templateText;
-}
-
-
-public void setTemplateText(Long templateText) {
- this.templateText = templateText;
-}
-
-
-public Integer getLocale() {
- return locale;
-}
-
-
-public void setLocale(Integer locale) {
- this.locale = locale;
-}
+ public Integer getLocale() {
+ return locale;
+ }
+ public void setLocale(Integer locale) {
+ this.locale = locale;
+ }
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/ListQuotaConfigurationsCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaMapping.java
similarity index 75%
rename from plugins/database/quota/src/org/apache/cloudstack/api/command/ListQuotaConfigurationsCmd.java
rename to plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaMapping.java
index c79863ca9c6..7e5f69fe85f 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/command/ListQuotaConfigurationsCmd.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaMapping.java
@@ -28,44 +28,40 @@ import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.quota.QuotaConfigurationVO;
-import org.apache.cloudstack.quota.QuotaManager;
+import org.apache.cloudstack.quota.QuotaDBUtilsImpl;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
-@APICommand(name = "listQuotaConfigurations", responseObject = QuotaConfigurationResponse.class, description = "Lists all Quota and Usage configurations", since = "4.2.0",
- requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
-public class ListQuotaConfigurationsCmd extends BaseListCmd {
+@APICommand(name = "quotaMapping", responseObject = QuotaConfigurationResponse.class, description = "Lists all Quota and Usage configurations", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class QuotaMapping extends BaseListCmd {
- public static final Logger s_logger = Logger
- .getLogger(ListQuotaConfigurationsCmd.class.getName());
+ public static final Logger s_logger = Logger.getLogger(QuotaMapping.class.getName());
private static final String s_name = "quotaconfigurationresponse";
@Inject
- private QuotaManager _quotaManager;
+ QuotaDBUtilsImpl _quotaDBUtils;
@Parameter(name = "type", type = CommandType.STRING, required = false, description = "Usage type of the resource")
private String usageType;
-
- public ListQuotaConfigurationsCmd() {
+ public QuotaMapping() {
super();
}
-
- public ListQuotaConfigurationsCmd(final QuotaManager quotaManager) {
+ public QuotaMapping(final QuotaDBUtilsImpl quotaDBUtils) {
super();
- _quotaManager = quotaManager;
+ _quotaDBUtils = quotaDBUtils;
}
@Override
public void execute() {
- final Pair, Integer> result = _quotaManager.listConfigurations(this);
+ final Pair, Integer> result = _quotaDBUtils.listConfigurations(this);
final List responses = new ArrayList();
for (final QuotaConfigurationVO resource : result.first()) {
- final QuotaConfigurationResponse configurationResponse = _quotaManager.createQuotaConfigurationResponse(resource);
+ final QuotaConfigurationResponse configurationResponse = _quotaDBUtils.createQuotaConfigurationResponse(resource);
configurationResponse.setObjectName("QuotaConfiguration");
responses.add(configurationResponse);
}
@@ -90,10 +86,8 @@ public class ListQuotaConfigurationsCmd extends BaseListCmd {
return usageType;
}
-
public void setUsageType(String usageType) {
this.usageType = usageType;
}
-
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaRefreshCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaRefreshCmd.java
index 9696aef773f..a8ba0967060 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaRefreshCmd.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaRefreshCmd.java
@@ -16,37 +16,25 @@
//under the License.
package org.apache.cloudstack.api.command;
-import javax.inject.Inject;
-
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.QuotaRefreshResponse;
-import org.apache.cloudstack.quota.QuotaManager;
import com.cloud.user.Account;
@APICommand(name = "quotaRefresh", responseObject = QuotaRefreshResponse.class, description = "Refresh the quota for all accounts if enabled", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class QuotaRefreshCmd extends BaseCmd {
- public static final Logger s_logger = Logger
- .getLogger(QuotaStatementCmd.class.getName());
+ public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class.getName());
private static final String s_name = "quotarefreshresponse";
- @Inject
- private QuotaManager _quotaManager;
-
public QuotaRefreshCmd() {
super();
}
- public QuotaRefreshCmd(final QuotaManager quotaManager) {
- super();
- _quotaManager = quotaManager;
- }
-
@Override
public String getCommandName() {
return s_name;
@@ -54,8 +42,7 @@ public class QuotaRefreshCmd extends BaseCmd {
@Override
public void execute() throws ServerApiException {
- final QuotaRefreshResponse response = new QuotaRefreshResponse(
- "Success");
+ final QuotaRefreshResponse response = new QuotaRefreshResponse("Success");
setResponseObject(response);
}
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 f349eba1038..305a26fa2a4 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
@@ -16,8 +16,6 @@
//under the License.
package org.apache.cloudstack.api.command;
-import javax.inject.Inject;
-
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@@ -26,7 +24,6 @@ import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.context.CallContext;
-import org.apache.cloudstack.quota.QuotaManager;
import org.apache.cloudstack.api.response.QuotaStatementResponse;
import com.cloud.user.Account;
@@ -34,63 +31,53 @@ import com.cloud.user.Account;
@APICommand(name = "quotaStatement", responseObject = QuotaStatementResponse.class, description = "Create a quota statement", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class QuotaStatementCmd extends BaseListCmd {
- public static final Logger s_logger = Logger
- .getLogger(QuotaStatementCmd.class.getName());
+ public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class.getName());
- private static final String s_name = "quotastatementresponse";
+ private static final String s_name = "quotastatementresponse";
- @Inject
- private QuotaManager _quotaManager;
+ @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "Optional, Account Id for which statement needs to be generated")
+ private String accountName;
- @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "Optional, Account Id for which statement needs to be generated")
- private String accountName;
+ @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, 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.DOMAIN_ID, type = CommandType.UUID, 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;
+ public QuotaStatementCmd() {
+ super();
+ }
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
- public QuotaStatementCmd() {
- super();
- }
+ @Override
+ public long getEntityOwnerId() {
+ Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true);
+ if (accountId == null) {
+ return CallContext.current().getCallingAccount().getId();
+ }
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+ @Override
+ public void execute() {
+ /**
+ * final Pair, Integer> result =
+ * _quotaManager.listConfigurations(this);
+ *
+ * final List responses = new
+ * ArrayList(); for (final QuotaConfigurationVO
+ * resource : result.first()) { final QuotaStatementResponse
+ * configurationResponse =
+ * _quotaManager.createQuotaConfigurationResponse(resource);
+ * configurationResponse.setObjectName("QuotaConfiguration");
+ * responses.add(configurationResponse); }
+ **/
- public QuotaStatementCmd(final QuotaManager quotaManager) {
- super();
- _quotaManager = quotaManager;
- }
-
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true);
- if (accountId == null) {
- return CallContext.current().getCallingAccount().getId();
- }
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
-
- @Override
- public void execute() {
- /**final Pair, Integer> result = _quotaManager.listConfigurations(this);
-
- final List responses = new ArrayList();
- for (final QuotaConfigurationVO resource : result.first()) {
- final QuotaStatementResponse configurationResponse = _quotaManager.createQuotaConfigurationResponse(resource);
- configurationResponse.setObjectName("QuotaConfiguration");
- responses.add(configurationResponse);
- }**/
-
- final ListResponse response = new ListResponse();
- //response.setResponses(responses, responses.size());
- response.setResponseName(getCommandName());
- setResponseObject(response);
- }
-
+ final ListResponse response = new ListResponse();
+ // response.setResponses(responses, responses.size());
+ response.setResponseName(getCommandName());
+ setResponseObject(response);
+ }
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTypesCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTypesCmd.java
new file mode 100644
index 00000000000..ae5e02701d4
--- /dev/null
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTypesCmd.java
@@ -0,0 +1,61 @@
+//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.List;
+
+import org.apache.log4j.Logger;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.QuotaTypeResponse;
+import org.apache.cloudstack.quota.QuotaUsageTypes;
+
+import com.cloud.user.Account;
+
+@APICommand(name = "quotaTypes", responseObject = QuotaConfigurationResponse.class, description = "Lists all Quota type resources", since = "4.2.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class QuotaTypesCmd extends BaseListCmd {
+
+ public static final Logger s_logger = Logger.getLogger(QuotaTypesCmd.class.getName());
+
+ private static final String s_name = "quotatyperesponse";
+
+ public QuotaTypesCmd() {
+ super();
+ }
+
+ @Override
+ public void execute() {
+ final List responses = QuotaUsageTypes.listQuotaUsageTypes();
+ final ListResponse response = new ListResponse();
+ response.setResponses(responses, responses.size());
+ response.setResponseName(getCommandName());
+ setResponseObject(response);
+ }
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaConfigurationResponse.java b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaConfigurationResponse.java
index 0e34988c8fd..b76e47ed89a 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaConfigurationResponse.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaConfigurationResponse.java
@@ -48,15 +48,14 @@ public class QuotaConfigurationResponse extends BaseResponse {
@Param(description = "description")
private String description;
+ public QuotaConfigurationResponse() {
+ super();
+ }
- public QuotaConfigurationResponse() {
- super();
- }
-
- public QuotaConfigurationResponse(final String usageType) {
- super();
- this.usageType = usageType;
- }
+ public QuotaConfigurationResponse(final String usageType) {
+ super();
+ this.usageType = usageType;
+ }
public String getUsageType() {
return usageType;
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaCreditsResponse.java b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaCreditsResponse.java
index 0a24348bc36..20f394a5228 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaCreditsResponse.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaCreditsResponse.java
@@ -43,61 +43,50 @@ public class QuotaCreditsResponse extends BaseResponse {
@Param(description = "the account name of the admin who updated the credits")
private Timestamp updatedOn;
+ public QuotaCreditsResponse() {
+ super();
+ }
- public QuotaCreditsResponse() {
- super();
- }
-
-
- public QuotaCreditsResponse(QuotaCreditsVO result) {
- super();
- if (result != null){
- this.credits = 100;
- this.balance = 200;
- this.updatedBy = "1";
- this.updatedOn = new Timestamp(System.currentTimeMillis());
- }
- }
-
+ public QuotaCreditsResponse(QuotaCreditsVO result) {
+ super();
+ if (result != null) {
+ this.credits = 100;
+ this.balance = 200;
+ this.updatedBy = "1";
+ this.updatedOn = new Timestamp(System.currentTimeMillis());
+ }
+ }
public Integer getCredits() {
return credits;
}
-
public void setCredits(Integer credits) {
this.credits = credits;
}
-
public Integer getBalance() {
return balance;
}
-
public void setBalance(Integer balance) {
this.balance = balance;
}
-
public String getUpdatedBy() {
return updatedBy;
}
-
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
-
public Timestamp getUpdatedOn() {
return updatedOn;
}
-
public void setUpdatedOn(Timestamp updatedOn) {
this.updatedOn = updatedOn;
}
-
}
\ No newline at end of file
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaEmailTemplateResponse.java b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaEmailTemplateResponse.java
index d35c3743e02..40d97a20506 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaEmailTemplateResponse.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaEmailTemplateResponse.java
@@ -25,7 +25,6 @@ import org.apache.cloudstack.api.BaseResponse;
import com.cloud.serializer.Param;
-
public class QuotaEmailTemplateResponse extends BaseResponse {
@SerializedName(ApiConstants.ID)
@@ -44,51 +43,40 @@ public class QuotaEmailTemplateResponse extends BaseResponse {
@Param(description = "the account name of the admin who updated the credits")
private Timestamp SentOn;
-
- public QuotaEmailTemplateResponse() {
- super();
- }
-
+ public QuotaEmailTemplateResponse() {
+ super();
+ }
public String getId() {
return id;
}
-
public void setId(String id) {
this.id = id;
}
-
public String getAccountName() {
return accountName;
}
-
public void setAccountName(String accountName) {
this.accountName = accountName;
}
-
public String getDomainId() {
return domainId;
}
-
public void setDomainId(String domainId) {
this.domainId = domainId;
}
-
public Timestamp getSentOn() {
return SentOn;
}
-
public void setSentOn(Timestamp sentOn) {
SentOn = sentOn;
}
-
-
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaRefreshResponse.java b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaRefreshResponse.java
index 0e58ca4578d..fd255382869 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaRefreshResponse.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaRefreshResponse.java
@@ -23,12 +23,10 @@ import com.google.gson.annotations.SerializedName;
public class QuotaRefreshResponse extends BaseResponse {
-
@SerializedName("result")
@Param(description = "Execution result for the quota refresh command")
private String result;
-
public QuotaRefreshResponse() {
super();
// TODO Auto-generated constructor stub
@@ -38,6 +36,7 @@ public class QuotaRefreshResponse extends BaseResponse {
super();
this.result = result;
}
+
public String getResult() {
return result;
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaStatementResponse.java b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaStatementResponse.java
index e0598a8df6e..7f48f6c2996 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaStatementResponse.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaStatementResponse.java
@@ -24,86 +24,85 @@ import com.cloud.serializer.Param;
public class QuotaStatementResponse extends BaseResponse {
- @SerializedName("usageType")
- @Param(description = "usageType")
- private String usageType;
+ @SerializedName("usageType")
+ @Param(description = "usageType")
+ private String usageType;
- @SerializedName("usageUnit")
- @Param(description = "usageUnit")
- private String usageUnit;
+ @SerializedName("usageUnit")
+ @Param(description = "usageUnit")
+ private String usageUnit;
- @SerializedName("usageDiscriminator")
- @Param(description = "usageDiscriminator")
- private String usageDiscriminator;
+ @SerializedName("usageDiscriminator")
+ @Param(description = "usageDiscriminator")
+ private String usageDiscriminator;
- @SerializedName("currencyValue")
- @Param(description = "currencyValue")
- private int currencyValue;
+ @SerializedName("currencyValue")
+ @Param(description = "currencyValue")
+ private int currencyValue;
- @SerializedName("include")
- @Param(description = "include")
- private int include;
+ @SerializedName("include")
+ @Param(description = "include")
+ private int include;
- @SerializedName("description")
- @Param(description = "description")
- private String description;
+ @SerializedName("description")
+ @Param(description = "description")
+ private String description;
+ public QuotaStatementResponse() {
+ super();
+ }
- public QuotaStatementResponse() {
- super();
- }
+ public QuotaStatementResponse(final String usageType) {
+ super();
+ this.usageType = usageType;
+ }
- public QuotaStatementResponse(final String usageType) {
- super();
- this.usageType = usageType;
- }
+ public String getUsageType() {
+ return usageType;
+ }
- public String getUsageType() {
- return usageType;
- }
+ public void setUsageType(String usageType) {
+ this.usageType = usageType;
+ }
- public void setUsageType(String usageType) {
- this.usageType = usageType;
- }
+ public String getUsageUnit() {
+ return usageUnit;
+ }
- public String getUsageUnit() {
- return usageUnit;
- }
+ public void setUsageUnit(String usageUnit) {
+ this.usageUnit = usageUnit;
+ }
- public void setUsageUnit(String usageUnit) {
- this.usageUnit = usageUnit;
- }
+ public String getUsageDiscriminator() {
+ return usageDiscriminator;
+ }
- public String getUsageDiscriminator() {
- return usageDiscriminator;
- }
+ public void setUsageDiscriminator(String usageDiscriminator) {
+ this.usageDiscriminator = usageDiscriminator;
+ }
- public void setUsageDiscriminator(String usageDiscriminator) {
- this.usageDiscriminator = usageDiscriminator;
- }
+ public int getCurrencyValue() {
+ return currencyValue;
+ }
- public int getCurrencyValue() {
- return currencyValue;
- }
+ public void setCurrencyValue(int currencyValue) {
+ this.currencyValue = currencyValue;
+ }
- public void setCurrencyValue(int currencyValue) {
- this.currencyValue = currencyValue;
- }
+ public int getInclude() {
+ return include;
+ }
- public int getInclude() {
- return include;
- }
+ public void setInclude(int include) {
+ this.include = include;
+ }
- public void setInclude(int include) {
- this.include = include;
- }
+ public String getDescription() {
+ return description;
+ }
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
+ public void setDescription(String description) {
+ this.description = description;
+ }
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaTypeResponse.java b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaTypeResponse.java
new file mode 100644
index 00000000000..faadeebb362
--- /dev/null
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaTypeResponse.java
@@ -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.
+package org.apache.cloudstack.api.response;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+
+import com.cloud.serializer.Param;
+
+public class QuotaTypeResponse extends BaseResponse {
+
+ @SerializedName("quotatypeid")
+ @Param(description = "quota type")
+ private Integer quotaType;
+
+ @SerializedName(ApiConstants.DESCRIPTION)
+ @Param(description = "description of usage type")
+ private String description;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Integer getQuotaType() {
+ return quotaType;
+ }
+
+ public void setQuotaType(Integer quotaType) {
+ this.quotaType = quotaType;
+ }
+
+ public QuotaTypeResponse(Integer quotaType, String description) {
+ this.quotaType = quotaType;
+ this.description = description;
+ setObjectName("usagetype");
+ }
+
+}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaBalanceVO.java b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaBalanceVO.java
index 39a9dab9546..638b560c85d 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaBalanceVO.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaBalanceVO.java
@@ -61,9 +61,7 @@ public class QuotaBalanceVO implements InternalIdentity {
public QuotaBalanceVO() {
}
- public QuotaBalanceVO(Long accountId, Long domainId,
- BigDecimal creditBalance, Date updatedOn, Long previousUpdateId,
- Date previousUpdateOn) {
+ public QuotaBalanceVO(Long accountId, Long domainId, BigDecimal creditBalance, Date updatedOn, Long previousUpdateId, Date previousUpdateOn) {
super();
this.accountId = accountId;
this.domainId = domainId;
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaConfigurationVO.java b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaConfigurationVO.java
index fd685b0ac70..eba9e40f228 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaConfigurationVO.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaConfigurationVO.java
@@ -67,11 +67,9 @@ public class QuotaConfigurationVO implements InternalIdentity {
@Column(name = "description")
private String description;
-
public QuotaConfigurationVO() {
}
-
public QuotaConfigurationVO(final String usagetype, final String usageunit, final String usagediscriminator, final int currencyvalue, final int include, final String description) {
this.usageType = usagetype;
this.usageUnit = usageunit;
@@ -81,67 +79,54 @@ public class QuotaConfigurationVO implements InternalIdentity {
this.description = description;
}
-
public String getUsageType() {
return usageType;
}
-
public void setUsageType(String usageType) {
this.usageType = usageType;
}
-
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 int getCurrencyValue() {
return currencyValue;
}
-
public void setCurrencyValue(int currencyValue) {
this.currencyValue = currencyValue;
}
-
public int getInclude() {
return include;
}
-
public void setInclude(int include) {
this.include = include;
}
-
public String getDescription() {
return description;
}
-
public void setDescription(String description) {
this.description = description;
}
-
@Override
public long getId() {
// TODO Auto-generated method stub
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaCreditsVO.java b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaCreditsVO.java
index 423b840ea26..c26e8e8ae98 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaCreditsVO.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaCreditsVO.java
@@ -54,8 +54,7 @@ public class QuotaCreditsVO implements InternalIdentity {
public QuotaCreditsVO() {
}
- public QuotaCreditsVO(long accountId, long domainId, int credit,
- long updatedBy) {
+ public QuotaCreditsVO(long accountId, long domainId, int credit, long updatedBy) {
super();
this.accountId = accountId;
this.domainId = domainId;
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaDBUtils.java b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaDBUtils.java
new file mode 100644
index 00000000000..fabb9c382c2
--- /dev/null
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaDBUtils.java
@@ -0,0 +1,39 @@
+//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;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.command.QuotaEditMappingCmd;
+import org.apache.cloudstack.api.command.QuotaMapping;
+import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
+import org.apache.cloudstack.api.response.QuotaCreditsResponse;
+
+import com.cloud.utils.Pair;
+import com.cloud.utils.component.PluggableService;
+
+public interface QuotaDBUtils extends PluggableService {
+
+ Pair, Integer> editQuotaMapping(QuotaEditMappingCmd cmd);
+
+ Pair, Integer> listConfigurations(QuotaMapping cmd);
+
+ QuotaConfigurationResponse createQuotaConfigurationResponse(QuotaConfigurationVO configuration);
+
+ QuotaCreditsResponse addQuotaCredits(Long accountId, Long domainId, Integer amount, Long updatedBy);
+
+}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaDBUtilsImpl.java b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaDBUtilsImpl.java
new file mode 100644
index 00000000000..9be68c296c1
--- /dev/null
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaDBUtilsImpl.java
@@ -0,0 +1,100 @@
+//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;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.command.QuotaEditMappingCmd;
+import org.apache.cloudstack.api.command.QuotaMapping;
+import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
+import org.apache.cloudstack.api.response.QuotaCreditsResponse;
+import org.apache.cloudstack.quota.dao.QuotaConfigurationDao;
+import org.apache.cloudstack.quota.dao.QuotaCreditsDao;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.utils.Pair;
+import com.cloud.utils.db.TransactionLegacy;
+
+@Component
+@Local(value = QuotaDBUtilsImpl.class)
+public class QuotaDBUtilsImpl {
+ private static final Logger s_logger = Logger.getLogger(QuotaDBUtilsImpl.class.getName());
+
+ @Inject
+ private QuotaConfigurationDao _quotaConfigurationDao;
+
+ @Inject
+ private QuotaCreditsDao _quotaCreditsDao;
+
+ public QuotaConfigurationResponse createQuotaConfigurationResponse(final QuotaConfigurationVO configuration) {
+ final QuotaConfigurationResponse response = new QuotaConfigurationResponse();
+ response.setUsageType(configuration.getUsageType());
+ response.setUsageUnit(configuration.getUsageUnit());
+ response.setUsageDiscriminator(configuration.getUsageDiscriminator());
+ response.setCurrencyValue(configuration.getCurrencyValue());
+ response.setInclude(configuration.getInclude());
+ response.setDescription(configuration.getDescription());
+ return response;
+ }
+
+ public Pair, Integer> listConfigurations(final QuotaMapping cmd) {
+ final Pair, Integer> result = _quotaConfigurationDao.searchConfigurations();
+ TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
+ return result;
+ }
+
+ public Pair, Integer> editQuotaMapping(QuotaEditMappingCmd cmd) {
+ String resourceName = cmd.getUsageType();
+ Integer quotaMapping = cmd.getValue();
+
+ TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
+ try {
+ QuotaConfigurationVO result = _quotaConfigurationDao.findByUsageType(resourceName);
+ if (result == null)
+ throw new InvalidParameterValueException(resourceName);
+ s_logger.info("Old value=" + result.getCurrencyValue() + ", new value = " + quotaMapping + ", for resource =" + resourceName);
+ result.setCurrencyValue(quotaMapping);
+ _quotaConfigurationDao.persist(result);
+ } finally {
+ txn.close();
+ }
+ final Pair, Integer> result = _quotaConfigurationDao.searchConfigurations();
+ TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
+ return result;
+ }
+
+ public QuotaCreditsResponse addQuotaCredits(Long accountId, Long domainId, Integer amount, Long updatedBy) {
+ QuotaCreditsVO result = null;
+ TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
+ try {
+ QuotaCreditsVO credits = new QuotaCreditsVO(accountId, domainId, amount, updatedBy);
+ credits.setUpdatedOn(new Date());
+ result = _quotaCreditsDao.persist(credits);
+ } finally {
+ txn.close();
+ }
+ TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
+ return new QuotaCreditsResponse(result);
+ }
+
+}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaEmailTemplatesVO.java b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaEmailTemplatesVO.java
index ce3a108fcbd..63c07e1bd27 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaEmailTemplatesVO.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaEmailTemplatesVO.java
@@ -43,7 +43,6 @@ public class QuotaEmailTemplatesVO implements InternalIdentity {
@Column(name = "template_text")
private String templateText;
-
@Column(name = "category")
private Integer category;
@@ -60,8 +59,7 @@ public class QuotaEmailTemplatesVO implements InternalIdentity {
public QuotaEmailTemplatesVO() {
}
- public QuotaEmailTemplatesVO(String templateName, String templateText,
- String locale, Integer version) {
+ public QuotaEmailTemplatesVO(String templateName, String templateText, String locale, Integer version) {
super();
this.templateName = templateName;
this.templateText = templateText;
@@ -91,7 +89,6 @@ public class QuotaEmailTemplatesVO implements InternalIdentity {
this.templateText = templateText;
}
-
public Integer getCategory() {
return category;
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaManager.java b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaManager.java
index 19b7086f906..5649ce29e73 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaManager.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaManager.java
@@ -16,26 +16,10 @@
//under the License.
package org.apache.cloudstack.quota;
-import java.util.List;
-
-import org.apache.cloudstack.api.command.ListQuotaConfigurationsCmd;
-import org.apache.cloudstack.api.command.QuotaEditResourceMappingCmd;
-import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
-import org.apache.cloudstack.api.response.QuotaCreditsResponse;
-
-import com.cloud.utils.Pair;
import com.cloud.utils.component.PluggableService;
public interface QuotaManager extends PluggableService {
public void calculateQuotaUsage(QuotaJobVO job, long startDateMillis, long endDateMillis);
- Pair, Integer> editQuotaMapping(QuotaEditResourceMappingCmd cmd);
-
- Pair, Integer> listConfigurations(ListQuotaConfigurationsCmd cmd);
-
- QuotaConfigurationResponse createQuotaConfigurationResponse(QuotaConfigurationVO configuration);
-
- QuotaCreditsResponse addQuotaCredits(Long accountId, Long domainId, Integer amount, Long updatedBy);
-
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaManagerImpl.java b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaManagerImpl.java
index 2b20830a49b..72614335c7f 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaManagerImpl.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaManagerImpl.java
@@ -24,37 +24,25 @@ import java.util.TimeZone;
import javax.ejb.Local;
import javax.inject.Inject;
-import org.apache.cloudstack.api.command.ListQuotaConfigurationsCmd;
+import org.apache.cloudstack.api.command.QuotaMapping;
import org.apache.cloudstack.api.command.QuotaCreditsCmd;
-import org.apache.cloudstack.api.command.QuotaEditResourceMappingCmd;
+import org.apache.cloudstack.api.command.QuotaEditMappingCmd;
import org.apache.cloudstack.api.command.QuotaEmailTemplateAddCmd;
import org.apache.cloudstack.api.command.QuotaRefreshCmd;
import org.apache.cloudstack.api.command.QuotaStatementCmd;
-import org.apache.cloudstack.api.response.QuotaConfigurationResponse;
-import org.apache.cloudstack.api.response.QuotaCreditsResponse;
-import org.apache.cloudstack.quota.dao.QuotaConfigurationDao;
-import org.apache.cloudstack.quota.dao.QuotaCreditsDao;
+import org.apache.cloudstack.api.command.QuotaTypesCmd;
import org.apache.cloudstack.quota.dao.QuotaJobDao;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
-import com.cloud.exception.InvalidParameterValueException;
import com.cloud.usage.UsageJobVO;
-import com.cloud.utils.Pair;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.db.TransactionLegacy;
@Component
@Local(value = QuotaManager.class)
public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
- private static final Logger s_logger = Logger
- .getLogger(QuotaManagerImpl.class.getName());
-
- @Inject
- private QuotaConfigurationDao _quotaConfigurationDao;
-
- @Inject
- private QuotaCreditsDao _quotaCreditsDao;
+ private static final Logger s_logger = Logger.getLogger(QuotaManagerImpl.class.getName());
@Inject
private QuotaJobDao _quotaJobDao;
@@ -67,88 +55,21 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
super();
}
- public QuotaManagerImpl(final QuotaConfigurationDao quotaConfigurationDao) {
- super();
- _quotaConfigurationDao = quotaConfigurationDao;
- }
-
@Override
public List> getCommands() {
final List> cmdList = new ArrayList>();
- cmdList.add(ListQuotaConfigurationsCmd.class);
+ cmdList.add(QuotaTypesCmd.class);
+ cmdList.add(QuotaMapping.class);
cmdList.add(QuotaCreditsCmd.class);
cmdList.add(QuotaEmailTemplateAddCmd.class);
cmdList.add(QuotaRefreshCmd.class);
cmdList.add(QuotaStatementCmd.class);
- cmdList.add(QuotaEditResourceMappingCmd.class);
+ cmdList.add(QuotaEditMappingCmd.class);
return cmdList;
}
@Override
- public Pair, Integer> listConfigurations(
- final ListQuotaConfigurationsCmd cmd) {
- final Pair, Integer> result = _quotaConfigurationDao
- .searchConfigurations();
- TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
- return result;
- }
-
- @Override
- public QuotaConfigurationResponse createQuotaConfigurationResponse(
- final QuotaConfigurationVO configuration) {
- final QuotaConfigurationResponse response = new QuotaConfigurationResponse();
- response.setUsageType(configuration.getUsageType());
- response.setUsageUnit(configuration.getUsageUnit());
- response.setUsageDiscriminator(configuration.getUsageDiscriminator());
- response.setCurrencyValue(configuration.getCurrencyValue());
- response.setInclude(configuration.getInclude());
- response.setDescription(configuration.getDescription());
- return response;
- }
-
- @Override
- public Pair, Integer> editQuotaMapping(
- QuotaEditResourceMappingCmd cmd) {
- String resourceName = cmd.getUsageType();
- Integer quotaMapping = cmd.getValue();
-
- TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
- try {
- QuotaConfigurationVO result = _quotaConfigurationDao.findByUsageType(resourceName);
- if (result==null) throw new InvalidParameterValueException(resourceName);
- s_logger.info("Old value=" + result.getCurrencyValue() + ", new value = " + quotaMapping + ", for resource =" + resourceName);
- result.setCurrencyValue(quotaMapping);
- _quotaConfigurationDao.persist(result);
- } finally {
- txn.close();
- }
- final Pair, Integer> result = _quotaConfigurationDao.searchConfigurations();
- TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
- return result;
- }
-
-
- @Override
- public QuotaCreditsResponse addQuotaCredits(Long accountId, Long domainId,
- Integer amount, Long updatedBy) {
- QuotaCreditsVO result = null;
- TransactionLegacy txn = TransactionLegacy
- .open(TransactionLegacy.USAGE_DB);
- try {
- QuotaCreditsVO credits = new QuotaCreditsVO(accountId, domainId,
- amount, updatedBy);
- credits.setUpdatedOn(new Date());
- result = _quotaCreditsDao.persist(credits);
- } finally {
- txn.close();
- }
- TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
- return new QuotaCreditsResponse(result);
- }
-
- @Override
- public void calculateQuotaUsage(QuotaJobVO job, long startDateMillis,
- long endDateMillis) {
+ public void calculateQuotaUsage(QuotaJobVO job, long startDateMillis, long endDateMillis) {
boolean success = false;
long timeStart = System.currentTimeMillis();
@@ -170,7 +91,8 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
TransactionLegacy jobUpdateTxn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
try {
jobUpdateTxn.start();
- // everything seemed to work...set endDate as the last success date
+ // everything seemed to work...set endDate as the last
+ // success date
_quotaJobDao.updateJobSuccess(job.getId(), startDateMillis, endDateMillis, System.currentTimeMillis() - timeStart, success);
// create a new job if this is a recurring job
@@ -191,8 +113,7 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
s_logger.info("Calculating quota usage for records between " + startDate + " and " + endDate);
}
- //get all the accounts from usage db
- TransactionLegacy userTxn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
+ // get all the accounts from usage db
} catch (Exception e) {
s_logger.error("Quota Manager error", e);
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaSentEmailsVO.java b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaSentEmailsVO.java
index 73b739ac513..82679685123 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaSentEmailsVO.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaSentEmailsVO.java
@@ -30,9 +30,7 @@ import org.apache.cloudstack.api.InternalIdentity;
@Entity
@Table(name = "quota_sent_emails")
public class QuotaSentEmailsVO implements InternalIdentity {
- public QuotaSentEmailsVO(Long id, String fromAddress, String toAddress,
- String ccAddress, String bccAddress, Date sendDate, String subject,
- String mailText, Long version, Long updatedBy) {
+ public QuotaSentEmailsVO(Long id, String fromAddress, String toAddress, String ccAddress, String bccAddress, Date sendDate, String subject, String mailText, Long version, Long updatedBy) {
super();
this.id = id;
this.fromAddress = fromAddress;
@@ -46,7 +44,6 @@ public class QuotaSentEmailsVO implements InternalIdentity {
this.updatedBy = updatedBy;
}
-
private static final long serialVersionUID = -7117933845287653210L;
@Id
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaUsageTypes.java b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaUsageTypes.java
new file mode 100644
index 00000000000..c788a40ca66
--- /dev/null
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaUsageTypes.java
@@ -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.
+package org.apache.cloudstack.quota;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cloudstack.api.response.QuotaTypeResponse;
+import org.apache.cloudstack.usage.UsageTypes;
+
+public class QuotaUsageTypes extends UsageTypes {
+ public static final int CPU_CLOCK_RATE = 24;
+ public static final int CPU_NUMBER = 25;
+ public static final int MEMORY = 26;
+
+ public static List responseList = new ArrayList();
+
+ public static List listQuotaUsageTypes() {
+ responseList.add(new QuotaTypeResponse(RUNNING_VM, "Running Vm Usage"));
+ responseList.add(new QuotaTypeResponse(ALLOCATED_VM, "Allocated Vm Usage"));
+ responseList.add(new QuotaTypeResponse(IP_ADDRESS, "IP Address Usage"));
+ responseList.add(new QuotaTypeResponse(NETWORK_BYTES_SENT, "Network Usage (Bytes Sent)"));
+ responseList.add(new QuotaTypeResponse(NETWORK_BYTES_RECEIVED, "Network Usage (Bytes Received)"));
+ responseList.add(new QuotaTypeResponse(VOLUME, "Volume Usage"));
+ responseList.add(new QuotaTypeResponse(TEMPLATE, "Template Usage"));
+ responseList.add(new QuotaTypeResponse(ISO, "ISO Usage"));
+ responseList.add(new QuotaTypeResponse(SNAPSHOT, "Snapshot Usage"));
+ responseList.add(new QuotaTypeResponse(SECURITY_GROUP, "Security Group Usage"));
+ responseList.add(new QuotaTypeResponse(LOAD_BALANCER_POLICY, "Load Balancer Usage"));
+ responseList.add(new QuotaTypeResponse(PORT_FORWARDING_RULE, "Port Forwarding Usage"));
+ responseList.add(new QuotaTypeResponse(NETWORK_OFFERING, "Network Offering Usage"));
+ responseList.add(new QuotaTypeResponse(VPN_USERS, "VPN users usage"));
+ responseList.add(new QuotaTypeResponse(VM_DISK_IO_READ, "VM Disk usage(I/O Read)"));
+ responseList.add(new QuotaTypeResponse(VM_DISK_IO_WRITE, "VM Disk usage(I/O Write)"));
+ responseList.add(new QuotaTypeResponse(VM_DISK_BYTES_READ, "VM Disk usage(Bytes Read)"));
+ responseList.add(new QuotaTypeResponse(VM_DISK_BYTES_WRITE, "VM Disk usage(Bytes Write)"));
+ responseList.add(new QuotaTypeResponse(VM_SNAPSHOT, "VM Snapshot storage usage"));
+ responseList.add(new QuotaTypeResponse(CPU_CLOCK_RATE, "Quota mapping for usign 1 CPU of clock rate 100MHz"));
+ responseList.add(new QuotaTypeResponse(CPU_NUMBER, "Quota mapping for running VM that has 1vCPU"));
+ responseList.add(new QuotaTypeResponse(MEMORY, "Quota mapping for usign 1MB or RAM for 1 hour"));
+ return responseList;
+ }
+
+}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaUsageVO.java b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaUsageVO.java
index 5ffe01ccfed..0aa2b8bc705 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaUsageVO.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaUsageVO.java
@@ -58,8 +58,7 @@ public class QuotaUsageVO implements InternalIdentity {
public QuotaUsageVO() {
}
- public QuotaUsageVO(Long usageItemId, String usageType,
- BigDecimal quotaUsed, Date startDate, Date endDate) {
+ public QuotaUsageVO(Long usageItemId, String usageType, BigDecimal quotaUsed, Date startDate, Date endDate) {
super();
this.usageItemId = usageItemId;
this.usageType = usageType;
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDao.java b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDao.java
index e2543ec428e..afc26cbf39c 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDao.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDao.java
@@ -27,8 +27,8 @@ import com.cloud.utils.db.SearchCriteria;
public interface QuotaBalanceDao extends GenericDao {
- Pair, Integer> searchBalance(SearchCriteria sc, Filter filter);
+ Pair, Integer> searchBalance(SearchCriteria sc, Filter filter);
- void saveQuotaBalance(List credits);
+ void saveQuotaBalance(List credits);
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDaoImpl.java b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDaoImpl.java
index 5473aa19cc8..48322f55236 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDaoImpl.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaBalanceDaoImpl.java
@@ -29,12 +29,11 @@ import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchCriteria;
@Component
-@Local(value = {QuotaBalanceDao.class})
+@Local(value = { QuotaBalanceDao.class })
public class QuotaBalanceDaoImpl extends GenericDaoBase implements QuotaBalanceDao {
@Override
- public Pair, Integer> searchBalance(
- SearchCriteria sc, Filter filter) {
+ public Pair, Integer> searchBalance(SearchCriteria sc, Filter filter) {
// TODO Auto-generated method stub
return null;
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaConfigurationDao.java b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaConfigurationDao.java
index 324e7d9e89e..b8fdd1a8a52 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaConfigurationDao.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaConfigurationDao.java
@@ -25,8 +25,8 @@ import com.cloud.utils.db.GenericDao;
public interface QuotaConfigurationDao extends GenericDao {
- QuotaConfigurationVO findByUsageType(String usageType);
+ QuotaConfigurationVO findByUsageType(String usageType);
- Pair, Integer> searchConfigurations();
+ Pair, Integer> searchConfigurations();
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaConfigurationDaoImpl.java b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaConfigurationDaoImpl.java
index cd2e5358e16..d01d7dfd7b6 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaConfigurationDaoImpl.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaConfigurationDaoImpl.java
@@ -30,40 +30,39 @@ import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.TransactionLegacy;
@Component
-@Local(value = {QuotaConfigurationDao.class})
+@Local(value = { QuotaConfigurationDao.class })
public class QuotaConfigurationDaoImpl extends GenericDaoBase implements QuotaConfigurationDao {
- private final SearchBuilder searchUsageType;
- private final SearchBuilder listAllIncludedUsageType;
+ private final SearchBuilder searchUsageType;
+ private final SearchBuilder listAllIncludedUsageType;
- public QuotaConfigurationDaoImpl() {
- super();
- searchUsageType = createSearchBuilder();
- searchUsageType.and("usage_type", searchUsageType.entity().getUsageType(), SearchCriteria.Op.EQ);
- searchUsageType.done();
+ public QuotaConfigurationDaoImpl() {
+ super();
+ searchUsageType = createSearchBuilder();
+ searchUsageType.and("usage_type", searchUsageType.entity().getUsageType(), SearchCriteria.Op.EQ);
+ searchUsageType.done();
- listAllIncludedUsageType = createSearchBuilder();
- listAllIncludedUsageType.and("include", listAllIncludedUsageType.entity().getInclude(), SearchCriteria.Op.EQ);
- listAllIncludedUsageType.done();
- }
+ listAllIncludedUsageType = createSearchBuilder();
+ listAllIncludedUsageType.and("include", listAllIncludedUsageType.entity().getInclude(), SearchCriteria.Op.EQ);
+ listAllIncludedUsageType.done();
+ }
- @Override
- public QuotaConfigurationVO findByUsageType(final String usageType) {
- final SearchCriteria sc = searchUsageType.create();
- sc.setParameters("usage_type", usageType);
- return findOneBy(sc);
- }
-
- @Override
- public Pair, Integer> searchConfigurations() {
- TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
- try {
- final SearchCriteria sc = listAllIncludedUsageType.create();
- sc.setParameters("include", 1);
- return searchAndCount(sc, null);
- } finally {
- txn.close();
- }
- }
+ @Override
+ public QuotaConfigurationVO findByUsageType(final String usageType) {
+ final SearchCriteria sc = searchUsageType.create();
+ sc.setParameters("usage_type", usageType);
+ return findOneBy(sc);
+ }
+ @Override
+ public Pair, Integer> searchConfigurations() {
+ TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
+ try {
+ final SearchCriteria sc = listAllIncludedUsageType.create();
+ sc.setParameters("include", 1);
+ return searchAndCount(sc, null);
+ } finally {
+ txn.close();
+ }
+ }
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaCreditsDao.java b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaCreditsDao.java
index 466030ddb83..673941dd57a 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaCreditsDao.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaCreditsDao.java
@@ -27,8 +27,8 @@ import com.cloud.utils.db.SearchCriteria;
public interface QuotaCreditsDao extends GenericDao {
- Pair, Integer> searchAndCountAllRecords(SearchCriteria sc, Filter filter);
+ Pair, Integer> searchAndCountAllRecords(SearchCriteria sc, Filter filter);
- void saveQuotaCredits(List credits);
+ void saveQuotaCredits(List credits);
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaCreditsDaoImpl.java b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaCreditsDaoImpl.java
index 1d55cbedf95..3c299a08455 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaCreditsDaoImpl.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaCreditsDaoImpl.java
@@ -29,12 +29,11 @@ import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchCriteria;
@Component
-@Local(value = {QuotaCreditsDao.class})
+@Local(value = { QuotaCreditsDao.class })
public class QuotaCreditsDaoImpl extends GenericDaoBase implements QuotaCreditsDao {
@Override
- public Pair, Integer> searchAndCountAllRecords(
- SearchCriteria sc, Filter filter) {
+ public Pair, Integer> searchAndCountAllRecords(SearchCriteria sc, Filter filter) {
// TODO Auto-generated method stub
return null;
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaEmailTemplatesDao.java b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaEmailTemplatesDao.java
index 7a55beca4d1..8b238378084 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaEmailTemplatesDao.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaEmailTemplatesDao.java
@@ -28,8 +28,8 @@ import com.cloud.utils.db.SearchCriteria;
public interface QuotaEmailTemplatesDao extends GenericDao {
- QuotaEmailTemplatesVO fetchTemplate(String templateName);
+ QuotaEmailTemplatesVO fetchTemplate(String templateName);
- Pair, Integer> searchBalance(SearchCriteria sc, Filter filter);
+ Pair, Integer> searchBalance(SearchCriteria sc, Filter filter);
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaEmailTemplatesDaoImpl.java b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaEmailTemplatesDaoImpl.java
index 75cad5e5951..1de17e7cab9 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaEmailTemplatesDaoImpl.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaEmailTemplatesDaoImpl.java
@@ -30,7 +30,7 @@ import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchCriteria;
@Component
-@Local(value = {QuotaEmailTemplatesDao.class})
+@Local(value = { QuotaEmailTemplatesDao.class })
public class QuotaEmailTemplatesDaoImpl extends GenericDaoBase implements QuotaEmailTemplatesDao {
@Override
@@ -40,8 +40,7 @@ public class QuotaEmailTemplatesDaoImpl extends GenericDaoBase, Integer> searchBalance(
- SearchCriteria sc, Filter filter) {
+ public Pair, Integer> searchBalance(SearchCriteria sc, Filter filter) {
// TODO Auto-generated method stub
return null;
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaJobDao.java b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaJobDao.java
index a2109d3abcc..20b328cff9b 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaJobDao.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaJobDao.java
@@ -23,19 +23,19 @@ import org.apache.cloudstack.quota.QuotaJobVO;
import com.cloud.utils.db.GenericDao;
public interface QuotaJobDao extends GenericDao {
- Long checkHeartbeat(String hostname, int pid, int aggregationDuration);
+ Long checkHeartbeat(String hostname, int pid, int aggregationDuration);
- void createNewJob(String hostname, int pid, int jobType);
+ void createNewJob(String hostname, int pid, int jobType);
- QuotaJobVO getLastJob();
+ QuotaJobVO getLastJob();
- QuotaJobVO getNextImmediateJob();
+ QuotaJobVO getNextImmediateJob();
- long getLastJobSuccessDateMillis();
+ long getLastJobSuccessDateMillis();
- Date getLastHeartbeat();
+ Date getLastHeartbeat();
- QuotaJobVO isOwner(String hostname, int pid);
+ QuotaJobVO isOwner(String hostname, int pid);
- void updateJobSuccess(Long jobId, long startMillis, long endMillis, long execTime, boolean success);
+ void updateJobSuccess(Long jobId, long startMillis, long endMillis, long execTime, boolean success);
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaJobDaoImpl.java b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaJobDaoImpl.java
index 0f9eafcb343..f0c7d09419c 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaJobDaoImpl.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaJobDaoImpl.java
@@ -34,168 +34,168 @@ import com.cloud.utils.db.TransactionLegacy;
import com.cloud.utils.exception.CloudRuntimeException;
@Component
-@Local(value = {QuotaJobDao.class})
+@Local(value = { QuotaJobDao.class })
public class QuotaJobDaoImpl extends GenericDaoBase implements QuotaJobDao {
- private static final Logger s_logger = Logger.getLogger(QuotaJobDaoImpl.class.getName());
+ private static final Logger s_logger = Logger.getLogger(QuotaJobDaoImpl.class.getName());
- private static final String GET_LAST_JOB_SUCCESS_DATE_MILLIS =
- "SELECT end_millis FROM cloud_usage.usage_job WHERE end_millis > 0 and success = 1 ORDER BY end_millis DESC LIMIT 1";
+ private static final String GET_LAST_JOB_SUCCESS_DATE_MILLIS = "SELECT end_millis FROM cloud_usage.usage_job WHERE end_millis > 0 and success = 1 ORDER BY end_millis DESC LIMIT 1";
- @Override
- public long getLastJobSuccessDateMillis() {
- TransactionLegacy txn = TransactionLegacy.currentTxn();
- PreparedStatement pstmt = null;
- String sql = GET_LAST_JOB_SUCCESS_DATE_MILLIS;
- try {
- pstmt = txn.prepareAutoCloseStatement(sql);
- ResultSet rs = pstmt.executeQuery();
- if (rs.next()) {
- return rs.getLong(1);
- }
- } catch (Exception ex) {
- s_logger.error("error getting last usage job success date", ex);
- } finally {
- txn.close();
- }
- return 0L;
- }
+ @Override
+ public long getLastJobSuccessDateMillis() {
+ TransactionLegacy txn = TransactionLegacy.currentTxn();
+ PreparedStatement pstmt = null;
+ String sql = GET_LAST_JOB_SUCCESS_DATE_MILLIS;
+ try {
+ pstmt = txn.prepareAutoCloseStatement(sql);
+ ResultSet rs = pstmt.executeQuery();
+ if (rs.next()) {
+ return rs.getLong(1);
+ }
+ } catch (Exception ex) {
+ s_logger.error("error getting last usage job success date", ex);
+ } finally {
+ txn.close();
+ }
+ return 0L;
+ }
- @Override
- public void updateJobSuccess(Long jobId, long startMillis, long endMillis, long execTime, boolean success) {
- TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
- try {
- txn.start();
+ @Override
+ public void updateJobSuccess(Long jobId, long startMillis, long endMillis, long execTime, boolean success) {
+ TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
+ try {
+ txn.start();
- QuotaJobVO job = lockRow(jobId, Boolean.TRUE);
- QuotaJobVO jobForUpdate = createForUpdate();
- jobForUpdate.setStartMillis(startMillis);
- jobForUpdate.setEndMillis(endMillis);
- jobForUpdate.setExecTime(execTime);
- jobForUpdate.setStartDate(new Date(startMillis));
- jobForUpdate.setEndDate(new Date(endMillis));
- jobForUpdate.setSuccess(success);
- update(job.getId(), jobForUpdate);
+ QuotaJobVO job = lockRow(jobId, Boolean.TRUE);
+ QuotaJobVO jobForUpdate = createForUpdate();
+ jobForUpdate.setStartMillis(startMillis);
+ jobForUpdate.setEndMillis(endMillis);
+ jobForUpdate.setExecTime(execTime);
+ jobForUpdate.setStartDate(new Date(startMillis));
+ jobForUpdate.setEndDate(new Date(endMillis));
+ jobForUpdate.setSuccess(success);
+ update(job.getId(), jobForUpdate);
- txn.commit();
- } catch (Exception ex) {
- txn.rollback();
- s_logger.error("error updating job success date", ex);
- throw new CloudRuntimeException(ex.getMessage());
- } finally {
- txn.close();
- }
- }
+ txn.commit();
+ } catch (Exception ex) {
+ txn.rollback();
+ s_logger.error("error updating job success date", ex);
+ throw new CloudRuntimeException(ex.getMessage());
+ } finally {
+ txn.close();
+ }
+ }
- @Override
- public Long checkHeartbeat(String hostname, int pid, int aggregationDuration) {
- QuotaJobVO job = getNextRecurringJob();
- if (job == null) {
- return null;
- }
+ @Override
+ public Long checkHeartbeat(String hostname, int pid, int aggregationDuration) {
+ QuotaJobVO job = getNextRecurringJob();
+ if (job == null) {
+ return null;
+ }
- if (job.getHost().equals(hostname) && (job.getPid() != null) && (job.getPid().intValue() == pid)) {
- return job.getId();
- }
+ if (job.getHost().equals(hostname) && (job.getPid() != null) && (job.getPid().intValue() == pid)) {
+ return job.getId();
+ }
- Date lastHeartbeat = job.getHeartbeat();
- if (lastHeartbeat == null) {
- return null;
- }
+ Date lastHeartbeat = job.getHeartbeat();
+ if (lastHeartbeat == null) {
+ return null;
+ }
- long sinceLastHeartbeat = System.currentTimeMillis() - lastHeartbeat.getTime();
+ long sinceLastHeartbeat = System.currentTimeMillis() - lastHeartbeat.getTime();
- // TODO: Make this check a little smarter..but in the mean time we want the mgmt
- // server to monitor the usage server, we need to make sure other usage
- // servers take over as the usage job owner more aggressively. For now
- // this is hardcoded to 5 minutes.
- if (sinceLastHeartbeat > (5 * 60 * 1000)) {
- return job.getId();
- }
- return null;
- }
+ // TODO: Make this check a little smarter..but in the mean time we want
+ // the mgmt
+ // server to monitor the usage server, we need to make sure other usage
+ // servers take over as the usage job owner more aggressively. For now
+ // this is hardcoded to 5 minutes.
+ if (sinceLastHeartbeat > (5 * 60 * 1000)) {
+ return job.getId();
+ }
+ return null;
+ }
- @Override
- public QuotaJobVO isOwner(String hostname, int pid) {
- TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
- try {
- if ((hostname == null) || (pid <= 0)) {
- return null;
- }
+ @Override
+ public QuotaJobVO isOwner(String hostname, int pid) {
+ TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
+ try {
+ if ((hostname == null) || (pid <= 0)) {
+ return null;
+ }
- QuotaJobVO job = getLastJob();
- if (job == null) {
- return null;
- }
+ QuotaJobVO job = getLastJob();
+ if (job == null) {
+ return null;
+ }
- if (hostname.equals(job.getHost()) && (job.getPid() != null) && (pid == job.getPid().intValue())) {
- return job;
- }
- } finally {
- txn.close();
- }
- return null;
- }
+ if (hostname.equals(job.getHost()) && (job.getPid() != null) && (pid == job.getPid().intValue())) {
+ return job;
+ }
+ } finally {
+ txn.close();
+ }
+ return null;
+ }
- @Override
- public void createNewJob(String hostname, int pid, int jobType) {
- QuotaJobVO newJob = new QuotaJobVO();
- newJob.setHost(hostname);
- newJob.setPid(pid);
- newJob.setHeartbeat(new Date());
- newJob.setJobType(jobType);
- persist(newJob);
- }
+ @Override
+ public void createNewJob(String hostname, int pid, int jobType) {
+ QuotaJobVO newJob = new QuotaJobVO();
+ newJob.setHost(hostname);
+ newJob.setPid(pid);
+ newJob.setHeartbeat(new Date());
+ newJob.setJobType(jobType);
+ persist(newJob);
+ }
- @Override
- public QuotaJobVO getLastJob() {
- Filter filter = new Filter(QuotaJobVO.class, "id", false, Long.valueOf(0), Long.valueOf(1));
- SearchCriteria sc = createSearchCriteria();
- sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
- List jobs = search(sc, filter);
+ @Override
+ public QuotaJobVO getLastJob() {
+ Filter filter = new Filter(QuotaJobVO.class, "id", false, Long.valueOf(0), Long.valueOf(1));
+ SearchCriteria sc = createSearchCriteria();
+ sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
+ List jobs = search(sc, filter);
- if ((jobs == null) || jobs.isEmpty()) {
- return null;
- }
- return jobs.get(0);
- }
+ if ((jobs == null) || jobs.isEmpty()) {
+ return null;
+ }
+ return jobs.get(0);
+ }
- private QuotaJobVO getNextRecurringJob() {
- Filter filter = new Filter(QuotaJobVO.class, "id", false, Long.valueOf(0), Long.valueOf(1));
- SearchCriteria sc = createSearchCriteria();
- sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
- sc.addAnd("jobType", SearchCriteria.Op.EQ, Integer.valueOf(QuotaJobVO.JOB_TYPE_RECURRING));
- List jobs = search(sc, filter);
+ private QuotaJobVO getNextRecurringJob() {
+ Filter filter = new Filter(QuotaJobVO.class, "id", false, Long.valueOf(0), Long.valueOf(1));
+ SearchCriteria sc = createSearchCriteria();
+ sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
+ sc.addAnd("jobType", SearchCriteria.Op.EQ, Integer.valueOf(QuotaJobVO.JOB_TYPE_RECURRING));
+ List jobs = search(sc, filter);
- if ((jobs == null) || jobs.isEmpty()) {
- return null;
- }
- return jobs.get(0);
- }
+ if ((jobs == null) || jobs.isEmpty()) {
+ return null;
+ }
+ return jobs.get(0);
+ }
- @Override
- public QuotaJobVO getNextImmediateJob() {
- Filter filter = new Filter(QuotaJobVO.class, "id", false, Long.valueOf(0), Long.valueOf(1));
- SearchCriteria sc = createSearchCriteria();
- sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
- sc.addAnd("jobType", SearchCriteria.Op.EQ, Integer.valueOf(QuotaJobVO.JOB_TYPE_SINGLE));
- sc.addAnd("scheduled", SearchCriteria.Op.EQ, Integer.valueOf(0));
- List jobs = search(sc, filter);
+ @Override
+ public QuotaJobVO getNextImmediateJob() {
+ Filter filter = new Filter(QuotaJobVO.class, "id", false, Long.valueOf(0), Long.valueOf(1));
+ SearchCriteria sc = createSearchCriteria();
+ sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
+ sc.addAnd("jobType", SearchCriteria.Op.EQ, Integer.valueOf(QuotaJobVO.JOB_TYPE_SINGLE));
+ sc.addAnd("scheduled", SearchCriteria.Op.EQ, Integer.valueOf(0));
+ List jobs = search(sc, filter);
- if ((jobs == null) || jobs.isEmpty()) {
- return null;
- }
- return jobs.get(0);
- }
+ if ((jobs == null) || jobs.isEmpty()) {
+ return null;
+ }
+ return jobs.get(0);
+ }
- @Override
- public Date getLastHeartbeat() {
- Filter filter = new Filter(QuotaJobVO.class, "heartbeat", false, Long.valueOf(0), Long.valueOf(1));
- SearchCriteria sc = createSearchCriteria();
- List jobs = search(sc, filter);
+ @Override
+ public Date getLastHeartbeat() {
+ Filter filter = new Filter(QuotaJobVO.class, "heartbeat", false, Long.valueOf(0), Long.valueOf(1));
+ SearchCriteria sc = createSearchCriteria();
+ List jobs = search(sc, filter);
- if ((jobs == null) || jobs.isEmpty()) {
- return null;
- }
- return jobs.get(0).getHeartbeat();
- }
+ if ((jobs == null) || jobs.isEmpty()) {
+ return null;
+ }
+ return jobs.get(0).getHeartbeat();
+ }
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaSentEmailsDaoImpl.java b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaSentEmailsDaoImpl.java
index 0b0d930da86..e7c34bc6724 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaSentEmailsDaoImpl.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaSentEmailsDaoImpl.java
@@ -29,12 +29,11 @@ import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchCriteria;
@Component
-@Local(value = {QuotaSentEmailsDao.class})
+@Local(value = { QuotaSentEmailsDao.class })
public class QuotaSentEmailsDaoImpl extends GenericDaoBase implements QuotaSentEmailsDao {
@Override
- public Pair, Integer> searchEmails(
- SearchCriteria sc, Filter filter) {
+ public Pair, Integer> searchEmails(SearchCriteria sc, Filter filter) {
// TODO Auto-generated method stub
return null;
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDao.java b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDao.java
index 234bc7ab2bd..602a4cdf57e 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDao.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDao.java
@@ -27,8 +27,8 @@ import com.cloud.utils.db.SearchCriteria;
public interface QuotaUsageDao extends GenericDao {
-Pair, Integer> searchAndCountAllRecords(SearchCriteria sc, Filter filter);
+ Pair, Integer> searchAndCountAllRecords(SearchCriteria sc, Filter filter);
-void saveQuotaUsage(List credits);
+ void saveQuotaUsage(List credits);
}
diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDaoImpl.java b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDaoImpl.java
index 787d65ee783..1253bd42ac5 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDaoImpl.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDaoImpl.java
@@ -20,7 +20,8 @@ import java.util.List;
import javax.ejb.Local;
-import org.springframework.stereotype.Component;import org.apache.cloudstack.quota.QuotaUsageVO;
+import org.springframework.stereotype.Component;
+import org.apache.cloudstack.quota.QuotaUsageVO;
import com.cloud.utils.Pair;
import com.cloud.utils.db.Filter;
@@ -28,12 +29,11 @@ import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchCriteria;
@Component
-@Local(value = {QuotaUsageDao.class})
-public class QuotaUsageDaoImpl extends GenericDaoBase implements QuotaUsageDao {
+@Local(value = { QuotaUsageDao.class })
+public class QuotaUsageDaoImpl extends GenericDaoBase implements QuotaUsageDao {
@Override
- public Pair, Integer> searchAndCountAllRecords(
- SearchCriteria sc, Filter filter) {
+ public Pair, Integer> searchAndCountAllRecords(SearchCriteria sc, Filter filter) {
// TODO Auto-generated method stub
return null;
}
diff --git a/ui/scripts/globalSettings.js b/ui/scripts/globalSettings.js
index ad0fecaa358..daa0f16aafc 100644
--- a/ui/scripts/globalSettings.js
+++ b/ui/scripts/globalSettings.js
@@ -125,7 +125,7 @@
var data = {};
listViewDataProvider(args, data);
$.ajax({
- url: createURL('listQuotaConfigurations'),
+ url: createURL('quotaMapping'),
data: data,
success: function(json) {
var items = json.quotaconfigurationresponse.QuotaConfiguration;
@@ -183,7 +183,7 @@
var items = [];
console.log(args);
$.ajax({
- url: createURL("listQuotaConfigurations&hostname=" + args.context.quotaConfiguration[0].hostname),
+ url: createURL("quotaMapping&hostname=" + args.context.quotaConfiguration[0].hostname),
dataType: "json",
async: true,
success: function(json) {