cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [10/36] Commit to try something on removing getZone
Date Fri, 06 Sep 2013 22:38:40 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
index cdb284a..9923db5 100644
--- a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
@@ -56,8 +56,6 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana
     private static final Logger s_logger = Logger.getLogger(NetworkACLManagerImpl.class);
 
     @Inject
-    EntityManager _entityMgr;
-    @Inject
     AccountManager _accountMgr;
     @Inject
     NetworkModel _networkMgr;
@@ -81,6 +79,8 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana
     NetworkModel _ntwkModel;
     @Inject
     ConfigurationManager _configMgr;
+    @Inject
+    EntityManager _entityMgr;
 
     @Override
     public NetworkACL createNetworkACL(String name, String description, long vpcId) {
@@ -105,7 +105,7 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana
 
         List<VpcGatewayVO> vpcGateways = _vpcGatewayDao.listByAclIdAndType(aclId, VpcGateway.Type.Private);
         for (VpcGatewayVO vpcGateway : vpcGateways) {
-            PrivateGateway privateGateway = _vpcMgr.getVpcPrivateGateway(vpcGateway.getId());
+            PrivateGateway privateGateway = _entityMgr.findById(PrivateGateway.class, vpcGateway.getId());
             if (!applyACLToPrivateGw(privateGateway)) {
                 aclApplyStatus = false;
                 s_logger.debug("failed to apply network acl item on private gateway " + privateGateway.getId() + "acl id " + aclId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java b/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
index 274ca44..50dd8e3 100644
--- a/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
+++ b/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
@@ -16,6 +16,23 @@
 // under the License.
 package com.cloud.network.vpc;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.command.user.network.CreateNetworkACLCmd;
+import org.apache.cloudstack.api.command.user.network.ListNetworkACLsCmd;
+import org.apache.cloudstack.context.CallContext;
+
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
@@ -34,6 +51,7 @@ import com.cloud.user.AccountManager;
 import com.cloud.utils.Pair;
 import com.cloud.utils.Ternary;
 import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.JoinBuilder;
 import com.cloud.utils.db.SearchBuilder;
@@ -42,23 +60,6 @@ import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.net.NetUtils;
 
-import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.command.user.network.CreateNetworkACLCmd;
-import org.apache.cloudstack.api.command.user.network.ListNetworkACLsCmd;
-import org.apache.cloudstack.context.CallContext;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
 
 @Component
 @Local(value = { NetworkACLService.class})
@@ -85,11 +86,13 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
     VpcGatewayDao _vpcGatewayDao;
     @Inject
     VpcManager _vpcMgr;
+    @Inject
+    EntityManager _entityMgr;
 
     @Override
     public NetworkACL createNetworkACL(String name, String description, long vpcId) {
         Account caller = CallContext.current().getCallingAccount();
-        Vpc vpc = _vpcMgr.getVpc(vpcId);
+        Vpc vpc = _entityMgr.findById(Vpc.class, vpcId);
         if(vpc == null){
             throw new InvalidParameterValueException("Unable to find VPC");
         }
@@ -151,7 +154,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
             throw new InvalidParameterValueException("Default ACL cannot be removed");
         }
 
-        Vpc vpc = _vpcMgr.getVpc(acl.getVpcId());
+        Vpc vpc = _entityMgr.findById(Vpc.class, acl.getVpcId());
         if(vpc == null){
             throw new InvalidParameterValueException("Unable to find specified VPC associated with the ACL");
         }
@@ -182,7 +185,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
         }
 
         if(aclId != NetworkACL.DEFAULT_DENY && aclId != NetworkACL.DEFAULT_ALLOW) {
-            Vpc vpc = _vpcMgr.getVpc(acl.getVpcId());
+            Vpc vpc = _entityMgr.findById(Vpc.class, acl.getVpcId());
             if(vpc == null){
                 throw new InvalidParameterValueException("Unable to find Vpc associated with the NetworkACL");
             }
@@ -192,7 +195,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
             }
         }
 
-        PrivateGateway privateGateway = _vpcMgr.getVpcPrivateGateway(privateGatewayId);
+        PrivateGateway privateGateway = _entityMgr.findById(PrivateGateway.class, privateGatewayId);
         _accountMgr.checkAccess(caller, null, true, privateGateway);
 
         return  _networkAclMgr.replaceNetworkACLForPrivateGw(acl, privateGateway);
@@ -224,7 +227,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
         if(aclId != NetworkACL.DEFAULT_DENY && aclId != NetworkACL.DEFAULT_ALLOW) {
             //ACL is not default DENY/ALLOW
             // ACL should be associated with a VPC
-            Vpc vpc = _vpcMgr.getVpc(acl.getVpcId());
+            Vpc vpc = _entityMgr.findById(Vpc.class, acl.getVpcId());
             if(vpc == null){
                 throw new InvalidParameterValueException("Unable to find Vpc associated with the NetworkACL");
             }
@@ -262,7 +265,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
                     throw new InvalidParameterValueException("Network Offering does not support NetworkACL service");
                 }
 
-                Vpc vpc = _vpcMgr.getVpc(network.getVpcId());
+                Vpc vpc = _entityMgr.findById(Vpc.class, network.getVpcId());
                 if(vpc == null){
                     throw new InvalidParameterValueException("Unable to find Vpc associated with the Network");
                 }
@@ -297,7 +300,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
             throw new InvalidParameterValueException("Default ACL cannot be modified");
         }
 
-        Vpc vpc = _vpcMgr.getVpc(acl.getVpcId());
+        Vpc vpc = _entityMgr.findById(Vpc.class, acl.getVpcId());
         if(vpc == null){
             throw new InvalidParameterValueException("Unable to find Vpc associated with the NetworkACL");
         }
@@ -519,7 +522,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
 
         NetworkACL acl = _networkAclMgr.getNetworkACL(aclItem.getAclId());
 
-        Vpc vpc = _vpcMgr.getVpc(acl.getVpcId());
+        Vpc vpc = _entityMgr.findById(Vpc.class, acl.getVpcId());
 
         Account caller = CallContext.current().getCallingAccount();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/vpc/NetworkACLVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLVO.java b/server/src/com/cloud/network/vpc/NetworkACLVO.java
deleted file mode 100644
index ad2ffbf..0000000
--- a/server/src/com/cloud/network/vpc/NetworkACLVO.java
+++ /dev/null
@@ -1,79 +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 com.cloud.network.vpc;
-
-import javax.persistence.*;
-import java.util.UUID;
-
-@Entity
-@Table(name="network_acl")
-public class NetworkACLVO implements NetworkACL{
-
-    @Id
-    @GeneratedValue(strategy= GenerationType.IDENTITY)
-    @Column(name="id")
-    private long id;
-
-    @Column(name="vpc_id")
-    Long vpcId;
-
-    @Column(name="uuid")
-    private String uuid;
-
-    @Column(name="name")
-    private String name;
-
-    @Column(name="description")
-    private String description;
-
-    public NetworkACLVO(){
-    }
-
-    protected NetworkACLVO(String name, String description, long vpcId){
-        this.uuid = UUID.randomUUID().toString();
-        this.name = name;
-        this.description = description;
-        this.vpcId = vpcId;
-    }
-
-    @Override
-    public String getDescription() {
-        return description;
-    }
-
-    @Override
-    public String getUuid() {
-        return uuid;
-    }
-
-    @Override
-    public Long getVpcId() {
-        return vpcId;
-    }
-
-    @Override
-    public long getId() {
-        return id;
-    }
-
-    @Override
-    public String getName() {
-        return name;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/vpc/VpcManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManager.java b/server/src/com/cloud/network/vpc/VpcManager.java
deleted file mode 100644
index e01413f..0000000
--- a/server/src/com/cloud/network/vpc/VpcManager.java
+++ /dev/null
@@ -1,170 +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 com.cloud.network.vpc;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.cloudstack.acl.ControlledEntity.ACLType;
-
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientAddressCapacityException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.network.IpAddress;
-import com.cloud.network.Network;
-import com.cloud.network.Network.Provider;
-import com.cloud.network.Network.Service;
-import com.cloud.network.PhysicalNetwork;
-import com.cloud.network.addr.PublicIp;
-import com.cloud.offering.NetworkOffering;
-import com.cloud.user.Account;
-
-
-public interface VpcManager extends VpcService{
-
-    /**
-     * Returns all existing VPCs for a given account
-     * @param accountId
-     * @return
-     */
-    List<? extends Vpc> getVpcsForAccount(long accountId);
-
-    
-    /**
-     * Destroys the VPC
-     * 
-     * @param vpc
-     * @param caller TODO
-     * @param callerUserId TODO
-     * @return
-     * @throws ConcurrentOperationException
-     * @throws ResourceUnavailableException
-     */
-    boolean destroyVpc(Vpc vpc, Account caller, Long callerUserId) throws ConcurrentOperationException, ResourceUnavailableException;
-
-
-    /**
-     * Returns true if the IP is allocated to the VPC; false otherwise
-     * 
-     * @param ip
-     * @return
-     */
-    boolean isIpAllocatedToVpc(IpAddress ip);
-
-
-    /**
-     * Disassociates the public IP address from VPC
-     * 
-     * @param ipId
-     * @param networkId
-     */
-    void unassignIPFromVpcNetwork(long ipId, long networkId);
-
-
-    /**
-     * Creates guest network in the VPC
-     * 
-     *
-     * @param ntwkOffId
-     * @param name
-     * @param displayText
-     * @param gateway
-     * @param cidr
-     * @param vlanId
-     * @param networkDomain
-     * @param owner
-     * @param domainId
-     * @param pNtwk
-     * @param zoneId
-     * @param aclType
-     * @param subdomainAccess
-     * @param vpcId
-     * @param caller
-     * @param displayNetworkEnabled
-     * @return
-     * @throws ConcurrentOperationException
-     * @throws InsufficientCapacityException
-     * @throws ResourceAllocationException
-     */
-    Network createVpcGuestNetwork(long ntwkOffId, String name, String displayText, String gateway, String cidr,
-                                  String vlanId, String networkDomain, Account owner, Long domainId, PhysicalNetwork pNtwk, long zoneId,
-                                  ACLType aclType, Boolean subdomainAccess, long vpcId, Long aclId, Account caller, Boolean displayNetworkEnabled)
-
-                    throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException;
-
-
-    /**
-     * Assigns source nat public IP address to VPC
-     * 
-     * @param owner
-     * @param vpc
-     * @return public IP address object
-     * @throws InsufficientAddressCapacityException
-     * @throws ConcurrentOperationException
-     */
-    PublicIp assignSourceNatIpAddressToVpc(Account owner, Vpc vpc) throws InsufficientAddressCapacityException, ConcurrentOperationException;
-
-
-    /**
-     * Validates network offering to find if it can be used for network creation in VPC
-     * 
-     * @param guestNtwkOff
-     * @param supportedSvcs TODO
-     */
-    void validateNtwkOffForVpc(NetworkOffering guestNtwkOff, List<Service> supportedSvcs);
-
-
-    /**
-     * @return list of hypervisors that are supported by VPC
-     */
-    List<HypervisorType> getSupportedVpcHypervisors();
-    
-    
-    /**
-     * Lists all the services and providers that the current VPC suppots
-     * @param vpcOffId
-     * @return map of Service to Provider(s) map 
-     */
-    Map<Service, Set<Provider>> getVpcOffSvcProvidersMap(long vpcOffId);
-    
-    
-    /**
-     * Returns VPC that is ready to be used
-     * @param vpcId
-     * @return VPC object
-     */
-    public Vpc getActiveVpc(long vpcId);
-
-
-    /**
-     * Performs network offering validation to determine if it can be used for network upgrade inside the VPC 
-     * @param networkId
-     * @param newNtwkOffId
-     * @param newCidr
-     * @param newNetworkDomain
-     * @param vpc
-     * @param gateway
-     * @param networkOwner TODO
-     */
-    void validateNtwkOffForNtwkInVpc(Long networkId, long newNtwkOffId, String newCidr, String newNetworkDomain, Vpc vpc, String gateway, Account networkOwner, Long aclId);
-
-    List<PrivateGateway> getVpcPrivateGateways(long vpcId);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index 4f9f286..597a7b0 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -32,13 +32,14 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
 import org.apache.cloudstack.acl.ControlledEntity.ACLType;
 import org.apache.cloudstack.api.command.user.vpc.ListPrivateGatewaysCmd;
 import org.apache.cloudstack.api.command.user.vpc.ListStaticRoutesCmd;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
+import org.apache.cloudstack.framework.config.ConfigDepot;
+import org.apache.cloudstack.framework.config.ConfigValue;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 
 import com.cloud.configuration.Config;
@@ -126,9 +127,8 @@ import com.cloud.vm.ReservationContextImpl;
 import com.cloud.vm.dao.DomainRouterDao;
 
 
-@Component
 @Local(value = { VpcManager.class, VpcService.class, VpcProvisioningService.class })
-public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvisioningService{
+public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvisioningService, VpcService {
     private static final Logger s_logger = Logger.getLogger(VpcManagerImpl.class);
     @Inject
     EntityManager _entityMgr;
@@ -190,12 +190,15 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
     NetworkACLDao _networkAclDao;
     @Inject
     IpAddressManager _ipAddrMgr;
+    @Inject
+    ConfigDepot _configDepot;
 
     private final ScheduledExecutorService _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("VpcChecker"));
     private List<VpcProvider> vpcElements = null;
     private final List<Service> nonSupportedServices = Arrays.asList(Service.SecurityGroup, Service.Firewall);
     private final List<Provider> supportedProviders = Arrays.asList(Provider.VPCVirtualRouter, Provider.NiciraNvp, Provider.InternalLbVm, Provider.Netscaler);
  
+    ConfigValue<String> _networkDomain;
 
     int _cleanupInterval;
     int _maxNetworks;
@@ -256,7 +259,8 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
 
         String maxNtwks = configs.get(Config.VpcMaxNetworks.key());
         _maxNetworks = NumbersUtil.parseInt(maxNtwks, 3); // max=3 is default
-        
+
+        _networkDomain = _configDepot.get(NetworkOrchestrationService.GuestDomainSuffix);
         
         IpAddressSearch = _ipAddressDao.createSearchBuilder();
         IpAddressSearch.and("accountId", IpAddressSearch.entity().getAllocatedToAccountId(), Op.EQ);
@@ -398,11 +402,6 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
     }
     
     @Override
-    public Vpc getVpc(long vpcId) {
-        return _vpcDao.findById(vpcId);
-    }
-    
-    @Override
     public Vpc getActiveVpc(long vpcId) {
         return _vpcDao.getActiveVpcById(vpcId);
     }
@@ -621,7 +620,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
 
             // 2) If null, generate networkDomain using domain suffix from the global config variables
             if (networkDomain == null) {
-                networkDomain = "cs" + Long.toHexString(owner.getId()) + _ntwkModel.getDefaultNetworkDomain(zoneId);
+                networkDomain = "cs" + Long.toHexString(owner.getId()) + _networkDomain.valueIn(zoneId);
             }
         }
         
@@ -709,7 +708,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
         CallContext ctx = CallContext.current();
 
         // Verify vpc id
-        Vpc vpc = getVpc(vpcId);
+        Vpc vpc = _vpcDao.findById(vpcId);
         if (vpc == null) {
             throw new InvalidParameterValueException("unable to find VPC id=" + vpcId);
         }
@@ -1017,7 +1016,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
         Account caller = ctx.getCallingAccount();
         
         //check if vpc exists
-        Vpc vpc = getVpc(vpcId);
+        Vpc vpc = _vpcDao.findById(vpcId);
         if (vpc == null) {
             throw new InvalidParameterValueException("Unable to find vpc by id " + vpcId);
         }
@@ -1353,11 +1352,6 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
         return getPrivateGatewayProfile(gateway);
     }
     
-    @Override
-    public VpcGateway getVpcGateway(long id) {
-        return _vpcGatewayDao.findById(id);
-    }
-
     protected PrivateGateway getPrivateGatewayProfile(VpcGateway gateway) {
         Network network = _ntwkModel.getNetwork(gateway.getNetworkId());
         return new PrivateGatewayProfile(gateway, network.getPhysicalNetworkId());
@@ -1659,7 +1653,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
             s_logger.debug("No static routes to apply");
             return true;
         }
-        Vpc vpc = getVpc(routes.get(0).getVpcId());
+        Vpc vpc = _vpcDao.findById(routes.get(0).getVpcId());
         
         s_logger.debug("Applying static routes for vpc " + vpc);
         String staticNatProvider = _vpcSrvcDao.getProviderForServiceInVpc(vpc.getId(), Service.StaticNat);
@@ -1778,7 +1772,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
     }
 
     protected boolean isCidrBlacklisted(String cidr, long zoneId) {
-        String routesStr = _configServer.getConfigValue(Config.BlacklistedRoutes.key(), Config.ConfigurationParameterScope.zone.toString(), zoneId);
+        String routesStr = _networkDomain.valueIn(zoneId);
         if (routesStr != null && !routesStr.isEmpty()) {
             String[] cidrBlackList = routesStr.split(",");
             
@@ -1959,7 +1953,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
             return null;
         }
 
-        Vpc vpc = getVpc(vpcId);
+        Vpc vpc = _vpcDao.findById(vpcId);
         if (vpc == null) {
             throw new InvalidParameterValueException("Invalid VPC id provided");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/vpc/dao/NetworkACLDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/NetworkACLDao.java b/server/src/com/cloud/network/vpc/dao/NetworkACLDao.java
deleted file mode 100644
index fb2b331..0000000
--- a/server/src/com/cloud/network/vpc/dao/NetworkACLDao.java
+++ /dev/null
@@ -1,23 +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 com.cloud.network.vpc.dao;
-
-import com.cloud.network.vpc.NetworkACLVO;
-import com.cloud.utils.db.GenericDao;
-
-public interface NetworkACLDao extends GenericDao<NetworkACLVO, Long>{
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/vpc/dao/NetworkACLDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/NetworkACLDaoImpl.java b/server/src/com/cloud/network/vpc/dao/NetworkACLDaoImpl.java
deleted file mode 100644
index fd3308d..0000000
--- a/server/src/com/cloud/network/vpc/dao/NetworkACLDaoImpl.java
+++ /dev/null
@@ -1,35 +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 com.cloud.network.vpc.dao;
-
-import com.cloud.network.vpc.NetworkACLVO;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import org.springframework.stereotype.Component;
-
-import javax.ejb.Local;
-
-@Component
-@Local(value = NetworkACLDao.class)
-@DB(txn = false)
-public class NetworkACLDaoImpl extends GenericDaoBase<NetworkACLVO, Long> implements NetworkACLDao{
-
-    protected NetworkACLDaoImpl() {
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/vpc/dao/NetworkACLItemDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/NetworkACLItemDaoImpl.java b/server/src/com/cloud/network/vpc/dao/NetworkACLItemDaoImpl.java
deleted file mode 100644
index 8162ce8..0000000
--- a/server/src/com/cloud/network/vpc/dao/NetworkACLItemDaoImpl.java
+++ /dev/null
@@ -1,113 +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 com.cloud.network.vpc.dao;
-
-import com.cloud.network.vpc.NetworkACLItem.State;
-import com.cloud.network.vpc.NetworkACLItemDao;
-import com.cloud.network.vpc.NetworkACLItemVO;
-import com.cloud.utils.db.*;
-import com.cloud.utils.db.SearchCriteria.Op;
-import org.springframework.stereotype.Component;
-
-import javax.ejb.Local;
-import java.util.List;
-
-@Component
-@Local(value = NetworkACLItemDao.class)
-@DB(txn = false)
-public class NetworkACLItemDaoImpl extends GenericDaoBase<NetworkACLItemVO, Long> implements NetworkACLItemDao {
-
-    protected final SearchBuilder<NetworkACLItemVO> AllFieldsSearch;
-    protected final SearchBuilder<NetworkACLItemVO> NotRevokedSearch;
-    protected final SearchBuilder<NetworkACLItemVO> ReleaseSearch;
-    protected final GenericSearchBuilder<NetworkACLItemVO, Integer> MaxNumberSearch;
-
-    protected NetworkACLItemDaoImpl() {
-        super();
-
-        AllFieldsSearch = createSearchBuilder();
-        AllFieldsSearch.and("protocol", AllFieldsSearch.entity().getProtocol(), Op.EQ);
-        AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
-        AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
-        AllFieldsSearch.and("aclId", AllFieldsSearch.entity().getAclId(), Op.EQ);
-        AllFieldsSearch.and("trafficType", AllFieldsSearch.entity().getTrafficType(), Op.EQ);
-        AllFieldsSearch.and("number", AllFieldsSearch.entity().getNumber(), Op.EQ);
-        AllFieldsSearch.and("action", AllFieldsSearch.entity().getAction(), Op.EQ);
-        AllFieldsSearch.done();
-
-        NotRevokedSearch = createSearchBuilder();
-        NotRevokedSearch.and("state", NotRevokedSearch.entity().getState(), Op.NEQ);
-        NotRevokedSearch.and("protocol", NotRevokedSearch.entity().getProtocol(), Op.EQ);
-        NotRevokedSearch.and("sourcePortStart", NotRevokedSearch.entity().getSourcePortStart(), Op.EQ);
-        NotRevokedSearch.and("sourcePortEnd", NotRevokedSearch.entity().getSourcePortEnd(), Op.EQ);
-        NotRevokedSearch.and("aclId", NotRevokedSearch.entity().getAclId(), Op.EQ);
-        NotRevokedSearch.and("trafficType", NotRevokedSearch.entity().getTrafficType(), Op.EQ);
-        NotRevokedSearch.done();
-
-        ReleaseSearch = createSearchBuilder();
-        ReleaseSearch.and("protocol", ReleaseSearch.entity().getProtocol(), Op.EQ);
-        ReleaseSearch.and("ports", ReleaseSearch.entity().getSourcePortStart(), Op.IN);
-        ReleaseSearch.done();
-
-        MaxNumberSearch = createSearchBuilder(Integer.class);
-        MaxNumberSearch.select(null, SearchCriteria.Func.MAX, MaxNumberSearch.entity().getNumber());
-        MaxNumberSearch.and("aclId", MaxNumberSearch.entity().getAclId(), Op.EQ);
-        MaxNumberSearch.done();
-    }
-
-
-    @Override
-    public boolean setStateToAdd(NetworkACLItemVO rule) {
-        SearchCriteria<NetworkACLItemVO> sc = AllFieldsSearch.create();
-        sc.setParameters("id", rule.getId());
-        sc.setParameters("state", State.Staged);
-
-        rule.setState(State.Add);
-
-        return update(rule, sc) > 0;
-    }
-
-    @Override
-    public boolean revoke(NetworkACLItemVO rule) {
-        rule.setState(State.Revoke);
-        return update(rule.getId(), rule);
-    }
-
-    @Override
-    public List<NetworkACLItemVO> listByACL(long aclId) {
-        SearchCriteria<NetworkACLItemVO> sc = AllFieldsSearch.create();
-        sc.setParameters("aclId", aclId);
-
-        return listBy(sc);
-    }
-
-    @Override
-    public int getMaxNumberByACL(long aclId) {
-        SearchCriteria<Integer> sc = MaxNumberSearch.create();
-        sc.setParameters("aclId", aclId);
-        Integer max = customSearch(sc, null).get(0);
-        return (max == null) ? 0 : max;
-    }
-
-    @Override
-    public NetworkACLItemVO findByAclAndNumber(long aclId, int number) {
-        SearchCriteria<NetworkACLItemVO> sc = AllFieldsSearch.create();
-        sc.setParameters("aclId", aclId);
-        sc.setParameters("number", number);
-        return findOneBy(sc);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
index 8d497c9..022493d 100755
--- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
@@ -5,7 +5,7 @@
 // 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,
@@ -25,14 +25,16 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.command.user.vpn.ListRemoteAccessVpnsCmd;
 import org.apache.cloudstack.api.command.user.vpn.ListVpnUsersCmd;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.framework.config.ConfigKey;
+import org.apache.cloudstack.framework.config.ConfigValue;
+import org.apache.cloudstack.framework.config.Configurable;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
 import com.cloud.configuration.Config;
 import com.cloud.domain.DomainVO;
 import com.cloud.domain.dao.DomainDao;
@@ -45,8 +47,12 @@ import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
 import com.cloud.network.Network.Service;
-import com.cloud.network.*;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.PublicIpAddress;
+import com.cloud.network.RemoteAccessVpn;
+import com.cloud.network.VpnUser;
 import com.cloud.network.VpnUser.State;
+import com.cloud.network.VpnUserVO;
 import com.cloud.network.dao.FirewallRulesDao;
 import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.IPAddressVO;
@@ -69,16 +75,27 @@ import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.PasswordGenerator;
 import com.cloud.utils.Ternary;
+import com.cloud.utils.component.InjectConfig;
 import com.cloud.utils.component.ManagerBase;
-import com.cloud.utils.db.*;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.JoinBuilder;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.db.Transaction;
 import com.cloud.utils.net.NetUtils;
 
-@Component
 @Local(value = RemoteAccessVpnService.class)
-public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAccessVpnService {
+public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAccessVpnService, Configurable {
     private final static Logger s_logger = Logger.getLogger(RemoteAccessVpnManagerImpl.class);
 
+    static final ConfigKey<String> RemoteAccessVpnClientIpRange = new ConfigKey<String>("Network", String.class, RemoteAccessVpnClientIpRangeCK, "10.1.2.1-10.1.2.8",
+        "The range of ips to be allocated to remote access vpn clients. The first ip in the range is used by the VPN server", false, ConfigKey.Scope.Account);
+
+    @InjectConfig(key = RemoteAccessVpnClientIpRangeCK)
+    ConfigValue<String> _remoteAccessVpnClientIpRange;
+
     @Inject AccountDao _accountDao;
     @Inject VpnUserDao _vpnUsersDao;
     @Inject RemoteAccessVpnDao _remoteAccessVpnDao;
@@ -98,12 +115,11 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
 
     int _userLimit;
     int _pskLength;
-    String _clientIpRange;
     SearchBuilder<RemoteAccessVpnVO> VpnSearch;
 
     @Override
     @DB
-    public RemoteAccessVpn createRemoteAccessVpn(long publicIpId, String ipRange, boolean openFirewall, long networkId) 
+    public RemoteAccessVpn createRemoteAccessVpn(long publicIpId, String ipRange, boolean openFirewall, long networkId)
             throws NetworkRuleConflictException {
         CallContext ctx = CallContext.current();
         Account caller = ctx.getCallingAccount();
@@ -150,7 +166,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
         }
 
         if (ipRange == null) {
-            ipRange = _configServer.getConfigValue(Config.RemoteAccessVpnClientIpRange.key(), Config.ConfigurationParameterScope.account.toString(), ipAddr.getAccountId());
+            ipRange = _remoteAccessVpnClientIpRange.valueIn(ipAddr.getAccountId());
         }
         String[] range = ipRange.split("-");
         if (range.length != 2) {
@@ -192,7 +208,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
     }
 
     private void validateRemoteAccessVpnConfiguration() throws ConfigurationException {
-        String ipRange = _clientIpRange;
+        String ipRange = _remoteAccessVpnClientIpRange.value();
         if (ipRange == null) {
             s_logger.warn("Remote Access VPN global configuration missing client ip range -- ignoring");
             return;
@@ -241,7 +257,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
                     break;
                 }
             }
-        } finally {        
+        } finally {
             if (success) {
                 //Cleanup corresponding ports
                 List<? extends FirewallRule> vpnFwRules = _rulesDao.listByIpAndPurpose(ipId, Purpose.Vpn);
@@ -258,7 +274,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
                     txn.start();
 
                     for (FirewallRule vpnFwRule : vpnFwRules) {
-                        //don't apply on the backend yet; send all 3 rules in a banch 
+                        //don't apply on the backend yet; send all 3 rules in a banch
                         _firewallMgr.revokeRelatedFirewallRule(vpnFwRule.getId(), false);
                         fwRules.add(_rulesDao.findByRelatedId(vpnFwRule.getId()));
                     }
@@ -276,7 +292,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
                     try {
                         txn.start();
                         _remoteAccessVpnDao.remove(vpn.getId());
-                        // Stop billing of VPN users when VPN is removed. VPN_User_ADD events will be generated when VPN is created again 
+                        // Stop billing of VPN users when VPN is removed. VPN_User_ADD events will be generated when VPN is created again
                         List<VpnUserVO> vpnUsers = _vpnUsersDao.listByAccount(vpn.getAccountId());
                         for(VpnUserVO user : vpnUsers){
                             // VPN_USER_REMOVE event is already generated for users in Revoke state
@@ -291,7 +307,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
                                 s_logger.debug("Successfully removed firewall rule with ip id=" + vpnFwRule.getSourceIpAddressId() + " and port " + vpnFwRule.getSourcePortStart() + " as a part of vpn cleanup");
                             }
                         }
-                        txn.commit();   
+                        txn.commit();
                     } catch (Exception ex) {
                         txn.rollback();
                         s_logger.warn("Unable to release the three vpn ports from the firewall rules", ex);
@@ -401,7 +417,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
                 vpn.setState(RemoteAccessVpn.State.Running);
                 _remoteAccessVpnDao.update(vpn.getId(), vpn);
 
-                // Start billing of existing VPN users in ADD and Active state 
+                // Start billing of existing VPN users in ADD and Active state
                 List<VpnUserVO> vpnUsers = _vpnUsersDao.listByAccount(vpn.getAccountId());
                 for(VpnUserVO user : vpnUsers){
                     if(user.getState() != VpnUser.State.Revoke){
@@ -410,7 +426,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
                     }
                 }
                 txn.commit();
-            } 
+            }
         }
     }
 
@@ -469,7 +485,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
 
         for (int i = 0; i < finals.length; i++) {
             VpnUserVO user = users.get(i);
-            if (finals[i]) {     
+            if (finals[i]) {
                 if (user.getState() == State.Add) {
                     user.setState(State.Active);
                     _vpnUsersDao.update(user.getId(), user);
@@ -479,7 +495,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
             } else {
                 if (user.getState() == State.Add && (user.getUsername()).equals(userName)) {
                     Transaction txn = Transaction.currentTxn();
-                    txn.start();            		
+                    txn.start();
                     _vpnUsersDao.remove(user.getId());
                     UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VPN_USER_REMOVE, user.getAccountId(),
                             0, user.getId(), user.getUsername(), user.getClass().getName(), user.getUuid());
@@ -556,9 +572,9 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
         _accountMgr.buildACLSearchParameters(caller, null, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false);
         Long domainId = domainIdRecursiveListProject.first();
         Boolean isRecursive = domainIdRecursiveListProject.second();
-        ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();        
+        ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
 
-        Filter filter = new Filter(RemoteAccessVpnVO.class, "serverAddressId", false, cmd.getStartIndex(), cmd.getPageSizeVal()); 
+        Filter filter = new Filter(RemoteAccessVpnVO.class, "serverAddressId", false, cmd.getStartIndex(), cmd.getPageSizeVal());
         SearchBuilder<RemoteAccessVpnVO> sb = _remoteAccessVpnDao.createSearchBuilder();
         _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
 
@@ -585,8 +601,6 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
 
         _userLimit = NumbersUtil.parseInt(configs.get(Config.RemoteAccessVpnUserLimit.key()), 8);
 
-        _clientIpRange = configs.get(Config.RemoteAccessVpnClientIpRange.key());
-
         _pskLength = NumbersUtil.parseInt(configs.get(Config.RemoteAccessVpnPskLength.key()), 24);
 
         validateRemoteAccessVpnConfiguration();
@@ -619,4 +633,14 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
 
         return result;
     }
+
+    @Override
+    public String getConfigComponentName() {
+        return RemoteAccessVpnService.class.getSimpleName();
+    }
+
+    @Override
+    public ConfigKey<?>[] getConfigKeys() {
+        return new ConfigKey<?>[] {RemoteAccessVpnClientIpRange};
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/resource/Discoverer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/Discoverer.java b/server/src/com/cloud/resource/Discoverer.java
deleted file mode 100755
index 9af7363..0000000
--- a/server/src/com/cloud/resource/Discoverer.java
+++ /dev/null
@@ -1,51 +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 com.cloud.resource;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-
-import com.cloud.exception.DiscoveryException;
-import com.cloud.host.HostVO;
-import com.cloud.hypervisor.Hypervisor;
-import com.cloud.utils.component.Adapter;
-
-/**
- * Discoverer encapsulates interfaces that will discover resources.
- *
- */
-public interface Discoverer extends Adapter {
-    /**
-     * Given an accessible ip address, find out what it is.
-     * 
-     * @param url
-     * @param username
-     * @param password
-     * @return ServerResource
-     */
-    Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI uri, String username, String password, List<String> hostTags) throws DiscoveryException;
-
-	void postDiscovery(List<HostVO> hosts, long msId)  throws DiscoveryException;
-	
-	boolean matchHypervisor(String hypervisor);
-	Hypervisor.HypervisorType getHypervisorType();
-	public void putParam(Map<String, String> params);
-	
-	ServerResource reloadResource(HostVO host);
-	
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/resource/ResourceManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManager.java b/server/src/com/cloud/resource/ResourceManager.java
deleted file mode 100755
index 85af36f..0000000
--- a/server/src/com/cloud/resource/ResourceManager.java
+++ /dev/null
@@ -1,140 +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 com.cloud.resource;
-
-import java.util.List;
-import java.util.Map;
-
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.api.StartupRoutingCommand;
-import com.cloud.dc.DataCenterVO;
-import com.cloud.dc.HostPodVO;
-import com.cloud.dc.PodCluster;
-import com.cloud.exception.AgentUnavailableException;
-import com.cloud.host.Host;
-import com.cloud.host.Host.Type;
-import com.cloud.host.HostStats;
-import com.cloud.host.HostVO;
-import com.cloud.host.Status;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.resource.ResourceState.Event;
-import com.cloud.utils.fsm.NoTransitionException;
-
-/**
- * ResourceManager manages how physical resources are organized within the
- * CloudStack. It also manages the life cycle of the physical resources.
- */
-public interface ResourceManager extends ResourceService {
-    /**
-     * Register a listener for different types of resource life cycle events.
-     * There can only be one type of listener per type of host.
-     * 
-     * @param Event type see ResourceListener.java, allow combination of multiple events.
-     * @param listener the listener to notify.
-     */
-    public void registerResourceEvent(Integer event, ResourceListener listener);
-
-    public void unregisterResourceEvent(ResourceListener listener);
-
-    /**
-     * 
-     * @param name of adapter
-     * @param adapter
-     * @param hates, a list of names which will be eliminated by this adapter. Especially for the case where
-     * can be only one adapter responds to an event, e.g. startupCommand
-     */
-    public void registerResourceStateAdapter(String name, ResourceStateAdapter adapter);
-
-    public void unregisterResourceStateAdapter(String name);
-
-    public Host createHostAndAgent(Long hostId, ServerResource resource, Map<String, String> details, boolean old, List<String> hostTags,
-            boolean forRebalance);
-
-    public Host addHost(long zoneId, ServerResource resource, Type hostType, Map<String, String> hostDetails);
-
-    public HostVO createHostVOForConnectedAgent(StartupCommand[] cmds);
-
-    public void checkCIDR(HostPodVO pod, DataCenterVO dc, String serverPrivateIP, String serverPrivateNetmask);
-
-    public HostVO fillRoutingHostVO(HostVO host, StartupRoutingCommand ssCmd, HypervisorType hyType, Map<String, String> details, List<String> hostTags);
-
-    public void deleteRoutingHost(HostVO host, boolean isForced, boolean forceDestroyStorage) throws UnableDeleteHostException;
-
-    public boolean executeUserRequest(long hostId, ResourceState.Event event) throws AgentUnavailableException;
-
-    boolean resourceStateTransitTo(Host host, Event event, long msId) throws NoTransitionException;
-
-    boolean umanageHost(long hostId);
-
-    boolean maintenanceFailed(long hostId);
-
-    public boolean maintain(final long hostId) throws AgentUnavailableException;
-
-    @Override
-    public boolean deleteHost(long hostId, boolean isForced, boolean isForceDeleteStorage);
-
-    public List<HostVO> findDirectlyConnectedHosts();
-
-    public List<HostVO> listAllUpAndEnabledHosts(Host.Type type, Long clusterId, Long podId, long dcId);
-
-    public List<HostVO> listAllHostsInCluster(long clusterId);
-
-    public List<HostVO> listHostsInClusterByStatus(long clusterId, Status status);
-
-    public List<HostVO> listAllUpAndEnabledHostsInOneZoneByType(Host.Type type, long dcId);
-
-    public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(HypervisorType type, long dcId);
-
-    public List<HostVO> listAllHostsInOneZoneByType(Host.Type type, long dcId);
-
-    public List<HostVO> listAllHostsInAllZonesByType(Type type);
-
-    public List<HypervisorType> listAvailHypervisorInZone(Long hostId, Long zoneId);
-
-    public HostVO findHostByGuid(String guid);
-
-    public HostVO findHostByName(String name);
-
-    public List<HostVO> listHostsByNameLike(String name);
-
-    HostStats getHostStatistics(long hostId);
-
-    Long getGuestOSCategoryId(long hostId);
-
-    String getHostTags(long hostId);
-
-    List<PodCluster> listByDataCenter(long dcId);
-
-    List<HostVO> listAllNotInMaintenanceHostsInOneZone(Type type, Long dcId);
-
-    HypervisorType getDefaultHypervisor(long zoneId);
-
-    HypervisorType getAvailableHypervisor(long zoneId);
-
-    Discoverer getMatchingDiscover(HypervisorType hypervisorType);
-
-    List<HostVO> findHostByGuid(long dcId, String guid);
-
-    /**
-     * @param type
-     * @param clusterId
-     * @param podId
-     * @param dcId
-     * @return
-     */
-    List<HostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 59c7097..8f4b43c 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -45,6 +45,7 @@ import org.apache.cloudstack.api.command.admin.host.ReconnectHostCmd;
 import org.apache.cloudstack.api.command.admin.host.UpdateHostCmd;
 import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.framework.config.ConfigValue;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.region.dao.RegionDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
@@ -69,6 +70,7 @@ import com.cloud.agent.manager.ClusteredAgentManagerImpl;
 import com.cloud.agent.transport.Request;
 import com.cloud.api.ApiDBUtils;
 import com.cloud.capacity.Capacity;
+import com.cloud.capacity.CapacityManager;
 import com.cloud.capacity.CapacityVO;
 import com.cloud.capacity.dao.CapacityDao;
 import com.cloud.cluster.ClusterManager;
@@ -136,6 +138,7 @@ import com.cloud.user.AccountManager;
 import com.cloud.user.User;
 import com.cloud.utils.StringUtils;
 import com.cloud.utils.UriUtils;
+import com.cloud.utils.component.InjectConfig;
 import com.cloud.utils.component.Manager;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.DB;
@@ -166,6 +169,11 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
     Gson _gson;
 
+    @InjectConfig(key = CapacityManager.CpuOverprovisioningFactorCK)
+    ConfigValue<Float> _cpuOverprovisioningFactor;
+    @InjectConfig(key = CapacityManager.MemOverprovisioningFactorCK)
+    ConfigValue<Float> _memOverprovisioningFactor;
+
     @Inject
     AccountManager _accountMgr;
     @Inject
@@ -472,8 +480,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
         if (clusterType == Cluster.ClusterType.CloudManaged) {
             Map<String, String> details = new HashMap<String, String>();
-            details.put("cpuOvercommitRatio", _configDao.getValue(Config.CPUOverprovisioningFactor.key()));
-            details.put("memoryOvercommitRatio", _configDao.getValue(Config.MemOverprovisioningFactor.key()));
+            details.put("cpuOvercommitRatio", _cpuOverprovisioningFactor.value().toString());
+            details.put("memoryOvercommitRatio", _memOverprovisioningFactor.value().toString());
             _clusterDetailsDao.persist(cluster.getId(), details);
             return result;
         }
@@ -483,8 +491,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
         details.put("url", url);
         details.put("username", username);
         details.put("password", password);
-        details.put("cpuOvercommitRatio", _configDao.getValue(Config.CPUOverprovisioningFactor.key()));
-        details.put("memoryOvercommitRatio", _configDao.getValue(Config.MemOverprovisioningFactor.key()));
+        details.put("cpuOvercommitRatio", _cpuOverprovisioningFactor.value().toString());
+        details.put("memoryOvercommitRatio", _memOverprovisioningFactor.value().toString());
         _clusterDetailsDao.persist(cluster.getId(), details);
 
         boolean success = false;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/resource/ResourceStateAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceStateAdapter.java b/server/src/com/cloud/resource/ResourceStateAdapter.java
deleted file mode 100755
index 68e43f3..0000000
--- a/server/src/com/cloud/resource/ResourceStateAdapter.java
+++ /dev/null
@@ -1,63 +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 com.cloud.resource;
-
-import java.util.List;
-import java.util.Map;
-
-import com.cloud.agent.api.StartupAnswer;
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.exception.ConnectionException;
-import com.cloud.host.HostVO;
-import com.cloud.utils.component.Adapter;
-
-public interface ResourceStateAdapter extends Adapter {
-    static public enum Event {
-        CREATE_HOST_VO_FOR_CONNECTED,
-        CREATE_HOST_VO_FOR_DIRECT_CONNECT,
-        DELETE_HOST,
-    }
-    
-    static public class DeleteHostAnswer {
-        private boolean isContinue;
-        private boolean isException;
-        
-        public DeleteHostAnswer(boolean isContinue) {
-            this.isContinue = isContinue;
-            this.isException = false;
-        }
-        
-        public DeleteHostAnswer(boolean isContinue, boolean isException) {
-            this.isContinue = isContinue;
-            this.isException = isException;
-        }
-        
-        public boolean getIsContinue() {
-            return this.isContinue;
-        }
-        
-        public boolean getIsException() {
-            return this.isException;
-        }
-    }
-    
-    public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd);
-    
-    public HostVO createHostVOForDirectConnectAgent(HostVO host, final StartupCommand[] startup, ServerResource resource, Map<String, String> details, List<String> hostTags);
-    
-    public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException;
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/server/ConfigurationServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ConfigurationServer.java b/server/src/com/cloud/server/ConfigurationServer.java
index 1c8ccfe..1d99973 100644
--- a/server/src/com/cloud/server/ConfigurationServer.java
+++ b/server/src/com/cloud/server/ConfigurationServer.java
@@ -34,6 +34,5 @@ public interface ConfigurationServer {
      */
     public void persistDefaultValues() throws InternalErrorException;
     public void updateKeyPairs();
-    public String getConfigValue(String name, String scope, Long resourceId);
     public List<ConfigurationVO> getConfigListByScope(String scope, Long resourceId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/server/ConfigurationServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java
index b3ead63..aed6019 100755
--- a/server/src/com/cloud/server/ConfigurationServerImpl.java
+++ b/server/src/com/cloud/server/ConfigurationServerImpl.java
@@ -46,31 +46,23 @@ import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.io.FileUtils;
 import org.apache.log4j.Logger;
 
+import org.apache.cloudstack.framework.config.ConfigDepot;
 import org.apache.cloudstack.framework.config.ConfigDepotAdmin;
 import org.apache.cloudstack.framework.config.ConfigurationVO;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
-import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
-import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 
 import com.cloud.configuration.Config;
+import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.Resource;
 import com.cloud.configuration.Resource.ResourceOwnerType;
 import com.cloud.configuration.Resource.ResourceType;
 import com.cloud.configuration.ResourceCountVO;
 import com.cloud.configuration.dao.ResourceCountDao;
-import com.cloud.dc.ClusterDetailsDao;
-import com.cloud.dc.ClusterDetailsVO;
-import com.cloud.dc.ClusterVO;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.DataCenterVO;
-import com.cloud.dc.DcDetailVO;
 import com.cloud.dc.HostPodVO;
 import com.cloud.dc.VlanVO;
-import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.dc.dao.DcDetailsDao;
 import com.cloud.dc.dao.HostPodDao;
 import com.cloud.dc.dao.VlanDao;
 import com.cloud.domain.DomainVO;
@@ -104,8 +96,6 @@ import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.test.IPRangeConfig;
 import com.cloud.user.Account;
-import com.cloud.user.AccountDetailVO;
-import com.cloud.user.AccountDetailsDao;
 import com.cloud.user.AccountVO;
 import com.cloud.user.User;
 import com.cloud.user.dao.AccountDao;
@@ -126,8 +116,6 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
 
     @Inject private ConfigurationDao _configDao;
     @Inject private DataCenterDao _zoneDao;
-    @Inject private ClusterDao _clusterDao;
-    @Inject private PrimaryDataStoreDao _storagePoolDao;
     @Inject private HostPodDao _podDao;
     @Inject private DiskOfferingDao _diskOfferingDao;
     @Inject private ServiceOfferingDao _serviceOfferingDao;
@@ -139,12 +127,12 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
     @Inject private AccountDao _accountDao;
     @Inject private ResourceCountDao _resourceCountDao;
     @Inject private NetworkOfferingServiceMapDao _ntwkOfferingServiceMapDao;
-    @Inject private DcDetailsDao _dcDetailsDao;
-    @Inject private ClusterDetailsDao _clusterDetailsDao;
-    @Inject private StoragePoolDetailsDao _storagePoolDetailsDao;
-    @Inject private AccountDetailsDao _accountDetailsDao;
     @Inject
     protected ConfigDepotAdmin _configDepotAdmin;
+    @Inject
+    protected ConfigDepot _configDepot;
+    @Inject
+    protected ConfigurationManager _configMgr;
 
     public ConfigurationServerImpl() {
     	setRunLevel(ComponentLifecycle.RUN_LEVEL_FRAMEWORK_BOOTSTRAP);
@@ -691,61 +679,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
         }
     }
 
-    @Override
-    public String getConfigValue(String name, String scope, Long resourceId) {
-        // If either of scope or resourceId is null then return global config value otherwise return value at the scope
-        Config c = Config.getConfig(name);
-        if (c == null) {
-            throw new CloudRuntimeException("Missing configuration variable " + name + " in configuration table");
-        }
-        String configScope = c.getScope();
-        if (scope != null && !scope.isEmpty()) {
-            if (!configScope.contains(scope)) {
-                throw new CloudRuntimeException("Invalid scope " + scope + " for the parameter " + name );
-            }
-            if (resourceId != null) {
-                switch (Config.ConfigurationParameterScope.valueOf(scope)) {
-                    case zone:      DataCenterVO zone = _zoneDao.findById(resourceId);
-                                    if (zone == null) {
-                                        throw new InvalidParameterValueException("unable to find zone by id " + resourceId);
-                                    }
-                                    DcDetailVO dcDetailVO = _dcDetailsDao.findDetail(resourceId, name);
-                                    if (dcDetailVO != null && dcDetailVO.getValue() != null) {
-                                        return dcDetailVO.getValue();
-                                    } break;
-
-                    case cluster:   ClusterVO cluster = _clusterDao.findById(resourceId);
-                                    if (cluster == null) {
-                                        throw new InvalidParameterValueException("unable to find cluster by id " + resourceId);
-                                    }
-                                    ClusterDetailsVO clusterDetailsVO = _clusterDetailsDao.findDetail(resourceId, name);
-                                    if (clusterDetailsVO != null && clusterDetailsVO.getValue() != null) {
-                                        return clusterDetailsVO.getValue();
-                                    } break;
-
-                    case storagepool:      StoragePoolVO pool = _storagePoolDao.findById(resourceId);
-                                    if (pool == null) {
-                                        throw new InvalidParameterValueException("unable to find storage pool by id " + resourceId);
-                                    }
-                                    StoragePoolDetailVO storagePoolDetailVO = _storagePoolDetailsDao.findDetail(resourceId, name);
-                                    if (storagePoolDetailVO != null && storagePoolDetailVO.getValue() != null) {
-                                        return storagePoolDetailVO.getValue();
-                                    } break;
-
-                    case account:   AccountVO account = _accountDao.findById(resourceId);
-                                    if (account == null) {
-                                        throw new InvalidParameterValueException("unable to find account by id " + resourceId);
-                                    }
-                                    AccountDetailVO accountDetailVO = _accountDetailsDao.findDetail(resourceId, name);
-                                    if (accountDetailVO != null && accountDetailVO.getValue() != null) {
-                                        return accountDetailVO.getValue();
-                                    } break;
-                    default:
-                }
-            }
-        }
-        return _configDao.getValue(name);
-    }
+
 
     @Override
     public List<ConfigurationVO> getConfigListByScope(String scope, Long resourceId) {
@@ -755,7 +689,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
         List<ConfigurationVO> configVOList = new ArrayList<ConfigurationVO>();
         for (Config param:configList){
             ConfigurationVO configVo = _configDao.findByName(param.toString());
-            configVo.setValue(getConfigValue(param.toString(), scope, resourceId));
+            configVo.setValue(_configDepot.get(param.toString()).valueIn(resourceId).toString());
             configVOList.add(configVo);
         }
         return configVOList;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 069a1d8..a10f0a0b 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -429,6 +429,8 @@ import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationSer
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
+import org.apache.cloudstack.framework.config.ConfigKey;
+import org.apache.cloudstack.framework.config.ConfigValue;
 import org.apache.cloudstack.framework.config.ConfigurationVO;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
@@ -452,6 +454,7 @@ import com.cloud.capacity.dao.CapacityDao;
 import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
 import com.cloud.cluster.ClusterManager;
 import com.cloud.configuration.Config;
+import com.cloud.configuration.ConfigurationManager;
 import com.cloud.consoleproxy.ConsoleProxyManagementState;
 import com.cloud.consoleproxy.ConsoleProxyManager;
 import com.cloud.dc.AccountVlanMapVO;
@@ -555,6 +558,7 @@ import com.cloud.utils.Pair;
 import com.cloud.utils.PasswordGenerator;
 import com.cloud.utils.Ternary;
 import com.cloud.utils.component.ComponentLifecycle;
+import com.cloud.utils.component.InjectConfig;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.concurrency.NamedThreadFactory;
 import com.cloud.utils.crypt.DBEncryptionUtil;
@@ -702,6 +706,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     VolumeDataFactory _volFactory;
     @Inject
     AccountService _accountService;
+    @Inject
+    ConfigurationManager _configMgr;
 
     @Inject
     DeploymentPlanningManager _dpMgr;
@@ -1625,22 +1631,22 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         int paramCountCheck = 0;
 
         if (zoneId != null) {
-            scope = Config.ConfigurationParameterScope.zone.toString();
+            scope = ConfigKey.Scope.Zone.toString();
             id = zoneId;
             paramCountCheck++;
         }
         if (clusterId != null) {
-            scope = Config.ConfigurationParameterScope.cluster.toString();
+            scope = ConfigKey.Scope.Cluster.toString();
             id = clusterId;
             paramCountCheck++;
         }
         if (accountId != null) {
-            scope = Config.ConfigurationParameterScope.account.toString();
+            scope = ConfigKey.Scope.Account.toString();
             id = accountId;
             paramCountCheck++;
         }
         if (storagepoolId != null) {
-            scope = Config.ConfigurationParameterScope.storagepool.toString();
+            scope = ConfigKey.Scope.StoragePool.toString();
             id = storagepoolId;
             paramCountCheck++;
         }
@@ -3232,6 +3238,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
 
         return cloudParams;
     }
+    
+    @InjectConfig(key = TemplateManager.AllowPublicUserTemplatesCK)
+    ConfigValue<Boolean> _allowPublicUserTemplates;
 
     @Override
     public Map<String, Object> listCapabilities(ListCapabilitiesCmd cmd) {
@@ -3256,7 +3265,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
 
         long diskOffMaxSize = Long.valueOf(_configDao.getValue(Config.CustomDiskOfferingMaxSize.key()));
 
-        String userPublicTemplateEnabled = _configServer.getConfigValue(Config.AllowPublicUserTemplates.key(), Config.ConfigurationParameterScope.account.toString(), caller.getId());
+        boolean userPublicTemplateEnabled = _allowPublicUserTemplates.valueIn(caller.getId());
 
         // add some parameters UI needs to handle API throttling
         boolean apiLimitEnabled = Boolean.parseBoolean(_configDao.getValue(Config.ApiLimitEnabled.key()));
@@ -3271,8 +3280,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         }
 
         capabilities.put("securityGroupsEnabled", securityGroupsEnabled);
-        capabilities
-        .put("userPublicTemplateEnabled", (userPublicTemplateEnabled == null || userPublicTemplateEnabled.equals("false") ? false : true));
+        capabilities.put("userPublicTemplateEnabled", userPublicTemplateEnabled);
         capabilities.put("cloudStackVersion", getVersion());
         capabilities.put("supportELB", supportELB);
         capabilities.put("projectInviteRequired", _projectMgr.projectInviteRequired());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index c138373..e89d0fd 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -73,6 +73,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
 import org.apache.cloudstack.framework.async.AsyncCallFuture;
+import org.apache.cloudstack.framework.config.ConfigKey;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
 import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
@@ -282,9 +283,6 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
     private int _createVolumeFromSnapshotWait;
     private int _copyvolumewait;
     int _storagePoolAcquisitionWaitSeconds = 1800; // 30 minutes
-    protected int _retry = 2;
-    protected int _pingInterval = 60; // seconds
-    protected int _hostRetry;
     // protected BigDecimal _overProvisioningFactor = new BigDecimal(1);
     private long _maxVolumeSizeInGb;
     private long _serverId;
@@ -444,9 +442,6 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
 
         Map<String, String> configs = _configDao.getConfiguration("management-server", params);
 
-        _retry = NumbersUtil.parseInt(configs.get(Config.StartRetry.key()), 10);
-        _pingInterval = NumbersUtil.parseInt(configs.get("ping.interval"), 60);
-        _hostRetry = NumbersUtil.parseInt(configs.get("host.retry"), 2);
         _storagePoolAcquisitionWaitSeconds = NumbersUtil.parseInt(configs.get("pool.acquisition.wait.seconds"), 1800);
         s_logger.info("pool.acquisition.wait.seconds is configured as " + _storagePoolAcquisitionWaitSeconds + " seconds");
 
@@ -894,7 +889,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
     @Override
     public BigDecimal getStorageOverProvisioningFactor(Long dcId) {
         return new BigDecimal(_configServer.getConfigValue(Config.StorageOverprovisioningFactor.key(),
-                Config.ConfigurationParameterScope.zone.toString(), dcId));
+                ConfigKey.Scope.Zone.toString(), dcId));
     }
 
     @Override
@@ -1504,7 +1499,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
     private boolean checkUsagedSpace(StoragePool pool) {
         StatsCollector sc = StatsCollector.getInstance();
         double storageUsedThreshold = Double.parseDouble(_configServer.getConfigValue(Config.StorageCapacityDisableThreshold.key(),
-                Config.ConfigurationParameterScope.zone.toString(), pool.getDataCenterId()));
+                ConfigKey.Scope.Zone.toString(), pool.getDataCenterId()));
         if (sc != null) {
             long totalSize = pool.getCapacityBytes();
             StorageStats stats = sc.getStoragePoolStats(pool.getId());
@@ -1610,7 +1605,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
         }
 
         double storageAllocatedThreshold = Double.parseDouble(_configServer.getConfigValue(Config.StorageAllocatedCapacityDisableThreshold.key(),
-                Config.ConfigurationParameterScope.zone.toString(), pool.getDataCenterId()));
+                ConfigKey.Scope.Zone.toString(), pool.getDataCenterId()));
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Checking pool: " + pool.getId() + " for volume allocation " + volumes.toString() + ", maxSize : " + totalOverProvCapacity
                     + ", totalAllocatedSize : " + allocatedSizeWithtemplate + ", askingSize : " + totalAskingSize + ", allocated disable threshold: "

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/template/TemplateAdapterBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateAdapterBase.java b/server/src/com/cloud/template/TemplateAdapterBase.java
index 6f38c84..e75e699 100755
--- a/server/src/com/cloud/template/TemplateAdapterBase.java
+++ b/server/src/com/cloud/template/TemplateAdapterBase.java
@@ -30,13 +30,13 @@ import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
 import org.apache.cloudstack.api.command.user.template.ExtractTemplateCmd;
 import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.framework.config.ConfigValue;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
 import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
 
 import com.cloud.api.ApiDBUtils;
-import com.cloud.configuration.Config;
 import com.cloud.configuration.Resource.ResourceType;
 import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.dao.DataCenterDao;
@@ -91,6 +91,10 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
     @Inject ConfigurationServer _configServer;
     @Inject ProjectManager _projectMgr;
 
+    @InjectConfig(key = TemplateManager.AllowPublicUserTemplatesCK)
+    ConfigValue<Boolean> _allowPublicUserTemplates;
+
+
     @Override
     public boolean stop() {
         return true;
@@ -170,7 +174,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
         }
 
         // check whether owner can create public templates
-        boolean allowPublicUserTemplates = Boolean.parseBoolean(_configServer.getConfigValue(Config.AllowPublicUserTemplates.key(), Config.ConfigurationParameterScope.account.toString(), templateOwner.getId()));
+        boolean allowPublicUserTemplates = _allowPublicUserTemplates.valueIn(templateOwner.getId());
         if (!isAdmin && !allowPublicUserTemplates && isPublic) {
             throw new InvalidParameterValueException("Only private templates/ISO can be created.");
         }
@@ -216,10 +220,10 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
         }
 
         Long id = _tmpltDao.getNextInSequence(Long.class, "id");
-        CallContext.current().setEventDetails("Id: " +id+ " name: " + name);
-        return new TemplateProfile(id, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic,
-                featured, isExtractable, imgfmt, guestOSId, zoneId, hypervisorType, templateOwner.getAccountName(), templateOwner.getDomainId(),
-                templateOwner.getAccountId(), chksum, bootable, templateTag, details, sshkeyEnabled, null, isDynamicallyScalable, templateType);
+        CallContext.current().setEventDetails("Id: " + id + " name: " + name);
+        return new TemplateProfile(id, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic, featured, isExtractable, imgfmt, guestOSId, zoneId,
+            hypervisorType, templateOwner.getAccountName(), templateOwner.getDomainId(), templateOwner.getAccountId(), chksum, bootable, templateTag, details, sshkeyEnabled, null,
+            isDynamicallyScalable, templateType);
 
     }
 
@@ -284,7 +288,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
             }
 
             template.setCrossZones(true);
-            for (DataCenterVO dc: dcs) {
+            for (DataCenterVO dc : dcs) {
                 _tmpltDao.addTemplateToZone(template, dc.getId());
             }
 
@@ -386,7 +390,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
             throw new InvalidParameterValueException("unable to find iso with id " + templateId);
         }
 
-        userId = accountAndUserValidation(account, userId, null, template, "Unable to delete iso " );
+        userId = accountAndUserValidation(account, userId, null, template, "Unable to delete iso ");
 
         UserVO user = _userDao.findById(userId);
         if (user == null) {
@@ -402,6 +406,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
 
     @Override
     abstract public VMTemplateVO create(TemplateProfile profile);
+    
     @Override
     abstract public boolean delete(TemplateProfile profile);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index 8a54355..3e6e71c 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -69,6 +69,9 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
 import org.apache.cloudstack.framework.async.AsyncCallFuture;
+import org.apache.cloudstack.framework.config.ConfigKey;
+import org.apache.cloudstack.framework.config.ConfigValue;
+import org.apache.cloudstack.framework.config.Configurable;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.framework.jobs.AsyncJobManager;
 import org.apache.cloudstack.storage.command.AttachCommand;
@@ -170,6 +173,7 @@ import com.cloud.utils.EnumUtils;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.AdapterBase;
+import com.cloud.utils.component.InjectConfig;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.concurrency.NamedThreadFactory;
 import com.cloud.utils.db.DB;
@@ -183,8 +187,11 @@ import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.VMInstanceDao;
 
 @Local(value = { TemplateManager.class, TemplateApiService.class })
-public class TemplateManagerImpl extends ManagerBase implements TemplateManager, TemplateApiService {
+public class TemplateManagerImpl extends ManagerBase implements TemplateManager, TemplateApiService, Configurable {
     private final static Logger s_logger = Logger.getLogger(TemplateManagerImpl.class);
+    @InjectConfig(key = TemplateManager.AllowPublicUserTemplatesCK)
+    ConfigValue<Boolean> _allowPublicUserTemplates;
+
     @Inject
     VMTemplateDao _tmpltDao;
     @Inject
@@ -1213,8 +1220,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
         boolean isAdmin = _accountMgr.isAdmin(caller.getType());
         // check configuration parameter(allow.public.user.templates) value for
         // the template owner
-        boolean allowPublicUserTemplates = Boolean.valueOf(_configServer.getConfigValue(Config.AllowPublicUserTemplates.key(),
-                Config.ConfigurationParameterScope.account.toString(), template.getAccountId()));
+        boolean allowPublicUserTemplates = _allowPublicUserTemplates.valueIn(template.getAccountId());
         if (!isAdmin && !allowPublicUserTemplates && isPublic != null && isPublic) {
             throw new InvalidParameterValueException("Only private " + mediaType + "s can be created.");
         }
@@ -1476,8 +1482,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
         }
         boolean  isDynamicScalingEnabled = cmd.isDynamicallyScalable();
         // check whether template owner can create public templates
-        boolean allowPublicUserTemplates = Boolean.parseBoolean(_configServer.getConfigValue(Config.AllowPublicUserTemplates.key(),
-                Config.ConfigurationParameterScope.account.toString(), templateOwner.getId()));
+        boolean allowPublicUserTemplates = _allowPublicUserTemplates.valueIn(templateOwner.getId());
         if (!isAdmin && !allowPublicUserTemplates && isPublic) {
             throw new PermissionDeniedException("Failed to create template " + name + ", only private templates can be created.");
         }
@@ -1792,4 +1797,14 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
 
         return _tmpltDao.findById(id);
     }
+
+    @Override
+    public String getConfigComponentName() {
+        return TemplateManager.class.getSimpleName();
+    }
+
+    @Override
+    public ConfigKey<?>[] getConfigKeys() {
+        return new ConfigKey<?>[] {AllowPublicUserTemplates};
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/vm/UserVmManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManager.java b/server/src/com/cloud/vm/UserVmManager.java
index 635d15e..e1bee8d 100755
--- a/server/src/com/cloud/vm/UserVmManager.java
+++ b/server/src/com/cloud/vm/UserVmManager.java
@@ -20,6 +20,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.cloudstack.framework.config.ConfigKey;
+
 import com.cloud.agent.api.VmDiskStatsEntry;
 import com.cloud.agent.api.VmStatsEntry;
 import com.cloud.api.query.vo.UserVmJoinVO;
@@ -39,6 +41,10 @@ import com.cloud.utils.Pair;
  * 
  */
 public interface UserVmManager extends UserVmService {
+    static final String EnableDynamicallyScaleVmCK = "enable.dynamic.scale.vm";
+    static final ConfigKey<Boolean> EnableDynamicallyScaleVm = new ConfigKey<Boolean>("Advanced", Boolean.class, EnableDynamicallyScaleVmCK, "false",
+        "Enables/Diables dynamically scaling a vm", true, ConfigKey.Scope.Zone);
+    
 
 	static final int MAX_USER_DATA_LENGTH_BYTES = 2048;
     /**


Mime
View raw message