incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [31/31] git commit: Pull changes from master into javelin
Date Sat, 12 Jan 2013 14:09:05 GMT
Updated Branches:
  refs/heads/javelin fdc9103fb -> 38eaa04b9


Pull changes from master into javelin

- Disables simulator plugin, breaks build, available via simulator profile
- Fixes spring injections
- Fix api,acl plugins, ApiServer, ApiDispatcher
- Fix other merge conflicts

Conflicts:
	docs/en-US/external-firewalls-and-load-balancers.xml
	plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java
	server/src/com/cloud/api/ApiDispatcher.java
	server/src/com/cloud/api/ApiServer.java
	server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
	utils/test/com/cloud/utils/log/CglibThrowableRendererTest.java

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>


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

Branch: refs/heads/javelin
Commit: 38eaa04b9882f1a32f74e3e9aa556792007bbed0
Parents: fdc9103 ad063ed
Author: Rohit Yadav <bhaisaab@apache.org>
Authored: Sat Jan 12 06:01:58 2013 -0800
Committer: Rohit Yadav <bhaisaab@apache.org>
Committed: Sat Jan 12 06:02:54 2013 -0800

----------------------------------------------------------------------
 api/src/com/cloud/network/NetworkService.java      |    2 +
 api/src/com/cloud/user/DomainService.java          |    2 +
 .../apache/cloudstack/acl/APIAccessChecker.java    |   29 --
 api/src/org/apache/cloudstack/acl/APIChecker.java  |   27 ++
 .../org/apache/cloudstack/api/ApiConstants.java    |    1 +
 .../apache/cloudstack/api/ResponseGenerator.java   |    7 -
 .../api/command/user/vm/DeployVMCmd.java           |   17 +-
 .../api/command/user/volume/ExtractVolumeCmd.java  |    2 +-
 client/tomcatconf/componentContext.xml.in          |    4 +-
 client/tomcatconf/components.xml.in                |    2 +-
 docs/en-US/autoscale.xml                           |  284 +++++++++++++++
 docs/en-US/building-marvin.xml                     |   46 +++
 docs/en-US/configure-snmp-rhel.xml                 |   86 +++++
 .../external-firewalls-and-load-balancers.xml      |   49 ++--
 docs/en-US/marvin.xml                              |    1 +
 ...guration-of-external-firewalls-loadbalancer.xml |   46 +++
 docs/en-US/system-service-offerings.xml            |    1 +
 .../storage/db/ObjectInDataStoreDaoImpl.java       |    5 +-
 .../acl/StaticRoleBasedAPIAccessChecker.java       |   86 ++----
 .../api/command/user/discovery/ListApisCmd.java    |   22 +-
 .../api/response/ApiDiscoveryResponse.java         |   26 ++-
 .../api/response/ApiParameterResponse.java         |   11 +
 .../api/response/ApiResponseResponse.java          |   45 +++
 .../cloudstack/discovery/ApiDiscoveryService.java  |    2 +-
 .../discovery/ApiDiscoveryServiceImpl.java         |  160 +++++++--
 plugins/pom.xml                                    |    1 -
 server/src/com/cloud/api/ApiDispatcher.java        |   22 +-
 server/src/com/cloud/api/ApiResponseHelper.java    |    5 -
 server/src/com/cloud/api/ApiServer.java            |   66 ++--
 .../consoleproxy/ConsoleProxyManagerImpl.java      |   39 +--
 .../src/com/cloud/network/NetworkManagerImpl.java  |    6 +
 server/src/com/cloud/user/DomainManagerImpl.java   |    5 +
 .../com/cloud/network/MockNetworkManagerImpl.java  |    6 +
 .../test/com/cloud/user/MockDomainManagerImpl.java |    6 +
 .../test/com/cloud/vpc/MockNetworkManagerImpl.java |    6 +
 tools/apidoc/gen_toc.py                            |    1 -
 tools/apidoc/pom.xml                               |    2 +-
 tools/devcloud-kvm/devcloud-kvm.sql                |    2 +-
 utils/src/com/cloud/utils/db/GenericDao.java       |    2 +-
 utils/src/com/cloud/utils/db/GenericDaoBase.java   |    2 +-
 .../utils/log/CglibThrowableRendererTest.java      |   38 ++-
 41 files changed, 920 insertions(+), 252 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/38eaa04b/client/tomcatconf/componentContext.xml.in
----------------------------------------------------------------------
diff --cc client/tomcatconf/componentContext.xml.in
index 44be3b6,0000000..384498f
mode 100644,000000..100644
--- a/client/tomcatconf/componentContext.xml.in
+++ b/client/tomcatconf/componentContext.xml.in
@@@ -1,52 -1,0 +1,52 @@@
 +<beans xmlns="http://www.springframework.org/schema/beans"
 +  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 +  xmlns:context="http://www.springframework.org/schema/context"
 +  xmlns:tx="http://www.springframework.org/schema/tx" 
 +  xmlns:aop="http://www.springframework.org/schema/aop"
 +  xsi:schemaLocation="http://www.springframework.org/schema/beans
 +                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 +                      http://www.springframework.org/schema/tx 
 +                      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
 +                      http://www.springframework.org/schema/aop
 +                      http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
 +                      http://www.springframework.org/schema/context
 +                      http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                    
 +
 +
 +  <!--
 +      Configurable components
 +  -->
-   <bean id="ManagementServerExtImpl" class ="com.cloud.server.ManagementServerExtImpl"
/>
- 
++  <bean id="management-server" class ="com.cloud.server.ManagementServerExtImpl" />
++  <bean id="configuration-server" class="com.cloud.server.ConfigurationServerImpl" />
 +   
 +  <!--
 +      Network Elements
 +  -->
 +  <bean id="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement">
 +    <property name="name" value="VirtualRouter"/>
 +  </bean>
 +  <bean id="Ovs" class="com.cloud.network.element.OvsElement">
 +    <property name="name" value="Ovs"/>
 +  </bean>
 +  <bean id="ExternalDhcpServer" class="com.cloud.network.element.ExternalDhcpElement">
 +    <property name="name" value="ExternalDhcpServer"/>
 +  </bean>
 +  <bean id="BareMetal" class="com.cloud.network.element.BareMetalElement">
 +    <property name="name" value="BareMetal"/>
 +  </bean>
 +  <bean id="SecurityGroupProvider" class="com.cloud.network.element.SecurityGroupElement">
 +    <property name="name" value="SecurityGroupProvider"/>
 +  </bean>
 +  <bean id="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement">
 +    <property name="name" value="VpcVirtualRouter"/>
 +  </bean>
 +  <bean id="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement">
 +    <property name="name" value="NiciraNvp"/>
 +  </bean>
 +                   
 +  <!--
 +     Adapters
 +  -->
 +  <bean id="StaticRoleBasedAPIAccessChecker" class="org.apache.cloudstack.acl.StaticRoleBasedAPIAccessChecker"/>
 +  
 +</beans>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/38eaa04b/engine/storage/src/org/apache/cloudstack/storage/db/ObjectInDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --cc engine/storage/src/org/apache/cloudstack/storage/db/ObjectInDataStoreDaoImpl.java
index 9932b48,0000000..4b0b2ca
mode 100644,000000..100644
--- a/engine/storage/src/org/apache/cloudstack/storage/db/ObjectInDataStoreDaoImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/db/ObjectInDataStoreDaoImpl.java
@@@ -1,20 -1,0 +1,19 @@@
 +package org.apache.cloudstack.storage.db;
- 
- 
++import org.springframework.stereotype.Component;
 +
 +import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
 +import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.State;
 +
 +import com.cloud.utils.db.GenericDaoBase;
 +
- 
++@Component
 +public class ObjectInDataStoreDaoImpl extends GenericDaoBase<ObjectInDataStoreVO, Long>
implements ObjectInDataStoreDao {
 +
 +    @Override
 +    public boolean updateState(State currentState, Event event,
 +            State nextState, ObjectInDataStoreVO vo, Object data) {
 +        // TODO Auto-generated method stub
 +        return false;
 +    }
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/38eaa04b/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java
----------------------------------------------------------------------
diff --cc plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java
index 7c69301,affd69e..2eaa6b0
--- a/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java
+++ b/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java
@@@ -27,45 -30,22 +27,37 @@@ import java.util.List
  import java.util.Map;
  import java.util.Set;
  
 +import javax.ejb.Local;
 +import javax.inject.Inject;
 +import javax.naming.ConfigurationException;
 +
  import org.apache.log4j.Logger;
 +import org.springframework.stereotype.Component;
 +
++import com.cloud.server.ManagementServer;
 +import com.cloud.exception.PermissionDeniedException;
 +import com.cloud.user.AccountManager;
 +import com.cloud.utils.component.AdapterBase;
++import com.cloud.utils.component.ComponentContext;
 +import com.cloud.utils.component.PluggableService;
  
  // This is the default API access checker that grab's the user's account
  // based on the account type, access is granted
 +@Component
- @Local(value=APIAccessChecker.class)
- public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIAccessChecker
{
+ @Local(value=APIChecker.class)
+ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIChecker {
  
      protected static final Logger s_logger = Logger.getLogger(StaticRoleBasedAPIAccessChecker.class);
-     public static final short ADMIN_COMMAND = 1;
-     public static final short DOMAIN_ADMIN_COMMAND = 4;
-     public static final short RESOURCE_DOMAIN_ADMIN_COMMAND = 2;
-     public static final short USER_COMMAND = 8;
  
-     @Inject AccountManager _accountMgr;
+     private static Map<RoleType, Set<String>> s_roleBasedApisMap =
+             new HashMap<RoleType, Set<String>>();
+ 
 +    @Inject List<PluggableService> _services;
-     private static Set<String> s_userCommands = null;
-     private static Set<String> s_resellerCommands = null; // AKA domain-admin
-     private static Set<String> s_adminCommands = null;
-     private static Set<String> s_resourceDomainAdminCommands = null;
-     private static Set<String> s_allCommands = null;
 +
      protected StaticRoleBasedAPIAccessChecker() {
          super();
-         s_allCommands = new HashSet<String>();
-         s_userCommands = new HashSet<String>();
-         s_resellerCommands = new HashSet<String>();
-         s_adminCommands = new HashSet<String>();
-         s_resourceDomainAdminCommands = new HashSet<String>();
+         for (RoleType roleType: RoleType.values())
+             s_roleBasedApisMap.put(roleType, new HashSet<String>());
      }
  
      @Override
@@@ -97,14 -61,16 +73,11 @@@
      @Override
      public boolean configure(String name, Map<String, Object> params) throws ConfigurationException
{
          super.configure(name, params);
--
--        // Read command properties files to build the static map per role.
-         Map<String, String> configPropertiesMap = new HashMap<String, String>();
 -        ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
 -        List<PluggableService> services = locator.getAllPluggableServices();
 -        services.add((PluggableService) ComponentLocator.getComponent(ManagementServer.Name));
 -
 -        for (PluggableService service : services) {
++        _services.add((PluggableService) ComponentContext.getComponent(ManagementServer.Name));
 +        for (PluggableService service : _services) {
-             configPropertiesMap.putAll(service.getProperties());
+             processConfigFiles(service.getProperties(), service.getClass().toString());
+             s_logger.info("Processed role based acl for: " + service.toString());
          }
- 
-         processConfigFiles(configPropertiesMap);
          return true;
      }
  

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/38eaa04b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
----------------------------------------------------------------------
diff --cc plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
index 2bc17bd,5f84486..6ff4085
--- a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
+++ b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
@@@ -16,8 -16,13 +16,13 @@@
  // under the License.
  package org.apache.cloudstack.discovery;
  
- import com.cloud.utils.PropertiesUtil;
+ import com.cloud.serializer.Param;
+ import com.cloud.server.ManagementServer;
  import com.cloud.utils.ReflectUtil;
+ import com.cloud.utils.StringUtils;
 -import com.cloud.utils.component.ComponentLocator;
++import com.cloud.utils.component.ComponentContext;
+ import com.cloud.utils.component.PluggableService;
+ import com.google.gson.annotations.SerializedName;
  import org.apache.cloudstack.acl.RoleType;
  import org.apache.cloudstack.api.APICommand;
  import org.apache.cloudstack.api.BaseCmd;
@@@ -27,10 -32,11 +32,13 @@@ import org.apache.cloudstack.api.BaseRe
  import org.apache.cloudstack.api.Parameter;
  import org.apache.cloudstack.api.response.ApiDiscoveryResponse;
  import org.apache.cloudstack.api.response.ApiParameterResponse;
+ import org.apache.cloudstack.api.response.ApiResponseResponse;
  import org.apache.cloudstack.api.response.ListResponse;
  import org.apache.log4j.Logger;
++import org.springframework.stereotype.Component;
  
  import javax.ejb.Local;
++import javax.inject.Inject;
  import java.lang.reflect.Field;
  import java.util.ArrayList;
  import java.util.HashMap;
@@@ -38,34 -45,61 +47,62 @@@ import java.util.List
  import java.util.Map;
  import java.util.Set;
  
++@Component
  @Local(value = ApiDiscoveryService.class)
  public class ApiDiscoveryServiceImpl implements ApiDiscoveryService {
      private static final Logger s_logger = Logger.getLogger(ApiDiscoveryServiceImpl.class);
  
-     private ListResponse<ApiDiscoveryResponse> _discoveryResponse = new ListResponse<ApiDiscoveryResponse>();
+     private static Map<RoleType, List<ApiDiscoveryResponse>> _roleTypeDiscoveryResponseListMap;
  
-     private Map<String, Class<?>> _apiNameCmdClassMap = new HashMap<String,
Class<?>>();
+     private static Map<String, ApiDiscoveryResponse> _apiNameDiscoveryResponseMap
=
+             new HashMap<String, ApiDiscoveryResponse>();
+ 
+     private static Map<String, List<RoleType>> _apiNameRoleTypeListMap = null;
+ 
++    @Inject List<PluggableService> _services;
 +
      protected ApiDiscoveryServiceImpl() {
          super();
-         generateApiNameCmdClassMap();
-         cacheListApiResponse();
+         if (_roleTypeDiscoveryResponseListMap == null) {
+             long startTime = System.nanoTime();
+             _roleTypeDiscoveryResponseListMap = new HashMap<RoleType, List<ApiDiscoveryResponse>>();
+             for (RoleType roleType: RoleType.values())
+                 _roleTypeDiscoveryResponseListMap.put(roleType, new ArrayList<ApiDiscoveryResponse>());
+             cacheResponseMap();
+             long endTime = System.nanoTime();
+             s_logger.info("Api Discovery Service: Annotation, docstrings, api relation graph
processed in " + (endTime - startTime) / 1000000.0 + " ms");
+         }
      }
  
-     private void generateApiNameCmdClassMap() {
-         Set<Class<?>> cmdClasses = ReflectUtil.getClassesWithAnnotation(APICommand.class,
-                 new String[]{"org.apache.cloudstack.api", "com.cloud.api"});
- 
-         for(Class<?> cmdClass: cmdClasses)
-             _apiNameCmdClassMap.put(cmdClass.getAnnotation(APICommand.class).name(), cmdClass);
+     private Map<String, List<RoleType>> getApiNameRoleTypeListMap() {
+         Map<String, List<RoleType>> apiNameRoleTypeMap = new HashMap<String,
List<RoleType>>();
 -        ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
 -        List<PluggableService> services = locator.getAllPluggableServices();
 -        services.add((PluggableService) ComponentLocator.getComponent(ManagementServer.Name));
 -        for (PluggableService service : services) {
++        _services.add((PluggableService) ComponentContext.getComponent(ManagementServer.Name));
++        for (PluggableService service : _services) {
+             for (Map.Entry<String, String> entry: service.getProperties().entrySet())
{
+                 String apiName = entry.getKey();
+                 String roleMask = entry.getValue();
+                 try {
+                     short cmdPermissions = Short.parseShort(roleMask);
+                     if (!apiNameRoleTypeMap.containsKey(apiName))
+                         apiNameRoleTypeMap.put(apiName, new ArrayList<RoleType>());
+                     for (RoleType roleType: RoleType.values()) {
+                         if ((cmdPermissions & roleType.getValue()) != 0)
+                             apiNameRoleTypeMap.get(apiName).add(roleType);
+                     }
+                 } catch (NumberFormatException nfe) {
+                 }
+             }
+         }
+         return apiNameRoleTypeMap;
      }
  
-     private void cacheListApiResponse() {
+     private void cacheResponseMap() {
+         Set<Class<?>> cmdClasses = ReflectUtil.getClassesWithAnnotation(APICommand.class,
+                 new String[]{"org.apache.cloudstack.api", "com.cloud.api"});
  
-         List<ApiDiscoveryResponse> apiDiscoveryResponses = new ArrayList<ApiDiscoveryResponse>();
+         Map<String, List<String>> responseApiNameListMap = new HashMap<String,
List<String>>();
  
-         for(String key: _apiNameCmdClassMap.keySet()) {
-             Class<?> cmdClass = _apiNameCmdClassMap.get(key);
+         for(Class<?> cmdClass: cmdClasses) {
              APICommand apiCmdAnnotation = cmdClass.getAnnotation(APICommand.class);
              if (apiCmdAnnotation == null)
                  apiCmdAnnotation = cmdClass.getSuperclass().getAnnotation(APICommand.class);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/38eaa04b/plugins/pom.xml
----------------------------------------------------------------------
diff --cc plugins/pom.xml
index a42ae29,a42ae29..8c68c28
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@@ -40,7 -40,7 +40,6 @@@
      <module>hypervisors/ovm</module>
      <module>hypervisors/xen</module>
      <module>hypervisors/kvm</module>
--    <module>hypervisors/simulator</module>
      <module>network-elements/elastic-loadbalancer</module>
      <module>network-elements/ovs</module>
      <module>network-elements/nicira-nvp</module>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/38eaa04b/server/src/com/cloud/api/ApiDispatcher.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiDispatcher.java
index 10810b7,55d7f42..67aa454
--- a/server/src/com/cloud/api/ApiDispatcher.java
+++ b/server/src/com/cloud/api/ApiDispatcher.java
@@@ -66,46 -58,55 +66,36 @@@ import com.cloud.user.AccountManager
  import com.cloud.user.UserContext;
  import com.cloud.utils.DateUtil;
  import com.cloud.utils.NumbersUtil;
 -import com.cloud.utils.component.ComponentLocator;
 -import com.cloud.utils.component.Inject;
 -import com.cloud.utils.component.PluggableService;
 -import com.cloud.utils.db.GenericDao;
 +import com.cloud.utils.ReflectUtil;
  import com.cloud.utils.exception.CSExceptionErrorCode;
  import com.cloud.utils.exception.CloudRuntimeException;
- import com.cloud.uuididentity.dao.IdentityDao;
  
 -// ApiDispatcher: A class that dispatches API commands to the appropriate manager for execution.
 +@Component
  public class ApiDispatcher {
      private static final Logger s_logger = Logger.getLogger(ApiDispatcher.class.getName());
  
 -    ComponentLocator _locator;
      Long _createSnapshotQueueSizeLimit;
 -    @Inject private AsyncJobManager _asyncMgr = null;
 -    @Inject private AccountManager _accountMgr = null;
 +    @Inject AsyncJobManager _asyncMgr = null;
 +    @Inject AccountManager _accountMgr = null;
      @Inject EntityManager _entityMgr = null;
-     @Inject IdentityDao _identityDao = null;
-     @Inject ConfigurationDao _configDao = null;
  
 -    Map<String, Class<? extends GenericDao>> _daoNameMap = new HashMap<String,
Class<? extends GenericDao>>();
 -    // singleton class
 -    private static ApiDispatcher s_instance = ApiDispatcher.getInstance();
 +    private static ApiDispatcher s_instance;
  
      public static ApiDispatcher getInstance() {
 -        if (s_instance == null) {
 -            s_instance = ComponentLocator.inject(ApiDispatcher.class);
 -        }
          return s_instance;
      }
  
      protected ApiDispatcher() {
          super();
-         Map<String, String> configs = _configDao.getConfiguration();
-         String strSnapshotLimit = configs.get(Config.ConcurrentSnapshotsThresholdPerHost.key());
-         if (strSnapshotLimit != null) {
-             Long snapshotLimit = NumbersUtil.parseLong(strSnapshotLimit, 1L);
-             if (snapshotLimit <= 0) {
-                 s_logger.debug("Global config parameter " + Config.ConcurrentSnapshotsThresholdPerHost.toString()
-                         + " is less or equal 0; defaulting to unlimited");
-             } else {
-                 _createSnapshotQueueSizeLimit = snapshotLimit;
-             }
-         }
 -        _locator = ComponentLocator.getLocator(ManagementServer.Name);
 -        ConfigurationDao configDao = _locator.getDao(ConfigurationDao.class);
 -        Map<String, String> configs = configDao.getConfiguration();
 -        String strSnapshotLimit = configs.get(Config.ConcurrentSnapshotsThresholdPerHost.key());
 -        if (strSnapshotLimit != null) {
 -            Long snapshotLimit = NumbersUtil.parseLong(strSnapshotLimit, 1L);
 -            if (snapshotLimit <= 0) {
 -                s_logger.debug("Global config parameter " + Config.ConcurrentSnapshotsThresholdPerHost.toString()
 -                        + " is less or equal 0; defaulting to unlimited");
 -            } else {
 -                _createSnapshotQueueSizeLimit = snapshotLimit;
 -            }
 -        }
 -        _daoNameMap.put("com.cloud.network.Network", NetworkDao.class);
 -        _daoNameMap.put("com.cloud.template.VirtualMachineTemplate", VMTemplateDao.class);
 +        s_instance = this;
 +    }
 +
++    public void setCreateSnapshotQueueSizeLimit(Long snapshotLimit) {
++        _createSnapshotQueueSizeLimit = snapshotLimit;
+     }
+ 
      public void dispatchCreateCmd(BaseAsyncCreateCmd cmd, Map<String, String> params)
{
 -    	processParameters(cmd, params);
 +        processParameters(cmd, params);
  
          try {
              UserContext ctx = UserContext.current();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/38eaa04b/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiServer.java
index 4cb892f,03462e4..e5b57e5
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@@ -51,19 -50,10 +51,19 @@@ import javax.inject.Inject
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  
- import org.apache.cloudstack.acl.APIAccessChecker;
 -import com.cloud.utils.ReflectUtil;
+ import org.apache.cloudstack.acl.APIChecker;
  import org.apache.cloudstack.acl.RoleType;
 -import org.apache.cloudstack.api.*;
 +import org.apache.cloudstack.api.APICommand;
 +import org.apache.cloudstack.api.BaseAsyncCmd;
 +import org.apache.cloudstack.api.BaseAsyncCreateCmd;
 +import org.apache.cloudstack.api.BaseCmd;
 +import org.apache.cloudstack.api.BaseListCmd;
 +import org.apache.cloudstack.api.ResponseObject;
 +import org.apache.cloudstack.api.ServerApiException;
 +import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
 +import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
 +import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
 +import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
  import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
  import org.apache.cloudstack.api.command.user.account.ListProjectAccountsCmd;
  import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
@@@ -128,34 -123,29 +128,33 @@@ import com.cloud.user.UserAccount
  import com.cloud.user.UserContext;
  import com.cloud.user.UserVO;
  import com.cloud.utils.Pair;
 -import com.cloud.utils.component.Adapters;
++import com.cloud.utils.NumbersUtil;
 +import com.cloud.utils.ReflectUtil;
  import com.cloud.utils.StringUtils;
 -import com.cloud.utils.component.ComponentLocator;
 -import com.cloud.utils.component.Inject;
 +import com.cloud.utils.component.ComponentContext;
 +import com.cloud.utils.component.PluggableService;
  import com.cloud.utils.concurrency.NamedThreadFactory;
  import com.cloud.utils.db.SearchCriteria;
  import com.cloud.utils.db.Transaction;
  import com.cloud.utils.exception.CSExceptionErrorCode;
- import com.cloud.uuididentity.dao.IdentityDao;
  
 +@Component
  public class ApiServer implements HttpRequestHandler {
      private static final Logger s_logger = Logger.getLogger(ApiServer.class.getName());
      private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName());
  
      public static boolean encodeApiResponse = false;
      public static String jsonContentType = "text/javascript";
 -    private ApiDispatcher _dispatcher;
 +    @Inject ApiDispatcher _dispatcher;
 +
 +    @Inject private AccountManager _accountMgr;
 +    @Inject private DomainManager _domainMgr;
 +    @Inject private AsyncJobManager _asyncMgr;
 +    @Inject private ConfigurationDao _configDao;
  
 -    @Inject private AccountManager _accountMgr = null;
 -    @Inject private DomainManager _domainMgr = null;
 -    @Inject private AsyncJobManager _asyncMgr = null;
 +    @Inject List<PluggableService> _pluggableServices;
-     @Inject IdentityDao _identityDao;
  
-     @Inject List<APIAccessChecker> _apiAccessCheckers;
 -    @Inject(adapter = APIChecker.class)
 -    protected Adapters<APIChecker> _apiAccessCheckers;
++    @Inject List<APIChecker> _apiAccessCheckers;
  
      private Account _systemAccount = null;
      private User _systemUser = null;
@@@ -203,6 -196,6 +202,18 @@@
              }
          }
  
++        Map<String, String> configs = _configDao.getConfiguration();
++        String strSnapshotLimit = configs.get(Config.ConcurrentSnapshotsThresholdPerHost.key());
++        if (strSnapshotLimit != null) {
++            Long snapshotLimit = NumbersUtil.parseLong(strSnapshotLimit, 1L);
++            if (snapshotLimit <= 0) {
++                s_logger.debug("Global config parameter " + Config.ConcurrentSnapshotsThresholdPerHost.toString()
++                        + " is less or equal 0; defaulting to unlimited");
++            } else {
++                _dispatcher.setCreateSnapshotQueueSizeLimit(snapshotLimit);
++            }
++        }
++
          Set<Class<?>> cmdClasses = ReflectUtil.getClassesWithAnnotation(APICommand.class,
                  new String[]{"org.apache.cloudstack.api", "com.cloud.api"});
  
@@@ -552,12 -545,12 +563,12 @@@
              }
  
              String commandName = command[0];
- /*
+ 
              // if userId not null, that mean that user is logged in
              if (userId != null) {
 -            	User user = ApiDBUtils.findUserById(userId);
 +                User user = ApiDBUtils.findUserById(userId);
                  if (!isCommandAvailable(user, commandName)) {
-                     s_logger.warn("The given command:" + commandName + " does not exist
or it is not available for user");
+                     s_logger.debug("The given command:" + commandName + " does not exist
or it is not available for user with id:" + userId);
                      throw new ServerApiException(BaseCmd.UNSUPPORTED_ACTION_ERROR, "The
given command does not exist or it is not available for user");
                  }
                  return true;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/38eaa04b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index 353ef73,5bc5d27..502ba30
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@@ -31,10 -31,9 +31,12 @@@ import javax.inject.Inject
  import javax.naming.ConfigurationException;
  import javax.persistence.Table;
  
 +import org.apache.cloudstack.api.ServerApiException;
+ import com.cloud.offering.DiskOffering;
+ import com.cloud.storage.dao.DiskOfferingDao;
  import org.apache.log4j.Logger;
 +import org.springframework.context.annotation.Primary;
 +import org.springframework.stereotype.Component;
  
  import com.cloud.agent.AgentManager;
  import com.cloud.agent.api.AgentControlAnswer;
@@@ -1511,26 -1519,23 +1509,23 @@@ public class ConsoleProxyManagerImpl im
          _itMgr.registerGuru(VirtualMachine.Type.ConsoleProxy, this);
  
          boolean useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key()));
 -        
 +
          //check if there is a default service offering configured
--        String cpvmSrvcOffIdStr = configs.get(Config.ConsoleProxyServiceOffering.key());

++        String cpvmSrvcOffIdStr = configs.get(Config.ConsoleProxyServiceOffering.key());
          if (cpvmSrvcOffIdStr != null) {
- 
-             Long cpvmSrvcOffId = null;
-             try {
-                 cpvmSrvcOffId = _identityDao.getIdentityId(DiskOfferingVO.class.getAnnotation(Table.class).name(),cpvmSrvcOffIdStr);
-             } catch (Exception e) {
-                 String msg = "Can't find system service offering specified by global config,
uuid=" + cpvmSrvcOffIdStr + " for console proxy vm";
-                 s_logger.warn(msg);
-             }
-             if(cpvmSrvcOffId != null){
-                 _serviceOffering = _offeringDao.findById(cpvmSrvcOffId);
+             DiskOffering diskOffering = _diskOfferingDao.findByUuid(cpvmSrvcOffIdStr);
+             if (diskOffering == null)
+                 diskOffering = _diskOfferingDao.findById(Long.parseLong(cpvmSrvcOffIdStr));
+             if (diskOffering != null) {
+                 _serviceOffering = _offeringDao.findById(diskOffering.getId());
+             } else {
+                 s_logger.warn("Can't find system service offering specified by global config,
uuid=" + cpvmSrvcOffIdStr + " for console proxy vm");
              }
--        } 
++        }
  
          if(_serviceOffering == null || !_serviceOffering.getSystemUse()){
 -        	int ramSize = NumbersUtil.parseInt(_configDao.getValue("console.ram.size"), DEFAULT_PROXY_VM_RAMSIZE);
 -        	int cpuFreq = NumbersUtil.parseInt(_configDao.getValue("console.cpu.mhz"), DEFAULT_PROXY_VM_CPUMHZ);
 +            int ramSize = NumbersUtil.parseInt(_configDao.getValue("console.ram.size"),
DEFAULT_PROXY_VM_RAMSIZE);
 +            int cpuFreq = NumbersUtil.parseInt(_configDao.getValue("console.cpu.mhz"), DEFAULT_PROXY_VM_CPUMHZ);
              _serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy",
1, ramSize, cpuFreq, 0, 0, false, null, useLocalStorage, true, null, true, VirtualMachine.Type.ConsoleProxy,
true);
              _serviceOffering.setUniqueName(ServiceOffering.consoleProxyDefaultOffUniqueName);
              _serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/38eaa04b/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/38eaa04b/server/src/com/cloud/user/DomainManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/38eaa04b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/38eaa04b/utils/test/com/cloud/utils/log/CglibThrowableRendererTest.java
----------------------------------------------------------------------
diff --cc utils/test/com/cloud/utils/log/CglibThrowableRendererTest.java
index bf917de,c1cd81e..59926f8
--- a/utils/test/com/cloud/utils/log/CglibThrowableRendererTest.java
+++ b/utils/test/com/cloud/utils/log/CglibThrowableRendererTest.java
@@@ -18,11 -18,16 +18,16 @@@ package com.cloud.utils.log
  
  import junit.framework.TestCase;
  
- import org.apache.log4j.Logger;
+ import org.apache.log4j.*;
  
 -import com.cloud.utils.component.ComponentLocator;
 +import com.cloud.utils.component.ComponentContext;
  import com.cloud.utils.db.DB;
  import com.cloud.utils.exception.CloudRuntimeException;
+ import org.apache.log4j.spi.RootLogger;
+ import org.apache.log4j.spi.ThrowableRenderer;
+ 
+ import java.io.CharArrayWriter;
+ import java.io.Writer;
  
  
  public class CglibThrowableRendererTest extends TestCase {
@@@ -49,8 -56,21 +56,21 @@@
          }
      }
  
+     private Logger getAlternateLogger(Writer writer, ThrowableRenderer renderer) {
+         Hierarchy hierarchy = new Hierarchy(new RootLogger(Level.INFO));
+         if (renderer != null) {
+             hierarchy.setThrowableRenderer(renderer);
+         }
+         Logger alternateRoot = hierarchy.getRootLogger();
+         alternateRoot.addAppender(new WriterAppender(new SimpleLayout(), writer));
+         return alternateRoot;
+     }
 -    
++
      public void testException() {
+         Writer w = new CharArrayWriter();
+         Logger alt = getAlternateLogger(w, null);
+ 
 -        Test test = ComponentLocator.inject(Test.class);
 +        Test test = ComponentContext.inject(Test.class);
          try {
              test.exception();
          } catch (Exception e) {


Mime
View raw message