90 Commits

Author SHA1 Message Date
Rohit Yadav
4347776ac6 CLOUDSTACK-8562: DB-Backed Dynamic Role Based API Access Checker
This feature allows root administrators to define new roles and associate API
permissions to them.

A limited form of role-based access control for the CloudStack management server
API is provided through a properties file, commands.properties, embedded in the
WAR distribution. Therefore, customizing API permissions requires unpacking the
distribution and modifying this file consistently on all servers. The old system
also does not permit the specification of additional roles.

FS:
https://cwiki.apache.org/confluence/display/CLOUDSTACK/Dynamic+Role+Based+API+Access+Checker+for+CloudStack

DB-Backed Dynamic Role Based API Access Checker for CloudStack brings following
changes, features and use-cases:
- Moves the API access definitions from commands.properties to the mgmt server DB
- Allows defining custom roles (such as a read-only ROOT admin) beyond the
  current set of four (4) roles
- All roles will resolve to one of the four known roles types (Admin, Resource
  Admin, Domain Admin and User) which maintains this association by requiring
  all new defined roles to specify a role type.
- Allows changes to roles and API permissions per role at runtime including additions or
  removal of roles and/or modifications of permissions, without the need
  of restarting management server(s)

Upgrade/installation notes:
- The feature will be enabled by default for new installations, existing
  deployments will continue to use the older static role based api access checker
  with an option to enable this feature
- During fresh installation or upgrade, the upgrade paths will add four default
  roles based on the four default role types
- For ease of migration, at the time of upgrade commands.properties will be used
  to add existing set of permissions to the default roles. cloud.account
  will have a new role_id column which will be populated based on default roles
  as well

Dynamic-roles migration tool: scripts/util/migrate-dynamicroles.py
- Allows admins to migrate to the dynamic role based checker at a future date
- Performs a harder one-way migrate and update
- Migrates rules from existing commands.properties file into db and deprecates it
- Enables an internal hidden switch to enable dynamic role based checker feature

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2016-05-11 09:45:19 +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
Wei Zhou
c01c73e44d CLOUDSTACK-9051: add unit tests for UpdateVmNicIp 2015-11-30 09:20:26 +01:00
Rajani Karuturi
863931a992 CLOUDSTACK-8816: some of the events do not have resource uuids
the key for an entity is sometimes an object a String with value
object.toString() due to serialization and deserialization of them.
Addressed this in the getter of CallContext to check for key.toString
if an object is not found with key.
2015-10-26 09:15:31 +05:30
Rajani Karuturi
1865433e69 unittests to verify empty password is not allowed during account create 2015-09-11 15:52:38 +05:30
John Burwell
ef44c7d305 CLOUDSTACK-8566: Strips the username and password credentials from host details
... map returned by the following API calls by filtering these fields from the
details attribute in the HostResponse class:

  * listHosts
  * addHost
  * cancelHostMaintenance
  * listHosts
  * prepareHostForMaintenance
  * reconnectHost
  * updateHost

This fix addresses CVE 2015-3251.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 3a48171bd8a70c6012afce32c7636afffc1d2f7d)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-08-14 10:49:40 +05:30
Daan Hoogland
520e0c8de0 CLOUDSTACK-8656: code in comment removed 2015-07-30 15:52:17 +02:00
wilderrodrigues
984fafce77 CLOUDSTACK-8641 - Adding unit tests
- Making sure that the boolean value is false and also that the updateHostPassword() method gets called.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #596
2015-07-16 18:28:27 +05:30
Daan Hoogland
4bba499412 rats: licenses missing 2015-07-06 17:04:26 +02:00
Daan Hoogland
a71c985223 findbugs: added test for getServiceProvider of CreateVpcOffering api
Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>

This closes #538
2015-07-06 16:22:19 +02:00
Pierre-Luc Dion
ed6016cf8e CreateSecondaryStagingStoreCmdTest.java: add license header 2014-11-30 23:15:15 -05:00
Laszlo Hornyak
b838436e58 cleanup around seemingly impossible cast
- changed type parameters on details map in CreateSecondaryStagingStoreCmd - <String, String> was misleading since it can not work with a string value and it is never a string
- introducing the type parameters allowed some simplifications in getDetails()
- added unit test

Signed-off-by: Laszlo Hornyak <laszlo.hornyak@gmail.com>
Signed-off-by: Pierre-Luc Dion <pdion891@apache.org>
2014-11-30 23:11:14 -05:00
Santhosh Edukulla
ef6ec7b276 Fixed few coverity issues like invalid boxing unboxing issues, resource leaks, null dereferences 2014-11-13 17:26:24 +05:30
Harikrishna Patnala
edf1047a20 CLOUDSTACK-7706: Coverity defects
Signed-off-by: Santhosh Edukulla <santhosh.edukulla@gmail.com>
2014-11-11 20:58:45 +05:30
SrikanteswaraRao Talluri
0e223d6787 Merge branch 'master' into marvin
Conflicts:
	test/integration/component/test_base_image_updation.py
	test/integration/component/test_cpu_domain_limits.py
	test/integration/component/test_cpu_limits.py
	test/integration/component/test_cpu_project_limits.py
	test/integration/component/test_ip_reservation.py
	test/integration/component/test_memory_limits.py
	test/integration/component/test_mm_domain_limits.py
	test/integration/component/test_mm_project_limits.py
	test/integration/component/test_persistent_networks.py
	test/integration/component/test_portable_ip.py
	test/integration/component/test_routers.py
	test/integration/smoke/test_deploy_vm.py
	test/integration/smoke/test_deploy_vm_with_userdata.py
	test/integration/smoke/test_internal_lb.py
	test/integration/smoke/test_vm_life_cycle.py
	test/integration/smoke/test_volumes.py
	tools/marvin/marvin/codes.py
	tools/marvin/marvin/configGenerator.py
	tools/marvin/marvin/lib/base.py
	tools/marvin/marvin/lib/common.py
	tools/marvin/marvin/lib/utils.py
2014-04-08 17:53:37 +05:30
Min Chen
99bdc8d875 Merge branch 'master' into rbac. 2014-03-13 11:05:03 -07: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
Santhosh Edukulla
bf72441d13 CLOUDSTACK-6006: Remove integration folder and lib 2014-02-04 12:01:58 +05:30
Min Chen
929fbabaa2 Merge branch 'master' into rbac. 2014-01-17 14:37:08 -08:00
Min Chen
649d9d927f CLOUDSTACK-5840:Migration from NFS to S3 should be done in one API
(updateCloudToUseObjectStore) instead of two APIs.
2014-01-08 17:25:13 -08:00
Alena Prokharchyk
b15431e574 CLOUDSTACK-5810: addSecondaryIp to vm's nic - derive the ip owner from the vm instance account, not from the caller 2014-01-06 17:09:14 -08:00
Daan Hoogland
6d0dbf5968 check for BroadcastDomainTypes on sourceNatIp 2014-01-06 22:13:51 +01:00
Alex Huang
be5e5cc641 All Checkstyle problems corrected 2013-12-12 12:26:07 -08:00
Min Chen
d252d95c26 Separate all vm related user APIs to have two different views. 2013-12-09 17:30:57 -08:00
Alex Huang
d620df2bdd Reformatted all of the code. 2013-11-21 06:15:26 -08:00
Alex Huang
224f479974 Removed trailing spaces 2013-11-21 04:08:01 -08:00
Alex Huang
8d62744681 Reformat all source code. Added checkstyle to check the source code 2013-11-20 07:26:53 -08:00
Alena Prokharchyk
78b1ac4126 CLOUDSTACK-3868: fixed "count" param in listUsageRecords API to return the actual number of records matching the search criteria. Used to return the wrong value - the number of records per page
Conflicts:
	server/src/com/cloud/usage/UsageServiceImpl.java
	utils/src/com/cloud/utils/db/GenericDaoBase.java
2013-10-31 15:25:57 -07:00
Daan Hoogland
2614b00c51 sdn hosted vpc gateways (using lswitch) 2013-09-18 16:56:56 +02:00
Alex Huang
b8e79c30a8 Compile complete 2013-09-06 15:40:37 -07:00
Daan Hoogland
53d09c6f18 uri code per broadcast/isolation type , default is to accept anything as uri , vlan and lswitch need some extra tlc
Signed-off-by: Hugo Trippaers <htrippaers@schubergphilis.com>
2013-08-15 14:26:26 +02:00
Alex Huang
5495f10bce Revert "Reverting the range of commits that broke the build"
This reverts commit b59e3aaefced03d40d5b4b63c421c69743bcd387.
2013-08-08 15:02:40 -07:00
Prasanna Santhanam
b59e3aaefc Reverting the range of commits that broke the build
This reverts commits 30c33415..f6a2c817bc

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
2013-08-08 14:46:56 +05:30
Alex Huang
f6a2c817bc Unit test successful. Had to comment out a timing test from Amogh 2013-08-07 16:41:06 -07:00
Alex Huang
5287f4c9ec Got everything running through testing 2013-08-07 16:41:06 -07:00
Min Chen
151a7ee497 CLOUDSTACK-3861 and CLOUDSTACK-3862: Deprecate old S3/Swift classes. 2013-08-02 18:16:46 -07:00
Alex Huang
f5e5b39c9b Moved the DB layer code into framework-db and change only the necessary projects to refer to it. Cut down on the dependencies introduced with all the code in utils. 2013-07-26 15:02:10 -07:00
Alex Huang
555211a080 Moved Configuration from api to utils and moved the package. This was done by eclipse so I only ran the unit test to verify everything is fine 2013-07-25 03:57:12 -07:00
Alex Huang
2d4464d2ba Applied review request 12685 2013-07-19 08:29:33 -07:00
Min Chen
98af424053 Merge branch 'master' into object_store. 2013-05-23 18:00:15 -07:00
Nitin Mehta
4eb310e926 iCLOUDSTACK-2321
Fix the response of scaleVMCmd
Add Scale System vm command
2013-05-17 17:43:43 +05:30
Nitin Mehta
5f0f1001be remove unwanted files 2013-05-12 14:30:10 +05:30
Nitin Mehta
c11dbad9c9 merge master 2013-05-11 15:28:43 +05:30
Alex Huang
3047929367 Merged 2013-05-10 16:21:43 -07:00
Alex Huang
ad2777c547 Moved agent commands to core and out of api 2013-05-06 16:34:20 -07:00
Harikrishna Patnala
38b4f84f17 CLOUDSTACK-2146: system vm scaleup failed ;{ "scalevirtualmachineresponse" : {"errorcode":530,"cserrorcode":9999,"errortext":"Failed to scale vm"} }
Only response generation for system vm scale up failed so fixed by changing the response object.

Signed-off-by: Abhinandan Prateek <aprateek@apache.org>
2013-05-03 16:49:08 +05:30
Min Chen
ff4c14ca63 Make old secondary storage APIs backward compatible. 2013-04-29 12:10:19 -07:00
Nitin Mehta
d1642a489c =initial changes 2013-04-25 18:29:57 +05:30
Jayapal
d5c3f87903 CLOUDSTACK-1741 Added ip uuid into the AddIptoVmNicCmd response
Signed-off-by: Abhinandan Prateek <aprateek@apache.org>
2013-04-25 15:16:26 +05:30
Harikrishna Patnala
eae22d2ffa CLOUDSTACK-741: Granular Global Parameters
Signed-off-by: Abhinandan Prateek <aprateek@apache.org>
2013-04-19 10:36:52 +05:30