You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ap...@apache.org on 2013/06/26 12:40:42 UTC

[1/4] git commit: updated refs/heads/master to c059153

Updated Branches:
  refs/heads/master ea7b4467d -> c0591531d


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: Abhinandan Prateek <ap...@apache.org>


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

Branch: refs/heads/master
Commit: ec2bf092847a12f0f29c26a01ecfc6add90fedb2
Parents: ea7b446
Author: Harikrishna Patnala <ha...@citrix.com>
Authored: Tue Jun 25 12:43:31 2013 +0530
Committer: Abhinandan Prateek <ap...@apache.org>
Committed: Wed Jun 26 15:56:40 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/ec2bf092/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 fb857a7..b24a238 100755
--- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -126,16 +126,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/ec2bf092/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 3a6d3aa..ba50849 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -175,7 +175,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/ec2bf092/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 273614c..cbf70fa 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -257,7 +257,6 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
     UploadDao _uploadDao;
     @Inject
     protected GuestOSDao _guestOSDao;
-    long _routerTemplateId = -1;
     @Inject
     StorageManager _storageMgr;
     @Inject
@@ -819,7 +818,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/ec2bf092/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index d2add32..2d0f8de 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/4] git commit: updated refs/heads/master to c059153

Posted by ap...@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: Abhinandan Prateek <ap...@apache.org>


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

Branch: refs/heads/master
Commit: 9385cf045359c9dd844548bdc701f4f614f37c68
Parents: 0d1f512
Author: Harikrishna Patnala <ha...@citrix.com>
Authored: Mon Jun 24 16:31:33 2013 +0530
Committer: Abhinandan Prateek <ap...@apache.org>
Committed: Wed Jun 26 16:00:12 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  | 24 +++++++++++++++--
 .../com/cloud/server/ManagementServerImpl.java  | 20 ++++++++++++++-
 .../src/com/cloud/storage/TemplateProfile.java  | 12 ++++++++-
 .../src/com/cloud/template/TemplateAdapter.java |  4 ++-
 .../com/cloud/template/TemplateAdapterBase.java | 27 +++++++++++---------
 .../com/cloud/template/TemplateManagerImpl.java |  7 ++++-
 12 files changed, 110 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9385cf04/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 16ef019..9a50ffa 100755
--- a/api/src/com/cloud/storage/Storage.java
+++ b/api/src/com/cloud/storage/Storage.java
@@ -85,6 +85,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/9385cf04/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 8ac7c3f..809e023 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -511,6 +511,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/9385cf04/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/9385cf04/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 6a8e555..13bd5da 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
@@ -117,6 +117,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 ///////////////////////
     /////////////////////////////////////////////////////
@@ -208,6 +211,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/9385cf04/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 9f55f9d..b4149c0 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.createTemplateUpdateResponse(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/9385cf04/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 e7b85f8..ad33e7a 100755
--- a/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
@@ -790,7 +790,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);
@@ -803,7 +803,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/9385cf04/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 8f63a6c..c67a971 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -163,7 +163,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()){
@@ -180,6 +180,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");
@@ -209,7 +213,11 @@ public class Upgrade410to420 implements DbUpgrade {
                     // update templete ID of system Vms
                     pstmt = conn.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = 'KVM'");
                     pstmt.setLong(1, templateId);
-                    pstmt.executeUpdate();
+                    pstmt.execute();
+                    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){
@@ -242,6 +250,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");
@@ -273,6 +285,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");
@@ -304,6 +320,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/9385cf04/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 97bac1b..40bc437 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -486,6 +486,7 @@ import com.cloud.storage.GuestOsCategory;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePool;
+import com.cloud.storage.Storage.TemplateType;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.Volume;
 import com.cloud.storage.VolumeManager;
@@ -506,6 +507,7 @@ import com.cloud.tags.dao.ResourceTagDao;
 import com.cloud.template.TemplateManager;
 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;
@@ -679,6 +681,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     UserVmManager _userVmMgr;
     @Inject
     VolumeDataFactory _volFactory;
+    @Inject
+    AccountService _accountService;
 
     private final ScheduledExecutorService _eventExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("EventChecker"));
     private final ScheduledExecutorService _alertExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("AlertChecker"));
@@ -1732,6 +1736,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
@@ -1752,8 +1757,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;
         }
@@ -1806,6 +1816,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/9385cf04/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 00aab4d..e87a805 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;
@@ -47,6 +48,7 @@ public class TemplateProfile {
 	String templateTag;
 	Map details;
     Boolean isDynamicallyScalable;
+    TemplateType templateType;
 	
 
 	public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
@@ -86,11 +88,12 @@ public class TemplateProfile {
             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.isDynamicallyScalable = isDynamicallyScalable;
+        this.templateType = templateType;
     }	
 
 	public Long getTemplateId() {
@@ -265,4 +268,11 @@ public class TemplateProfile {
         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/9385cf04/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 d50d45b..17c6347 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,6 +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/9385cf04/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 c1f0604..7835680 100755
--- a/server/src/com/cloud/template/TemplateAdapterBase.java
+++ b/server/src/com/cloud/template/TemplateAdapterBase.java
@@ -106,7 +106,7 @@ 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);
 	}
 
 	@Override
@@ -114,7 +114,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
 			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
 
@@ -214,8 +214,9 @@ 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, null, 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, null, isDynamicallyScalable, templateType);
 
 	}
 
@@ -228,10 +229,11 @@ 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(), null, 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(), null, cmd.isDynamicallyScalable(),
+                cmd.isRoutingType() ? TemplateType.ROUTING : TemplateType.USER);
 
 	}
 
@@ -242,15 +244,16 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
 	    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());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9385cf04/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 cbf70fa..f70d44d 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -347,12 +347,17 @@ 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);


[4/4] git commit: updated refs/heads/master to c059153

Posted by ap...@apache.org.
CLOUDSTACK-3187: cluster.(cpu/memory).allocated.capacity.disablethreshold in not considering overcommit factor. cluster is getting disable based on actual use

Signed-off-by: Abhinandan Prateek <ap...@apache.org>


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

Branch: refs/heads/master
Commit: c0591531d8f29505f2f53c008b6d3fb9d8399b94
Parents: 9385cf0
Author: Harikrishna Patnala <ha...@citrix.com>
Authored: Tue Jun 25 17:34:24 2013 +0530
Committer: Abhinandan Prateek <ap...@apache.org>
Committed: Wed Jun 26 16:02:21 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/capacity/dao/CapacityDaoImpl.java  | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0591531/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java b/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java
index d14ad87..cecc145 100755
--- a/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java
+++ b/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java
@@ -119,7 +119,7 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
     /* In the below query"LIST_CLUSTERS_CROSSING_THRESHOLD" the threshold value is getting from the cluster_details table if not present then it gets from the global configuration
     *
     * CASE statement works like
-    * if (cluster_details table has thershold value)
+    * if (cluster_details table has threshold value)
     * then
     *     if (value from the cluster_details table is not null)
     *     then
@@ -132,15 +132,15 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
     *     */
     private static final String LIST_CLUSTERS_CROSSING_THRESHOLD = "SELECT clusterList.cluster_id " +
                        "FROM (	SELECT cluster.cluster_id cluster_id, ( (sum(cluster.used) + sum(cluster.reserved) + ?)/sum(cluster.total) ) ratio, cluster.configValue value " +
-                                "FROM (	SELECT capacity.cluster_id cluster_id, capacity.used_capacity used, capacity.reserved_capacity reserved, capacity.total_capacity total, " +
+                                "FROM (	SELECT capacity.cluster_id cluster_id, capacity.used_capacity used, capacity.reserved_capacity reserved, capacity.total_capacity * overcommit.value total, " +
                                             "CASE (SELECT count(*) FROM `cloud`.`cluster_details` details WHERE details.cluster_id = capacity.cluster_id AND details.name = ? ) " +
                                                 "WHEN 1 THEN (	CASE WHEN (SELECT details.value FROM `cloud`.`cluster_details` details WHERE details.cluster_id = capacity.cluster_id AND details.name = ?) is NULL " +
                                                                     "THEN (SELECT config.value FROM `cloud`.`configuration` config WHERE config.name = ?)" +
                                                                     "ELSE (SELECT details.value FROM `cloud`.`cluster_details` details WHERE details.cluster_id = capacity.cluster_id AND details.name = ? ) END )"  +
                                                 "ELSE (	SELECT config.value FROM `cloud`.`configuration` config WHERE config.name = ?) " +
                                             "END configValue " +
-                                        "FROM `cloud`.`op_host_capacity` capacity " +
-                                        "WHERE capacity.data_center_id = ? AND capacity.capacity_type = ? AND capacity.total_capacity > 0) cluster " +
+                                        "FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`cluster_details` overcommit ON overcommit.cluster_id = capacity.cluster_id " +
+                                        "WHERE capacity.data_center_id = ? AND capacity.capacity_type = ? AND capacity.total_capacity > 0 AND overcommit.name = ?) cluster " +
 
                                 "GROUP BY cluster.cluster_id)  clusterList " +
                         "WHERE clusterList.ratio > clusterList.value; ";
@@ -180,14 +180,19 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
          // we need to check with disabled thresholds of each cluster if not defined at cluster consider the global value
          try {
              pstmt = txn.prepareAutoCloseStatement(sql.toString());
-             pstmt.setLong(1,compute_requested);
+             pstmt.setLong(1, compute_requested);
              pstmt.setString(2, configName);
              pstmt.setString(3, configName);
              pstmt.setString(4, configName);
              pstmt.setString(5, configName);
              pstmt.setString(6, configName);
-             pstmt.setLong(7,zoneId);
-             pstmt.setShort(8,capacityType);
+             pstmt.setLong(7, zoneId);
+             pstmt.setShort(8, capacityType);
+             if (capacityType == 0) {
+                 pstmt.setString(9, "memoryOvercommitRatio");
+             } else if(capacityType == 1) {
+                pstmt.setString(9, "cpuOvercommitRatio");
+             }
 
              ResultSet rs = pstmt.executeQuery();
              while (rs.next()) {


[2/4] git commit: updated refs/heads/master to c059153

Posted by ap...@apache.org.
CLOUDSTACK-3208: showing xenhost username and password details in plain text in logs when we pefrom removehost from CS

Signed-off-by: Abhinandan Prateek <ap...@apache.org>


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

Branch: refs/heads/master
Commit: 0d1f512728f909aec296bf0e1cfbcdcaf2f563f6
Parents: ec2bf09
Author: Harikrishna Patnala <ha...@citrix.com>
Authored: Wed Jun 26 15:25:40 2013 +0530
Committer: Abhinandan Prateek <ap...@apache.org>
Committed: Wed Jun 26 15:57:31 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0d1f5127/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java
index e4dd675..5af1781 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java
@@ -550,7 +550,7 @@ public class XenServerConnectionPool {
                     }
                 } catch (UuidInvalid e) {
                     String msg = "Host(" + hostUuid + ") doesn't belong to pool(" + poolUuid + "), please execute 'xe pool-join master-address=" + mConn.getIp()
-                        + " master-username=" + mConn.getUsername() + " master-password=" + mConn.getPassword();
+                        + " master-username=" + mConn.getUsername();
                     if (s_logger.isDebugEnabled()) {
                         s_logger.debug(msg);
                     }