cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [4/4] git commit: updated refs/heads/master to abbae2a
Date Tue, 27 Aug 2013 00:29:55 GMT
Fixed the problem with offerings and templates.  These two items due to a previous patch all the way back in 2.1.x versions uses the removed column incorrectly.  No one fixed since then.  Hence, there's a bunch of findbyidincludingremoved calls in the cloudstack code around these two items.


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

Branch: refs/heads/master
Commit: abbae2aa87471274cffa35b54ae8157c1efaade9
Parents: 2d05fe4
Author: Alex Huang <alex.huang@citrix.com>
Authored: Mon Aug 26 17:30:58 2013 -0700
Committer: Alex Huang <alex.huang@citrix.com>
Committed: Mon Aug 26 17:31:10 2013 -0700

----------------------------------------------------------------------
 .../configuration/ConfigurationService.java     |  16 --
 api/src/com/cloud/offering/DiskOffering.java    |   6 +
 .../cloud/template/VirtualMachineTemplate.java  |   6 +
 .../admin/systemvm/ScaleSystemVMCmd.java        |  22 ++-
 .../admin/systemvm/UpgradeSystemVMCmd.java      |   8 +-
 .../user/address/AssociateIPAddrCmd.java        |  12 +-
 .../command/user/network/CreateNetworkCmd.java  |  17 +-
 .../api/command/user/vm/DeployVMCmd.java        |  16 +-
 .../api/command/user/vm/UpgradeVMCmd.java       |   8 +-
 .../com/cloud/vm/VirtualMachineManagerImpl.java |   4 +-
 .../cloud/vm/VirtualMachineManagerImplTest.java |   8 +-
 .../src/com/cloud/storage/DiskOfferingVO.java   |  57 ++++--
 .../src/com/cloud/storage/VMTemplateVO.java     |  82 +++++----
 .../storage/image/store/TemplateObject.java     | 121 ++++++------
 .../storage/image/TemplateEntityImpl.java       |  11 +-
 .../db/src/com/cloud/utils/db/GenericDao.java   |   4 +-
 .../db/src/com/cloud/utils/db/SqlGenerator.java |  11 +-
 server/src/com/cloud/api/ApiDBUtils.java        |  19 +-
 server/src/com/cloud/api/ApiResponseHelper.java |   5 +-
 .../configuration/ConfigurationManager.java     |  12 +-
 .../configuration/ConfigurationManagerImpl.java |  43 +----
 .../com/cloud/network/IpAddressManagerImpl.java |   2 +-
 .../com/cloud/network/NetworkManagerImpl.java   |   6 +-
 .../src/com/cloud/network/NetworkModelImpl.java |  45 ++---
 .../com/cloud/network/NetworkServiceImpl.java   |  10 +-
 .../cloud/network/as/AutoScaleManagerImpl.java  |   2 +-
 .../cloud/network/guru/PrivateNetworkGuru.java  |   2 +-
 .../lb/LoadBalancingRulesManagerImpl.java       |   4 +-
 .../VirtualNetworkApplianceManagerImpl.java     |   7 +-
 .../cloud/network/rules/RulesManagerImpl.java   |  14 +-
 .../network/vpc/NetworkACLManagerImpl.java      |  29 +--
 .../com/cloud/network/vpc/VpcManagerImpl.java   |   4 +-
 .../com/cloud/template/TemplateManagerImpl.java |  19 +-
 server/src/com/cloud/vm/UserVmManagerImpl.java  |  14 +-
 server/test/com/cloud/vm/UserVmManagerTest.java |  17 +-
 .../cloud/vpc/MockConfigurationManagerImpl.java |  26 ---
 .../com/cloud/vpc/NetworkACLManagerTest.java    |   8 +
 setup/db/db/schema-420to430.sql                 | 183 +++++++++++++++++++
 38 files changed, 557 insertions(+), 323 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/api/src/com/cloud/configuration/ConfigurationService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/configuration/ConfigurationService.java b/api/src/com/cloud/configuration/ConfigurationService.java
index 938b061..9e5fa82 100644
--- a/api/src/com/cloud/configuration/ConfigurationService.java
+++ b/api/src/com/cloud/configuration/ConfigurationService.java
@@ -255,34 +255,18 @@ public interface ConfigurationService {
 
     boolean deleteNetworkOffering(DeleteNetworkOfferingCmd cmd);
 
-    NetworkOffering getNetworkOffering(long id);
-
-    Integer getNetworkOfferingNetworkRate(long networkOfferingId, Long dataCenterId);
-
     Account getVlanAccount(long vlanId);
 
     List<? extends NetworkOffering> listNetworkOfferings(TrafficType trafficType, boolean systemOnly);
 
-    ServiceOffering getServiceOffering(long serviceOfferingId);
-
     Long getDefaultPageSize();
 
-    Integer getServiceOfferingNetworkRate(long serviceOfferingId, Long dataCenterId);
-
-    DiskOffering getDiskOffering(long diskOfferingId);
-
     boolean updateLDAP(LDAPConfigCmd cmd) throws NamingException;
 
 	boolean removeLDAP(LDAPRemoveCmd cmd);
 
     LDAPConfigCmd listLDAPConfig(LDAPConfigCmd cmd);
 
-    /**
-     * @param offering
-     * @return
-     */
-    boolean isOfferingForVpc(NetworkOffering offering);
-
     PortableIpRange createPortableIpRange(CreatePortableIpRangeCmd cmd) throws ConcurrentOperationException;
 
     boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/api/src/com/cloud/offering/DiskOffering.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/offering/DiskOffering.java b/api/src/com/cloud/offering/DiskOffering.java
index c7bf5c1..a4c7dc3 100644
--- a/api/src/com/cloud/offering/DiskOffering.java
+++ b/api/src/com/cloud/offering/DiskOffering.java
@@ -28,6 +28,12 @@ import org.apache.cloudstack.api.InternalIdentity;
  *
  */
 public interface DiskOffering extends InfrastructureEntity, Identity, InternalIdentity {
+    enum State {
+        Inactive,
+        Active,
+    }
+
+    State getState();
 
     String getUniqueName();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/api/src/com/cloud/template/VirtualMachineTemplate.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/template/VirtualMachineTemplate.java b/api/src/com/cloud/template/VirtualMachineTemplate.java
index 114785a..d13146c 100755
--- a/api/src/com/cloud/template/VirtualMachineTemplate.java
+++ b/api/src/com/cloud/template/VirtualMachineTemplate.java
@@ -28,6 +28,10 @@ import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.storage.Storage.TemplateType;
 
 public interface VirtualMachineTemplate extends ControlledEntity, Identity, InternalIdentity {
+    enum State {
+        Active,
+        Inactive;
+    }
 
     public static enum BootloaderType {
         PyGrub, HVM, External, CD
@@ -44,6 +48,8 @@ public interface VirtualMachineTemplate extends ControlledEntity, Identity, Inte
         all // all templates (only usable by admins)
     }
 
+    State getState();
+
     boolean isFeatured();
 
     /**

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java
index 94040df..212f129 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java
@@ -16,17 +16,25 @@
 // under the License.
 package org.apache.cloudstack.api.command.admin.systemvm;
 
-import com.cloud.event.EventTypes;
-import com.cloud.exception.*;
+import org.apache.log4j.Logger;
 
-import org.apache.cloudstack.api.*;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
 import org.apache.cloudstack.api.response.ServiceOfferingResponse;
 import org.apache.cloudstack.api.response.SystemVmResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ManagementServerException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.exception.VirtualMachineMigrationException;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.user.Account;
 import com.cloud.vm.VirtualMachine;
@@ -85,7 +93,7 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd {
     public void execute(){
         CallContext.current().setEventDetails("SystemVm Id: "+getId());
 
-        ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
+        ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
         if (serviceOffering == null) {
             throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
         }
@@ -109,7 +117,7 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd {
         if (result != null) {
             SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade system vm");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java
index efb1a2f..738b15d 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java
@@ -16,6 +16,8 @@
 // under the License.
 package org.apache.cloudstack.api.command.admin.systemvm;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -27,8 +29,6 @@ import org.apache.cloudstack.api.response.ServiceOfferingResponse;
 import org.apache.cloudstack.api.response.SystemVmResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.user.Account;
@@ -88,7 +88,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
     public void execute(){
         CallContext.current().setEventDetails("Vm Id: "+getId());
 
-        ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
+        ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
         if (serviceOffering == null) {
             throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
         }
@@ -97,7 +97,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
         if (result != null) {
             SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to reboot system vm");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
index fa1570e..91d0974 100644
--- a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
@@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.address;
 
 import java.util.List;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
@@ -36,8 +38,6 @@ import org.apache.cloudstack.api.response.VpcResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.event.EventTypes;
@@ -216,7 +216,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
                 throw new InvalidParameterValueException("Unable to find network by network id specified");
             }
 
-            NetworkOffering offering = _configService.getNetworkOffering(network.getNetworkOfferingId());
+            NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
 
             DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
             if (zone.getNetworkType() == NetworkType.Basic && offering.getElasticIp() && offering.getElasticLb()) {
@@ -278,8 +278,8 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
             }
 
             if (ip != null) {
-                this.setEntityId(ip.getId());
-                this.setEntityUuid(ip.getUuid());
+                setEntityId(ip.getId());
+                setEntityUuid(ip.getUuid());
             } else {
                 throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to allocate ip address");
             }
@@ -309,7 +309,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
         if (result != null) {
             IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(result);
             ipResponse.setResponseName(getCommandName());
-            this.setResponseObject(ipResponse);
+            setResponseObject(ipResponse);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign ip address");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
index c926d81..5ce0000 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
@@ -16,17 +16,24 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.network;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.response.*;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.NetworkACLResponse;
+import org.apache.cloudstack.api.response.NetworkOfferingResponse;
+import org.apache.cloudstack.api.response.NetworkResponse;
+import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
+import org.apache.cloudstack.api.response.ProjectResponse;
+import org.apache.cloudstack.api.response.VpcResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.InvalidParameterValueException;
@@ -212,7 +219,7 @@ public class CreateNetworkCmd extends BaseCmd {
     }
 
     public Long getPhysicalNetworkId() {
-        NetworkOffering offering = _configService.getNetworkOffering(networkOfferingId);
+        NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, networkOfferingId);
         if (offering == null) {
             throw new InvalidParameterValueException("Unable to find network offering by id " + networkOfferingId);
         }
@@ -288,7 +295,7 @@ public class CreateNetworkCmd extends BaseCmd {
         if (result != null) {
             NetworkResponse response = _responseGenerator.createNetworkResponse(result);
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         }else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
index 75c1c79..3866eba 100755
--- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
@@ -24,6 +24,8 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
 import org.apache.cloudstack.affinity.AffinityGroupResponse;
 import org.apache.cloudstack.api.ACL;
@@ -46,8 +48,6 @@ import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.event.EventTypes;
@@ -443,7 +443,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
         if (result != null) {
             UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to deploy vm");
         }
@@ -460,7 +460,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
                 throw new InvalidParameterValueException("Unable to find zone by id=" + zoneId);
             }
 
-            ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
+            ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
             if (serviceOffering == null) {
                 throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
             }
@@ -473,7 +473,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
 
             DiskOffering diskOffering = null;
             if (diskOfferingId != null) {
-                diskOffering = _configService.getDiskOffering(diskOfferingId);
+                diskOffering = _entityMgr.findById(DiskOffering.class, diskOfferingId);
                 if (diskOffering == null) {
                     throw new InvalidParameterValueException("Unable to find disk offering " + diskOfferingId);
                 }
@@ -495,19 +495,19 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
                     throw new InvalidParameterValueException("Can't specify network Ids in Basic zone");
                 } else {
                     vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name,
-                            displayName, diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
+                            displayName, diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
                 }
             } else {
                 if (zone.isSecurityGroupEnabled())  {
                     vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(),
-                            owner, name, displayName, diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
+                            owner, name, displayName, diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
 
                 } else {
                     if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
                         throw new InvalidParameterValueException("Can't create vm with security groups; security group feature is not enabled per zone");
                     }
                     vm = _userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName,
-                            diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
+                            diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
 
                 }
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
index 671a61b..161131b 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
@@ -16,6 +16,8 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vm;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -26,8 +28,6 @@ import org.apache.cloudstack.api.response.ServiceOfferingResponse;
 import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.offering.ServiceOffering;
@@ -92,7 +92,7 @@ public class UpgradeVMCmd extends BaseCmd {
     public void execute() throws ResourceAllocationException{
         CallContext.current().setEventDetails("Vm Id: "+getId());
 
-        ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
+        ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
         if (serviceOffering == null) {
             throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
         }
@@ -101,7 +101,7 @@ public class UpgradeVMCmd extends BaseCmd {
         if (result != null){
             UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade vm");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 28df9a6..8e0a71c 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -2754,7 +2754,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
     public boolean upgradeVmDb(long vmId, long serviceOfferingId) {
         VMInstanceVO vmForUpdate = _vmDao.createForUpdate();
         vmForUpdate.setServiceOfferingId(serviceOfferingId);
-        ServiceOffering newSvcOff = _configMgr.getServiceOffering(serviceOfferingId);
+        ServiceOffering newSvcOff = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
         vmForUpdate.setHaEnabled(newSvcOff.getOfferHA());
         vmForUpdate.setLimitCpuUse(newSvcOff.getLimitCpuUse());
         vmForUpdate.setServiceOfferingId(newSvcOff.getId());
@@ -3267,7 +3267,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
 
         long newServiceofferingId = vm.getServiceOfferingId();
-        ServiceOffering newServiceOffering = _configMgr.getServiceOffering(newServiceofferingId);
+        ServiceOffering newServiceOffering = _entityMgr.findById(ServiceOffering.class, newServiceofferingId);
         HostVO hostVo = _hostDao.findById(vm.getHostId());
 
         Float memoryOvercommitRatio = Float.parseFloat(_configServer.getConfigValue(Config.MemOverprovisioningFactor.key(), Config.ConfigurationParameterScope.cluster.toString(),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/engine/orchestration/test/com/cloud/vm/VirtualMachineManagerImplTest.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/test/com/cloud/vm/VirtualMachineManagerImplTest.java b/engine/orchestration/test/com/cloud/vm/VirtualMachineManagerImplTest.java
index 5f68074..8fc1235 100644
--- a/engine/orchestration/test/com/cloud/vm/VirtualMachineManagerImplTest.java
+++ b/engine/orchestration/test/com/cloud/vm/VirtualMachineManagerImplTest.java
@@ -33,6 +33,7 @@ import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
+import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 import org.mockito.Spy;
 
@@ -77,6 +78,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.hypervisor.HypervisorGuru;
 import com.cloud.hypervisor.HypervisorGuruManager;
 import com.cloud.network.NetworkManager;
+import com.cloud.offering.ServiceOffering;
 import com.cloud.server.ConfigurationServer;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.storage.DiskOfferingVO;
@@ -96,6 +98,7 @@ import com.cloud.user.UserVO;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.UserDao;
 import com.cloud.utils.Pair;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.VirtualMachine.Event;
 import com.cloud.vm.VirtualMachine.State;
@@ -199,6 +202,8 @@ public class VirtualMachineManagerImplTest {
     HostVO _destHostMock;
     @Mock
     Map<Volume, StoragePool> _volumeToPoolMock;
+    @Mock
+    EntityManager _entityMgr;
 
     @Before
     public void setup() {
@@ -227,6 +232,7 @@ public class VirtualMachineManagerImplTest {
         _vmMgr._vmDao = _vmInstanceDao;
         _vmMgr._configServer = _configServer;
         _vmMgr._uservmDetailsDao = _vmDetailsDao;
+        _vmMgr._entityMgr = _entityMgr;
 
         when(_vmMock.getId()).thenReturn(314l);
         when(_vmInstance.getId()).thenReturn(1L);
@@ -236,7 +242,7 @@ public class VirtualMachineManagerImplTest {
         when(_vmInstance.getType()).thenReturn(VirtualMachine.Type.User);
         when(_host.getId()).thenReturn(1L);
         when(_hostDao.findById(anyLong())).thenReturn(null);
-        when(_configMgr.getServiceOffering(anyLong())).thenReturn(getSvcoffering(512));
+        when(_entityMgr.findById(Mockito.eq(ServiceOffering.class), anyLong())).thenReturn(getSvcoffering(512));
         when(_workDao.persist(_work)).thenReturn(_work);
         when(_workDao.update("1", _work)).thenReturn(true);
         when(_work.getId()).thenReturn("1");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/DiskOfferingVO.java b/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
index 975619f..04064b6 100755
--- a/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
+++ b/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
@@ -24,6 +24,8 @@ import javax.persistence.Column;
 import javax.persistence.DiscriminatorColumn;
 import javax.persistence.DiscriminatorType;
 import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
@@ -72,7 +74,7 @@ public class DiskOfferingVO implements DiskOffering {
     @Column(name = "type")
     Type type;
 
-    @Column(name = GenericDao.REMOVED)
+    @Column(name = GenericDao.REMOVED_COLUMN)
     @Temporal(TemporalType.TIMESTAMP)
     private Date removed;
 
@@ -121,8 +123,12 @@ public class DiskOfferingVO implements DiskOffering {
     @Column(name="display_offering")
     boolean displayOffering = true;
 
+    @Enumerated(EnumType.STRING)
+    @Column(name = "state")
+    State state;
+
     public DiskOfferingVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public DiskOfferingVO(Long domainId, String name, String displayText, long diskSize, String tags, boolean isCustomized,
@@ -132,20 +138,21 @@ public class DiskOfferingVO implements DiskOffering {
         this.displayText = displayText;
         this.diskSize = diskSize;
         this.tags = tags;
-        this.recreatable = false;
-        this.type = Type.Disk;
-        this.useLocalStorage = false;
-        this.customized = isCustomized;
-        this.uuid = UUID.randomUUID().toString();
-        this.customizedIops = isCustomizedIops;
+        recreatable = false;
+        type = Type.Disk;
+        useLocalStorage = false;
+        customized = isCustomized;
+        uuid = UUID.randomUUID().toString();
+        customizedIops = isCustomizedIops;
         this.minIops = minIops;
         this.maxIops = maxIops;
+        state = State.Active;
     }
 
     public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable,
             boolean useLocalStorage, boolean systemUse, boolean customized) {
-        this.domainId = null;
-        this.type = Type.Service;
+        domainId = null;
+        type = Type.Service;
         this.name = name;
         this.displayText = displayText;
         this.tags = tags;
@@ -153,14 +160,15 @@ public class DiskOfferingVO implements DiskOffering {
         this.useLocalStorage = useLocalStorage;
         this.systemUse = systemUse;
         this.customized = customized;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
+        state = State.Active;
     }
 
     // domain specific offerings constructor (null domainId implies public
     // offering)
     public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable,
             boolean useLocalStorage, boolean systemUse, boolean customized, Long domainId) {
-        this.type = Type.Service;
+        type = Type.Service;
         this.name = name;
         this.displayText = displayText;
         this.tags = tags;
@@ -169,7 +177,17 @@ public class DiskOfferingVO implements DiskOffering {
         this.systemUse = systemUse;
         this.customized = customized;
         this.domainId = domainId;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
+        state = State.Active;
+    }
+
+    @Override
+    public State getState() {
+        return state;
+    }
+
+    public void setState(State state) {
+        this.state = state;
     }
 
     @Override
@@ -235,6 +253,7 @@ public class DiskOfferingVO implements DiskOffering {
         return type;
     }
 
+    @Override
     public boolean isRecreatable() {
         return recreatable;
     }
@@ -299,7 +318,7 @@ public class DiskOfferingVO implements DiskOffering {
     }
 
     public void setUniqueName(String name) {
-        this.uniqueName = name;
+        uniqueName = name;
     }
 
     @Override
@@ -355,7 +374,7 @@ public class DiskOfferingVO implements DiskOffering {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
@@ -382,34 +401,42 @@ public class DiskOfferingVO implements DiskOffering {
         this.displayOffering = displayOffering;
     }
 
+    @Override
     public void setBytesReadRate(Long bytesReadRate) {
         this.bytesReadRate = bytesReadRate;
     }
 
+    @Override
     public Long getBytesReadRate() {
         return bytesReadRate;
     }
 
+    @Override
     public void setBytesWriteRate(Long bytesWriteRate) {
         this.bytesWriteRate = bytesWriteRate;
     }
 
+    @Override
     public Long getBytesWriteRate() {
         return bytesWriteRate;
     }
 
+    @Override
     public void setIopsReadRate(Long iopsReadRate) {
         this.iopsReadRate = iopsReadRate;
     }
 
+    @Override
     public Long getIopsReadRate() {
         return iopsReadRate;
     }
 
+    @Override
     public void setIopsWriteRate(Long iopsWriteRate) {
         this.iopsWriteRate = iopsWriteRate;
     }
 
+    @Override
     public Long getIopsWriteRate() {
         return iopsWriteRate;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/engine/schema/src/com/cloud/storage/VMTemplateVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/VMTemplateVO.java b/engine/schema/src/com/cloud/storage/VMTemplateVO.java
index 60c1a4e..6c2447c 100755
--- a/engine/schema/src/com/cloud/storage/VMTemplateVO.java
+++ b/engine/schema/src/com/cloud/storage/VMTemplateVO.java
@@ -31,14 +31,11 @@ import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 
-import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
-
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.storage.Storage.TemplateType;
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.fsm.StateObject;
 
 @Entity
 @Table(name = "vm_template")
@@ -80,7 +77,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
     @Column(name = GenericDao.CREATED_COLUMN)
     private Date created = null;
 
-    @Column(name = GenericDao.REMOVED)
+    @Column(name = GenericDao.REMOVED_COLUMN)
     @Temporal(TemporalType.TIMESTAMP)
     private Date removed;
 
@@ -118,6 +115,10 @@ public class VMTemplateVO implements VirtualMachineTemplate {
     @Column(name = "source_template_id")
     private Long sourceTemplateId;
 
+    @Column(name = "state")
+    @Enumerated(EnumType.STRING)
+    private State state;
+
     @Column(name = "template_tag")
     private String templateTag;
 
@@ -141,7 +142,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
     Date updated;
 
     @Transient
-    Map details;
+    Map<String, String> details;
 
     @Column(name = "dynamically_scalable")
     protected boolean dynamicallyScalable;
@@ -156,7 +157,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
     }
 
     public VMTemplateVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     /**
@@ -165,23 +166,24 @@ public class VMTemplateVO implements VirtualMachineTemplate {
     public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured,
             boolean isExtractable, TemplateType type, String url, boolean requiresHvm, int bits, long accountId,
             String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable,
-            HypervisorType hyperType, Map details) {
+            HypervisorType hyperType, Map<String, String> details) {
         this(id, generateUniqueName(id, accountId, name), name, format, isPublic, featured, isExtractable, type, url,
                 null, requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType,
                 details);
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured,
             boolean isExtractable, TemplateType type, String url, boolean requiresHvm, int bits, long accountId,
             String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable,
-            HypervisorType hyperType, String templateTag, Map details, boolean sshKeyEnabled, boolean isDynamicallyScalable) {
+            HypervisorType hyperType, String templateTag, Map<String, String> details, boolean sshKeyEnabled, boolean isDynamicallyScalable) {
         this(id, name, format, isPublic, featured, isExtractable, type, url, requiresHvm, bits, accountId, cksum,
                 displayText, enablePassword, guestOSId, bootable, hyperType, details);
         this.templateTag = templateTag;
-        this.uuid = UUID.randomUUID().toString();
-        this.enableSshKey = sshKeyEnabled;
-        this.dynamicallyScalable = isDynamicallyScalable;
+        uuid = UUID.randomUUID().toString();
+        enableSshKey = sshKeyEnabled;
+        dynamicallyScalable = isDynamicallyScalable;
+        state = State.Active;
     }
 
 
@@ -200,14 +202,14 @@ public class VMTemplateVO implements VirtualMachineTemplate {
             HypervisorType hyperType) {
         this.id = id;
         this.name = name;
-        this.publicTemplate = isPublic;
+        publicTemplate = isPublic;
         this.featured = featured;
-        this.templateType = type;
+        templateType = type;
         this.url = url;
         this.requiresHvm = requiresHvm;
         this.bits = bits;
         this.accountId = accountId;
-        this.checksum = cksum;
+        checksum = cksum;
         this.uniqueName = uniqueName;
         this.displayText = displayText;
         this.enablePassword = enablePassword;
@@ -215,30 +217,33 @@ public class VMTemplateVO implements VirtualMachineTemplate {
         this.created = created;
         this.guestOSId = guestOSId;
         this.bootable = bootable;
-        this.hypervisorType = hyperType;
-        this.uuid = UUID.randomUUID().toString();
+        hypervisorType = hyperType;
+        uuid = UUID.randomUUID().toString();
+        state = State.Active;
     }
 
     // Has an extra attribute - isExtractable
     public VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic,
             boolean featured, boolean isExtractable, TemplateType type, String url, Date created, boolean requiresHvm,
             int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId,
-            boolean bootable, HypervisorType hyperType, Map details) {
+            boolean bootable, HypervisorType hyperType, Map<String, String> details) {
         this(id, uniqueName, name, format, isPublic, featured, type, url, created, requiresHvm, bits, accountId, cksum,
                 displayText, enablePassword, guestOSId, bootable, hyperType);
-        this.extractable = isExtractable;
-        this.uuid = UUID.randomUUID().toString();
+        extractable = isExtractable;
+        uuid = UUID.randomUUID().toString();
         this.details = details;
+        state = State.Active;
     }
 
     public VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic,
             boolean featured, boolean isExtractable, TemplateType type, String url, Date created, boolean requiresHvm,
             int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId,
-            boolean bootable, HypervisorType hyperType, String templateTag, Map details) {
+            boolean bootable, HypervisorType hyperType, String templateTag, Map<String, String> details) {
         this(id, uniqueName, name, format, isPublic, featured, isExtractable, type, url, created, requiresHvm, bits,
                 accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType, details);
         this.templateTag = templateTag;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
+        state = State.Active;
     }
 
     @Override
@@ -270,6 +275,15 @@ public class VMTemplateVO implements VirtualMachineTemplate {
     }
 
     @Override
+    public State getState() {
+        return state;
+    }
+
+    public void setState(State state) {
+        this.state = state;
+    }
+
+    @Override
     public long getId() {
         return id;
     }
@@ -280,7 +294,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
     }
 
     public void setTemplateType(TemplateType type) {
-        this.templateType = type;
+        templateType = type;
     }
 
     public boolean requiresHvm() {
@@ -455,18 +469,19 @@ public class VMTemplateVO implements VirtualMachineTemplate {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
         this.uuid = uuid;
     }
 
-    public Map getDetails() {
-        return this.details;
+    @Override
+    public Map<String, String> getDetails() {
+        return details;
     }
 
-    public void setDetails(Map details) {
+    public void setDetails(Map<String, String> details) {
         this.details = details;
     }
 
@@ -480,7 +495,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
         }
         VMTemplateVO other = (VMTemplateVO) that;
 
-        return ((this.getUniqueName().equals(other.getUniqueName())));
+        return ((getUniqueName().equals(other.getUniqueName())));
     }
 
     @Override
@@ -516,8 +531,9 @@ public class VMTemplateVO implements VirtualMachineTemplate {
             this.dynamicallyScalable = dynamicallyScalable;
         }
 
+        @Override
         public Boolean isDynamicallyScalable() {
-            return this.dynamicallyScalable;
+            return dynamicallyScalable;
         }
 
     @Override
@@ -534,19 +550,19 @@ public class VMTemplateVO implements VirtualMachineTemplate {
     }
 
     public Long getSize() {
-        return this.size;
+        return size;
     }
 
     public long getUpdatedCount() {
-        return this.updatedCount;
+        return updatedCount;
     }
 
     public void incrUpdatedCount() {
-        this.updatedCount++;
+        updatedCount++;
     }
 
     public void decrUpdatedCount() {
-        this.updatedCount--;
+        updatedCount--;
     }
 
     public Date getUpdated() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
index 0a1836e..f0675f3 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
@@ -23,6 +23,8 @@ import java.util.Map;
 
 import javax.inject.Inject;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
@@ -33,7 +35,6 @@ import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 import org.apache.cloudstack.storage.to.TemplateObjectTO;
-import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.to.DataObjectType;
@@ -70,7 +71,7 @@ public class TemplateObject implements TemplateInfo {
     }
 
     protected void configure(VMTemplateVO template, DataStore dataStore) {
-        this.imageVO = template;
+        imageVO = template;
         this.dataStore = dataStore;
     }
 
@@ -81,31 +82,36 @@ public class TemplateObject implements TemplateInfo {
     }
 
     public void setSize(Long size) {
-        this.imageVO.setSize(size);
+        imageVO.setSize(size);
     }
 
     public VMTemplateVO getImage() {
-        return this.imageVO;
+        return imageVO;
     }
 
     @Override
     public DataStore getDataStore() {
-        return this.dataStore;
+        return dataStore;
     }
 
     @Override
     public String getUniqueName() {
-        return this.imageVO.getUniqueName();
+        return imageVO.getUniqueName();
     }
 
     @Override
     public long getId() {
-        return this.imageVO.getId();
+        return imageVO.getId();
+    }
+
+    @Override
+    public State getState() {
+        return imageVO.getState();
     }
 
     @Override
     public String getUuid() {
-        return this.imageVO.getUuid();
+        return imageVO.getUuid();
     }
 
     @Override
@@ -113,7 +119,7 @@ public class TemplateObject implements TemplateInfo {
         if ( url != null ){
             return url;
         }
-        VMTemplateVO image = imageDao.findById(this.imageVO.getId());
+        VMTemplateVO image = imageDao.findById(imageVO.getId());
 
         return image.getUrl();
 
@@ -121,8 +127,8 @@ public class TemplateObject implements TemplateInfo {
 
     @Override
     public Long getSize() {
-        if (this.dataStore == null) {
-            return this.imageVO.getSize();
+        if (dataStore == null) {
+            return imageVO.getSize();
         }
 
         /*
@@ -142,7 +148,7 @@ public class TemplateObject implements TemplateInfo {
          * templateSize = templateHostVO.getSize(); } totalAllocatedSize +=
          * (templateSize + _extraBytesPerVolume); }
          */
-        VMTemplateVO image = imageDao.findById(this.imageVO.getId());
+        VMTemplateVO image = imageDao.findById(imageVO.getId());
         return image.getSize();
     }
 
@@ -153,7 +159,7 @@ public class TemplateObject implements TemplateInfo {
 
     @Override
     public ImageFormat getFormat() {
-        return this.imageVO.getFormat();
+        return imageVO.getFormat();
     }
 
     @Override
@@ -175,25 +181,24 @@ public class TemplateObject implements TemplateInfo {
     @Override
     public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer) {
         try {
-            if (this.getDataStore().getRole() == DataStoreRole.Primary) {
+            if (getDataStore().getRole() == DataStoreRole.Primary) {
                 if (answer instanceof CopyCmdAnswer) {
                     CopyCmdAnswer cpyAnswer = (CopyCmdAnswer) answer;
                     TemplateObjectTO newTemplate = (TemplateObjectTO) cpyAnswer.getNewData();
-                    VMTemplateStoragePoolVO templatePoolRef = templatePoolDao.findByPoolTemplate(this.getDataStore()
-                            .getId(), this.getId());
+                    VMTemplateStoragePoolVO templatePoolRef = templatePoolDao.findByPoolTemplate(getDataStore()
+                            .getId(), getId());
                     templatePoolRef.setDownloadPercent(100);
                     templatePoolRef.setDownloadState(Status.DOWNLOADED);
                     templatePoolRef.setLocalDownloadPath(newTemplate.getPath());
                     templatePoolRef.setInstallPath(newTemplate.getPath());
                     templatePoolDao.update(templatePoolRef.getId(), templatePoolRef);
                 }
-            } else if (this.getDataStore().getRole() == DataStoreRole.Image
-                    || this.getDataStore().getRole() == DataStoreRole.ImageCache) {
+            } else if (getDataStore().getRole() == DataStoreRole.Image
+                    || getDataStore().getRole() == DataStoreRole.ImageCache) {
                 if (answer instanceof CopyCmdAnswer) {
                     CopyCmdAnswer cpyAnswer = (CopyCmdAnswer) answer;
                     TemplateObjectTO newTemplate = (TemplateObjectTO) cpyAnswer.getNewData();
-                    TemplateDataStoreVO templateStoreRef = this.templateStoreDao.findByStoreTemplate(this
-                            .getDataStore().getId(), this.getId());
+                    TemplateDataStoreVO templateStoreRef = templateStoreDao.findByStoreTemplate(getDataStore().getId(), getId());
                     templateStoreRef.setInstallPath(newTemplate.getPath());
                     templateStoreRef.setDownloadPercent(100);
                     templateStoreRef.setDownloadState(Status.DOWNLOADED);
@@ -202,8 +207,8 @@ public class TemplateObject implements TemplateInfo {
                         templateStoreRef.setPhysicalSize(newTemplate.getPhysicalSize());
                     }
                     templateStoreDao.update(templateStoreRef.getId(), templateStoreRef);
-                    if (this.getDataStore().getRole() == DataStoreRole.Image) {
-                        VMTemplateVO templateVO = this.imageDao.findById(this.getId());
+                    if (getDataStore().getRole() == DataStoreRole.Image) {
+                        VMTemplateVO templateVO = imageDao.findById(getId());
                         if (newTemplate.getFormat() != null) {
                             templateVO.setFormat(newTemplate.getFormat());
                         }
@@ -212,7 +217,7 @@ public class TemplateObject implements TemplateInfo {
                             templateVO.setUniqueName(newTemplate.getName());
                         }
                         templateVO.setSize(newTemplate.getSize());
-                        this.imageDao.update(templateVO.getId(), templateVO);
+                        imageDao.update(templateVO.getId(), templateVO);
                     }
                 }
             }
@@ -234,12 +239,12 @@ public class TemplateObject implements TemplateInfo {
 
     @Override
     public void incRefCount() {
-        if (this.dataStore == null) {
+        if (dataStore == null) {
             return;
         }
 
-        if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
-            TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), this.getId());
+        if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
+            TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId());
             store.incrRefCnt();
             store.setLastUpdated(new Date());
             templateStoreDao.update(store.getId(), store);
@@ -248,11 +253,11 @@ public class TemplateObject implements TemplateInfo {
 
     @Override
     public void decRefCount() {
-        if (this.dataStore == null) {
+        if (dataStore == null) {
             return;
         }
-        if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
-            TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), this.getId());
+        if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
+            TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId());
             store.decrRefCnt();
             store.setLastUpdated(new Date());
             templateStoreDao.update(store.getId(), store);
@@ -261,11 +266,11 @@ public class TemplateObject implements TemplateInfo {
 
     @Override
     public Long getRefCount() {
-        if (this.dataStore == null) {
+        if (dataStore == null) {
             return null;
         }
-        if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
-            TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), this.getId());
+        if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
+            TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId());
             return store.getRefCnt();
         }
         return null;
@@ -274,10 +279,10 @@ public class TemplateObject implements TemplateInfo {
     @Override
     public DataTO getTO() {
         DataTO to = null;
-        if (this.dataStore == null) {
+        if (dataStore == null) {
             to = new TemplateObjectTO(this);
         } else {
-            to = this.dataStore.getDriver().getTO(this);
+            to = dataStore.getDriver().getTO(this);
             if (to == null) {
                 to = new TemplateObjectTO(this);
             }
@@ -288,91 +293,91 @@ public class TemplateObject implements TemplateInfo {
 
     @Override
     public String getInstallPath() {
-        if (this.dataStore == null) {
+        if (dataStore == null) {
             return null;
         }
-        DataObjectInStore obj = objectInStoreMgr.findObject(this, this.dataStore);
+        DataObjectInStore obj = objectInStoreMgr.findObject(this, dataStore);
         return obj.getInstallPath();
     }
 
     @Override
     public long getAccountId() {
-        return this.imageVO.getAccountId();
+        return imageVO.getAccountId();
     }
 
     @Override
     public boolean isFeatured() {
-        return this.imageVO.isFeatured();
+        return imageVO.isFeatured();
     }
 
     @Override
     public boolean isPublicTemplate() {
-        return this.imageVO.isPublicTemplate();
+        return imageVO.isPublicTemplate();
     }
 
     @Override
     public boolean isExtractable() {
-        return this.imageVO.isExtractable();
+        return imageVO.isExtractable();
     }
 
     @Override
     public String getName() {
-        return this.imageVO.getName();
+        return imageVO.getName();
     }
 
     @Override
     public boolean isRequiresHvm() {
-        return this.imageVO.isRequiresHvm();
+        return imageVO.isRequiresHvm();
     }
 
     @Override
     public String getDisplayText() {
-        return this.imageVO.getDisplayText();
+        return imageVO.getDisplayText();
     }
 
     @Override
     public boolean getEnablePassword() {
-        return this.imageVO.getEnablePassword();
+        return imageVO.getEnablePassword();
     }
 
     @Override
     public boolean getEnableSshKey() {
-        return this.imageVO.getEnableSshKey();
+        return imageVO.getEnableSshKey();
     }
 
     @Override
     public boolean isCrossZones() {
-        return this.imageVO.isCrossZones();
+        return imageVO.isCrossZones();
     }
 
     @Override
     public Date getCreated() {
-        return this.imageVO.getCreated();
+        return imageVO.getCreated();
     }
 
     @Override
     public long getGuestOSId() {
-        return this.imageVO.getGuestOSId();
+        return imageVO.getGuestOSId();
     }
 
     @Override
     public boolean isBootable() {
-        return this.imageVO.isBootable();
+        return imageVO.isBootable();
     }
 
     @Override
     public TemplateType getTemplateType() {
-        return this.imageVO.getTemplateType();
+        return imageVO.getTemplateType();
     }
 
     @Override
     public HypervisorType getHypervisorType() {
-        return this.imageVO.getHypervisorType();
+        return imageVO.getHypervisorType();
     }
 
     @Override
     public int getBits() {
-        return this.imageVO.getBits();
+        return imageVO.getBits();
     }
 
     @Override
@@ -380,7 +385,7 @@ public class TemplateObject implements TemplateInfo {
         if (url != null ){
             return url;
         }
-        return this.imageVO.getUrl();
+        return imageVO.getUrl();
     }
 
     public void setUrl(String url){
@@ -389,22 +394,22 @@ public class TemplateObject implements TemplateInfo {
 
     @Override
     public String getChecksum() {
-        return this.imageVO.getChecksum();
+        return imageVO.getChecksum();
     }
 
     @Override
     public Long getSourceTemplateId() {
-        return this.imageVO.getSourceTemplateId();
+        return imageVO.getSourceTemplateId();
     }
 
     @Override
     public String getTemplateTag() {
-        return this.imageVO.getTemplateTag();
+        return imageVO.getTemplateTag();
     }
 
     @Override
     public Map getDetails() {
-        return this.imageVO.getDetails();
+        return imageVO.getDetails();
     }
 
     @Override
@@ -414,7 +419,7 @@ public class TemplateObject implements TemplateInfo {
 
     @Override
     public long getDomainId() {
-        return this.imageVO.getDomainId();
+        return imageVO.getDomainId();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java
index 138f57c..90506df 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java
@@ -34,6 +34,11 @@ import com.cloud.storage.Storage.TemplateType;
 public class TemplateEntityImpl implements TemplateEntity {
     protected TemplateInfo templateInfo;
 
+    @Override
+    public State getState() {
+        return templateInfo.getState();
+    }
+
     public TemplateEntityImpl(TemplateInfo templateInfo) {
         this.templateInfo = templateInfo;
     }
@@ -47,17 +52,17 @@ public class TemplateEntityImpl implements TemplateEntity {
     }
 
     public TemplateInfo getTemplateInfo() {
-        return this.templateInfo;
+        return templateInfo;
     }
 
     @Override
     public String getUuid() {
-        return this.templateInfo.getUuid();
+        return templateInfo.getUuid();
     }
 
     @Override
     public long getId() {
-        return this.templateInfo.getId();
+        return templateInfo.getId();
     }
 
     public String getExternalId() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/framework/db/src/com/cloud/utils/db/GenericDao.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/GenericDao.java b/framework/db/src/com/cloud/utils/db/GenericDao.java
index 66d0f67..f32880f 100755
--- a/framework/db/src/com/cloud/utils/db/GenericDao.java
+++ b/framework/db/src/com/cloud/utils/db/GenericDao.java
@@ -31,9 +31,7 @@ public interface GenericDao<T, ID extends Serializable> {
  
     /**
      */
-    static final String REMOVED_COLUMN = "cloud_removed";
-    
-    static final String REMOVED = "removed";
+    static final String REMOVED_COLUMN = "removed";
     
     /**
      * This column can be used if the table wants to track creation time.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/framework/db/src/com/cloud/utils/db/SqlGenerator.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/SqlGenerator.java b/framework/db/src/com/cloud/utils/db/SqlGenerator.java
index e48fee5..473e839 100755
--- a/framework/db/src/com/cloud/utils/db/SqlGenerator.java
+++ b/framework/db/src/com/cloud/utils/db/SqlGenerator.java
@@ -136,7 +136,6 @@ public class SqlGenerator {
             Attribute attr = new Attribute(clazz, overrides, field, tableName, embedded, isId);
 
             if (attr.getColumnName().equals(GenericDao.REMOVED_COLUMN)) {
-                attr.setColumnName(GenericDao.REMOVED);
                 attr.setTrue(Attribute.Flag.DaoGenerated);
                 attr.setFalse(Attribute.Flag.Insertable);
                 attr.setFalse(Attribute.Flag.Updatable);
@@ -145,7 +144,7 @@ public class SqlGenerator {
                 attr.setFalse(Attribute.Flag.Date);
                 attr.setTrue(Attribute.Flag.Nullable);
                 attr.setTrue(Attribute.Flag.Removed);
-            } 
+            }
 
             if (attr.isId()) {
                 List<Attribute> attrs = _ids.get(tableName);
@@ -281,7 +280,7 @@ public class SqlGenerator {
         for (Attribute attr : _attributes) {
 
             if (attr.columnName.equalsIgnoreCase(name)) {
-                if (attr.columnName.equalsIgnoreCase(GenericDao.REMOVED) && attr.isUpdatable()) {
+                if (attr.columnName.equalsIgnoreCase(GenericDao.REMOVED_COLUMN) && attr.isUpdatable()) {
                     return null;
                 }
                 return attr;
@@ -385,7 +384,7 @@ public class SqlGenerator {
         }
 
         sql.append(") VALUES (");
-        for (Attribute attr : attrs) {
+        for (int i = 0; i < attrs.size(); i++) {
             sql.append("?, ");
         }
 
@@ -435,7 +434,7 @@ public class SqlGenerator {
     }
 
     public Pair<String, Attribute[]> buildRemoveSql() {
-        Attribute attribute = findAttribute(GenericDao.REMOVED);
+        Attribute attribute = findAttribute(GenericDao.REMOVED_COLUMN);
         if (attribute == null) {
             return null;
         }
@@ -518,7 +517,7 @@ public class SqlGenerator {
     }
 
     public Pair<String, Attribute> getRemovedAttribute() {
-        Attribute removed = findAttribute(GenericDao.REMOVED);
+        Attribute removed = findAttribute(GenericDao.REMOVED_COLUMN);
         if (removed == null) {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index 1ada63f..6347381 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -106,6 +106,7 @@ import com.cloud.capacity.CapacityVO;
 import com.cloud.capacity.dao.CapacityDao;
 import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
 import com.cloud.configuration.Config;
+import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.ConfigurationService;
 import com.cloud.configuration.Resource.ResourceType;
 import com.cloud.dc.AccountVlanMapVO;
@@ -203,7 +204,6 @@ import com.cloud.network.vpc.dao.VpcDao;
 import com.cloud.network.vpc.dao.VpcGatewayDao;
 import com.cloud.network.vpc.dao.VpcOfferingDao;
 import com.cloud.offering.DiskOffering;
-import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.offerings.dao.NetworkOfferingDao;
@@ -298,6 +298,7 @@ public class ApiDBUtils {
     static NetworkModel _networkModel;
     static NetworkManager _networkMgr;
     static TemplateManager _templateMgr;
+    static ConfigurationManager _configMgr;
 
     static StatsCollector _statsCollector;
 
@@ -340,7 +341,7 @@ public class ApiDBUtils {
     static NetworkOfferingDao _networkOfferingDao;
     static NetworkDao _networkDao;
     static PhysicalNetworkDao _physicalNetworkDao;
-    static ConfigurationService _configMgr;
+    static ConfigurationService _configSvc;
     static ConfigurationDao _configDao;
     static ConsoleProxyDao _consoleProxyDao;
     static FirewallRulesCidrsDao _firewallCidrsDao;
@@ -452,7 +453,7 @@ public class ApiDBUtils {
     @Inject private NetworkOfferingDao networkOfferingDao;
     @Inject private NetworkDao networkDao;
     @Inject private PhysicalNetworkDao physicalNetworkDao;
-    @Inject private ConfigurationService configMgr;
+    @Inject private ConfigurationService configSvc;
     @Inject private ConfigurationDao configDao;
     @Inject private ConsoleProxyDao consoleProxyDao;
     @Inject private FirewallRulesCidrsDao firewallCidrsDao;
@@ -511,17 +512,20 @@ public class ApiDBUtils {
     @Inject private NetworkACLDao networkACLDao;
     @Inject private ServiceOfferingDetailsDao serviceOfferingDetailsDao;
     @Inject private AccountService accountService;
+    @Inject
+    private ConfigurationManager configMgr;
 
     @PostConstruct
     void init() {
         _ms = ms;
+        _configMgr = configMgr;
         _asyncMgr = asyncMgr;
         _securityGroupMgr = securityGroupMgr;
         _storageMgr = storageMgr;
         _userVmMgr = userVmMgr;
         _networkModel = networkModel;
         _networkMgr = networkMgr;
-        _configMgr = configMgr;
+        _configSvc = configSvc;
         _templateMgr = templateMgr;
 
         _accountDao = accountDao;
@@ -1026,7 +1030,7 @@ public class ApiDBUtils {
     }
 
     public static Account getVlanAccount(long vlanId) {
-        return _configMgr.getVlanAccount(vlanId);
+        return _configSvc.getVlanAccount(vlanId);
     }
 
     public static boolean isSecurityGroupEnabledInZone(long zoneId) {
@@ -1153,11 +1157,6 @@ public class ApiDBUtils {
         return _taggedResourceService.getUuid(resourceId, resourceType);
     }
 
-    public static boolean isOfferingForVpc(NetworkOffering offering) {
-        boolean vpcProvider = _configMgr.isOfferingForVpc(offering);
-        return vpcProvider;
-    }
-
     public static List<? extends ResourceTag> listByResourceTypeAndId(TaggedResourceType type, long resourceId) {
         return _taggedResourceService.listByResourceTypeAndId(type, resourceId);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index c771431..2f8fdbc 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -172,6 +172,7 @@ import com.cloud.api.response.ApiResponseSerializer;
 import com.cloud.capacity.Capacity;
 import com.cloud.capacity.CapacityVO;
 import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
+import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.Resource.ResourceOwnerType;
 import com.cloud.configuration.Resource.ResourceType;
 import com.cloud.configuration.ResourceCount;
@@ -309,6 +310,8 @@ public class ApiResponseHelper implements ResponseGenerator {
     protected AccountManager _accountMgr;
     @Inject
     protected AsyncJobManager _jobMgr;
+    @Inject
+    ConfigurationManager _configMgr;
 
     @Override
     public UserResponse createUserResponse(User user) {
@@ -2089,7 +2092,7 @@ public class ApiResponseHelper implements ResponseGenerator {
 
             serviceResponses.add(svcRsp);
         }
-        response.setForVpc(ApiDBUtils.isOfferingForVpc(offering));
+        response.setForVpc(_configMgr.isOfferingForVpc(offering));
 
         response.setServices(serviceResponses);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/server/src/com/cloud/configuration/ConfigurationManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java
index 72253fe..792ff94 100755
--- a/server/src/com/cloud/configuration/ConfigurationManager.java
+++ b/server/src/com/cloud/configuration/ConfigurationManager.java
@@ -43,7 +43,6 @@ import com.cloud.org.Grouping.AllocationState;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.storage.DiskOfferingVO;
 import com.cloud.user.Account;
-import com.cloud.utils.component.Manager;
 import com.cloud.vm.VirtualMachine;
 
 /**
@@ -51,7 +50,16 @@ import com.cloud.vm.VirtualMachine;
  * configuration values
  * 
  */
-public interface ConfigurationManager extends ConfigurationService, Manager {
+public interface ConfigurationManager {
+    /**
+     * @param offering
+     * @return
+     */
+    boolean isOfferingForVpc(NetworkOffering offering);
+
+    Integer getNetworkOfferingNetworkRate(long networkOfferingId, Long dataCenterId);
+
+    Integer getServiceOfferingNetworkRate(long serviceOfferingId, Long dataCenterId);
 
     /**
      * Updates a configuration entry with a new value

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/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 5ef574d..3f603d3 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -207,7 +207,7 @@ import com.cloud.vm.dao.NicSecondaryIpDao;
 
 @Local(value = { ConfigurationManager.class, ConfigurationService.class })
 public class ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService {
-    public static final Logger s_logger = Logger.getLogger(ConfigurationManagerImpl.class.getName());
+    public static final Logger s_logger = Logger.getLogger(ConfigurationManagerImpl.class);
 
     @Inject
     EntityManager _entityMgr;
@@ -2228,7 +2228,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         }
 
         // Verify input parameters
-        ServiceOffering offeringHandle = getServiceOffering(id);
+        ServiceOffering offeringHandle = _entityMgr.findById(ServiceOffering.class, id);
 
         if (offeringHandle == null) {
             throw new InvalidParameterValueException("unable to find service offering " + id);
@@ -2419,7 +2419,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         Integer sortKey = cmd.getSortKey();
 
         // Check if diskOffering exists
-        DiskOffering diskOfferingHandle = getDiskOffering(diskOfferingId);
+        DiskOffering diskOfferingHandle = _entityMgr.findById(DiskOffering.class, diskOfferingId);
 
         if (diskOfferingHandle == null) {
             throw new InvalidParameterValueException("Unable to find disk offering by id " + diskOfferingId);
@@ -2482,13 +2482,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
     public boolean deleteDiskOffering(DeleteDiskOfferingCmd cmd) {
         Long diskOfferingId = cmd.getId();
 
-        DiskOffering offering = getDiskOffering(diskOfferingId);
+        DiskOfferingVO offering = _diskOfferingDao.findById(diskOfferingId);
 
         if (offering == null) {
             throw new InvalidParameterValueException("Unable to find disk offering by id " + diskOfferingId);
         }
 
-        if (_diskOfferingDao.remove(diskOfferingId)) {
+        offering.setState(DiskOffering.State.Inactive);
+        if (_diskOfferingDao.update(offering.getId(), offering)) {
             CallContext.current().setEventDetails("Disk offering id=" + diskOfferingId);
             return true;
         } else {
@@ -2508,7 +2509,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         }
 
         // Verify service offering id
-        ServiceOffering offering = getServiceOffering(offeringId);
+        ServiceOfferingVO offering = _serviceOfferingDao.findById(offeringId);
         if (offering == null) {
             throw new InvalidParameterValueException("unable to find service offering " + offeringId);
         }
@@ -2517,7 +2518,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
             throw new InvalidParameterValueException("Default service offerings cannot be deleted");
         }
 
-        if (_serviceOfferingDao.remove(offeringId)) {
+        offering.setState(DiskOffering.State.Inactive);
+        if (_serviceOfferingDao.update(offeringId, offering)) {
             CallContext.current().setEventDetails("Service offering id=" + offeringId);
             return true;
         } else {
@@ -4768,15 +4770,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
     }
 
     @Override
-    public NetworkOffering getNetworkOffering(long id) {
-        return _networkOfferingDao.findById(id);
-    }
-
-    @Override
     public Integer getNetworkOfferingNetworkRate(long networkOfferingId, Long dataCenterId) {
 
         // validate network offering information
-        NetworkOffering no = getNetworkOffering(networkOfferingId);
+        NetworkOffering no = _entityMgr.findById(NetworkOffering.class, networkOfferingId);
         if (no == null) {
             throw new InvalidParameterValueException("Unable to find network offering by id=" + networkOfferingId);
         }
@@ -4889,16 +4886,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
 
 
     @Override
-    public ServiceOffering getServiceOffering(long serviceOfferingId) {
-        ServiceOfferingVO offering = _serviceOfferingDao.findById(serviceOfferingId);
-        if (offering != null && offering.getRemoved() == null) {
-            return offering;
-        }
-
-        return null;
-    }
-
-    @Override
     public Long getDefaultPageSize() {
         return _defaultPageSize;
     }
@@ -4938,16 +4925,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
     }
 
     @Override
-    public DiskOffering getDiskOffering(long diskOfferingId) {
-        DiskOfferingVO offering = _diskOfferingDao.findById(diskOfferingId);
-        if (offering != null && offering.getRemoved() == null) {
-            return offering;
-        }
-
-        return null;
-    }
-
-    @Override
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_PORTABLE_IP_RANGE_CREATE,
             eventDescription = "creating portable ip range", async = false)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/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 74d9150..5f06c48 100644
--- a/server/src/com/cloud/network/IpAddressManagerImpl.java
+++ b/server/src/com/cloud/network/IpAddressManagerImpl.java
@@ -1768,7 +1768,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
     @Override
     public IpAddress assignSystemIp(long networkId, Account owner, boolean forElasticLb, boolean forElasticIp) throws InsufficientAddressCapacityException {
         Network guestNetwork = _networksDao.findById(networkId);
-        NetworkOffering off = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
+        NetworkOffering off = _entityMgr.findById(NetworkOffering.class, guestNetwork.getNetworkOfferingId());
         IpAddress ip = null;
         if ((off.getElasticLb() && forElasticLb) || (off.getElasticIp() && forElasticIp)) {
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abbae2aa/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index 09e48df..ae27554 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -1821,7 +1821,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
         // If networkDomain is not specified, take it from the global configuration
         if (_networkModel.areServicesSupportedByNetworkOffering(networkOfferingId, Service.Dns)) {
             Map<Network.Capability, String> dnsCapabilities = _networkModel.getNetworkOfferingServiceCapabilities
-                    (_configMgr.getNetworkOffering(networkOfferingId), Service.Dns);
+                    (_entityMgr.findById(NetworkOffering.class, networkOfferingId), Service.Dns);
             String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification);
             if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) {
                 if (networkDomain != null) {
@@ -2214,7 +2214,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
                         _networkAccountDao.remove(networkAccount.getId());
                 }
 
-                NetworkOffering ntwkOff = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
+                NetworkOffering ntwkOff = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
                 boolean updateResourceCount = resourceCountNeedsUpdate(ntwkOff, network.getAclType());
                 if (updateResourceCount) {
                     _resourceLimitMgr.decrementResourceCount(owner.getId(), ResourceType.network);
@@ -3105,7 +3105,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
         if (lbElements.size() > 1) {
             String providerName = null;
             //get network offering details
-            NetworkOffering off = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
+            NetworkOffering off = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
             if (lbScheme == Scheme.Public) {
                 providerName = _ntwkOffDetailsDao.getDetail(off.getId(), NetworkOffering.Detail.PublicLbProvider);
             } else {


Mime
View raw message