You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ja...@apache.org on 2013/06/28 15:28:25 UTC

[1/5] git commit: updated refs/heads/master-6-17-stable to 11a28aa

Updated Branches:
  refs/heads/master-6-17-stable 53b40d233 -> 11a28aae4


Assertion failure in updatephysicalnetwork Test.

Signed-off-by: Jayapal <ja...@apache.org>


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

Branch: refs/heads/master-6-17-stable
Commit: 9231810bc1ae19d9fc1bee5e3d5e00072b94f662
Parents: 53b40d2
Author: Bharat Kumar <bh...@citrix.com>
Authored: Fri Jun 28 18:11:59 2013 +0530
Committer: Jayapal <ja...@apache.org>
Committed: Fri Jun 28 18:50:16 2013 +0530

----------------------------------------------------------------------
 server/test/com/cloud/network/UpdatePhysicalNetworkTest.java | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9231810b/server/test/com/cloud/network/UpdatePhysicalNetworkTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/UpdatePhysicalNetworkTest.java b/server/test/com/cloud/network/UpdatePhysicalNetworkTest.java
index ca9d149..25c023e 100644
--- a/server/test/com/cloud/network/UpdatePhysicalNetworkTest.java
+++ b/server/test/com/cloud/network/UpdatePhysicalNetworkTest.java
@@ -22,6 +22,7 @@ import com.cloud.network.NetworkServiceImpl;
 import com.cloud.network.dao.PhysicalNetworkDao;
 import com.cloud.network.dao.PhysicalNetworkVO;
 import com.cloud.utils.Pair;
+import com.cloud.utils.db.Transaction;
 import org.junit.Test;
 import org.junit.*;
 import org.mockito.ArgumentCaptor;
@@ -54,6 +55,7 @@ public class UpdatePhysicalNetworkTest {
 
     @Test
     public void updatePhysicalNetworkTest(){
+        Transaction txn = Transaction.open("updatePhysicalNetworkTest");
         NetworkServiceImpl networkService = setUp();
         existingRange.add(new Pair<Integer, Integer>(520, 524));
         when(_physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetworkVO);
@@ -61,6 +63,7 @@ public class UpdatePhysicalNetworkTest {
         when(_physicalNetworkDao.update(anyLong(), any(physicalNetworkVO.getClass()))).thenReturn(true);
         when(physicalNetworkVO.getVnet()).thenReturn(existingRange);
         networkService.updatePhysicalNetwork(1l, null, null, "525-530", null, null);
+        txn.close("updatePhysicalNetworkTest");
         verify(physicalNetworkVO).setVnet(argumentCaptor.capture());
         assertEquals("520-530", argumentCaptor.getValue());
     }


[2/5] git commit: updated refs/heads/master-6-17-stable to 11a28aa

Posted by ja...@apache.org.
CLOUDSTACK-2987 Ensure XStools to be there in template inorder to enable dynamic scaling of vm

CLOUDSTACK-3042 - handle Scaling up of vm memory/CPU based on the presence of XS tools in the template
This also takes care of updation of VM after XS tools are installed in the vm and set memory values accordingly to support dynamic scaling after stop start of VM

Signed-off-by: Jayapal <ja...@apache.org>


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

Branch: refs/heads/master-6-17-stable
Commit: d8690837ded1e7219ece5889b8302b5d2a85d730
Parents: 9231810
Author: Harikrishna Patnala <ha...@citrix.com>
Authored: Fri Jun 28 11:01:49 2013 +0530
Committer: Jayapal <ja...@apache.org>
Committed: Fri Jun 28 18:50:24 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/template/VirtualMachineTemplate.java  |  2 ++
 api/src/com/cloud/vm/VirtualMachine.java            |  2 ++
 api/src/org/apache/cloudstack/api/ApiConstants.java |  1 +
 .../cloudstack/api/BaseUpdateTemplateOrIsoCmd.java  |  7 +++++++
 .../api/command/user/iso/RegisterIsoCmd.java        |  7 +++++++
 .../command/user/template/RegisterTemplateCmd.java  |  7 +++++++
 .../cloudstack/api/command/user/vm/UpdateVMCmd.java |  7 +++++++
 .../cloudstack/api/response/TemplateResponse.java   |  7 +++++++
 .../cloudstack/api/response/UserVmResponse.java     |  7 +++++++
 core/src/com/cloud/agent/api/ScaleVmCommand.java    |  3 ++-
 .../schema/src/com/cloud/storage/VMTemplateVO.java  | 14 +++++++++++++-
 engine/schema/src/com/cloud/vm/VMInstanceVO.java    |  1 +
 .../storage/image/TemplateEntityImpl.java           |  6 ++++++
 .../xen/src/com/cloud/hypervisor/XenServerGuru.java |  1 +
 .../hypervisor/xen/resource/CitrixResourceBase.java |  4 ++++
 .../xen/resource/XenServer56FP1Resource.java        |  1 +
 server/src/com/cloud/api/ApiResponseHelper.java     |  4 ++++
 .../com/cloud/api/query/dao/UserVmJoinDaoImpl.java  |  5 +++++
 server/src/com/cloud/api/query/vo/UserVmJoinVO.java | 11 +++++++++++
 .../com/cloud/hypervisor/HypervisorGuruBase.java    | 13 +++++++++----
 .../src/com/cloud/server/ManagementServerImpl.java  |  7 ++++++-
 server/src/com/cloud/storage/TemplateProfile.java   | 12 +++++++++++-
 server/src/com/cloud/template/TemplateAdapter.java  |  2 +-
 .../src/com/cloud/template/TemplateAdapterBase.java | 12 ++++++------
 server/src/com/cloud/vm/UserVmManagerImpl.java      | 13 +++++++++++++
 .../src/com/cloud/vm/VirtualMachineManagerImpl.java | 14 ++++++++++++--
 .../com/cloud/vm/VirtualMachineManagerImplTest.java | 16 +++++++++++++---
 setup/db/db/schema-410to420.sql                     | 15 ++++++++++-----
 28 files changed, 176 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/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 cedc793..114785a 100755
--- a/api/src/com/cloud/template/VirtualMachineTemplate.java
+++ b/api/src/com/cloud/template/VirtualMachineTemplate.java
@@ -92,4 +92,6 @@ public interface VirtualMachineTemplate extends ControlledEntity, Identity, Inte
 
     String getTemplateTag();
     Map getDetails();
+
+    Boolean isDynamicallyScalable();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/api/src/com/cloud/vm/VirtualMachine.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/VirtualMachine.java b/api/src/com/cloud/vm/VirtualMachine.java
index ce9add6..c172fbf 100755
--- a/api/src/com/cloud/vm/VirtualMachine.java
+++ b/api/src/com/cloud/vm/VirtualMachine.java
@@ -158,6 +158,8 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
         }
     }
 
+    public static final String IsDynamicScalingEnabled = "enable.dynamic.scaling";
+
     public enum Event {
         CreateRequested,
         StartRequested,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index c4dba5d..170ee62 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -506,6 +506,7 @@ public class ApiConstants {
     public static final String DEPLOYMENT_PLANNER = "deploymentplanner";
     public static final String ACL_ID = "aclid";
     public static final String NUMBER = "number";
+    public static final String IS_DYNAMICALLY_SCALABLE = "isdynamicallyscalable";
 
     public enum HostDetails {
         all, capacity, events, stats, min;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java b/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
index 6fd9773..b01c8d0 100644
--- a/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
@@ -54,6 +54,9 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
     @Parameter(name=ApiConstants.SORT_KEY, type=CommandType.INTEGER, description="sort key of the template, integer")
     private Integer sortKey;
 
+    @Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE, type = CommandType.BOOLEAN, description = "true if template/ISO contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory")
+    private Boolean isDynamicallyScalable;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -89,4 +92,8 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
     public Integer getSortKey() {
         return sortKey;
     }
+
+    public Boolean isDynamicallyScalable() {
+        return isDynamicallyScalable;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
index 284d553..1e7e3da 100644
--- a/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
@@ -93,6 +93,9 @@ public class RegisterIsoCmd extends BaseCmd {
             description="Image store uuid")
     private String imageStoreUuid;
 
+    @Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE, type = CommandType.BOOLEAN, description = "true if iso contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory")
+    protected Boolean isDynamicallyScalable;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -149,6 +152,10 @@ public class RegisterIsoCmd extends BaseCmd {
         return this.imageStoreUuid;
     }
 
+    public Boolean isDynamicallyScalable() {
+        return isDynamicallyScalable ==  null ? false : isDynamicallyScalable;
+    }
+
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
index c9da0c2..837faf6 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
@@ -118,6 +118,9 @@ public class RegisterTemplateCmd extends BaseCmd {
     @Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="Template details in key/value pairs.")
     protected Map details;
 
+    @Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE, type = CommandType.BOOLEAN, description = "true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory")
+    protected Boolean isDynamicallyScalable;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -208,6 +211,10 @@ public class RegisterTemplateCmd extends BaseCmd {
         return params;
     }
 
+    public Boolean isDynamicallyScalable() {
+        return isDynamicallyScalable == null ? false : isDynamicallyScalable;
+    }
+
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java
index 2860283..26e5609 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java
@@ -67,6 +67,9 @@ public class UpdateVMCmd extends BaseCmd{
     @Parameter(name=ApiConstants.DISPLAY_VM, type=CommandType.BOOLEAN, description="an optional field, whether to the display the vm to the end user or not.")
     private Boolean displayVm;
 
+    @Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE, type = CommandType.BOOLEAN, description = "true if VM contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory")
+    protected Boolean isDynamicallyScalable;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -95,6 +98,10 @@ public class UpdateVMCmd extends BaseCmd{
         return displayVm;
     }
 
+    public Boolean isDynamicallyScalable() {
+        return isDynamicallyScalable;
+    }
+
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/api/src/org/apache/cloudstack/api/response/TemplateResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/TemplateResponse.java b/api/src/org/apache/cloudstack/api/response/TemplateResponse.java
index ed933ff..2089c4b 100644
--- a/api/src/org/apache/cloudstack/api/response/TemplateResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/TemplateResponse.java
@@ -139,6 +139,9 @@ public class TemplateResponse extends BaseResponse implements ControlledEntityRe
     @SerializedName(ApiConstants.SSHKEY_ENABLED) @Param(description="true if template is sshkey enabled, false otherwise")
     private Boolean sshKeyEnabled;
 
+    @SerializedName(ApiConstants.IS_DYNAMICALLY_SCALABLE) @Param(description="true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory")
+    private Boolean isDynamicallyScalable;
+
     @Override
     public String getObjectId() {
         return this.getId();
@@ -296,4 +299,8 @@ public class TemplateResponse extends BaseResponse implements ControlledEntityRe
         this.sshKeyEnabled = sshKeyEnabled;
     }
 
+    public void setDynamicallyScalable(boolean isDynamicallyScalable) {
+        this.isDynamicallyScalable = isDynamicallyScalable;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/UserVmResponse.java b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
index 5b71ba2..0df9413 100644
--- a/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
@@ -189,6 +189,9 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
     @SerializedName(ApiConstants.DISPLAY_VM) @Param(description="an optional field whether to the display the vm to the end user or not.")
     private Boolean displayVm;
 
+    @SerializedName(ApiConstants.IS_DYNAMICALLY_SCALABLE) @Param(description="true if vm contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory.")
+    private Boolean isDynamicallyScalable;
+
     public UserVmResponse(){
         securityGroupList = new LinkedHashSet<SecurityGroupResponse>();
         nics = new LinkedHashSet<NicResponse>();
@@ -432,4 +435,8 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
         this.affinityGroupList.add(affinityGroup);
     }
 
+    public void setDynamicallyScalable(boolean isDynamicallyScalable) {
+        this.isDynamicallyScalable = isDynamicallyScalable;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/core/src/com/cloud/agent/api/ScaleVmCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/ScaleVmCommand.java b/core/src/com/cloud/agent/api/ScaleVmCommand.java
index b361485..83cdcac 100644
--- a/core/src/com/cloud/agent/api/ScaleVmCommand.java
+++ b/core/src/com/cloud/agent/api/ScaleVmCommand.java
@@ -41,7 +41,7 @@ public class ScaleVmCommand extends Command {
 	}
 
 	public ScaleVmCommand(String vmName, int cpus,
-			Integer minSpeed, Integer maxSpeed, long minRam, long maxRam, boolean limitCpuUse) {
+			Integer minSpeed, Integer maxSpeed, long minRam, long maxRam, boolean limitCpuUse, boolean isDynamicallyScalable) {
 		super();
 		this.vmName = vmName;
 		this.cpus = cpus;
@@ -50,6 +50,7 @@ public class ScaleVmCommand extends Command {
 		this.minRam = minRam;
 		this.maxRam = maxRam;
 		this.vm = new VirtualMachineTO(1L, vmName, null, cpus, minSpeed, maxSpeed, minRam, maxRam, null, null, false, limitCpuUse, null);
+        vm.setEnableDynamicallyScaleVm(isDynamicallyScalable);
 		/*vm.setName(vmName);
 		vm.setCpus(cpus);
 		vm.setRam(minRam, maxRam);*/

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/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 e643d75..3bf83c0 100755
--- a/engine/schema/src/com/cloud/storage/VMTemplateVO.java
+++ b/engine/schema/src/com/cloud/storage/VMTemplateVO.java
@@ -148,6 +148,9 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
     @Transient
     Map details;
 
+    @Column(name = "dynamically_scalable")
+    protected boolean dynamicallyScalable;
+
     @Override
     public String getUniqueName() {
         return uniqueName;
@@ -171,12 +174,13 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
     	this.state = TemplateState.Allocated;
     }
 
-    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) {
+    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) {
         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.state = TemplateState.Allocated;
     	this.enableSshKey = sshKeyEnabled;
+        this.dynamicallyScalable = isDynamicallyScalable;
     }
 
     public VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic, boolean featured, TemplateType type, String url, Date created, boolean requiresHvm, int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hyperType) {
@@ -530,5 +534,13 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
 	        this.updated = updated;
 	    }
 
+        public void setDynamicallyScalable(boolean dynamicallyScalable) {
+            this.dynamicallyScalable = dynamicallyScalable;
+        }
+
+        public Boolean isDynamicallyScalable() {
+            return this.dynamicallyScalable;
+        }
+
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/engine/schema/src/com/cloud/vm/VMInstanceVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/VMInstanceVO.java b/engine/schema/src/com/cloud/vm/VMInstanceVO.java
index fbe03dc..e1d2892 100644
--- a/engine/schema/src/com/cloud/vm/VMInstanceVO.java
+++ b/engine/schema/src/com/cloud/vm/VMInstanceVO.java
@@ -146,6 +146,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
     @Enumerated(value=EnumType.STRING)
     protected HypervisorType hypervisorType;
 
+
 /*
     @Column(name="tags")
     protected String tags;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/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 4d162bb..cbf3a1f 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java
@@ -101,6 +101,12 @@ public class TemplateEntityImpl implements TemplateEntity {
         return null;
     }
 
+    @Override
+    public Boolean isDynamicallyScalable() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
 
     @Override
     public void addDetail(String name, String value) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/plugins/hypervisors/xen/src/com/cloud/hypervisor/XenServerGuru.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/XenServerGuru.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/XenServerGuru.java
index 8c38a69..c52020e 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/XenServerGuru.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/XenServerGuru.java
@@ -26,6 +26,7 @@ import com.cloud.storage.dao.GuestOSDao;
 import com.cloud.template.VirtualMachineTemplate.BootloaderType;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.VirtualMachineProfileImpl;
 
 @Local(value=HypervisorGuru.class)
 public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index bb267fb..2397d70 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -680,6 +680,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 throw new CloudRuntimeException("Unable to scale the vm: " + vmName + " as DMC - Dynamic memory control is not enabled for the XenServer:" + _host.uuid + " ,check your license and hypervisor version.");
             }
 
+            if(!vmSpec.isEnableDynamicallyScaleVm()) {
+                throw new CloudRuntimeException("Unable to Scale the vm: " + vmName + "as vm does not have xs tools to support dynamic scaling");
+            }
+
             // stop vm which is running on this host or is in halted state
             Iterator<VM> iter = vms.iterator();
             while ( iter.hasNext() ) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
index 5b343e7..dff5d7d 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
@@ -165,6 +165,7 @@ public class XenServer56FP1Resource extends XenServer56Resource {
         vmr.actionsAfterCrash = Types.OnCrashBehaviour.DESTROY;
         vmr.actionsAfterShutdown = Types.OnNormalExit.DESTROY;
 
+        Map<String, String> details = vmSpec.getDetails();
         if (isDmcEnabled(conn, host) && vmSpec.isEnableDynamicallyScaleVm()) {
             //scaling is allowed
             vmr.memoryStaticMin = getStaticMin(vmSpec.getOs(), vmSpec.getBootloader() == BootloaderType.CD, vmSpec.getMinRam(), vmSpec.getMaxRam());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/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 14254ac..04bba3e 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -1306,6 +1306,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         response.setTags(tagResponses);
 
         response.setObjectName("iso");
+        response.setDynamicallyScalable(result.isDynamicallyScalable());
         return response;
     }
 
@@ -1520,6 +1521,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         templateResponse.setTags(tagResponses);
 
         templateResponse.setObjectName("template");
+        templateResponse.setDynamicallyScalable(template.isDynamicallyScalable());
         responses.add(templateResponse);
         return responses;
     }
@@ -1545,6 +1547,7 @@ public class ApiResponseHelper implements ResponseGenerator {
             isoResponse.setChecksum(iso.getChecksum());
             isoResponse.setPasswordEnabled(false);
             isoResponse.setDetails(iso.getDetails());
+            isoResponse.setDynamicallyScalable(iso.isDynamicallyScalable());
 
             // add account ID and name
             Account owner = ApiDBUtils.findAccountById(iso.getAccountId());
@@ -1721,6 +1724,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         isoResponse.setPublic(iso.isPublicTemplate());
         isoResponse.setChecksum(iso.getChecksum());
         isoResponse.setDetails(iso.getDetails());
+        isoResponse.setDynamicallyScalable(iso.isDynamicallyScalable());
 
         // TODO: implement
         GuestOS os = ApiDBUtils.findGuestOSById(iso.getGuestOSId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
index 4c41018..7db22c8 100644
--- a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
@@ -247,6 +247,11 @@ public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implem
         }
 
         userVmResponse.setObjectName(objectName);
+        if (userVm.isDynamicallyScalable() == null) {
+            userVmResponse.setDynamicallyScalable(false);
+        } else {
+            userVmResponse.setDynamicallyScalable(userVm.isDynamicallyScalable());
+        }
 
         return userVmResponse;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/UserVmJoinVO.java b/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
index c97d71a..c784104 100644
--- a/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
@@ -391,6 +391,9 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity {
     @Column(name="uuid")
     private String uuid;
 
+    @Column(name="dynamically_scalable")
+    private boolean isDynamicallyScalable;
+
     public UserVmJoinVO() {
     }
 
@@ -1717,5 +1720,13 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity {
         return affinityGroupDescription;
     }
 
+    public Boolean isDynamicallyScalable() {
+        return isDynamicallyScalable;
+    }
+
+    public void setDynamicallyScalable(boolean isDynamicallyScalable) {
+        this.isDynamicallyScalable = isDynamicallyScalable;
+    }
+
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/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 1ad9a1f..be36b8d 100644
--- a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
+++ b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
@@ -29,6 +29,8 @@ import com.cloud.configuration.Config;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.server.ConfigurationServer;
 import com.cloud.storage.dao.VMTemplateDetailsDao;
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.storage.VMTemplateVO;
 import com.cloud.utils.component.AdapterBase;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
@@ -37,6 +39,7 @@ import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.NicDao;
 import com.cloud.vm.dao.NicSecondaryIpDao;
+import com.cloud.vm.dao.UserVmDetailsDao;
 import com.cloud.vm.dao.VMInstanceDao;
 
 public abstract class HypervisorGuruBase extends AdapterBase implements HypervisorGuru {
@@ -47,7 +50,6 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
     @Inject NicSecondaryIpDao _nicSecIpDao;
     @Inject ConfigurationServer _configServer;
 
-
     protected HypervisorGuruBase() {
         super();
     }
@@ -120,15 +122,18 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
         if(detailsInVm != null) {
         	details.putAll(detailsInVm);
         }
+        if (details.get(VirtualMachine.IsDynamicScalingEnabled) == null || details.get(VirtualMachine.IsDynamicScalingEnabled).isEmpty()) {
+            to. setEnableDynamicallyScaleVm(false);
+        } else {
+            // check if XStools/VMWare tools are present in the VM and dynamic scaling feature is enabled (per zone/global)
+            to.setEnableDynamicallyScaleVm(details.get(VirtualMachine.IsDynamicScalingEnabled).equals("true") && Boolean.parseBoolean(_configServer.getConfigValue(Config.EnableDynamicallyScaleVm.key(), Config.ConfigurationParameterScope.zone.toString(), vm.getDataCenterId())));
+        }
         to.setDetails(details);
-        
         // Workaround to make sure the TO has the UUID we need for Niciri integration
         VMInstanceVO vmInstance = _virtualMachineDao.findById(to.getId());
         to.setUuid(vmInstance.getUuid());
 
         //
-        to.setEnableDynamicallyScaleVm(Boolean.parseBoolean(_configServer.getConfigValue(Config.EnableDynamicallyScaleVm.key(), Config.ConfigurationParameterScope.zone.toString(), vm.getDataCenterId())));
-
         return to;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index dea761d..69c3f6c 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -1873,6 +1873,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         Boolean passwordEnabled = cmd.isPasswordEnabled();
         Boolean bootable = cmd.isBootable();
         Integer sortKey = cmd.getSortKey();
+        Boolean isDynamicallyScalable = cmd.isDynamicallyScalable();
         Account account = UserContext.current().getCaller();
 
         // verify that template exists
@@ -1894,7 +1895,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         _accountMgr.checkAccess(account, AccessType.ModifyEntry, true, template);
 
         boolean updateNeeded = !(name == null && displayText == null && format == null && guestOSId == null && passwordEnabled == null
-                && bootable == null && sortKey == null);
+                && bootable == null && sortKey == null && isDynamicallyScalable == null);
         if (!updateNeeded) {
             return template;
         }
@@ -1943,6 +1944,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
             template.setBootable(bootable);
         }
 
+        if (isDynamicallyScalable != null) {
+            template.setDynamicallyScalable(isDynamicallyScalable);
+        }
+
         _templateDao.update(id, template);
 
         return _templateDao.findById(id);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/server/src/com/cloud/storage/TemplateProfile.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/TemplateProfile.java b/server/src/com/cloud/storage/TemplateProfile.java
index 0b55f1f..ca23d00 100755
--- a/server/src/com/cloud/storage/TemplateProfile.java
+++ b/server/src/com/cloud/storage/TemplateProfile.java
@@ -47,6 +47,7 @@ public class TemplateProfile {
 	String templateTag;
 	Long imageStoreId;
 	Map details;
+    Boolean isDynamicallyScalable;
 	
 	public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
 			String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId,
@@ -84,11 +85,12 @@ public class TemplateProfile {
     public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
             String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId,
             HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, String templateTag, Map details, Boolean sshKeyEnabled,
-            Long imageStoreId) {
+            Long imageStoreId, Boolean isDynamicallyScalable) {
         this(templateId, userId, name, displayText, bits, passwordEnabled, requiresHvm, url, isPublic, featured, isExtractable, format, guestOsId, zoneId,
                 hypervisorType, accountName, domainId, accountId, chksum, bootable, details, sshKeyEnabled);
         this.templateTag = templateTag;
         this.imageStoreId = imageStoreId;
+        this.isDynamicallyScalable = isDynamicallyScalable;
     }	
 	
 	public Long getTemplateId() {
@@ -258,4 +260,12 @@ public class TemplateProfile {
     public Long getImageStoreId() {
         return this.imageStoreId;
     }
+
+    public Boolean IsDynamicallyScalable() {
+        return this.isDynamicallyScalable;
+    }
+
+    public void setScalabe(Boolean isDynamicallyScalabe) {
+        this.isDynamicallyScalable = isDynamicallyScalabe;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/server/src/com/cloud/template/TemplateAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateAdapter.java b/server/src/com/cloud/template/TemplateAdapter.java
index 9a2d877..bb7cd23 100755
--- a/server/src/com/cloud/template/TemplateAdapter.java
+++ b/server/src/com/cloud/template/TemplateAdapter.java
@@ -69,5 +69,5 @@ public interface TemplateAdapter extends Adapter {
     public TemplateProfile prepare(boolean isIso, long userId, String name, String displayText, Integer bits,
             Boolean passwordEnabled, Boolean requiresHVM, String url, Boolean isPublic, Boolean featured,
             Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
-            String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshKeyEnabled, String imageStoreUuid) throws ResourceAllocationException;	
+            String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshKeyEnabled, String imageStoreUuid, Boolean isDynamicallyScalable) throws ResourceAllocationException;
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/server/src/com/cloud/template/TemplateAdapterBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateAdapterBase.java b/server/src/com/cloud/template/TemplateAdapterBase.java
index 0940d3e..c57697b 100755
--- a/server/src/com/cloud/template/TemplateAdapterBase.java
+++ b/server/src/com/cloud/template/TemplateAdapterBase.java
@@ -104,14 +104,14 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
             Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
             String accountName, Long domainId, String chksum, Boolean bootable, Map details) throws ResourceAllocationException {
 	    return prepare(isIso, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic, featured, isExtractable, format, guestOSId, zoneId, hypervisorType,
-	            chksum, bootable, null, null, details, false, null);
+	            chksum, bootable, null, null, details, false, null, false);
 	}
 	
 	public TemplateProfile prepare(boolean isIso, long userId, String name, String displayText, Integer bits,
 			Boolean passwordEnabled, Boolean requiresHVM, String url, Boolean isPublic, Boolean featured,
 			Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
 			String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshkeyEnabled,
-			String imageStoreUuid) throws ResourceAllocationException {
+			String imageStoreUuid, Boolean isDynamicallyScalable) throws ResourceAllocationException {
 		//Long accountId = null;
 		// parameters verification
 		
@@ -226,7 +226,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
         Long id = _tmpltDao.getNextInSequence(Long.class, "id");
         UserContext.current().setEventDetails("Id: " +id+ " name: " + name);
 		return new TemplateProfile(id, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic,
-				featured, isExtractable, imgfmt, guestOSId, zoneId, hypervisorType, templateOwner.getAccountName(), templateOwner.getDomainId(), templateOwner.getAccountId(), chksum, bootable, templateTag, details, sshkeyEnabled, imageStoreId);
+				featured, isExtractable, imgfmt, guestOSId, zoneId, hypervisorType, templateOwner.getAccountName(), templateOwner.getDomainId(), templateOwner.getAccountId(), chksum, bootable, templateTag, details, sshkeyEnabled, imageStoreId, isDynamicallyScalable);
 	}
 	
 	@Override
@@ -241,7 +241,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
 		return prepare(false, UserContext.current().getCallerUserId(), cmd.getTemplateName(), cmd.getDisplayText(),
 				cmd.getBits(), cmd.isPasswordEnabled(), cmd.getRequiresHvm(), cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(),
 				cmd.isExtractable(), cmd.getFormat(), cmd.getOsTypeId(), cmd.getZoneId(), HypervisorType.getType(cmd.getHypervisor()),
-				cmd.getChecksum(), true, cmd.getTemplateTag(), owner, cmd.getDetails(), cmd.isSshKeyEnabled(), cmd.getImageStoreUuid());
+				cmd.getChecksum(), true, cmd.getTemplateTag(), owner, cmd.getDetails(), cmd.isSshKeyEnabled(), cmd.getImageStoreUuid(), cmd.isDynamicallyScalable());
 	}
 
 	public TemplateProfile prepare(RegisterIsoCmd cmd) throws ResourceAllocationException {
@@ -252,7 +252,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
 	   
 		return prepare(true, UserContext.current().getCallerUserId(), cmd.getIsoName(), cmd.getDisplayText(), 64, false,
 					true, cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(), cmd.isExtractable(), ImageFormat.ISO.toString(), cmd.getOsTypeId(),
-					cmd.getZoneId(), HypervisorType.None, cmd.getChecksum(), cmd.isBootable(), null, owner, null, false, cmd.getImageStoreUuid());
+					cmd.getZoneId(), HypervisorType.None, cmd.getChecksum(), cmd.isBootable(), null, owner, null, false, cmd.getImageStoreUuid(), cmd.isDynamicallyScalable());
 	}
 	
 	protected VMTemplateVO persistTemplate(TemplateProfile profile) {
@@ -261,7 +261,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
 				profile.getFeatured(), profile.getIsExtractable(), TemplateType.USER, profile.getUrl(), profile.getRequiresHVM(),
 				profile.getBits(), profile.getAccountId(), profile.getCheckSum(), profile.getDisplayText(),
 				profile.getPasswordEnabled(), profile.getGuestOsId(), profile.getBootable(), profile.getHypervisorType(), profile.getTemplateTag(), 
-				profile.getDetails(), profile.getSshKeyEnabled());
+				profile.getDetails(), profile.getSshKeyEnabled(), profile.IsDynamicallyScalable());
 
 		template.setImageDataStoreId(profile.getImageStoreId());
 		if (zoneId == null || zoneId.longValue() == -1) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 4be6c18..fcfedf1 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1709,6 +1709,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
         Long id = cmd.getId();
         Long osTypeId = cmd.getOsTypeId();
         String userData = cmd.getUserData();
+        Boolean isDynamicallyScalable = cmd.isDynamicallyScalable();
         Account caller = UserContext.current().getCaller();
 
         // Input validation
@@ -1796,6 +1797,17 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
             }
         }
 
+        if (isDynamicallyScalable != null) {
+            UserVmDetailVO vmDetailVO = _vmDetailsDao.findDetail(vm.getId(), VirtualMachine.IsDynamicScalingEnabled);
+            if (vmDetailVO == null) {
+                vmDetailVO = new UserVmDetailVO(vm.getId(), VirtualMachine.IsDynamicScalingEnabled, isDynamicallyScalable.toString());
+                _vmDetailsDao.persist(vmDetailVO);
+            } else {
+                vmDetailVO.setValue(isDynamicallyScalable.toString());
+                _vmDetailsDao.update(vmDetailVO.getId(), vmDetailVO);
+            }
+        }
+
         _vmDao.updateVM(id, displayName, ha, osTypeId, userData, isDisplayVmEnabled);
 
         if (updateUserdata) {
@@ -2684,6 +2696,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
                 owner.getDomainId(), owner.getId(), offering.getId(), userData,
                 hostName, diskOfferingId);
         vm.setUuid(uuidName);
+        vm.setDetail(VirtualMachine.IsDynamicScalingEnabled, template.isDynamicallyScalable().toString());
 
         if (sshPublicKey != null) {
             vm.setDetail("SSH.PublicKey", sshPublicKey);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index f946cd1..08a7103 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -167,6 +167,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.exception.ExecutionException;
 import com.cloud.utils.fsm.NoTransitionException;
 import com.cloud.utils.fsm.StateMachine2;
+import com.cloud.vm.UserVmDetailVO;
 import com.cloud.vm.ItWorkVO.Step;
 import com.cloud.vm.VirtualMachine.Event;
 import com.cloud.vm.VirtualMachine.State;
@@ -3227,14 +3228,23 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
     @Override
     public VMInstanceVO reConfigureVm(VMInstanceVO vm , ServiceOffering oldServiceOffering, boolean reconfiguringOnExistingHost) throws ResourceUnavailableException, ConcurrentOperationException {
 
+        UserVmDetailVO vmDetailVO = _uservmDetailsDao.findDetail(vm.getId(), VirtualMachine.IsDynamicScalingEnabled);
+        Boolean isDynamicallyScalable;
+        if (vmDetailVO == null) {
+            isDynamicallyScalable = false;
+        } else {
+            isDynamicallyScalable = (vmDetailVO.getValue()).equals("true");
+        }
+
         long newServiceofferingId = vm.getServiceOfferingId();
         ServiceOffering newServiceOffering = _configMgr.getServiceOffering(newServiceofferingId);
-        HostVO hostVo = _hostDao.findById(vm.hostId);
+        HostVO hostVo = _hostDao.findById(vm.getHostId());
+
         Float memoryOvercommitRatio = Float.parseFloat(_configServer.getConfigValue(Config.MemOverprovisioningFactor.key(), Config.ConfigurationParameterScope.cluster.toString(), hostVo.getClusterId()));
         Float cpuOvercommitRatio = Float.parseFloat(_configServer.getConfigValue(Config.CPUOverprovisioningFactor.key(), Config.ConfigurationParameterScope.cluster.toString(), hostVo.getClusterId()));
         long minMemory = (long) (newServiceOffering.getRamSize()/memoryOvercommitRatio);
         ScaleVmCommand reconfigureCmd = new ScaleVmCommand(vm.getInstanceName(), newServiceOffering.getCpu(),
-                (int) (newServiceOffering.getSpeed()/cpuOvercommitRatio), newServiceOffering.getSpeed(), minMemory * 1024 * 1024, newServiceOffering.getRamSize() * 1024 * 1024, newServiceOffering.getLimitCpuUse());
+                (int) (newServiceOffering.getSpeed()/cpuOvercommitRatio), newServiceOffering.getSpeed(), minMemory * 1024 * 1024, newServiceOffering.getRamSize() * 1024 * 1024, newServiceOffering.getLimitCpuUse(), isDynamicallyScalable);
 
         Long dstHostId = vm.getHostId();
         ItWorkVO work = new ItWorkVO(UUID.randomUUID().toString(), _nodeId, State.Running, vm.getType(), vm.getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java b/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
index 8715c9e..1847a05 100644
--- a/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
+++ b/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
@@ -75,7 +75,7 @@ import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.UserDao;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.dao.UserVmDao;
-import com.cloud.vm.dao.VMInstanceDao;
+import com.cloud.vm.dao.UserVmDetailsDao;
 import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
 import org.apache.cloudstack.api.command.user.vm.ScaleVMCmd;
 import com.cloud.utils.Pair;
@@ -160,12 +160,15 @@ public class VirtualMachineManagerImplTest {
         ConfigurationServer _configServer;
         @Mock
         HostVO hostVO;
+        @Mock
+        UserVmDetailVO _vmDetailVO;
 
         @Mock ClusterDao _clusterDao;
         @Mock HostPodDao _podDao;
         @Mock DataCenterDao _dcDao;
         @Mock DiskOfferingDao _diskOfferingDao;
         @Mock PrimaryDataStoreDao _storagePoolDao;
+        @Mock UserVmDetailsDao _vmDetailsDao;
         @Mock StoragePoolHostDao _poolHostDao;
         @Mock NetworkManager _networkMgr;
         @Mock HypervisorGuruManager _hvGuruMgr;
@@ -206,6 +209,7 @@ public class VirtualMachineManagerImplTest {
             _vmMgr._vmSnapshotMgr = _vmSnapshotMgr;
             _vmMgr._vmDao = _vmInstanceDao;
             _vmMgr._configServer = _configServer;
+            _vmMgr._uservmDetailsDao = _vmDetailsDao;
 
             when(_vmMock.getId()).thenReturn(314l);
             when(_vmInstance.getId()).thenReturn(1L);
@@ -244,14 +248,20 @@ public class VirtualMachineManagerImplTest {
         DeployDestination dest = new DeployDestination(null, null, null, _host);
         long l = 1L;
 
+        doReturn(3L).when(_vmInstance).getId();
+        when(_vmDetailsDao.findDetail(3L, VirtualMachine.IsDynamicScalingEnabled)).thenReturn(_vmDetailVO);
+        doReturn("true").when(_vmDetailVO).getValue();
         when(_vmInstanceDao.findById(anyLong())).thenReturn(_vmInstance);
         ServiceOfferingVO newServiceOffering = getSvcoffering(512);
-        when(_hostDao.findById(_vmInstance.hostId)).thenReturn(hostVO);
+        doReturn(1L).when(_vmInstance).getHostId();
+        doReturn(hostVO).when(_hostDao).findById(1L);
+        doReturn(1L).when(_vmInstance).getDataCenterId();
         doReturn(1L).when(hostVO).getClusterId();
+        when(_configServer.getConfigValue(Config.EnableDynamicallyScaleVm.key(), Config.ConfigurationParameterScope.zone.toString(), 1L)).thenReturn("true");
         when(_configServer.getConfigValue(Config.MemOverprovisioningFactor.key(), Config.ConfigurationParameterScope.cluster.toString(), 1L)).thenReturn("1.0");
         when(_configServer.getConfigValue(Config.CPUOverprovisioningFactor.key(), Config.ConfigurationParameterScope.cluster.toString(), 1L)).thenReturn("1.0");
         ScaleVmCommand reconfigureCmd = new ScaleVmCommand("myVmName", newServiceOffering.getCpu(),
-                newServiceOffering.getSpeed(), newServiceOffering.getSpeed(), newServiceOffering.getRamSize(), newServiceOffering.getRamSize(), newServiceOffering.getLimitCpuUse());
+                newServiceOffering.getSpeed(), newServiceOffering.getSpeed(), newServiceOffering.getRamSize(), newServiceOffering.getRamSize(), newServiceOffering.getLimitCpuUse(), true);
         Answer answer = new ScaleVmAnswer(reconfigureCmd, true, "details");
         when(_agentMgr.send(2l, reconfigureCmd)).thenReturn(null);
         _vmMgr.reConfigureVm(_vmInstance, getSvcoffering(256), false);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8690837/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 9e14dbb..fde5fdb 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -1498,7 +1498,8 @@ CREATE VIEW `cloud`.`user_vm_view` AS
         affinity_group.id affinity_group_id,
         affinity_group.uuid affinity_group_uuid,
         affinity_group.name affinity_group_name,
-        affinity_group.description affinity_group_description
+        affinity_group.description affinity_group_description,
+        vm_details.value dynamically_scalable
 
     from
         `cloud`.`user_vm`
@@ -1559,10 +1560,13 @@ CREATE VIEW `cloud`.`user_vm_view` AS
         `cloud`.`async_job` ON async_job.instance_id = vm_instance.id
             and async_job.instance_type = 'VirtualMachine'
             and async_job.job_status = 0
-	left join 
-	`cloud`.`affinity_group_vm_map` ON vm_instance.id = affinity_group_vm_map.instance_id
-	left join 
-	`cloud`.`affinity_group` ON affinity_group_vm_map.affinity_group_id = affinity_group.id;
+            left join
+        `cloud`.`affinity_group_vm_map` ON vm_instance.id = affinity_group_vm_map.instance_id
+            left join
+        `cloud`.`affinity_group` ON affinity_group_vm_map.affinity_group_id = affinity_group.id
+            left join
+        `cloud`.`user_vm_details` vm_details ON vm_details.vm_id = vm_instance.id
+            and vm_details.name = 'enable.dynamic.scaling';
 
 DROP VIEW IF EXISTS `cloud`.`volume_view`;
 CREATE VIEW `cloud`.`volume_view` AS
@@ -1857,3 +1861,4 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'manag
 
 alter table `cloud`.`network_offerings` add column egress_default_policy boolean default false;
 
+ALTER TABLE `cloud`.`vm_template` ADD COLUMN `dynamically_scalable` tinyint(1) unsigned NOT NULL DEFAULT 0  COMMENT 'true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory';


[4/5] git commit: updated refs/heads/master-6-17-stable to 11a28aa

Posted by ja...@apache.org.
CLOUDSTACK-2794: Global parameter "router.template.id" should be removed The parameter was not in use. We use zone/global coonfigutaion parameters router.template.xenserver/vmware/hyperv/kvm/lxc to deploy router

Signed-off-by: Jayapal <ja...@apache.org>


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

Branch: refs/heads/master-6-17-stable
Commit: 98b47ab4667e57e110faa88a71ce2f78a2161a8b
Parents: 75d860b
Author: Harikrishna Patnala <ha...@citrix.com>
Authored: Fri Jun 28 14:38:34 2013 +0530
Committer: Jayapal <ja...@apache.org>
Committed: Fri Jun 28 18:50:56 2013 +0530

----------------------------------------------------------------------
 .../cloud/agent/manager/AgentManagerImpl.java   | 23 +++++++++++---------
 server/src/com/cloud/configuration/Config.java  |  1 -
 .../com/cloud/template/TemplateManagerImpl.java |  2 --
 setup/db/db/schema-410to420.sql                 |  1 +
 4 files changed, 14 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/98b47ab4/server/src/com/cloud/agent/manager/AgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java
index 6baeecf..917785e 100755
--- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -130,16 +130,19 @@ import edu.emory.mathcs.backport.java.util.Collections;
 /**
  * Implementation of the Agent Manager. This class controls the connection to the agents.
  *
- * @config {@table || Param Name | Description | Values | Default || || port | port to listen on for agent connection. | Integer
- *         | 8250 || || workers | # of worker threads | Integer | 5 || || router.template.id | default id for template | Integer
- *         | 1 || || router.ram.size | default ram for router vm in mb | Integer | 128 || || router.ip.address | ip address for
- *         the router | ip | 10.1.1.1 || || wait | Time to wait for control commands to return | seconds | 1800 || || domain |
- *         domain for domain routers| String | foo.com || || alert.wait | time to wait before alerting on a disconnected agent |
- *         seconds | 1800 || || update.wait | time to wait before alerting on a updating agent | seconds | 600 || ||
- *         ping.interval | ping interval in seconds | seconds | 60 || || instance.name | Name of the deployment String |
- *         required || || start.retry | Number of times to retry start | Number | 2 || || ping.timeout | multiplier to
- *         ping.interval before announcing an agent has timed out | float | 2.0x || || router.stats.interval | interval to
- *         report router statistics | seconds | 300s || * }
+ * @config {@table  || Param Name | Description | Values | Default ||
+ *                  || port | port to listen on for agent connection. | Integer | 8250 ||
+ *                  || workers | # of worker threads | Integer | 5 || || router.ram.size | default ram for router vm in mb | Integer | 128 ||
+ *                  || router.ip.address | ip address for the router | ip | 10.1.1.1 ||
+ *                  || wait | Time to wait for control commands to return | seconds | 1800 ||
+ *                  || domain | domain for domain routers| String | foo.com ||
+ *                  || alert.wait | time to wait before alerting on a disconnected agent | seconds | 1800 ||
+ *                  || update.wait | time to wait before alerting on a updating agent | seconds | 600 ||
+ *                  || ping.interval | ping interval in seconds | seconds | 60 ||
+ *                  || instance.name | Name of the deployment String | required ||
+ *                  || start.retry | Number of times to retry start | Number | 2 ||
+ *                  || ping.timeout | multiplier to ping.interval before announcing an agent has timed out | float | 2.0x ||
+ *                  || router.stats.interval | interval to report router statistics | seconds | 300s || }
  **/
 @Local(value = { AgentManager.class })
 public class AgentManagerImpl extends ManagerBase implements AgentManager, HandlerFactory {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/98b47ab4/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index e219077..4f971ed 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -172,7 +172,6 @@ public enum Config {
 	ExternalNetworkStatsInterval("Advanced", NetworkManager.class, Integer.class, "external.network.stats.interval", "300", "Interval (in seconds) to report external network statistics.", null),
 	RouterCheckInterval("Advanced", NetworkManager.class, Integer.class, "router.check.interval", "30", "Interval (in seconds) to report redundant router status.", null),
 	RouterCheckPoolSize("Advanced", NetworkManager.class, Integer.class, "router.check.poolsize", "10", "Numbers of threads using to check redundant router status.", null),
-	RouterTemplateId("Advanced", NetworkManager.class, Long.class, "router.template.id", "1", "Default ID for template.", null),
     RouterTemplateXen("Advanced", NetworkManager.class, String.class, "router.template.xen", "SystemVM Template (XenServer)", "Name of the default router template on Xenserver.", null, ConfigurationParameterScope.zone.toString()),
     RouterTemplateKVM("Advanced", NetworkManager.class, String.class, "router.template.kvm", "SystemVM Template (KVM)", "Name of the default router template on KVM.", null, ConfigurationParameterScope.zone.toString()),
     RouterTemplateVmware("Advanced", NetworkManager.class, String.class, "router.template.vmware", "SystemVM Template (vSphere)", "Name of the default router template on Vmware.", null, ConfigurationParameterScope.zone.toString()),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/98b47ab4/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index f04b868..81318a9 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -229,7 +229,6 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
     @Inject UploadDao _uploadDao;
     @Inject
     protected GuestOSDao _guestOSDao;
-    long _routerTemplateId = -1;
     @Inject StorageManager _storageMgr;
     @Inject AsyncJobManager _asyncMgr;
     @Inject UserVmManager _vmMgr;
@@ -1205,7 +1204,6 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
         
         final Map<String, String> configs = _configDao.getConfiguration("AgentManager", params);
-        _routerTemplateId = NumbersUtil.parseInt(configs.get("router.template.id"), 1);
 
         String value = _configDao.getValue(Config.PrimaryStorageDownloadWait.toString());
         _primaryStorageDownloadWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.PrimaryStorageDownloadWait.getDefaultValue()));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/98b47ab4/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index fde5fdb..8263ad2 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -30,6 +30,7 @@ INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hype
 UPDATE `cloud`.`hypervisor_capabilities` SET `storage_motion_supported`=true WHERE id=16;
 UPDATE `cloud`.`hypervisor_capabilities` SET `storage_motion_supported`=true WHERE id=11;
 DELETE FROM `cloud`.`configuration` where name='vmware.percluster.host.max';
+DELETE FROM `cloud`.`configuration` where name='router.template.id';
 INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'AgentManager', 'xen.nics.max', '7', 'Maximum allowed nics for Vms created on Xen');
 INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'midonet.apiserver.address', 'http://localhost:8081', 'Specify the address at which the Midonet API server can be contacted (if using Midonet)');
 INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'midonet.providerrouter.id', 'd7c5e6a3-e2f4-426b-b728-b7ce6a0448e5', 'Specifies the UUID of the Midonet provider router (if using Midonet)');


[3/5] git commit: updated refs/heads/master-6-17-stable to 11a28aa

Posted by ja...@apache.org.
CLOUDSTACK-2835: VR Deployement from admin registered template is failing because registered template type is user. Additional parameter "isrouter" in register/update template API for the root admin. True if registered template is of type ROUTING.

Signed-off-by: Jayapal <ja...@apache.org>


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

Branch: refs/heads/master-6-17-stable
Commit: 75d860b3ac03e7bec2d8849859584654bfb7d801
Parents: d869083
Author: Harikrishna Patnala <ha...@citrix.com>
Authored: Fri Jun 28 14:37:25 2013 +0530
Committer: Jayapal <ja...@apache.org>
Committed: Fri Jun 28 18:50:34 2013 +0530

----------------------------------------------------------------------
 api/src/com/cloud/storage/Storage.java          |  1 +
 .../org/apache/cloudstack/api/ApiConstants.java |  1 +
 .../api/BaseUpdateTemplateOrIsoCmd.java         |  7 +++++
 .../user/template/RegisterTemplateCmd.java      |  7 +++++
 .../user/template/UpdateTemplateCmd.java        |  1 +
 .../cloud/storage/dao/VMTemplateDaoImpl.java    | 19 +++++++++--
 .../com/cloud/upgrade/dao/Upgrade410to420.java  | 22 ++++++++++++-
 .../com/cloud/server/ManagementServerImpl.java  | 20 +++++++++++-
 .../src/com/cloud/storage/TemplateProfile.java  | 13 +++++++-
 .../src/com/cloud/template/TemplateAdapter.java |  5 ++-
 .../com/cloud/template/TemplateAdapterBase.java | 33 +++++++++++---------
 .../com/cloud/template/TemplateManagerImpl.java | 11 +++++--
 12 files changed, 116 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/75d860b3/api/src/com/cloud/storage/Storage.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/Storage.java b/api/src/com/cloud/storage/Storage.java
index c130fe2..5b44efd 100755
--- a/api/src/com/cloud/storage/Storage.java
+++ b/api/src/com/cloud/storage/Storage.java
@@ -84,6 +84,7 @@ public class Storage {
     }
 
     public static enum TemplateType {
+        ROUTING, // Router template
         SYSTEM, /* routing, system vm template */
         BUILTIN, /* buildin template */
         PERHOST, /* every host has this template, don't need to install it in secondary storage */

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/75d860b3/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index 170ee62..f23e353 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -507,6 +507,7 @@ public class ApiConstants {
     public static final String ACL_ID = "aclid";
     public static final String NUMBER = "number";
     public static final String IS_DYNAMICALLY_SCALABLE = "isdynamicallyscalable";
+    public static final String ROUTING = "isrouting";
 
     public enum HostDetails {
         all, capacity, events, stats, min;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/75d860b3/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java b/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
index b01c8d0..a4c5bfa 100644
--- a/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
@@ -57,6 +57,9 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
     @Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE, type = CommandType.BOOLEAN, description = "true if template/ISO contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory")
     private Boolean isDynamicallyScalable;
 
+    @Parameter(name = ApiConstants.ROUTING, type = CommandType.BOOLEAN, description = "true if the template type is routing i.e., if template is used to deploy router")
+    protected Boolean isRoutingType;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -96,4 +99,8 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
     public Boolean isDynamicallyScalable() {
         return isDynamicallyScalable;
     }
+
+    public Boolean isRoutingType() {
+        return isRoutingType;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/75d860b3/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
index 837faf6..5c2e274 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
@@ -121,6 +121,9 @@ public class RegisterTemplateCmd extends BaseCmd {
     @Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE, type = CommandType.BOOLEAN, description = "true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory")
     protected Boolean isDynamicallyScalable;
 
+    @Parameter(name = ApiConstants.ROUTING, type = CommandType.BOOLEAN, description = "true if the template type is routing i.e., if template is used to deploy router")
+    protected Boolean isRoutingType;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -215,6 +218,10 @@ public class RegisterTemplateCmd extends BaseCmd {
         return isDynamicallyScalable == null ? false : isDynamicallyScalable;
     }
 
+    public Boolean isRoutingType() {
+        return isRoutingType == null ? false : isRoutingType;
+    }
+
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/75d860b3/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java
index 3987dbe..21cc0fd 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java
@@ -70,6 +70,7 @@ public class UpdateTemplateCmd extends BaseUpdateTemplateOrIsoCmd {
         if (result != null) {
             TemplateResponse response = _responseGenerator.createIsoResponse(result);
             response.setObjectName("template");
+            response.setTemplateType(result.getTemplateType().toString());//Template can be either USER or ROUTING type
             response.setResponseName(getCommandName());
             this.setResponseObject(response);
         } else {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/75d860b3/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
index d45ef73..37020cd 100755
--- a/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
@@ -898,7 +898,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
 	@Override
 	public VMTemplateVO findRoutingTemplate(HypervisorType hType, String templateName) {
 	    SearchCriteria<VMTemplateVO> sc = tmpltTypeHyperSearch2.create();
-        sc.setParameters("templateType", Storage.TemplateType.SYSTEM);
+        sc.setParameters("templateType", TemplateType.ROUTING);
         sc.setParameters("hypervisorType", hType);
         if (templateName != null) {
             sc.setParameters("templateName", templateName);
@@ -910,7 +910,22 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
         if (tmplts.size() > 0) {
             return tmplts.get(0);
         } else {
-            return null;
+            sc = tmpltTypeHyperSearch2.create();
+            sc.setParameters("templateType", TemplateType.SYSTEM);
+            sc.setParameters("hypervisorType", hType);
+            if (templateName != null) {
+                sc.setParameters("templateName", templateName);
+            }
+
+            // order by descending order of id and select the first (this is going
+            // to be the latest)
+            tmplts = listBy(sc, new Filter(VMTemplateVO.class, "id", false, null, 1l));
+
+            if (tmplts.size() > 0) {
+                return tmplts.get(0);
+            } else {
+                return null;
+            }
         }
 	}
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/75d860b3/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
index 8378eec..90a311b 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -148,7 +148,7 @@ public class Upgrade410to420 implements DbUpgrade {
             s_logger.debug("Updating XenSever System Vms");
             //XenServer
             try {
-                //Get 4.2.0 xenserer system Vm template Id
+                //Get 4.2.0 XenServer system Vm template Id
                 pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name like 'systemvm-xenserver-4.2' and removed is null order by id desc limit 1");
                 rs = pstmt.executeQuery();
                 if(rs.next()){
@@ -165,6 +165,10 @@ public class Upgrade410to420 implements DbUpgrade {
                     pstmt.setLong(1, templateId);
                     pstmt.executeUpdate();
                     pstmt.close();
+                    // Change value of global configuration parameter router.template.xen
+                    pstmt = conn.prepareStatement("INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'NetworkManager', 'router.template.xen', 'systemvm-xenserver-4.2', 'Name of the default router template on Xenserver')");
+                    pstmt.execute();
+                    pstmt.close();
                 } else {
                     if (xenserver){
                         throw new CloudRuntimeException("4.2.0 XenServer SystemVm template not found. Cannot upgrade system Vms");
@@ -196,6 +200,10 @@ public class Upgrade410to420 implements DbUpgrade {
                     pstmt.setLong(1, templateId);
                     pstmt.executeUpdate();
                     pstmt.close();
+                    // Change value of global configuration parameter router.template.kvm
+                    pstmt = conn.prepareStatement("INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'NetworkManager', 'router.template.kvm', 'systemvm-kvm-4.2', 'Name of the default router template on KVM')");
+                    pstmt.execute();
+                    pstmt.close();
                 } else {
                     if (kvm){
                         throw new CloudRuntimeException("4.2.0 KVM SystemVm template not found. Cannot upgrade system Vms");
@@ -227,6 +235,10 @@ public class Upgrade410to420 implements DbUpgrade {
                     pstmt.setLong(1, templateId);
                     pstmt.executeUpdate();
                     pstmt.close();
+                    // Change value of global configuration parameter router.template.vmware
+                    pstmt = conn.prepareStatement("INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'NetworkManager', 'router.template.vmware', 'systemvm-vmware-4.2', 'Name of the default router template on Vmware')");
+                    pstmt.execute();
+                    pstmt.close();
                 } else {
                     if (VMware){
                         throw new CloudRuntimeException("4.2.0 VMware SystemVm template not found. Cannot upgrade system Vms");
@@ -258,6 +270,10 @@ public class Upgrade410to420 implements DbUpgrade {
                     pstmt.setLong(1, templateId);
                     pstmt.executeUpdate();
                     pstmt.close();
+                    // Change value of global configuration parameter router.template.hyperv
+                    pstmt = conn.prepareStatement("INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'NetworkManager', 'router.template.hyperv', 'systemvm-hyperv-4.2', 'Name of the default router template on Hyperv')");
+                    pstmt.execute();
+                    pstmt.close();
                 } else {
                     if (Hyperv){
                         throw new CloudRuntimeException("4.2.0 HyperV SystemVm template not found. Cannot upgrade system Vms");
@@ -289,6 +305,10 @@ public class Upgrade410to420 implements DbUpgrade {
                     pstmt.setLong(1, templateId);
                     pstmt.executeUpdate();
                     pstmt.close();
+                    // Change value of global configuration parameter router.template.lxc
+                    pstmt = conn.prepareStatement("INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'NetworkManager', 'router.template.lxc', 'systemvm-lxc-4.2', 'Name of the default router template on LXC')");
+                    pstmt.execute();
+                    pstmt.close();
                 } else {
                     if (LXC){
                         throw new CloudRuntimeException("4.2.0 LXC SystemVm template not found. Cannot upgrade system Vms");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/75d860b3/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 69c3f6c..7023687 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -508,6 +508,7 @@ import com.cloud.storage.StoragePool;
 import com.cloud.storage.Upload;
 import com.cloud.storage.Upload.Mode;
 import com.cloud.storage.UploadVO;
+import com.cloud.storage.Storage.TemplateType;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.Volume;
 import com.cloud.storage.VolumeManager;
@@ -529,6 +530,7 @@ import com.cloud.template.TemplateManager;
 import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
+import com.cloud.user.AccountService;
 import com.cloud.user.SSHKeyPair;
 import com.cloud.user.SSHKeyPairVO;
 import com.cloud.user.User;
@@ -766,6 +768,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     ConfigurationServer _configServer;
     @Inject
     UserVmManager _userVmMgr;
+    @Inject
+    AccountService _accountService;
 
     private final ScheduledExecutorService _eventExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("EventChecker"));
     private final ScheduledExecutorService _alertExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("AlertChecker"));
@@ -1874,6 +1878,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         Boolean bootable = cmd.isBootable();
         Integer sortKey = cmd.getSortKey();
         Boolean isDynamicallyScalable = cmd.isDynamicallyScalable();
+        Boolean isRoutingTemplate = cmd.isRoutingType();
         Account account = UserContext.current().getCaller();
 
         // verify that template exists
@@ -1894,8 +1899,13 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         // do a permission check
         _accountMgr.checkAccess(account, AccessType.ModifyEntry, true, template);
 
+        if(cmd.isRoutingType() != null){
+            if(!_accountService.isRootAdmin(account.getType())){
+                throw new PermissionDeniedException("Parameter isrouting can only be specified by a Root Admin, permission denied");
+            }
+        }
         boolean updateNeeded = !(name == null && displayText == null && format == null && guestOSId == null && passwordEnabled == null
-                && bootable == null && sortKey == null && isDynamicallyScalable == null);
+                && bootable == null && sortKey == null && isDynamicallyScalable == null && isRoutingTemplate == null);
         if (!updateNeeded) {
             return template;
         }
@@ -1948,6 +1958,14 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
             template.setDynamicallyScalable(isDynamicallyScalable);
         }
 
+        if (isRoutingTemplate != null) {
+            if (isRoutingTemplate) {
+                template.setTemplateType(TemplateType.ROUTING);
+            } else {
+                template.setTemplateType(TemplateType.USER);
+            }
+        }
+
         _templateDao.update(id, template);
 
         return _templateDao.findById(id);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/75d860b3/server/src/com/cloud/storage/TemplateProfile.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/TemplateProfile.java b/server/src/com/cloud/storage/TemplateProfile.java
index ca23d00..b5a1f55 100755
--- a/server/src/com/cloud/storage/TemplateProfile.java
+++ b/server/src/com/cloud/storage/TemplateProfile.java
@@ -20,6 +20,7 @@ import java.util.Map;
 
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.Storage.ImageFormat;
+import com.cloud.storage.Storage.TemplateType;
 
 public class TemplateProfile {	
 	Long userId;
@@ -48,6 +49,7 @@ public class TemplateProfile {
 	Long imageStoreId;
 	Map details;
     Boolean isDynamicallyScalable;
+    TemplateType templateType;
 	
 	public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
 			String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId,
@@ -85,12 +87,13 @@ public class TemplateProfile {
     public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
             String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId,
             HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, String templateTag, Map details, Boolean sshKeyEnabled,
-            Long imageStoreId, Boolean isDynamicallyScalable) {
+            Long imageStoreId, Boolean isDynamicallyScalable, TemplateType templateType) {
         this(templateId, userId, name, displayText, bits, passwordEnabled, requiresHvm, url, isPublic, featured, isExtractable, format, guestOsId, zoneId,
                 hypervisorType, accountName, domainId, accountId, chksum, bootable, details, sshKeyEnabled);
         this.templateTag = templateTag;
         this.imageStoreId = imageStoreId;
         this.isDynamicallyScalable = isDynamicallyScalable;
+        this.templateType = templateType;
     }	
 	
 	public Long getTemplateId() {
@@ -268,4 +271,12 @@ public class TemplateProfile {
     public void setScalabe(Boolean isDynamicallyScalabe) {
         this.isDynamicallyScalable = isDynamicallyScalabe;
     }
+
+    public TemplateType getTemplateType() {
+        return templateType;
+    }
+
+    public void setTemplateType(TemplateType templateType) {
+        this.templateType = templateType;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/75d860b3/server/src/com/cloud/template/TemplateAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateAdapter.java b/server/src/com/cloud/template/TemplateAdapter.java
index bb7cd23..c280542 100755
--- a/server/src/com/cloud/template/TemplateAdapter.java
+++ b/server/src/com/cloud/template/TemplateAdapter.java
@@ -28,6 +28,7 @@ import com.cloud.exception.ResourceAllocationException;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.TemplateProfile;
 import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.Storage.TemplateType;
 import com.cloud.user.Account;
 import com.cloud.utils.component.Adapter;
 
@@ -69,5 +70,7 @@ public interface TemplateAdapter extends Adapter {
     public TemplateProfile prepare(boolean isIso, long userId, String name, String displayText, Integer bits,
             Boolean passwordEnabled, Boolean requiresHVM, String url, Boolean isPublic, Boolean featured,
             Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
-            String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshKeyEnabled, String imageStoreUuid, Boolean isDynamicallyScalable) throws ResourceAllocationException;
+            String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshKeyEnabled,
+            String imageStoreUuid, Boolean isDynamicallyScalable, TemplateType templateType) throws ResourceAllocationException;
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/75d860b3/server/src/com/cloud/template/TemplateAdapterBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateAdapterBase.java b/server/src/com/cloud/template/TemplateAdapterBase.java
index c57697b..0158917 100755
--- a/server/src/com/cloud/template/TemplateAdapterBase.java
+++ b/server/src/com/cloud/template/TemplateAdapterBase.java
@@ -104,14 +104,14 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
             Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
             String accountName, Long domainId, String chksum, Boolean bootable, Map details) throws ResourceAllocationException {
 	    return prepare(isIso, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic, featured, isExtractable, format, guestOSId, zoneId, hypervisorType,
-	            chksum, bootable, null, null, details, false, null, false);
+	            chksum, bootable, null, null, details, false, null, false, TemplateType.USER);
 	}
 	
 	public TemplateProfile prepare(boolean isIso, long userId, String name, String displayText, Integer bits,
 			Boolean passwordEnabled, Boolean requiresHVM, String url, Boolean isPublic, Boolean featured,
 			Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
 			String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshkeyEnabled,
-			String imageStoreUuid, Boolean isDynamicallyScalable) throws ResourceAllocationException {
+			String imageStoreUuid, Boolean isDynamicallyScalable, TemplateType templateType) throws ResourceAllocationException {
 		//Long accountId = null;
 		// parameters verification
 		
@@ -225,8 +225,10 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
         
         Long id = _tmpltDao.getNextInSequence(Long.class, "id");
         UserContext.current().setEventDetails("Id: " +id+ " name: " + name);
-		return new TemplateProfile(id, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic,
-				featured, isExtractable, imgfmt, guestOSId, zoneId, hypervisorType, templateOwner.getAccountName(), templateOwner.getDomainId(), templateOwner.getAccountId(), chksum, bootable, templateTag, details, sshkeyEnabled, imageStoreId, isDynamicallyScalable);
+
+        return new TemplateProfile(id, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic,
+                featured, isExtractable, imgfmt, guestOSId, zoneId, hypervisorType, templateOwner.getAccountName(), templateOwner.getDomainId(),
+                templateOwner.getAccountId(), chksum, bootable, templateTag, details, sshkeyEnabled, imageStoreId, isDynamicallyScalable, templateType);
 	}
 	
 	@Override
@@ -235,13 +237,13 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
         Account caller = UserContext.current().getCaller();
         Account owner = _accountMgr.getAccount(cmd.getEntityOwnerId());
         _accountMgr.checkAccess(caller, null, true, owner);
-	    
 
-        
-		return prepare(false, UserContext.current().getCallerUserId(), cmd.getTemplateName(), cmd.getDisplayText(),
-				cmd.getBits(), cmd.isPasswordEnabled(), cmd.getRequiresHvm(), cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(),
-				cmd.isExtractable(), cmd.getFormat(), cmd.getOsTypeId(), cmd.getZoneId(), HypervisorType.getType(cmd.getHypervisor()),
-				cmd.getChecksum(), true, cmd.getTemplateTag(), owner, cmd.getDetails(), cmd.isSshKeyEnabled(), cmd.getImageStoreUuid(), cmd.isDynamicallyScalable());
+    return prepare(false, UserContext.current().getCallerUserId(), cmd.getTemplateName(), cmd.getDisplayText(),
+                cmd.getBits(), cmd.isPasswordEnabled(), cmd.getRequiresHvm(), cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(),
+                cmd.isExtractable(), cmd.getFormat(), cmd.getOsTypeId(), cmd.getZoneId(), HypervisorType.getType(cmd.getHypervisor()),
+                cmd.getChecksum(), true, cmd.getTemplateTag(), owner, cmd.getDetails(), cmd.isSshKeyEnabled(), cmd.getImageStoreUuid(), cmd.isDynamicallyScalable(),
+                cmd.isRoutingType() ? TemplateType.ROUTING : TemplateType.USER);
+
 	}
 
 	public TemplateProfile prepare(RegisterIsoCmd cmd) throws ResourceAllocationException {
@@ -249,16 +251,17 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
 	    Account caller = UserContext.current().getCaller();
 	    Account owner = _accountMgr.getAccount(cmd.getEntityOwnerId());
 	    _accountMgr.checkAccess(caller, null, true, owner);
-	   
-		return prepare(true, UserContext.current().getCallerUserId(), cmd.getIsoName(), cmd.getDisplayText(), 64, false,
-					true, cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(), cmd.isExtractable(), ImageFormat.ISO.toString(), cmd.getOsTypeId(),
-					cmd.getZoneId(), HypervisorType.None, cmd.getChecksum(), cmd.isBootable(), null, owner, null, false, cmd.getImageStoreUuid(), cmd.isDynamicallyScalable());
+
+        return prepare(true, UserContext.current().getCallerUserId(), cmd.getIsoName(), cmd.getDisplayText(), 64, false,
+                true, cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(), cmd.isExtractable(), ImageFormat.ISO.toString(), cmd.getOsTypeId(),
+                cmd.getZoneId(), HypervisorType.None, cmd.getChecksum(), cmd.isBootable(), null, owner, null, false, cmd.getImageStoreUuid(), cmd.isDynamicallyScalable(),
+                TemplateType.USER);
 	}
 	
 	protected VMTemplateVO persistTemplate(TemplateProfile profile) {
 		Long zoneId = profile.getZoneId();
 		VMTemplateVO template = new VMTemplateVO(profile.getTemplateId(), profile.getName(), profile.getFormat(), profile.getIsPublic(),
-				profile.getFeatured(), profile.getIsExtractable(), TemplateType.USER, profile.getUrl(), profile.getRequiresHVM(),
+				profile.getFeatured(), profile.getIsExtractable(), profile.getTemplateType(), profile.getUrl(), profile.getRequiresHVM(),
 				profile.getBits(), profile.getAccountId(), profile.getCheckSum(), profile.getDisplayText(),
 				profile.getPasswordEnabled(), profile.getGuestOsId(), profile.getBootable(), profile.getHypervisorType(), profile.getTemplateTag(), 
 				profile.getDetails(), profile.getSshKeyEnabled(), profile.IsDynamicallyScalable());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/75d860b3/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index 517d4ba..f04b868 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -304,17 +304,22 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_TEMPLATE_CREATE, eventDescription = "creating template")
     public VirtualMachineTemplate registerTemplate(RegisterTemplateCmd cmd) throws URISyntaxException, ResourceAllocationException{
+        Account account = UserContext.current().getCaller();
         if(cmd.getTemplateTag() != null){
-            Account account = UserContext.current().getCaller();
             if(!_accountService.isRootAdmin(account.getType())){
                 throw new PermissionDeniedException("Parameter templatetag can only be specified by a Root Admin, permission denied");
             }
         }
-        
+        if(cmd.isRoutingType() != null){
+            if(!_accountService.isRootAdmin(account.getType())){
+                throw new PermissionDeniedException("Parameter isrouting can only be specified by a Root Admin, permission denied");
+            }
+        }
+
     	TemplateAdapter adapter = getAdapter(HypervisorType.getType(cmd.getHypervisor()));
     	TemplateProfile profile = adapter.prepare(cmd);
     	VMTemplateVO template = adapter.create(profile);
-    	
+
     	if (template != null){
         	return template;
         }else {


[5/5] git commit: updated refs/heads/master-6-17-stable to 11a28aa

Posted by ja...@apache.org.
CLOUDSTACK-3245: non admin user not able to register template

Signed-off-by: Jayapal <ja...@apache.org>


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

Branch: refs/heads/master-6-17-stable
Commit: 11a28aae455ba070a8afa105a51a758a78762f9e
Parents: 98b47ab
Author: Harikrishna Patnala <ha...@citrix.com>
Authored: Fri Jun 28 14:41:32 2013 +0530
Committer: Jayapal <ja...@apache.org>
Committed: Fri Jun 28 18:51:02 2013 +0530

----------------------------------------------------------------------
 .../api/command/user/template/RegisterTemplateCmd.java           | 2 +-
 server/src/com/cloud/template/TemplateAdapterBase.java           | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/11a28aae/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
index 5c2e274..fd007fe 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
@@ -219,7 +219,7 @@ public class RegisterTemplateCmd extends BaseCmd {
     }
 
     public Boolean isRoutingType() {
-        return isRoutingType == null ? false : isRoutingType;
+        return isRoutingType;
     }
 
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/11a28aae/server/src/com/cloud/template/TemplateAdapterBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateAdapterBase.java b/server/src/com/cloud/template/TemplateAdapterBase.java
index 0158917..ef32b6b 100755
--- a/server/src/com/cloud/template/TemplateAdapterBase.java
+++ b/server/src/com/cloud/template/TemplateAdapterBase.java
@@ -238,11 +238,13 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
         Account owner = _accountMgr.getAccount(cmd.getEntityOwnerId());
         _accountMgr.checkAccess(caller, null, true, owner);
 
+        boolean isRouting = (cmd.isRoutingType() == null) ? false : cmd.isRoutingType();
+
     return prepare(false, UserContext.current().getCallerUserId(), cmd.getTemplateName(), cmd.getDisplayText(),
                 cmd.getBits(), cmd.isPasswordEnabled(), cmd.getRequiresHvm(), cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(),
                 cmd.isExtractable(), cmd.getFormat(), cmd.getOsTypeId(), cmd.getZoneId(), HypervisorType.getType(cmd.getHypervisor()),
                 cmd.getChecksum(), true, cmd.getTemplateTag(), owner, cmd.getDetails(), cmd.isSshKeyEnabled(), cmd.getImageStoreUuid(), cmd.isDynamicallyScalable(),
-                cmd.isRoutingType() ? TemplateType.ROUTING : TemplateType.USER);
+                isRouting ? TemplateType.ROUTING : TemplateType.USER);
 
 	}