cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [11/36] Commit to try something on removing getZone
Date Fri, 06 Sep 2013 22:38:41 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index d960c58..425937a 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -71,6 +71,8 @@ import org.apache.cloudstack.config.Configuration;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+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.region.PortableIp;
@@ -90,6 +92,7 @@ import org.apache.log4j.Logger;
 
 import com.cloud.alert.AlertManager;
 import com.cloud.api.ApiDBUtils;
+import com.cloud.capacity.CapacityManager;
 import com.cloud.capacity.dao.CapacityDao;
 import com.cloud.configuration.Resource.ResourceType;
 import com.cloud.dc.AccountVlanMapVO;
@@ -359,10 +362,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
 
     private void weightBasedParametersForValidation() {
         weightBasedParametersForValidation = new HashSet<String>();
-        weightBasedParametersForValidation.add(Config.CPUCapacityThreshold.key());
-        weightBasedParametersForValidation.add(Config.StorageAllocatedCapacityThreshold.key());
-        weightBasedParametersForValidation.add(Config.StorageCapacityThreshold.key());
-        weightBasedParametersForValidation.add(Config.MemoryCapacityThreshold.key());
+        weightBasedParametersForValidation.add(AlertManager.CPUCapacityThreshold.key());
+        weightBasedParametersForValidation.add(AlertManager.StorageAllocatedCapacityThreshold.key());
+        weightBasedParametersForValidation.add(AlertManager.StorageCapacityThreshold.key());
+        weightBasedParametersForValidation.add(AlertManager.MemoryCapacityThreshold.key());
         weightBasedParametersForValidation.add(Config.PublicIpCapacityThreshold.key());
         weightBasedParametersForValidation.add(Config.PrivateIpCapacityThreshold.key());
         weightBasedParametersForValidation.add(Config.SecondaryStorageCapacityThreshold.key());
@@ -381,8 +384,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
 
     private void overProvisioningFactorsForValidation() {
         overprovisioningFactorsForValidation = new HashSet<String>();
-        overprovisioningFactorsForValidation.add(Config.MemOverprovisioningFactor.key());
-        overprovisioningFactorsForValidation.add(Config.CPUOverprovisioningFactor.key());
+        overprovisioningFactorsForValidation.add(CapacityManager.MemOverprovisioningFactor.key());
+        overprovisioningFactorsForValidation.add(CapacityManager.CpuOverprovisioningFactor.key());
         overprovisioningFactorsForValidation.add(Config.StorageOverprovisioningFactor.key());
     }
 
@@ -444,9 +447,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         // if scope is mentioned as global or not mentioned then it is normal
         // global parameter updation
         if (scope != null && !scope.isEmpty()
-                && !Config.ConfigurationParameterScope.global.toString().equalsIgnoreCase(scope)) {
-            switch (Config.ConfigurationParameterScope.valueOf(scope)) {
-            case zone:
+                && !ConfigKey.Scope.Global.toString().equalsIgnoreCase(scope)) {
+            switch (ConfigKey.Scope.valueOf(scope)) {
+            case Zone:
                 DataCenterVO zone = _zoneDao.findById(resourceId);
                 if (zone == null) {
                     throw new InvalidParameterValueException("unable to find zone by id " + resourceId);
@@ -460,7 +463,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
                     _dcDetailsDao.update(dcDetailVO.getId(), dcDetailVO);
                 }
                 break;
-            case cluster:
+            case Cluster:
                 ClusterVO cluster = _clusterDao.findById(resourceId);
                 if (cluster == null) {
                     throw new InvalidParameterValueException("unable to find cluster by id " + resourceId);
@@ -475,7 +478,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
                 }
                 break;
 
-            case storagepool:
+            case StoragePool:
                 StoragePoolVO pool = _storagePoolDao.findById(resourceId);
                 if (pool == null) {
                     throw new InvalidParameterValueException("unable to find storage pool by id " + resourceId);
@@ -491,7 +494,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
                 }
                 break;
 
-            case account:
+            case Account:
                 AccountVO account = _accountDao.findById(resourceId);
                 if (account == null) {
                     throw new InvalidParameterValueException("unable to find account by id " + resourceId);
@@ -655,22 +658,22 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         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++;
         }
@@ -4624,6 +4627,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         }
     }
 
+    @InjectConfig(key = NetworkOrchestrationService.NetworkThrottlingRateCK)
+    ConfigValue<Integer> _networkThrottlingRate;
+
     @Override
     public Integer getNetworkOfferingNetworkRate(long networkOfferingId, Long dataCenterId) {
 
@@ -4637,8 +4643,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         if (no.getRateMbps() != null) {
             networkRate = no.getRateMbps();
         } else {
-            networkRate = Integer.parseInt(_configServer.getConfigValue(Config.NetworkThrottlingRate.key(),
-                    Config.ConfigurationParameterScope.zone.toString(), dataCenterId));
+            networkRate = _networkThrottlingRate.valueIn(dataCenterId);
         }
 
         // networkRate is unsigned int in netowrkOfferings table, and can't be
@@ -4761,8 +4766,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
             // for domain router service offering, get network rate from
             if (offering.getSystemVmType() != null
                     && offering.getSystemVmType().equalsIgnoreCase(VirtualMachine.Type.DomainRouter.toString())) {
-                networkRate = Integer.parseInt(_configServer.getConfigValue(Config.NetworkThrottlingRate.key(),
-                        Config.ConfigurationParameterScope.zone.toString(), dataCenterId));
+                networkRate = _networkThrottlingRate.valueIn(dataCenterId);
             } else {
                 networkRate = Integer.parseInt(_configDao.getValue(Config.VmNetworkThrottlingRate.key()));
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/ha/HighAvailabilityManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/HighAvailabilityManager.java b/server/src/com/cloud/ha/HighAvailabilityManager.java
deleted file mode 100644
index dd0b3e6..0000000
--- a/server/src/com/cloud/ha/HighAvailabilityManager.java
+++ /dev/null
@@ -1,114 +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.ha;
-
-import java.util.List;
-
-import com.cloud.host.HostVO;
-import com.cloud.host.Status;
-import com.cloud.utils.component.Manager;
-import com.cloud.vm.VMInstanceVO;
-
-/**
- * HighAvailabilityManager checks to make sure the VMs are running fine.
- */
-public interface HighAvailabilityManager extends Manager {
-    public enum WorkType {
-        Migration,  // Migrating VMs off of a host.
-        Stop,       // Stops a VM for storage pool migration purposes.  This should be obsolete now.
-        CheckStop,  // Checks if a VM has been stopped.
-        ForceStop,  // Force a VM to stop even if the states don't allow it.  Use this only if you know the VM is stopped on the physical hypervisor.
-        Destroy,    // Destroy a VM.
-        HA;         // Restart a VM.
-    }
-
-    enum Step {
-        Scheduled,
-        Investigating,
-        Fencing,
-        Stopping,
-        Restarting,
-        Migrating,
-        Cancelled,
-        Done,
-        Error,
-    }
-
-    /**
-     * Investigate why a host has disconnected and migrate the VMs on it
-     * if necessary.
-     * 
-     * @param host - the host that has disconnected.
-     */
-    Status investigate(long hostId);
-
-    /**
-     * Restart a vm that has gone away due to various reasons.  Whether a
-     * VM is restarted depends on various reasons.
-     *   1. Is the VM really dead.  This method will try to find out.
-     *   2. Is the VM HA enabled?  If not, the VM is simply stopped.
-     * 
-     * All VMs that enter HA mode is not allowed to be operated on until it
-     * has been determined that the VM is dead.
-     * 
-     * @param vm the vm that has gone away.
-     * @param investigate must be investigated before we do anything with this vm.
-     */
-    void scheduleRestart(VMInstanceVO vm, boolean investigate);
-
-    void cancelDestroy(VMInstanceVO vm, Long hostId);
-    
-    void scheduleDestroy(VMInstanceVO vm, long hostId);
-    
-    /**
-     * Schedule restarts for all vms running on the host.
-     * @param host host.
-     * @param investigate TODO
-     */
-    void scheduleRestartForVmsOnHost(HostVO host, boolean investigate);
-
-    /**
-     * Schedule the vm for migration.
-     * 
-     * @param vm
-     * @return true if schedule worked.
-     */
-    boolean scheduleMigration(VMInstanceVO vm);
-    
-    List<VMInstanceVO> findTakenMigrationWork();
-
-    /**
-     * Schedules a work item to stop a VM.  This method schedules a work
-     * item to do one of three things.
-     * 
-     * 1. Perform a regular stop of a VM: WorkType.Stop
-     * 2. Perform a force stop of a VM: WorkType.ForceStop
-     * 3. Check if a VM has been stopped: WorkType.CheckStop
-     * 
-     * @param vm virtual machine to stop.
-     * @param host host the virtual machine is on.
-     * @param type which type of stop is requested. 
-     */
-    void scheduleStop(VMInstanceVO vm, long hostId, WorkType type);
-
-    void cancelScheduledMigrations(HostVO host);
-
-    /**
-     * @return
-     */
-    String getHaTag();
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
index 8a9df03..b1b2d40 100644
--- a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
+++ b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
@@ -21,18 +21,21 @@ import java.util.Map;
 
 import javax.inject.Inject;
 
+import org.apache.cloudstack.framework.config.ConfigValue;
+
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.to.DiskTO;
 import com.cloud.agent.api.to.NicTO;
 import com.cloud.agent.api.to.VirtualMachineTO;
-import com.cloud.configuration.Config;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.server.ConfigurationServer;
 import com.cloud.storage.dao.VMTemplateDetailsDao;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.AdapterBase;
+import com.cloud.utils.component.InjectConfig;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
+import com.cloud.vm.UserVmManager;
 import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
@@ -48,6 +51,9 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
     @Inject NicSecondaryIpDao _nicSecIpDao;
     @Inject ConfigurationServer _configServer;
 
+    @InjectConfig(key = UserVmManager.EnableDynamicallyScaleVmCK)
+    ConfigValue<Boolean> _enableDynamicallyScaleVm;
+
     protected HypervisorGuruBase() {
         super();
     }
@@ -124,7 +130,7 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
         // Workaround to make sure the TO has the UUID we need for Niciri integration
         VMInstanceVO vmInstance = _virtualMachineDao.findById(to.getId());
         // check if XStools/VMWare tools are present in the VM and dynamic scaling feature is enabled (per zone/global)
-        Boolean isDynamicallyScalable = vmInstance.isDynamicallyScalable() && Boolean.parseBoolean(_configServer.getConfigValue(Config.EnableDynamicallyScaleVm.key(), Config.ConfigurationParameterScope.zone.toString(), vm.getDataCenterId()));
+        Boolean isDynamicallyScalable = vmInstance.isDynamicallyScalable() && _enableDynamicallyScaleVm.valueIn(vm.getDataCenterId());
         to.setEnableDynamicallyScaleVm(isDynamicallyScalable);
         to.setUuid(vmInstance.getUuid());
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/hypervisor/HypervisorGuruManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/HypervisorGuruManager.java b/server/src/com/cloud/hypervisor/HypervisorGuruManager.java
deleted file mode 100644
index 5249750..0000000
--- a/server/src/com/cloud/hypervisor/HypervisorGuruManager.java
+++ /dev/null
@@ -1,27 +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.hypervisor;
-
-import com.cloud.agent.api.Command;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.utils.component.Manager;
-
-public interface HypervisorGuruManager extends Manager {
-	HypervisorGuru getGuru(HypervisorType hypervisorType);
-    long getGuruProcessedCommandTargetHost(long hostId, Command cmd);
-}
-

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/IpAddressManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/IpAddressManagerImpl.java b/server/src/com/cloud/network/IpAddressManagerImpl.java
index 37552f6..2daea2d 100644
--- a/server/src/com/cloud/network/IpAddressManagerImpl.java
+++ b/server/src/com/cloud/network/IpAddressManagerImpl.java
@@ -34,6 +34,9 @@ import org.apache.cloudstack.acl.ControlledEntity.ACLType;
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
+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.region.PortableIp;
 import org.apache.cloudstack.region.PortableIpDao;
@@ -43,7 +46,6 @@ import org.apache.cloudstack.region.Region;
 import com.cloud.agent.AgentManager;
 import com.cloud.alert.AlertManager;
 import com.cloud.api.ApiDBUtils;
-import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.Resource.ResourceType;
 import com.cloud.dc.AccountVlanMapVO;
@@ -123,7 +125,6 @@ import com.cloud.offerings.dao.NetworkOfferingDao;
 import com.cloud.offerings.dao.NetworkOfferingDetailsDao;
 import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
 import com.cloud.org.Grouping;
-import com.cloud.server.ConfigurationServer;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
 import com.cloud.user.ResourceLimitService;
@@ -133,6 +134,7 @@ import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.UserDao;
 import com.cloud.utils.Journal;
 import com.cloud.utils.Pair;
+import com.cloud.utils.component.InjectConfig;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.EntityManager;
@@ -158,9 +160,12 @@ import com.cloud.vm.dao.NicSecondaryIpDao;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.VMInstanceDao;
 
-public class IpAddressManagerImpl extends ManagerBase implements IpAddressManager {
+public class IpAddressManagerImpl extends ManagerBase implements IpAddressManager, Configurable {
     private static final Logger s_logger = Logger.getLogger(IpAddressManagerImpl.class);
 
+    @InjectConfig(key = UseSystemPublicIpsCK)
+    ConfigValue<Boolean> _useSystemPublicIps;
+
     @Inject
     NetworkOrchestrationService _networkMgr = null;
     @Inject
@@ -206,8 +211,6 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
     @Inject
     NetworkOfferingDetailsDao _ntwkOffDetailsDao;
     @Inject
-    ConfigurationServer _configServer;
-    @Inject
     AccountGuestVlanMapDao _accountGuestVlanMapDao;
     @Inject
     DataCenterVnetDao _datacenterVnetDao;
@@ -724,9 +727,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
         // If all the dedicated IPs of the owner are in use fetch an IP from the system pool
         if (addrs.size() == 0 && fetchFromDedicatedRange) {
             // Verify if account is allowed to acquire IPs from the system
-            boolean useSystemIps = Boolean.parseBoolean(_configServer.getConfigValue(Config.UseSystemPublicIps.key(),
-                Config.ConfigurationParameterScope.account.toString(),
-                owner.getId()));
+            boolean useSystemIps = _useSystemPublicIps.valueIn(owner.getId());
             if (useSystemIps && nonDedicatedVlanDbIds != null && !nonDedicatedVlanDbIds.isEmpty()) {
                 fetchFromDedicatedRange = false;
                 sc.setParameters("vlanId", nonDedicatedVlanDbIds.toArray());
@@ -1917,4 +1918,14 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
         ipaddr = acquireGuestIpAddress(network, requestedIp);
         return ipaddr;
     }
+
+    @Override
+    public String getConfigComponentName() {
+        return IpAddressManager.class.getSimpleName();
+    }
+
+    @Override
+    public ConfigKey<?>[] getConfigKeys() {
+        return new ConfigKey<?>[] {UseSystemPublicIps};
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/NetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java
index c040a1a..df9f651 100755
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -205,7 +205,6 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
     SearchBuilder<NicVO> NicForTrafficTypeSearch;
 
    
-    private String _networkDomain;
     private boolean _allowSubdomainNetworkAccess;
 
     private Map<String, String> _configs;
@@ -970,11 +969,6 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
     }
 
     @Override
-    public String getGlobalGuestDomainSuffix() {
-        return _networkDomain;
-    }
-
-    @Override
     public String getStartIpAddress(long networkId) {
         List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(networkId);
         if (vlans.isEmpty()) {
@@ -1597,11 +1591,6 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
     }
 
     @Override
-    public String getDefaultNetworkDomain(long zoneId) {
-        return _configServer.getConfigValue(Config.GuestDomainSuffix.key(), Config.ConfigurationParameterScope.zone.toString(), zoneId);
-    }
-
-    @Override
     public List<Provider> getNtwkOffDistinctProviders(long ntkwOffId) {
         List<String> providerNames = _ntwkOfferingSrvcDao.getDistinctProviders(ntkwOffId);
         List<Provider> providers = new ArrayList<Provider>();
@@ -1900,7 +1889,6 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
     @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
         _configs = _configDao.getConfiguration("Network", params);
-        _networkDomain = _configs.get(Config.GuestDomainSuffix.key());
         _allowSubdomainNetworkAccess = Boolean.valueOf(_configs.get(Config.SubDomainNetworkAccess.key()));
         _executeInSequenceNtwkElmtCmd = Boolean.valueOf(_configs.get(Config.ExecuteInSequenceNetworkElementCommands.key()));
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index cf4f503..5d2ef4f 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -293,6 +293,8 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
     NetworkACLDao _networkACLDao;
     @Inject
     IpAddressManager _ipAddrMgr;
+    @Inject
+    EntityManager _entityMgr;
 
     int _cidrLimit;
     boolean _allowSubdomainNetworkAccess;
@@ -1930,7 +1932,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
 
         //perform below validation if the network is vpc network
         if (network.getVpcId() != null && networkOfferingId != null) {
-            Vpc vpc = _vpcMgr.getVpc(network.getVpcId());
+            Vpc vpc = _entityMgr.findById(Vpc.class, network.getVpcId());
             _vpcMgr.validateNtwkOffForNtwkInVpc(networkId, networkOfferingId, null, null, vpc, null, _accountMgr.getAccount(network.getAccountId()), null);
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/NetworkStateListener.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkStateListener.java b/server/src/com/cloud/network/NetworkStateListener.java
deleted file mode 100644
index 520244c..0000000
--- a/server/src/com/cloud/network/NetworkStateListener.java
+++ /dev/null
@@ -1,105 +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;
-
-import com.cloud.event.EventCategory;
-import com.cloud.event.dao.UsageEventDao;
-import com.cloud.network.Network.Event;
-import com.cloud.network.Network.State;
-import com.cloud.network.dao.NetworkDao;
-import com.cloud.server.ManagementServer;
-import com.cloud.utils.component.ComponentContext;
-import com.cloud.utils.fsm.StateListener;
-import org.apache.cloudstack.framework.events.EventBus;
-import org.apache.cloudstack.framework.events.EventBusException;
-import org.apache.log4j.Logger;
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
-
-import javax.inject.Inject;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-public class NetworkStateListener implements StateListener<State, Event, Network> {
-
-    @Inject protected UsageEventDao _usageEventDao;
-    @Inject protected NetworkDao _networkDao;
-
-    protected static EventBus _eventBus = null;
-
-    private static final Logger s_logger = Logger.getLogger(NetworkStateListener.class);
-
-    public NetworkStateListener(UsageEventDao usageEventDao, NetworkDao networkDao) {
-        this._usageEventDao = usageEventDao;
-        this._networkDao = networkDao;
-    }
-
-    @Override
-    public boolean preStateTransitionEvent(State oldState, Event event, State newState, Network vo, boolean status, Object opaque) {
-        pubishOnEventBus(event.name(), "preStateTransitionEvent", vo, oldState, newState);
-        return true;
-    }
-
-    @Override
-    public boolean postStateTransitionEvent(State oldState, Event event, State newState, Network vo, boolean status, Object opaque) {
-        pubishOnEventBus(event.name(), "postStateTransitionEvent", vo, oldState, newState);
-        return true;
-    }
-
-    private void pubishOnEventBus(String event, String status, Network vo, State oldState, State newState) {
-
-        try {
-            _eventBus = ComponentContext.getComponent(EventBus.class);
-        } catch(NoSuchBeanDefinitionException nbe) {
-            return; // no provider is configured to provide events bus, so just return
-        }
-
-        String resourceName = getEntityFromClassName(Network.class.getName());
-        org.apache.cloudstack.framework.events.Event eventMsg =  new org.apache.cloudstack.framework.events.Event(
-                ManagementServer.Name,
-                EventCategory.RESOURCE_STATE_CHANGE_EVENT.getName(),
-                event,
-                resourceName,
-                vo.getUuid());
-        Map<String, String> eventDescription = new HashMap<String, String>();
-        eventDescription.put("resource", resourceName);
-        eventDescription.put("id", vo.getUuid());
-        eventDescription.put("old-state", oldState.name());
-        eventDescription.put("new-state", newState.name());
-
-        String eventDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date());
-        eventDescription.put("eventDateTime", eventDate);
-
-        eventMsg.setDescription(eventDescription);
-        try {
-            _eventBus.publish(eventMsg);
-        } catch (EventBusException e) {
-            s_logger.warn("Failed to publish state change event on the the event bus.");
-        }
-    }
-
-    private String getEntityFromClassName(String entityClassName) {
-        int index = entityClassName.lastIndexOf(".");
-        String entityName = entityClassName;
-        if (index != -1) {
-            entityName = entityClassName.substring(index+1);
-        }
-        return entityName;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
index b45d1c1..c512dda 100644
--- a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
@@ -25,9 +25,6 @@ import java.util.Set;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import com.cloud.network.dao.NetworkDao;
-import com.cloud.network.vpc.*;
-import com.cloud.network.vpc.dao.VpcGatewayDao;
 import org.apache.log4j.Logger;
 
 import com.cloud.dc.DataCenter;
@@ -46,27 +43,37 @@ import com.cloud.network.Site2SiteVpnConnection;
 import com.cloud.network.Site2SiteVpnGateway;
 import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
 import com.cloud.network.dao.IPAddressDao;
+import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.Site2SiteVpnGatewayDao;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.router.VirtualRouter.Role;
 import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
+import com.cloud.network.vpc.NetworkACLItem;
+import com.cloud.network.vpc.NetworkACLItemDao;
+import com.cloud.network.vpc.NetworkACLItemVO;
+import com.cloud.network.vpc.PrivateGateway;
+import com.cloud.network.vpc.StaticRouteProfile;
+import com.cloud.network.vpc.Vpc;
+import com.cloud.network.vpc.VpcGateway;
+import com.cloud.network.vpc.VpcManager;
+import com.cloud.network.vpc.dao.VpcGatewayDao;
 import com.cloud.offering.NetworkOffering;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachine.Type;
 import com.cloud.vm.VirtualMachineProfile;
 
-@Local(value = {NetworkElement.class, FirewallServiceProvider.class, 
-        DhcpServiceProvider.class, UserDataServiceProvider.class, 
+@Local(value = {NetworkElement.class, FirewallServiceProvider.class,
+        DhcpServiceProvider.class, UserDataServiceProvider.class,
         StaticNatServiceProvider.class, LoadBalancingServiceProvider.class,
         PortForwardingServiceProvider.class, IpDeployer.class, VpcProvider.class,
         Site2SiteVpnServiceProvider.class, NetworkACLServiceProvider.class})
 public class VpcVirtualRouterElement extends VirtualRouterElement implements VpcProvider, Site2SiteVpnServiceProvider, NetworkACLServiceProvider{
     private static final Logger s_logger = Logger.getLogger(VpcVirtualRouterElement.class);
-    @Inject 
+    @Inject
     VpcManager _vpcMgr;
     @Inject
     VpcVirtualNetworkApplianceManager _vpcRouterMgr;
@@ -82,6 +89,8 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
     VpcGatewayDao _vpcGatewayDao;
     @Inject
     NetworkACLItemDao _networkACLItemDao;
+    @Inject
+    EntityManager _entityMgr;
 
     private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
 
@@ -107,17 +116,17 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
             }
         } else {
             if (!_networkMgr.isProviderSupportServiceInNetwork(network.getId(), service, getProvider())) {
-                s_logger.trace("Element " + getProvider().getName() + " doesn't support service " + service.getName() 
+                s_logger.trace("Element " + getProvider().getName() + " doesn't support service " + service.getName()
                         + " in the network " + network);
                 return false;
-            } 
+            }
         }
 
         return true;
     }
 
     @Override
-    public boolean implementVpc(Vpc vpc, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, 
+    public boolean implementVpc(Vpc vpc, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
     ResourceUnavailableException, InsufficientCapacityException {
 
         Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param, Object>(1);
@@ -181,12 +190,12 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
             }
         }
 
-        return true;       
+        return true;
     }
 
     @Override
-    public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, 
-            DeployDestination dest, ReservationContext context) 
+    public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm,
+            DeployDestination dest, ReservationContext context)
                     throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
 
         Long vpcId = network.getVpcId();
@@ -204,7 +213,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
         if (vm.getType() == Type.User) {
             Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param, Object>(1);
             params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
-            List<DomainRouterVO> routers = _vpcRouterMgr.deployVirtualRouterInVpc(vpc, dest, 
+            List<DomainRouterVO> routers = _vpcRouterMgr.deployVirtualRouterInVpc(vpc, dest,
                     _accountMgr.getAccount(vpc.getAccountId()), params);
             if ((routers == null) || (routers.size() == 0)) {
                 throw new ResourceUnavailableException("Can't find at least one running router!",
@@ -230,7 +239,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
     }
 
     @Override
-    public boolean shutdown(Network network, ReservationContext context, boolean cleanup) 
+    public boolean shutdown(Network network, ReservationContext context, boolean cleanup)
             throws ConcurrentOperationException, ResourceUnavailableException {
         boolean success = true;
         Long vpcId = network.getVpcId();
@@ -330,7 +339,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
 
         List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(gateway.getVpcId());
         if (routers == null || routers.isEmpty()) {
-            s_logger.debug(this.getName() + " element doesn't need to create Private gateway on the backend; VPC virtual " +
+            s_logger.debug(getName() + " element doesn't need to create Private gateway on the backend; VPC virtual " +
                     "router doesn't exist in the vpc id=" + gateway.getVpcId());
             return true;
         }
@@ -365,7 +374,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
 
         List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(gateway.getVpcId());
         if (routers == null || routers.isEmpty()) {
-            s_logger.debug(this.getName() + " element doesn't need to delete Private gateway on the backend; VPC virtual " +
+            s_logger.debug(getName() + " element doesn't need to delete Private gateway on the backend; VPC virtual " +
                     "router doesn't exist in the vpc id=" + gateway.getVpcId());
             return true;
         }
@@ -381,7 +390,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
 
 
     @Override
-    public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress, Set<Service> services) 
+    public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress, Set<Service> services)
             throws ResourceUnavailableException {
         boolean canHandle = true;
         for (Service service : services) {
@@ -393,7 +402,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
         if (canHandle) {
             List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
             if (routers == null || routers.isEmpty()) {
-                s_logger.debug(this.getName() + " element doesn't need to associate ip addresses on the backend; VPC virtual " +
+                s_logger.debug(getName() + " element doesn't need to associate ip addresses on the backend; VPC virtual " +
                         "router doesn't exist in the network " + network.getId());
                 return true;
             }
@@ -479,7 +488,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
         }
 
         Long vpcId = ip.getVpcId();
-        Vpc vpc = _vpcMgr.getVpc(vpcId);
+        Vpc vpc = _entityMgr.findById(Vpc.class, vpcId);
 
         if (!_ntwkModel.isProviderEnabledInZone(vpc.getZoneId(), Provider.VPCVirtualRouter.getName())) {
             throw new ResourceUnavailableException("VPC provider is not enabled in zone " + vpc.getZoneId(),
@@ -507,7 +516,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
         }
 
         Long vpcId = ip.getVpcId();
-        Vpc vpc = _vpcMgr.getVpc(vpcId);
+        Vpc vpc = _entityMgr.findById(Vpc.class, vpcId);
 
         if (!_ntwkModel.isProviderEnabledInZone(vpc.getZoneId(), Provider.VPCVirtualRouter.getName())) {
             throw new ResourceUnavailableException("VPC provider is not enabled in zone " + vpc.getZoneId(),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java b/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
index e26fe74..199da05 100644
--- a/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
@@ -139,8 +139,8 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
         // Get a vlan tag
         int vlanTag;
         if (config.getBroadcastUri() == null) {
-            String vnet = _dcDao.allocateVnet(zone.getId(), config.getPhysicalNetworkId(), config.getAccountId(),
-                    context.getReservationId(), canUseSystemGuestVlan(config.getAccountId()));
+            String vnet = _dcDao.allocateVnet(zone.getId(), config.getPhysicalNetworkId(), config.getAccountId(), context.getReservationId(),
+                _useSystemGuestVlans.valueIn(config.getAccountId()));
 
             try {
                 vlanTag = Integer.parseInt(vnet);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/guru/GuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/GuestNetworkGuru.java b/server/src/com/cloud/network/guru/GuestNetworkGuru.java
index a3eab0f..cbb5ac7 100755
--- a/server/src/com/cloud/network/guru/GuestNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/GuestNetworkGuru.java
@@ -27,6 +27,9 @@ import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
+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 com.cloud.configuration.Config;
@@ -66,6 +69,7 @@ import com.cloud.server.ConfigurationServer;
 import com.cloud.user.Account;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.AdapterBase;
+import com.cloud.utils.component.InjectConfig;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.exception.CloudRuntimeException;
@@ -78,7 +82,7 @@ import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.NicDao;
 
 @Local(value = NetworkGuru.class)
-public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
+public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGuru, Configurable {
     private static final Logger s_logger = Logger.getLogger(GuestNetworkGuru.class);
     @Inject
     protected NetworkOrchestrationService _networkMgr;
@@ -103,6 +107,13 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
     @Inject
     IpAddressManager _ipAddrMgr;
     Random _rand = new Random(System.currentTimeMillis());
+    
+    static final ConfigKey<Boolean> UseSystemGuestVlans = new ConfigKey<Boolean>("Advanced", Boolean.class, "use.system.guest.vlans", "true",
+        "If true, when account has dedicated guest vlan range(s), once the vlans dedicated to the account have been consumed vlans will be allocated from the system pool", false,
+        ConfigKey.Scope.Account);
+
+    @InjectConfig(key = "use.system.guest.vlans")
+    ConfigValue<Boolean> _useSystemGuestVlans;
 
     private static final TrafficType[] _trafficTypes = {TrafficType.Guest};
 
@@ -159,11 +170,6 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
         return _isolationMethods;
     }
 
-    public boolean canUseSystemGuestVlan(long accountId) {
-        return Boolean.parseBoolean(_configServer.getConfigValue(Config.UseSystemGuestVlans.key(),
-            Config.ConfigurationParameterScope.account.toString(), accountId));
-    }
-
     protected abstract boolean canHandle(NetworkOffering offering, final NetworkType networkType, PhysicalNetwork physicalNetwork);
 
     @Override
@@ -269,8 +275,7 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
     protected void allocateVnet(Network network, NetworkVO implemented, long dcId,
     		long physicalNetworkId, String reservationId) throws InsufficientVirtualNetworkCapcityException {
         if (network.getBroadcastUri() == null) {
-            String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId, network.getAccountId(), reservationId,
-                    canUseSystemGuestVlan(network.getAccountId()));
+            String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId, network.getAccountId(), reservationId, _useSystemGuestVlans.valueIn(network.getAccountId()));
             if (vnet == null) {
                 throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a " +
                 		"part of network " + network + " implement ", DataCenter.class, dcId);
@@ -434,4 +439,14 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
         networkProfile.setDns1(dc.getDns1());
         networkProfile.setDns2(dc.getDns2());
     }
+
+    @Override
+    public String getConfigComponentName() {
+        return GuestNetworkGuru.class.getSimpleName();
+    }
+
+    @Override
+    public ConfigKey<?>[] getConfigKeys() {
+        return new ConfigKey<?>[] {UseSystemGuestVlans};
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java
index dbbc2d5..4ea09e5 100644
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.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,
@@ -16,6 +16,11 @@
 // under the License.
 package com.cloud.network.router;
 
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cloudstack.framework.config.ConfigKey;
+
 import com.cloud.deploy.DeployDestination;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
@@ -30,20 +35,33 @@ import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.StaticNat;
 import com.cloud.user.Account;
 import com.cloud.user.User;
-import com.cloud.uservm.UserVm;
 import com.cloud.utils.component.Manager;
 import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.VirtualMachineProfile;
 
-import java.util.List;
-import java.util.Map;
-
 /**
  * NetworkManager manages the network for the different end users.
  *
  */
 public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkApplianceService{
+    static final String RouterTemplateXenCK = "router.template.xen";
+    static final String RouterTemplateKvmCK = "router.template.kvm";
+    static final String RouterTemplateVmwareCK = "router.template.vmware";
+    static final String RouterTemplateHyperVCK = "router.template.hyperv";
+    static final String RouterTemplateLxcCK = "router.template.lxc";
+
+    static final ConfigKey<String> RouterTemplateXen = new ConfigKey<String>(String.class, RouterTemplateXenCK, "Advanced", "SystemVM Template (XenServer)",
+        "Name of the default router template on Xenserver.", true, ConfigKey.Scope.Zone, null);
+    static final ConfigKey<String> RouterTemplateKvm = new ConfigKey<String>(String.class, RouterTemplateKvmCK, "Advanced", "SystemVM Template (KVM)",
+        "Name of the default router template on KVM.", true, ConfigKey.Scope.Zone, null);
+    static final ConfigKey<String> RouterTemplateVmware = new ConfigKey<String>(String.class, RouterTemplateVmwareCK, "Advanced", "SystemVM Template (vSphere)",
+        "Name of the default router template on Vmware.", true, ConfigKey.Scope.Zone, null);
+    static final ConfigKey<String> RouterTemplateHyperV = new ConfigKey<String>(String.class, RouterTemplateHyperVCK, "Advanced", "SystemVM Template (HyperV)",
+        "Name of the default router template on Hyperv.", true, ConfigKey.Scope.Zone, null);
+    static final ConfigKey<String> RouterTemplateLxc = new ConfigKey<String>(String.class, RouterTemplateLxcCK, "Advanced", "SystemVM Template (LXC)",
+        "Name of the default router template on LXC.", true, ConfigKey.Scope.Zone, null);
+
     public static final int DEFAULT_ROUTER_VM_RAMSIZE = 128;            // 128M
     public static final int DEFAULT_ROUTER_CPU_MHZ = 500;            	// 500 MHz
     public static final boolean USE_POD_VLAN = false;
@@ -61,7 +79,7 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
      * @param routers TODO
      * 
      */
-    boolean savePasswordToRouter(Network network, NicProfile nic, VirtualMachineProfile profile, 
+    boolean savePasswordToRouter(Network network, NicProfile nic, VirtualMachineProfile profile,
             List<? extends VirtualRouter> routers) throws ResourceUnavailableException;
 
     boolean saveSSHPublicKeyToRouter(Network network, NicProfile nic, VirtualMachineProfile profile,
@@ -70,39 +88,39 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
     boolean saveUserDataToRouter(Network network, NicProfile nic, VirtualMachineProfile profile,
             List<? extends VirtualRouter> routers) throws ResourceUnavailableException;
 
-	List<DomainRouterVO> deployVirtualRouterInGuestNetwork(Network guestNetwork, DeployDestination dest, Account owner, 
+	List<DomainRouterVO> deployVirtualRouterInGuestNetwork(Network guestNetwork, DeployDestination dest, Account owner,
 	        Map<VirtualMachineProfile.Param, Object> params, boolean isRedundant) throws InsufficientCapacityException,
 	        ResourceUnavailableException, ConcurrentOperationException;
 	
-    boolean startRemoteAccessVpn(Network network, RemoteAccessVpn vpn, List<? extends VirtualRouter> routers) 
+    boolean startRemoteAccessVpn(Network network, RemoteAccessVpn vpn, List<? extends VirtualRouter> routers)
             throws ResourceUnavailableException;
 	
-	boolean deleteRemoteAccessVpn(Network network, RemoteAccessVpn vpn, List<? extends VirtualRouter> routers) 
+	boolean deleteRemoteAccessVpn(Network network, RemoteAccessVpn vpn, List<? extends VirtualRouter> routers)
 	        throws ResourceUnavailableException;
     
-    boolean associatePublicIP (Network network, final List<? extends PublicIpAddress> ipAddress, 
+    boolean associatePublicIP (Network network, final List<? extends PublicIpAddress> ipAddress,
             List<? extends VirtualRouter> routers) throws ResourceUnavailableException;
     
-    boolean applyFirewallRules(Network network, final List<? extends FirewallRule> rules, 
+    boolean applyFirewallRules(Network network, final List<? extends FirewallRule> rules,
             List<? extends VirtualRouter> routers) throws ResourceUnavailableException;
     
     List<VirtualRouter> getRoutersForNetwork(long networkId);
 
-    String[] applyVpnUsers(Network network, List<? extends VpnUser> users, List<DomainRouterVO> routers) 
+    String[] applyVpnUsers(Network network, List<? extends VpnUser> users, List<DomainRouterVO> routers)
             throws ResourceUnavailableException;
     
-    VirtualRouter stop(VirtualRouter router, boolean forced, User callingUser, Account callingAccount) 
+    VirtualRouter stop(VirtualRouter router, boolean forced, User callingUser, Account callingAccount)
             throws ConcurrentOperationException, ResourceUnavailableException;
 
     String getDnsBasicZoneUpdate();
     
-    boolean applyStaticNats(Network network, final List<? extends StaticNat> rules, List<? extends VirtualRouter> routers) 
+    boolean applyStaticNats(Network network, final List<? extends StaticNat> rules, List<? extends VirtualRouter> routers)
             throws ResourceUnavailableException;
     
-	boolean applyDhcpEntry(Network config, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, 
+	boolean applyDhcpEntry(Network config, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest,
 	        List<DomainRouterVO> routers) throws ResourceUnavailableException;
 	
-	boolean applyUserData(Network config, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, 
+	boolean applyUserData(Network config, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest,
 	        List<DomainRouterVO> routers) throws ResourceUnavailableException;
 
     boolean applyLoadBalancingRules(Network network, List<? extends LoadBalancingRule> rules, List<? extends VirtualRouter> routers) throws ResourceUnavailableException;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 90a4bff..d033760 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -47,6 +47,9 @@ import org.apache.cloudstack.api.command.admin.router.UpgradeRouterCmd;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.context.ServerContexts;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
+import org.apache.cloudstack.framework.config.ConfigDepot;
+import org.apache.cloudstack.framework.config.ConfigKey;
+import org.apache.cloudstack.framework.config.ConfigValue;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.utils.identity.ManagementServerNode;
 
@@ -218,6 +221,7 @@ import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.PasswordGenerator;
 import com.cloud.utils.StringUtils;
+import com.cloud.utils.component.InjectConfig;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.concurrency.NamedThreadFactory;
 import com.cloud.utils.db.DB;
@@ -363,6 +367,8 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
     NetworkService _networkSvc;
     @Inject
     IpAddressManager _ipAddrMgr;
+    @Inject
+    ConfigDepot _configDepot;
 
     
     int _routerRamSize;
@@ -635,9 +641,28 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
         }
     }
 
+    @InjectConfig(key = RouterTemplateXenCK)
+    ConfigValue<String> _routerTemplateXen;
+    @InjectConfig(key = RouterTemplateKvmCK)
+    ConfigValue<String> _routerTemplateKvm;
+    @InjectConfig(key = RouterTemplateVmwareCK)
+    ConfigValue<String> _routerTemplateVmware;
+    @InjectConfig(key = RouterTemplateHyperVCK)
+    ConfigValue<String> _routerTemplateHyperV;
+    @InjectConfig(key = RouterTemplateLxcCK)
+    ConfigValue<String> _routerTemplateLxc;
+    @InjectConfig(key = NetworkOrchestrationService.NetworkLockTimeoutCK)
+    ConfigValue<Integer> _networkLockTimeout;
+    @InjectConfig(key = "use.external.dns")
+    ConfigValue<Boolean> _useExternalDnsServers;
+
+    static final ConfigKey<Boolean> UseExternalDnsServers = new ConfigKey<Boolean>(Boolean.class, "use.external.dns", "Advanced", "false",
+        "Bypass internal dns, use external dns1 and dns2", true, ConfigKey.Scope.Zone, null);
     @Override
     public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
 
+        _useExternalDnsServers = _configDepot.get(UseExternalDnsServers);
+
         _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("RouterMonitor"));
         _checkExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("RouterStatusMonitor"));
         _networkStatsUpdateExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("NetworkStatsUpdater"));
@@ -1426,7 +1451,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
             InsufficientCapacityException, ResourceUnavailableException {
 
         List<DomainRouterVO> routers = new ArrayList<DomainRouterVO>();
-        Network lock = _networkDao.acquireInLockTable(guestNetwork.getId(), _networkMgr.getNetworkLockTimeout());
+        Network lock = _networkDao.acquireInLockTable(guestNetwork.getId(), _networkLockTimeout.value());
         if (lock == null) {
             throw new ConcurrentOperationException("Unable to lock network " + guestNetwork.getId());
         }
@@ -1621,19 +1646,19 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
                 String templateName = null;
                 switch (hType) {
                     case XenServer:
-                        templateName = _configServer.getConfigValue(Config.RouterTemplateXen.key(), Config.ConfigurationParameterScope.zone.toString(), dest.getDataCenter().getId());
+                        templateName = _routerTemplateXen.valueIn(dest.getDataCenter().getId());
                         break;
                     case KVM:
-                        templateName = _configServer.getConfigValue(Config.RouterTemplateKVM.key(), Config.ConfigurationParameterScope.zone.toString(), dest.getDataCenter().getId());
+                        templateName = _routerTemplateKvm.valueIn(dest.getDataCenter().getId());
                         break;
                     case VMware:
-                        templateName = _configServer.getConfigValue(Config.RouterTemplateVmware.key(), Config.ConfigurationParameterScope.zone.toString(), dest.getDataCenter().getId());
+                        templateName = _routerTemplateVmware.valueIn(dest.getDataCenter().getId());
                         break;
                     case Hyperv:
-                        templateName = _configServer.getConfigValue(Config.RouterTemplateHyperv.key(), Config.ConfigurationParameterScope.zone.toString(), dest.getDataCenter().getId());
+                        templateName = _routerTemplateHyperV.valueIn(dest.getDataCenter().getId());
                         break;
                     case LXC:
-                        templateName = _configServer.getConfigValue(Config.RouterTemplateLXC.key(), Config.ConfigurationParameterScope.zone.toString(), dest.getDataCenter().getId());
+                        templateName = _routerTemplateLxc.valueIn(dest.getDataCenter().getId());
                         break;
                     default: break;
                 }
@@ -2151,10 +2176,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
 
             boolean useExtDns = !dnsProvided;
             /* For backward compatibility */
-            String use_external_dns = _configServer.getConfigValue(Config.UseExternalDnsServers.key(), Config.ConfigurationParameterScope.zone.toString(), dc.getId());
-            if (use_external_dns != null && use_external_dns.equals("true")) {
-                useExtDns = true;
-            }
+            useExtDns = _useExternalDnsServers.valueIn(dc.getId());
 
             if (useExtDns) {
                 buf.append(" useextdns=true");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
index abe0746..68e68d7 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -161,6 +161,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     VpcGatewayDao _vpcGatewayDao;
     @Inject
     NetworkACLItemDao _networkACLItemDao;
+    @Inject
+    EntityManager _entityMgr;
     
     @Override
     public List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner,
@@ -627,7 +629,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             
             //add vpc cidr/dns/networkdomain to the boot load args
             StringBuilder buf = profile.getBootArgsBuilder();
-            Vpc vpc = _vpcMgr.getVpc(vr.getVpcId());
+            Vpc vpc = _entityMgr.findById(Vpc.class, vr.getVpcId());
             buf.append(" vpccidr=" + vpc.getCidr() + " domain=" + vpc.getNetworkDomain());
             
             buf.append(" dns1=").append(defaultDns1);
@@ -829,7 +831,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         for (StaticRoute route : routes) {
             VpcGateway gateway = gatewayMap.get(route.getVpcGatewayId());
             if (gateway == null) {
-                gateway = _vpcMgr.getVpcGateway(route.getVpcGatewayId());
+                gateway = _entityMgr.findById(VpcGateway.class, route.getVpcGatewayId());
                 gatewayMap.put(gateway.getId(), gateway);
             }
             staticRouteProfiles.add(new StaticRouteProfile(route, gateway));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/rules/FirewallManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/FirewallManager.java b/server/src/com/cloud/network/rules/FirewallManager.java
deleted file mode 100644
index 6d36ed3..0000000
--- a/server/src/com/cloud/network/rules/FirewallManager.java
+++ /dev/null
@@ -1,89 +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.rules;
-
-import java.util.List;
-
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.dao.IPAddressVO;
-import com.cloud.network.firewall.FirewallService;
-import com.cloud.network.rules.FirewallRule.FirewallRuleType;
-import com.cloud.network.rules.FirewallRule.Purpose;
-import com.cloud.user.Account;
-
-public interface FirewallManager extends FirewallService {
-    /**
-     * detectRulesConflict finds conflicts in networking rules. It checks for
-     * conflicts between the following types of netowrking rules;
-     * 1. one to one nat ip forwarding
-     * 2. port forwarding
-     * 3. load balancing
-     * 
-     * and conflicts are detected between those two rules. In this case, it
-     * is possible for both rules to be rolled back when, technically, we should
-     * and the user can simply re-add one of the rules themselves.
-     * 
-     * @param newRule
-     *            the new rule created.
-     * @throws NetworkRuleConflictException
-     */
-    void detectRulesConflict(FirewallRule newRule) throws NetworkRuleConflictException;
-
-    void validateFirewallRule(Account caller, IPAddressVO ipAddress, Integer portStart, Integer portEnd, String proto,
-            Purpose purpose, FirewallRuleType type, Long networkid, FirewallRule.TrafficType trafficType);
-
-    boolean applyRules(List<? extends FirewallRule> rules, boolean continueOnError, boolean updateRulesInDB) throws ResourceUnavailableException;
-
-    boolean applyFirewallRules(List<FirewallRuleVO> rules, boolean continueOnError, Account caller);
-
-    public void revokeRule(FirewallRuleVO rule, Account caller, long userId, boolean needUsageEvent);
-
-    boolean revokeFirewallRulesForIp(long ipId, long userId, Account caller) throws ResourceUnavailableException;
-
-    /**
-     * Revokes a firewall rule
-     * 
-     * @param ruleId
-     *            the id of the rule to revoke.
-     * @param caller
-     *            TODO
-     * @param userId
-     *            TODO
-     * @return
-     */
-    boolean revokeFirewallRule(long ruleId, boolean apply, Account caller, long userId);
-
-    FirewallRule createFirewallRule(Long ipAddrId, Account caller, String xId, Integer portStart, Integer portEnd, String protocol, List<String> sourceCidrList, Integer icmpCode, Integer icmpType, Long relatedRuleId,
-            FirewallRule.FirewallRuleType type, Long networkId, FirewallRule.TrafficType traffictype)
-            throws NetworkRuleConflictException;
-
-    FirewallRule createRuleForAllCidrs(long ipAddrId, Account caller, Integer startPort, Integer endPort, String protocol, Integer icmpCode, Integer icmpType, Long relatedRuleId, long networkId) throws NetworkRuleConflictException;
-
-    boolean revokeAllFirewallRulesForNetwork(long networkId, long userId, Account caller) throws ResourceUnavailableException;
-
-    boolean revokeFirewallRulesForVm(long vmId);
-
-    boolean addSystemFirewallRules(IPAddressVO ip, Account acct);
-
-    /**
-     * @param rule
-     */
-    void removeRule(FirewallRule rule);
-
-    boolean applyDefaultEgressFirewallRule(Long networkId, boolean defaultPolicy) throws ResourceUnavailableException;
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/rules/RulesManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/RulesManager.java b/server/src/com/cloud/network/rules/RulesManager.java
deleted file mode 100644
index 201d79d..0000000
--- a/server/src/com/cloud/network/rules/RulesManager.java
+++ /dev/null
@@ -1,66 +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.rules;
-
-import java.util.List;
-
-import com.cloud.exception.InsufficientAddressCapacityException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.IpAddress;
-import com.cloud.user.Account;
-import com.cloud.uservm.UserVm;
-import com.cloud.vm.Nic;
-import com.cloud.vm.VirtualMachine;
-
-/**
- * Rules Manager manages the network rules created for different networks.
- */
-public interface RulesManager extends RulesService {
-
-    boolean applyPortForwardingRulesForNetwork(long networkId, boolean continueOnError, Account caller);
-
-    boolean applyStaticNatRulesForNetwork(long networkId, boolean continueOnError, Account caller);
-
-    void checkRuleAndUserVm(FirewallRule rule, UserVm userVm, Account caller);
-
-    boolean revokeAllPFAndStaticNatRulesForIp(long ipId, long userId, Account caller) throws ResourceUnavailableException;
-
-    boolean revokeAllPFStaticNatRulesForNetwork(long networkId, long userId, Account caller) throws ResourceUnavailableException;
-
-    boolean revokePortForwardingRulesForVm(long vmId);
-
-    FirewallRule[] reservePorts(IpAddress ip, String protocol, FirewallRule.Purpose purpose, boolean openFirewall, Account caller, int... ports) throws NetworkRuleConflictException;
-
-    boolean applyStaticNatsForNetwork(long networkId, boolean continueOnError, Account caller);
-
-    void getSystemIpAndEnableStaticNatForVm(VirtualMachine vm, boolean getNewIp) throws InsufficientAddressCapacityException;
-
-    boolean disableStaticNat(long ipAddressId, Account caller, long callerUserId, boolean releaseIpIfElastic) throws ResourceUnavailableException;
-
-    /**
-     * @param networkId
-     * @param continueOnError
-     * @param caller
-     * @param forRevoke
-     * @return
-     */
-    boolean applyStaticNatForNetwork(long networkId, boolean continueOnError, Account caller, boolean forRevoke);
-
-    List<FirewallRuleVO> listAssociatedRulesForGuestNic(Nic nic);
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/rules/RulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/RulesManagerImpl.java b/server/src/com/cloud/network/rules/RulesManagerImpl.java
index 4620ed8..965bd62 100755
--- a/server/src/com/cloud/network/rules/RulesManagerImpl.java
+++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java
@@ -57,6 +57,7 @@ import com.cloud.network.rules.FirewallRule.FirewallRuleType;
 import com.cloud.network.rules.FirewallRule.Purpose;
 import com.cloud.network.rules.dao.PortForwardingRulesDao;
 import com.cloud.network.vpc.VpcManager;
+import com.cloud.network.vpc.VpcService;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.projects.Project.ListProjectResourcesCriteria;
 import com.cloud.server.ResourceTag.TaggedResourceType;
@@ -140,6 +141,8 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
     NicSecondaryIpDao _nicSecondaryDao;
     @Inject
     LoadBalancerVMMapDao _loadBalancerVMMapDao;
+    @Inject
+    VpcService _vpcService;
 
     
     protected void checkIpAndUserVm(IpAddress ipAddress, UserVm userVm, Account caller, Boolean ignoreVmState) {
@@ -506,7 +509,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
 
                             // associate portable IP to vpc, if network is part of VPC
                             if (network.getVpcId() != null) {
-                                _vpcMgr.associateIPToVpc(ipId, network.getVpcId());
+                                _vpcService.associateIPToVpc(ipId, network.getVpcId());
                             }
 
                             // associate portable IP with guest network

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/rules/StaticNatRuleImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/StaticNatRuleImpl.java b/server/src/com/cloud/network/rules/StaticNatRuleImpl.java
deleted file mode 100644
index 6103689..0000000
--- a/server/src/com/cloud/network/rules/StaticNatRuleImpl.java
+++ /dev/null
@@ -1,147 +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.rules;
-
-import java.util.List;
-
-
-public class StaticNatRuleImpl implements StaticNatRule {
-    long id;
-    String xid;
-    String uuid;
-    String protocol;
-    int portStart;
-    int portEnd;
-    State state;
-    long accountId;
-    long domainId;
-    long networkId;
-    long sourceIpAddressId;
-    String destIpAddress;
-
-    public StaticNatRuleImpl(FirewallRuleVO rule, String dstIp) {
-        this.id = rule.getId();
-        this.xid = rule.getXid();
-        this.uuid = rule.getUuid();
-        this.protocol = rule.getProtocol();
-        this.portStart = rule.getSourcePortStart();
-        this.portEnd = rule.getSourcePortEnd();
-        this.state = rule.getState();
-        this.accountId = rule.getAccountId();
-        this.domainId = rule.getDomainId();
-        this.networkId = rule.getNetworkId();
-        this.sourceIpAddressId = rule.getSourceIpAddressId();
-        this.destIpAddress = dstIp;
-    }
-
-    @Override
-    public String getProtocol() {
-        return protocol;
-    }
-
-    @Override
-    public Integer getSourcePortEnd() {
-        return portEnd;
-    }
-
-    @Override
-    public Purpose getPurpose() {
-        return Purpose.StaticNat;
-    }
-
-    @Override
-    public State getState() {
-        return state;
-    }
-
-    @Override
-    public long getAccountId() {
-        return accountId;
-    }
-
-    @Override
-    public long getDomainId() {
-        return domainId;
-    }
-
-    @Override
-    public long getNetworkId() {
-        return networkId;
-    }
-
-    @Override
-    public long getId() {
-        return id;
-    }
-
-    @Override
-    public Integer getSourcePortStart() {
-        return portStart;
-    }
-
-    @Override
-    public Long getSourceIpAddressId() {
-        return sourceIpAddressId;
-    }
-
-    @Override
-    public String getDestIpAddress() {
-        return destIpAddress;
-    }
-
-    @Override
-    public String getXid() {
-        return xid;
-    }
-
-
-    @Override
-    public String getUuid() {
-        return uuid;
-    }
-
-    @Override
-    public Integer getIcmpCode() {
-        return null;
-    }
-
-    @Override
-    public Integer getIcmpType() {
-        return null;
-    }
-
-    @Override
-    public List<String> getSourceCidrList() {
-        return null;
-    }
-
-    @Override
-    public Long getRelated() {
-        return null;
-    }
-
-	@Override
-	public FirewallRuleType getType() {
-		return FirewallRuleType.User;
-	}
-
-    @Override
-    public TrafficType getTrafficType() {
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/vpc/NetworkACLItemDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLItemDao.java b/server/src/com/cloud/network/vpc/NetworkACLItemDao.java
deleted file mode 100644
index e4b1871..0000000
--- a/server/src/com/cloud/network/vpc/NetworkACLItemDao.java
+++ /dev/null
@@ -1,37 +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 com.cloud.utils.db.GenericDao;
-
-import java.util.List;
-
-/*
- * Data Access Object for network_acl_item table
- */
-public interface NetworkACLItemDao extends GenericDao<NetworkACLItemVO, Long> {
-
-    boolean setStateToAdd(NetworkACLItemVO rule);
-
-    boolean revoke(NetworkACLItemVO rule);
-
-    List<NetworkACLItemVO> listByACL(long aclId);
-
-    int getMaxNumberByACL(long aclId);
-
-    NetworkACLItemVO findByAclAndNumber(long aclId, int number);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/vpc/NetworkACLItemVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLItemVO.java b/server/src/com/cloud/network/vpc/NetworkACLItemVO.java
deleted file mode 100644
index 46f84c9..0000000
--- a/server/src/com/cloud/network/vpc/NetworkACLItemVO.java
+++ /dev/null
@@ -1,237 +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 com.cloud.network.rules.FirewallRule;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.net.NetUtils;
-
-import javax.persistence.*;
-import java.util.*;
-
-@Entity
-@Table(name="network_acl_item")
-public class NetworkACLItemVO implements NetworkACLItem {
-
-    @Id
-    @GeneratedValue(strategy=GenerationType.IDENTITY)
-    @Column(name="id")
-    long id;
-
-    @Column(name="start_port", updatable=false)
-    Integer sourcePortStart;
-
-    @Column(name="end_port", updatable=false)
-    Integer sourcePortEnd;
-
-    @Column(name="protocol", updatable=false)
-    String protocol = NetUtils.TCP_PROTO;
-
-    @Enumerated(value=EnumType.STRING)
-    @Column(name="state")
-    State state;
-
-    @Column(name=GenericDao.CREATED_COLUMN)
-    Date created;
-
-    @Column(name="acl_id")
-    long aclId;
-
-    @Column(name="icmp_code")
-    Integer icmpCode;
-
-    @Column(name="icmp_type")
-    Integer icmpType;
-
-    @Column(name="traffic_type")
-    @Enumerated(value=EnumType.STRING)
-    TrafficType trafficType;
-
-    @Column(name="cidr")
-    String sourceCidrs;
-
-    @Column(name="uuid")
-    String uuid;
-
-    @Column(name="number")
-    int number;
-
-    @Column(name="action")
-    @Enumerated(value=EnumType.STRING)
-    Action action;
-
-    public NetworkACLItemVO() {
-        this.uuid = UUID.randomUUID().toString();
-    }
-
-    public NetworkACLItemVO(Integer portStart, Integer portEnd, String protocol,
-                            long aclId, List<String> sourceCidrs, Integer icmpCode,
-                            Integer icmpType, TrafficType trafficType, Action action, int number) {
-        this.sourcePortStart = portStart;
-        this.sourcePortEnd = portEnd;
-        this.protocol = protocol;
-        this.aclId = aclId;
-        this.state = State.Staged;
-        this.icmpCode = icmpCode;
-        this.icmpType = icmpType;
-        setSourceCidrList(sourceCidrs);
-        this.uuid = UUID.randomUUID().toString();
-        this.trafficType = trafficType;
-        this.action = action;
-        this.number = number;
-    }
-
-    public void setSourceCidrList(List<String> sourceCidrs) {
-        if(sourceCidrs == null){
-            this.sourceCidrs = null;
-        } else {
-            StringBuilder sb = new StringBuilder();
-            for(String cidr : sourceCidrs){
-                if(sb.length() != 0){
-                    sb.append(",");
-                }
-                sb.append(cidr);
-            }
-            this.sourceCidrs=sb.toString();
-        }
-    }
-
-    @Override
-    public List<String> getSourceCidrList() {
-        if(sourceCidrs == null || sourceCidrs.isEmpty()){
-            return null;
-        } else {
-            List<String> cidrList = new ArrayList<String>();
-            String[] cidrs = sourceCidrs.split(",");
-            for(String cidr : cidrs){
-                cidrList.add(cidr);
-            }
-            return cidrList;
-        }
-    }
-
-    @Override
-    public long getId() {
-        return id;
-    }
-
-    @Override
-    public Integer getSourcePortStart() {
-        return sourcePortStart;
-    }
-
-    @Override
-    public Integer getSourcePortEnd() {
-        return sourcePortEnd;
-    }
-
-    @Override
-    public String getProtocol() {
-        return protocol;
-    }
-
-    public void setState(State state) {
-        this.state = state;
-    }
-
-    @Override
-    public State getState() {
-        return state;
-    }
-
-    @Override
-    public long getAclId() {
-        return aclId;
-    }
-
-    public Date getCreated() {
-        return created;
-    }
-
-
-
-    @Override
-    public String toString() {
-        return new StringBuilder("Rule[").append(id).append("-").append("NetworkACL").append("-").append(state).append("]").toString();
-    }
-
-    @Override
-    public Integer getIcmpCode() {
-        return icmpCode;
-    }
-
-    @Override
-    public Integer getIcmpType() {
-        return icmpType;
-    }
-
-    @Override
-    public String getUuid() {
-        return this.uuid;
-    }
-
-    @Override
-    public Action getAction() {
-        return action;
-    }
-
-    @Override
-    public int getNumber() {
-        return number;
-    }
-
-    @Override
-    public TrafficType getTrafficType() {
-        return trafficType;
-    }
-
-    public void setSourcePortStart(Integer sourcePortStart) {
-        this.sourcePortStart = sourcePortStart;
-    }
-
-    public void setSourcePortEnd(Integer sourcePortEnd) {
-        this.sourcePortEnd = sourcePortEnd;
-    }
-
-    public void setProtocol(String protocol) {
-        this.protocol = protocol;
-    }
-
-    public void setIcmpCode(Integer icmpCode) {
-        this.icmpCode = icmpCode;
-    }
-
-    public void setIcmpType(Integer icmpType) {
-        this.icmpType = icmpType;
-    }
-
-    public void setTrafficType(TrafficType trafficType) {
-        this.trafficType = trafficType;
-    }
-
-    public void setSourceCidrs(String sourceCidrs) {
-        this.sourceCidrs = sourceCidrs;
-    }
-
-    public void setNumber(int number) {
-        this.number = number;
-    }
-
-    public void setAction(Action action) {
-        this.action = action;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435e74e9/server/src/com/cloud/network/vpc/NetworkACLManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLManager.java b/server/src/com/cloud/network/vpc/NetworkACLManager.java
deleted file mode 100644
index 463e43b..0000000
--- a/server/src/com/cloud/network/vpc/NetworkACLManager.java
+++ /dev/null
@@ -1,155 +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 com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.dao.NetworkVO;
-import com.cloud.user.Account;
-
-import java.util.List;
-
-
-public interface NetworkACLManager{
-
-    /**
-     * Creates Network ACL for the specified VPC
-     * @param name
-     * @param description
-     * @param vpcId
-     * @return
-     */
-    NetworkACL createNetworkACL(String name, String description, long vpcId);
-
-    /**
-     * Fetches Network ACL with specified Id
-     * @param id
-     * @return
-     */
-    NetworkACL getNetworkACL(long id);
-
-    /**
-     * Applies the items in the ACL to all associated networks
-     * @param aclId
-     * @return
-     * @throws ResourceUnavailableException
-     */
-    boolean applyNetworkACL(long aclId) throws ResourceUnavailableException;
-
-    /**
-     * Deletes the specified Network ACL
-     * @param id
-     * @return
-     */
-    boolean deleteNetworkACL(NetworkACL acl);
-
-    /**
-     * Associates acl with a network and applies the ACLItems
-     * @param acl
-     * @param network
-     * @return
-     */
-    boolean replaceNetworkACL(NetworkACL acl, NetworkVO network) throws ResourceUnavailableException;
-
-    /**
-     * Creates a Network ACL Item within an ACL and applies it to associated networks
-     * @param sourcePortStart
-     * @param sourcePortEnd
-     * @param protocol
-     * @param sourceCidrList
-     * @param icmpCode
-     * @param icmpType
-     * @param trafficType
-     * @param aclId
-     * @param action
-     * @param number
-     * @return
-     */
-    NetworkACLItem createNetworkACLItem(Integer sourcePortStart, Integer sourcePortEnd, String protocol,
-                                        List<String> sourceCidrList, Integer icmpCode, Integer icmpType,
-                                        NetworkACLItem.TrafficType trafficType, Long aclId, String action, Integer number);
-
-    /**
-     * Returns Network ACL Item with specified Id
-     * @param ruleId
-     * @return
-     */
-    NetworkACLItem getNetworkACLItem(long ruleId);
-
-    /**
-     * Revoke ACL Item and apply changes
-     * @param ruleId
-     * @return
-     */
-    boolean revokeNetworkACLItem(long ruleId);
-
-    /**
-     * Revoke ACL Items for network and remove them in back-end. Db is not updated
-     * @param networkId
-     * @param userId
-     * @param caller
-     * @return
-     * @throws ResourceUnavailableException
-     */
-    boolean revokeACLItemsForNetwork(long networkId) throws ResourceUnavailableException;
-
-    /**
-     * List network ACL items by network
-     * @param guestNtwkId
-     * @return
-     */
-    List<NetworkACLItemVO> listNetworkACLItems(long guestNtwkId);
-
-    /**
-     * Applies asscociated ACL to specified network
-     * @param networkId
-     * @return
-     * @throws ResourceUnavailableException
-     */
-    boolean applyACLToNetwork(long networkId) throws ResourceUnavailableException;
-
-    /**
-     * Updates and existing network ACL Item
-     * @param id
-     * @param protocol
-     * @param sourceCidrList
-     * @param trafficType
-     * @param action
-     * @param number
-     * @param sourcePortStart
-     * @param sourcePortEnd
-     * @param icmpCode
-     * @param icmpType
-     * @return
-     * @throws ResourceUnavailableException
-     */
-    NetworkACLItem updateNetworkACLItem(Long id, String protocol, List<String> sourceCidrList, NetworkACLItem.TrafficType trafficType,
-                                        String action, Integer number, Integer sourcePortStart, Integer sourcePortEnd,
-                                        Integer icmpCode, Integer icmpType) throws ResourceUnavailableException;
-
-    /**
-     * Associates acl with a network and applies the ACLItems
-     * @param acl
-     * @param gateway
-     * @return
-     */
-
-    boolean replaceNetworkACLForPrivateGw(NetworkACL acl, PrivateGateway gateway) throws ResourceUnavailableException;
-
-    boolean revokeACLItemsForPrivateGw(PrivateGateway gateway) throws ResourceUnavailableException;
-
-    boolean applyACLToPrivateGw(PrivateGateway gateway) throws ResourceUnavailableException;
-}


Mime
View raw message