29 Commits

Author SHA1 Message Date
Rohit Yadav
95abb6efc3 CLOUDSTACK-9361: Centrally handle API validations
Validate API arguments based on annotations. Introduces:
- NotNullOrEmpty: for doing null and empty string checks
- PositiveNumber: number > 0 (natural number)

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2016-05-11 09:40:22 +05:30
Abhinandan Prateek
987fcbd441 CLOUDSTACK-8592: Implement Quota service
Quota service while allowing for scalability will make sure that the cloud is
not exploited by attacks, careless use and program errors. To address this
problem, we propose to employ a quota-enforcement service that allows resource
usage within certain bounds as defined by policies and available quotas for
various entities.  Quota service extends the functionality of usage server to
provide a measurement for the resources used by the accounts and domains using a
common unit referred to as cloud currency in this document. It can be configured
to ensure that your usage won’t exceed the budget allocated to accounts/domain
in cloud currency.  It will let user know how much of the cloud resources he is
using. It will help the cloud admins, if they want, to ensure that a user does
not go beyond his allocated quota. Per usage cycle if a account is found to be
exceeding its quota then it is locked. Locking an account means that it will not
be able to initiat e a new resource allocation request, whether it is more
storage or an additional ip. Needless to say quota service as well as any action
on the account is configurable.

Changes from Github code review:

- Added marvin test for quota plugin API
- removed unused commented code
- debug messages in debug enabled check
- checks for nulls, fixed access to member variables and feature
- changes based on PR comments
- unit tests for UsageTypes
- unit tests for all Cmd classes
- unit tests for all service and manager impls
- try-catch-finally or try-with-resource in dao impls for failsafe db switching
- remove dead code
- add missing quota calculation case (regression fixed)
- replace tabs with spaces in pom.xmls
- quota: though default value for quota_calculated is 0, the usage server
  makes it null while entering usage entries. Flipping the condition so
  as to acocunt for that.
- quotatypes: fix NPE in quota type
- quota framework test fixes
- made statement period configurable
- changed default email templates to reflect the fact that exhausted quota may not result in a locked account
- added quotaUpdateCmd that refreshes quota balances and sends alerts and statements
- report quotaSummary command returns quota balance, quota usage and state for all account
- made UI framework changes to allow for text area input in edit views
- process usage entries that have greater than 0 usage
- orocess quota entries only if tariff is non zero
- if there are credit entries but no balance entry create a dummy balance entry
- remove any credit entries that are before the last balance entry
  when displaying balance statement
- on a rerun the last balance is now getting added

FS: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Quota+Service+-+FS
PR: https://github.com/apache/cloudstack/pull/768

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-12-07 23:02:48 +05:30
Rajani Karuturi
37c3451aae CLOUDSTACK-8816 Fixed entityUuid missing in some cases is events
context parameters is Map<object,Object>. This has been used
interchangeably with String and class object resulting the param value
not being available in some cases if its put with object and get with
class.forName()

made the put and get consistent by using Object as key everywhere.
2015-09-09 14:23:27 +05:30
Rafael da Fonseca
ae328a6588 Fix 2 findbugs STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE warnings in BaseCmd.java Dateformat objects are not threadsafe and should be defined as instance variables Both INPUT_FORMAT and NEW_INPUT_FORMAT are only used in ParamProcessWorker.java and doesn't makes it more readable to declare in own class
Add missing import statement

Removed extraneous file

Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>

This closes #457
2015-06-15 16:32:30 +02:00
Ilia Shakitko
fe29998938 GetUsageRecordsCmd - NewInputFormat for START_DATE and END_DATE (with time; backward capabile)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-04-24 11:34:51 +02:00
Rohit Yadav
c0d3e6f5e8 server: ignore params signatureversion and expires when validating API args
(cherry picked from commit d361bf684704719902419d372c6ce31d941abe9e)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-04-14 16:52:32 +05:30
Hugo Trippaers
cf4ff03c90 CID-1191682 Fix missing break statement 2014-09-19 08:28:42 +02:00
Koushik Das
4e07dd1dc4 CLOUDSTACK-7581: Empty 'ID' parameters allowed in API calls
Fix is to fail API calls with empty 'id' parameter value upfront rather than going ahead and failing with NPE later on
2014-09-18 17:10:25 +05:30
Santhosh Edukulla
19ffc93e2e Fixed few coverity reported issues:Aug22 2014 2014-08-21 17:09:27 +05:30
Min Chen
a216046191 CLOUDSTACK-7165:[Automation] NPE observed during restart and expunge VM. 2014-07-25 15:51:47 -07:00
Santhosh Edukulla
97d296bfbd Fixed Coverity reported performance issues like inefficient string concatenations, wrong boxing or unboxing types, inefficent map element retrievals
Signed-off-by: Daan Hoogland <daan@onecht.net>
2014-07-01 22:06:25 +02:00
Nitin Mehta
c2a0fb4e52 CLOUDSTACK-6895: 1. Populate firstclass entities as uuids in the context instead of dbids for performance.
2. Add ctxDetails in the ParamGenericValidationWorker to avoid warning for api validation
3. Add some missing events.
4. Correcting mapping for ResourceObjectType.NetworkACL and ResourceObjectType.NetworkACLItem
(cherry picked from commit 8a9092c3cd4e3c034f9f4d0a7491875dc080e9dc)
2014-06-11 15:24:56 -07:00
Min Chen
ba848087f8 Disable IAM feature from 4.4 release. 2014-05-22 18:27:08 -07:00
Min Chen
0f79223f28 CLOUDSTACK-6613:IAM: authorizeSecurityGroupIngress fails when SG Name is
passed.
2014-05-08 23:19:28 -07:00
Min Chen
d7c5382c58 CLOUDSTACK-6535: IAM:MS:API createVMSnapshot doesn't preserve access
rights.
2014-05-01 15:57:28 -07:00
Nitin Mehta
dd55095fd5 CLOUDSTACK-6530: Populate the first class entities in the context to be available for publishing more information for the event bus, checking the displayable property etc.
(cherry picked from commit 3e7ea4e8d99a92872007f11a09ab87c8ba61e1da)
2014-04-28 18:21:48 -07:00
Prachi Damle
a0cd0c4d9d Changes while processing the @ACL annotation, to include only 1 object per parameter even if the parameter is tied to multiple interfaces in the @EntityReference 2014-04-17 17:54:19 -07:00
Min Chen
da13165743 Change AccountManagerImpl.checkAccess to invoke SecurityChecker
interface that takes multiple controlled entities.
2014-04-17 17:53:01 -07:00
Antonio Fornie
f5ba020633 Fix: ParamGenericValidationWorker shouldn't be case sensitive
Signed-off-by: Alena Prokharchyk <alena.prokharchyk@citrix.com>
2014-04-14 10:05:19 -07:00
Daan Hoogland
e97e65bff0 findbugs: toArray of the right type, not Object[] 2014-04-05 10:14:54 +02:00
Min Chen
94ebc90877 Remove usage of sameOwner checkAccess invocation, and convert to
OperateEntry IAM check.
2014-04-04 16:38:29 -07:00
Prachi Damle
a509f94544 Adding SecurityChecker list for the ParamProcessWorker 2014-04-04 16:38:29 -07:00
Prachi Damle
897e0d3abe SecurityChecker can accept multiple ControlledEntity 2014-04-04 16:38:29 -07:00
Antonio Fornie
39e5b768e8 More generic parameters that are not unknown
Adding some more parameter names that should not be considered unknown since they belong to general use paramters

Signed-off-by: Alena Prokharchyk <alena.prokharchyk@citrix.com>
2014-03-13 10:40:14 -07:00
Daan Hoogland
07102b400f findbugs: scope and final to mitgate possible abuse of fields 2014-03-10 09:39:35 +01:00
Daan Hoogland
c257fb0e3e rats 2014-03-07 19:27:58 +01:00
Antonio Fornie
c211f0bbbe Dispatcher corrections, refactoring and tests
Corrects problems from previous attempt. Fixes based on help comments from
the community and conflict resolution

Signed-off-by: Daan Hoogland <daan@onecht.net>
2014-03-07 19:12:07 +01:00
Alena Prokharchyk
782c530685 Revert "CLOUDSTACK-6003 fixing plus refactoring dispatcher" as it breaks API dispatching for commands having Map<String,String> as a parameter type
This reverts commit 447430c3df38c36d947c44c4aebd961d8cbb14c4.

Conflicts:
	api/src/org/apache/cloudstack/api/BaseCmd.java
	server/src/com/cloud/api/ApiDispatcher.java
	server/src/com/cloud/network/as/AutoScaleManagerImpl.java
	server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
2014-02-06 14:46:58 -08:00
Antonio Fornie
447430c3df CLOUDSTACK-6003 fixing plus refactoring dispatcher
Signed-off-by: Daan Hoogland <daan@onecht.net>
(cherry picked from commit a9bcc1ea3b7dfd3fcc5c795b0095c77851ebe618)
Signed-off-by: Daan Hoogland <daan@onecht.net>
2014-02-04 13:37:08 +01:00