You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2015/01/20 07:41:46 UTC

[1/8] git commit: updated refs/heads/4.5 to 31a6517

Repository: cloudstack
Updated Branches:
  refs/heads/4.5 4e01d61f8 -> 31a651740


CLOUDSTACK-7916: Generate Alerts if System VMs cannot be started.

(cherry picked from commit 3907bc6f9d2b4a61a4d0b32e5c1a15d95210531e)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: a12ab8a2b3a14d2fed2bca287823bb558d0501fb
Parents: 4e01d61
Author: Nitin Mehta <ni...@citrix.com>
Authored: Fri Nov 14 13:18:27 2014 -0800
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:55:36 2015 +0530

----------------------------------------------------------------------
 .../cloud/alert/ConsoleProxyAlertAdapter.java   |  12 +-
 .../alert/SecondaryStorageVmAlertAdapter.java   |  11 +-
 .../consoleproxy/ConsoleProxyManagerImpl.java   |  74 +++++++------
 .../SecondaryStorageManagerImpl.java            | 110 ++++++++++---------
 4 files changed, 112 insertions(+), 95 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a12ab8a2/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java b/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java
index df4f5ba..4ca5f4a 100644
--- a/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java
+++ b/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java
@@ -53,7 +53,8 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
 
         DataCenterVO dc = _dcDao.findById(args.getZoneId());
         ConsoleProxyVO proxy = args.getProxy();
-        if (proxy == null)
+        //FIXME - Proxy can be null in case of creation failure. Have a better fix than checking for != 0
+        if (proxy == null && args.getProxyId() != 0)
             proxy = _consoleProxyDao.findById(args.getProxyId());
 
         switch (args.getType()) {
@@ -98,12 +99,9 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
 
             case ConsoleProxyAlertEventArgs.PROXY_CREATE_FAILURE:
                 if (s_logger.isDebugEnabled())
-                    s_logger.debug("Console proxy creation failure, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " +
-                        proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
-
-                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(),
-                    "Console proxy creation failure. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() +
-                        ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()) + ", error details: " + args.getMessage(),
+                    s_logger.debug("Console proxy creation failure, zone: " + dc.getName());
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), null,
+                    "Console proxy creation failure. zone: " + dc.getName() + ", error details: " + args.getMessage(),
                     "Console proxy creation failure (zone " + dc.getName() + ")");
                 break;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a12ab8a2/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java b/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java
index b7834bb..3bfedce 100644
--- a/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java
+++ b/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java
@@ -53,7 +53,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert
 
         DataCenterVO dc = _dcDao.findById(args.getZoneId());
         SecondaryStorageVmVO secStorageVm = args.getSecStorageVm();
-        if (secStorageVm == null)
+        if (secStorageVm == null && args.getSecStorageVmId() != 0)
             secStorageVm = _ssvmDao.findById(args.getSecStorageVmId());
 
         switch (args.getType()) {
@@ -103,13 +103,10 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert
 
             case SecStorageVmAlertEventArgs.SSVM_CREATE_FAILURE:
                 if (s_logger.isDebugEnabled())
-                    s_logger.debug("Secondary Storage Vm creation failure, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " +
-                        secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
+                    s_logger.debug("Secondary Storage Vm creation failure, zone: " + dc.getName());
 
-                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(), secStorageVm.getPodIdToDeployIn(),
-                    "Secondary Storage Vm creation failure. zone: " +
-                        dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " +
-                        (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()) + ", error details: " + args.getMessage(),
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(), null,
+                    "Secondary Storage Vm creation failure. zone: " + dc.getName() + ", error details: " + args.getMessage(),
                     "Secondary Storage Vm creation failure (zone " + dc.getName() + ")");
                 break;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a12ab8a2/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index 7f2b52a..a527160 100755
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -535,6 +535,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
             if (proxy.getState() == VirtualMachine.State.Stopped) {
                 _itMgr.advanceStart(proxy.getUuid(), null, null);
                 proxy = _consoleProxyDao.findById(proxy.getId());
+                return proxy;
             }
 
             // For VMs that are in Stopping, Starting, Migrating state, let client to wait by returning null
@@ -664,9 +665,6 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("Unable to allocate console proxy storage, remove the console proxy record from DB, proxy id: " + proxyVmId);
             }
-
-            SubscriptionMgr.getInstance().notifySubscribers(ConsoleProxyManager.ALERT_SUBJECT, this,
-                new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_CREATE_FAILURE, dataCenterId, proxyVmId, null, "Unable to allocate storage"));
         }
         return null;
     }
@@ -883,43 +881,57 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
         }
 
         ConsoleProxyVO proxy = null;
-        if (_allocProxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
-            try {
-                proxy = assignProxyFromStoppedPool(dataCenterId);
-                if (proxy == null) {
-                    if (s_logger.isInfoEnabled()) {
-                        s_logger.info("No stopped console proxy is available, need to allocate a new console proxy");
-                    }
+        String errorString = null;
+        try{
+            if (_allocProxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
+                try {
+                    proxy = assignProxyFromStoppedPool(dataCenterId);
+                    if (proxy == null) {
+                        if (s_logger.isInfoEnabled()) {
+                            s_logger.info("No stopped console proxy is available, need to allocate a new console proxy");
+                        }
 
-                    try {
-                        proxy = startNew(dataCenterId);
-                    } catch (ConcurrentOperationException e) {
-                        s_logger.info("Concurrent Operation caught " + e);
-                    }
-                } else {
-                    if (s_logger.isInfoEnabled()) {
-                        s_logger.info("Found a stopped console proxy, bring it up to running pool. proxy vm id : " + proxy.getId());
+                        try {
+                            proxy = startNew(dataCenterId);
+                        } catch (ConcurrentOperationException e) {
+                            s_logger.info("Concurrent Operation caught " + e);
+                        }
+                    } else {
+                        if (s_logger.isInfoEnabled()) {
+                            s_logger.info("Found a stopped console proxy, bring it up to running pool. proxy vm id : " + proxy.getId());
+                        }
                     }
+                } finally {
+                    _allocProxyLock.unlock();
+                }
+            } else {
+                if (s_logger.isInfoEnabled()) {
+                    s_logger.info("Unable to acquire proxy allocation lock, skip for next time");
                 }
-            } finally {
-                _allocProxyLock.unlock();
-            }
-        } else {
-            if (s_logger.isInfoEnabled()) {
-                s_logger.info("Unable to acquire proxy allocation lock, skip for next time");
             }
-        }
-
-        if (proxy != null) {
-            long proxyVmId = proxy.getId();
-            proxy = startProxy(proxyVmId);
 
             if (proxy != null) {
-                if (s_logger.isInfoEnabled()) {
-                    s_logger.info("Console proxy " + proxy.getHostName() + " is started");
+                long proxyVmId = proxy.getId();
+                proxy = startProxy(proxyVmId);
+
+                if (proxy != null) {
+                    if (s_logger.isInfoEnabled()) {
+                        s_logger.info("Console proxy " + proxy.getHostName() + " is started");
+                    }
+                    SubscriptionMgr.getInstance().notifySubscribers(ConsoleProxyManager.ALERT_SUBJECT, this,
+                        new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_UP, dataCenterId, proxy.getId(), proxy, null));
                 }
             }
+        }catch (Exception e){
+           errorString = e.getMessage();
+        }finally {
+            // TODO - For now put all the alerts as creation failure. Distinguish between creation vs start failure in future.
+            // Also add failure reason since startvm masks some of them.
+            if(proxy == null || proxy.getState() != State.Running)
+                SubscriptionMgr.getInstance().notifySubscribers(ConsoleProxyManager.ALERT_SUBJECT, this,
+                    new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_CREATE_FAILURE, dataCenterId, 0l, null, errorString));
         }
+
     }
 
     public boolean isZoneReady(Map<Long, ZoneHostInfo> zoneHostInfoMap, long dataCenterId) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a12ab8a2/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
index 25e5b85..9edd600 100755
--- a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
+++ b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
@@ -506,9 +506,6 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
                 s_logger.debug("Unable to allocate secondary storage vm storage, remove the secondary storage vm record from DB, secondary storage vm id: " +
                     secStorageVmId);
             }
-
-            SubscriptionMgr.getInstance().notifySubscribers(ALERT_SUBJECT, this,
-                new SecStorageVmAlertEventArgs(SecStorageVmAlertEventArgs.SSVM_CREATE_FAILURE, dataCenterId, secStorageVmId, null, "Unable to allocate storage"));
         }
         return null;
     }
@@ -654,70 +651,83 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
             }
             return;
         }
-
-        boolean secStorageVmFromStoppedPool = false;
-        SecondaryStorageVmVO secStorageVm = assignSecStorageVmFromStoppedPool(dataCenterId, role);
-        if (secStorageVm == null) {
-            if (s_logger.isInfoEnabled()) {
-                s_logger.info("No stopped secondary storage vm is available, need to allocate a new secondary storage vm");
-            }
-
-            if (_allocLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
-                try {
-                    secStorageVm = startNew(dataCenterId, role);
-                    for (UploadVO upload : _uploadDao.listAll()) {
-                        _uploadDao.expunge(upload.getId());
-                    }
-                } finally {
-                    _allocLock.unlock();
-                }
-            } else {
+        SecondaryStorageVmVO secStorageVm = null;
+        String errorString = null;
+        try{
+            boolean secStorageVmFromStoppedPool = false;
+            secStorageVm = assignSecStorageVmFromStoppedPool(dataCenterId, role);
+            if (secStorageVm == null) {
                 if (s_logger.isInfoEnabled()) {
-                    s_logger.info("Unable to acquire synchronization lock to allocate secStorageVm resource for standby capacity, wait for next scan");
+                    s_logger.info("No stopped secondary storage vm is available, need to allocate a new secondary storage vm");
                 }
-                return;
-            }
-        } else {
-            if (s_logger.isInfoEnabled()) {
-                s_logger.info("Found a stopped secondary storage vm, bring it up to running pool. secStorageVm vm id : " + secStorageVm.getId());
-            }
-            secStorageVmFromStoppedPool = true;
-        }
 
-        if (secStorageVm != null) {
-            long secStorageVmId = secStorageVm.getId();
-            GlobalLock secStorageVmLock = GlobalLock.getInternLock(getSecStorageVmLockName(secStorageVmId));
-            try {
-                if (secStorageVmLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
+                if (_allocLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
                     try {
-                        secStorageVm = startSecStorageVm(secStorageVmId);
+                        secStorageVm = startNew(dataCenterId, role);
+                        for (UploadVO upload : _uploadDao.listAll()) {
+                            _uploadDao.expunge(upload.getId());
+                        }
                     } finally {
-                        secStorageVmLock.unlock();
+                        _allocLock.unlock();
                     }
                 } else {
                     if (s_logger.isInfoEnabled()) {
-                        s_logger.info("Unable to acquire synchronization lock to start secStorageVm for standby capacity, secStorageVm vm id : " + secStorageVm.getId());
+                        s_logger.info("Unable to acquire synchronization lock to allocate secStorageVm resource for standby capacity, wait for next scan");
                     }
                     return;
                 }
-            } finally {
-                secStorageVmLock.releaseRef();
-            }
-
-            if (secStorageVm == null) {
+            } else {
                 if (s_logger.isInfoEnabled()) {
-                    s_logger.info("Unable to start secondary storage vm for standby capacity, secStorageVm vm Id : " + secStorageVmId +
-                        ", will recycle it and start a new one");
+                    s_logger.info("Found a stopped secondary storage vm, bring it up to running pool. secStorageVm vm id : " + secStorageVm.getId());
                 }
+                secStorageVmFromStoppedPool = true;
+            }
 
-                if (secStorageVmFromStoppedPool) {
-                    destroySecStorageVm(secStorageVmId);
+            if (secStorageVm != null) {
+                long secStorageVmId = secStorageVm.getId();
+                GlobalLock secStorageVmLock = GlobalLock.getInternLock(getSecStorageVmLockName(secStorageVmId));
+                try {
+                    if (secStorageVmLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
+                        try {
+                            secStorageVm = startSecStorageVm(secStorageVmId);
+                        } finally {
+                            secStorageVmLock.unlock();
+                        }
+                    } else {
+                        if (s_logger.isInfoEnabled()) {
+                            s_logger.info("Unable to acquire synchronization lock to start secStorageVm for standby capacity, secStorageVm vm id : " + secStorageVm.getId());
+                        }
+                        return;
+                    }
+                } finally {
+                    secStorageVmLock.releaseRef();
                 }
-            } else {
-                if (s_logger.isInfoEnabled()) {
-                    s_logger.info("Secondary storage vm " + secStorageVm.getHostName() + " is started");
+
+                if (secStorageVm == null) {
+                    if (s_logger.isInfoEnabled()) {
+                        s_logger.info("Unable to start secondary storage vm for standby capacity, secStorageVm vm Id : " + secStorageVmId +
+                            ", will recycle it and start a new one");
+                    }
+
+                    if (secStorageVmFromStoppedPool) {
+                        destroySecStorageVm(secStorageVmId);
+                    }
+                } else {
+                    SubscriptionMgr.getInstance().notifySubscribers(ALERT_SUBJECT, this,
+                            new SecStorageVmAlertEventArgs(SecStorageVmAlertEventArgs.SSVM_UP, dataCenterId, secStorageVmId, secStorageVm, null));
+                    if (s_logger.isInfoEnabled()) {
+                        s_logger.info("Secondary storage vm " + secStorageVm.getHostName() + " is started");
+                    }
                 }
             }
+        }catch (Exception e){
+            errorString = e.getMessage();
+        }finally{
+            // TODO - For now put all the alerts as creation failure. Distinguish between creation vs start failure in future.
+            // Also add failure reason since startvm masks some of them.
+            if(secStorageVm == null || secStorageVm.getState() != State.Running)
+                SubscriptionMgr.getInstance().notifySubscribers(ALERT_SUBJECT, this,
+                        new SecStorageVmAlertEventArgs(SecStorageVmAlertEventArgs.SSVM_CREATE_FAILURE, dataCenterId, 0l, null, errorString));
         }
     }
 


[5/8] git commit: updated refs/heads/4.5 to 31a6517

Posted by bh...@apache.org.
CLOUDSTACK-7840: UI control tip for 'Add Primary Storage' -> 'Provider' seems wrong

-Removed the invalid help text.

(cherry picked from commit 1f21f399ab7711534febd77bb695e6c149293481)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 1998217f6a4d00d27c88e559bd5889a003b39060
Parents: b3e84ca
Author: Gabor Apati-Nagy <ga...@citrix.com>
Authored: Tue Nov 4 18:32:32 2014 +0000
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 12:02:07 2015 +0530

----------------------------------------------------------------------
 ui/scripts/system.js | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1998217f/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index fdaaed4..f55807a 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -17010,7 +17010,6 @@
                                     },
                                     provider: {
                                         label: 'label.provider',
-                                        docID: 'helpPrimaryStorageZone',
                                         validation: {
                                             required: true
                                         },


[3/8] git commit: updated refs/heads/4.5 to 31a6517

Posted by bh...@apache.org.
CLOUDSTACK-7909: Change the capacity_state in op_host_Capacity table only on explicit enabling/disabling of the host and remove the logic for changing it when cluster/pod/zone is enabled/disabled. Also add the logic in capacity checker thread so that previous  changes finally get consistent with this new model and also its good to have it for sanity reasons.

(cherry picked from commit ade305be20021d20a881693625864f46a335ea98)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>

Conflicts:
	server/src/com/cloud/capacity/CapacityManagerImpl.java


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

Branch: refs/heads/4.5
Commit: be0882b19e16b72cacc1a38b6bb72953b9053c5a
Parents: 665aa6b
Author: Nitin Mehta <ni...@citrix.com>
Authored: Thu Nov 13 13:54:45 2014 -0800
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:58:04 2015 +0530

----------------------------------------------------------------------
 .../com/cloud/capacity/CapacityManagerImpl.java | 25 ++++++++++++--------
 .../configuration/ConfigurationManagerImpl.java |  6 ++---
 .../com/cloud/resource/ResourceManagerImpl.java | 15 ++++--------
 3 files changed, 21 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be0882b1/server/src/com/cloud/capacity/CapacityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java
index e5b7d19..5ea7e3e 100755
--- a/server/src/com/cloud/capacity/CapacityManagerImpl.java
+++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java
@@ -27,6 +27,8 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import com.cloud.resource.ResourceState;
+
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
@@ -49,7 +51,6 @@ import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.StartupCommand;
 import com.cloud.agent.api.StartupRoutingCommand;
-import com.cloud.api.ApiDBUtils;
 import com.cloud.capacity.dao.CapacityDao;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationManager;
@@ -67,7 +68,6 @@ import com.cloud.host.dao.HostDao;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
 import com.cloud.offering.ServiceOffering;
-import com.cloud.org.Grouping.AllocationState;
 import com.cloud.resource.ResourceListener;
 import com.cloud.resource.ResourceManager;
 import com.cloud.resource.ServerResource;
@@ -597,6 +597,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
         long usedMemory = 0;
         long reservedMemory = 0;
         long reservedCpu = 0;
+        final CapacityState capacityState = (host.getResourceState() == ResourceState.Enabled) ? CapacityState.Enabled : CapacityState.Disabled;
 
         List<VMInstanceVO> vms = _vmDao.listUpByHostId(host.getId());
         if (s_logger.isDebugEnabled()) {
@@ -680,6 +681,12 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
                 cpuCap.setTotalCapacity(hostTotalCpu);
 
             }
+            // Set the capacity state as per the host allocation state.
+            if(capacityState != cpuCap.getCapacityState()){
+                s_logger.debug("Calibrate cpu capacity state for host: " + host.getId() + " old capacity state:" + cpuCap.getTotalCapacity() + " new capacity state:" + hostTotalCpu);
+                cpuCap.setCapacityState(capacityState);
+            }
+            memCap.setCapacityState(capacityState);
 
             if (cpuCap.getUsedCapacity() == usedCpu && cpuCap.getReservedCapacity() == reservedCpu) {
                 s_logger.debug("No need to calibrate cpu capacity, host:" + host.getId() + " usedCpu: " + cpuCap.getUsedCapacity() + " reservedCpu: " +
@@ -702,6 +709,11 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
                 memCap.setTotalCapacity(host.getTotalMemory());
 
             }
+            // Set the capacity state as per the host allocation state.
+            if(capacityState != memCap.getCapacityState()){
+                s_logger.debug("Calibrate memory capacity state for host: " + host.getId() + " old capacity state:" + cpuCap.getTotalCapacity() + " new capacity state:" + hostTotalCpu);
+                memCap.setCapacityState(capacityState);
+            }
 
             if (memCap.getUsedCapacity() == usedMemory && memCap.getReservedCapacity() == reservedMemory) {
                 s_logger.debug("No need to calibrate memory capacity, host:" + host.getId() + " usedMem: " + memCap.getUsedCapacity() + " reservedMem: " +
@@ -741,14 +753,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
                         new CapacityVO(host.getId(), host.getDataCenterId(), host.getPodId(), host.getClusterId(), usedMemoryFinal, host.getTotalMemory(),
                             Capacity.CAPACITY_TYPE_MEMORY);
                     capacity.setReservedCapacity(reservedMemoryFinal);
-                    CapacityState capacityState = CapacityState.Enabled;
-                    if (host.getClusterId() != null) {
-                        ClusterVO cluster = ApiDBUtils.findClusterById(host.getClusterId());
-                        if (cluster != null) {
-                            capacityState = _configMgr.findClusterAllocationState(cluster) == AllocationState.Disabled ? CapacityState.Disabled : CapacityState.Enabled;
-                            capacity.setCapacityState(capacityState);
-                        }
-                    }
+                    capacity.setCapacityState(capacityState);
                     _capacityDao.persist(capacity);
 
                     capacity =

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be0882b1/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index d9ce3fd..b18e154 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -1237,9 +1237,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
             String ipRange = startIp + "-" + endIp;
             pod.setDescription(ipRange);
             Grouping.AllocationState allocationState = null;
-                    if (allocationStateStrFinal != null && !allocationStateStrFinal.isEmpty()) {
-                        allocationState = Grouping.AllocationState.valueOf(allocationStateStrFinal);
-                        _capacityDao.updateCapacityState(null, pod.getId(), null, null, allocationStateStrFinal);
+            if (allocationStateStrFinal != null && !allocationStateStrFinal.isEmpty()) {
+                allocationState = Grouping.AllocationState.valueOf(allocationStateStrFinal);
                 pod.setAllocationState(allocationState);
             }
 
@@ -1774,7 +1773,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
                     throw new InvalidParameterValueException("Cannot enable this Zone since: " + ex.getMessage());
                 }
             }
-            _capacityDao.updateCapacityState(zone.getId(), null, null, null, allocationStateStr);
             zone.setAllocationState(allocationState);
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be0882b1/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 5a1b8ce..5723196 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -30,6 +30,7 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import com.cloud.capacity.CapacityState;
 import com.cloud.vm.VirtualMachine;
 
 import org.apache.cloudstack.api.ApiConstants;
@@ -68,7 +69,6 @@ import com.cloud.agent.api.UpdateHostPasswordCommand;
 import com.cloud.agent.api.VgpuTypesInfo;
 import com.cloud.agent.api.to.GPUDeviceTO;
 import com.cloud.agent.transport.Request;
-import com.cloud.api.ApiDBUtils;
 import com.cloud.capacity.Capacity;
 import com.cloud.capacity.CapacityManager;
 import com.cloud.capacity.CapacityVO;
@@ -126,7 +126,6 @@ import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.IPAddressVO;
 import com.cloud.org.Cluster;
 import com.cloud.org.Grouping;
-import com.cloud.org.Grouping.AllocationState;
 import com.cloud.org.Managed;
 import com.cloud.serializer.GsonHelper;
 import com.cloud.service.dao.ServiceOfferingDetailsDao;
@@ -1041,7 +1040,6 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
                 s_logger.error("Unable to resolve " + allocationState + " to a valid supported allocation State");
                 throw new InvalidParameterValueException("Unable to resolve " + allocationState + " to a supported state");
             } else {
-                _capacityDao.updateCapacityState(null, null, cluster.getId(), null, allocationState);
                 cluster.setAllocationState(newAllocationState);
                 doUpdate = true;
             }
@@ -1163,14 +1161,9 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
             throw new NoTransitionException("No next resource state found for current state =" + currentState + " event =" + event);
         }
 
-        // TO DO - Make it more granular and have better conversion into
-        // capacity type
-
-        if (host.getType() == Type.Routing && host.getClusterId() != null) {
-            AllocationState capacityState = _configMgr.findClusterAllocationState(ApiDBUtils.findClusterById(host.getClusterId()));
-            if (capacityState == AllocationState.Enabled && nextState != ResourceState.Enabled) {
-                capacityState = AllocationState.Disabled;
-            }
+        // TO DO - Make it more granular and have better conversion into capacity type
+        if(host.getType() == Type.Routing){
+            CapacityState capacityState =  (nextState == ResourceState.Enabled) ? CapacityState.Enabled : CapacityState.Disabled;
             _capacityDao.updateCapacityState(null, null, null, host.getId(), capacityState.toString());
         }
         return _hostDao.updateResourceState(currentState, event, nextState, host);


[7/8] git commit: updated refs/heads/4.5 to 31a6517

Posted by bh...@apache.org.
CLOUDSTACK-7771: Throw exception while restoring vm if the template is already deleted. Also fix the usage event being generated from the right template id and fix the log message which sometime showed incorrect template id.
CLOUDSTACK-4201: listServiceOfferings API needs to be able to take virtualmachineid of SystemVM and return service offerings available for the vm to change service offering

(cherry picked from commit ee0f0a1cffb96a8371d9a8c4210b428660f79d4f)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: a6f9411b1eb46739c9b47fc16ad7796cc0e3d221
Parents: 1288d53
Author: Nitin Mehta <ni...@citrix.com>
Authored: Wed Oct 22 15:03:25 2014 -0700
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 12:05:25 2015 +0530

----------------------------------------------------------------------
 server/src/com/cloud/api/query/QueryManagerImpl.java |  7 ++++++-
 server/src/com/cloud/vm/UserVmManagerImpl.java       | 12 ++++++++++--
 server/test/com/cloud/vm/UserVmManagerTest.java      |  8 ++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a6f9411b/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java
index a5e7d5c..62714ea 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -27,6 +27,8 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 
 import com.cloud.utils.StringUtils;
+import com.cloud.vm.VMInstanceVO;
+import com.cloud.vm.dao.VMInstanceDao;
 import org.apache.cloudstack.acl.ControlledEntity.ACLType;
 import org.apache.cloudstack.affinity.AffinityGroupDomainMapVO;
 import org.apache.cloudstack.affinity.AffinityGroupResponse;
@@ -248,6 +250,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
     private UserVmDao _userVmDao;
 
     @Inject
+    private VMInstanceDao _vmInstanceDao;
+
+    @Inject
     private SecurityGroupJoinDao _securityGroupJoinDao;
 
     @Inject
@@ -2576,7 +2581,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
         }
 
         if (vmId != null) {
-            UserVmVO vmInstance = _userVmDao.findById(vmId);
+            VMInstanceVO vmInstance = _vmInstanceDao.findById(vmId);
             if ((vmInstance == null) || (vmInstance.getRemoved() != null)) {
                 InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a virtual machine with specified id");
                 ex.addProxyObject(vmId.toString(), "vmId");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a6f9411b/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 3f539b2..22f2769 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -35,6 +35,8 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.log4j.Logger;
 import org.apache.cloudstack.acl.ControlledEntity.ACLType;
@@ -303,6 +305,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
     @Inject
     protected VMTemplateZoneDao _templateZoneDao = null;
     @Inject
+    protected TemplateDataStoreDao _templateStoreDao;
+    @Inject
     protected DomainDao _domainDao = null;
     @Inject
     protected UserVmCloneSettingDao _vmCloneSettingDao = null;
@@ -4762,6 +4766,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
                     throw ex;
                 }
             }
+            TemplateDataStoreVO tmplStore = _templateStoreDao.findByTemplateZoneReady(template.getId(), vm.getDataCenterId());
+            if (tmplStore == null) {
+                throw new InvalidParameterValueException("Cannot restore the vm as the template " + template.getUuid() + " isn't available in the zone");
+            }
 
             if (needRestart) {
                 try {
@@ -4794,7 +4802,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
             }
 
             // Create Usage event for the newly created volume
-            UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, newVol.getAccountId(), newVol.getDataCenterId(), newVol.getId(), newVol.getName(), newVol.getDiskOfferingId(), templateId, newVol.getSize());
+            UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, newVol.getAccountId(), newVol.getDataCenterId(), newVol.getId(), newVol.getName(), newVol.getDiskOfferingId(), template.getId(), newVol.getSize());
             _usageEventDao.persist(usageEvent);
 
             handleManagedStorage(vm, root);
@@ -4867,7 +4875,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
             }
         }
 
-        s_logger.debug("Restore VM " + vmId + " with template " + newTemplateId + " done successfully");
+        s_logger.debug("Restore VM " + vmId + " done successfully");
         return vm;
 
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a6f9411b/server/test/com/cloud/vm/UserVmManagerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/UserVmManagerTest.java b/server/test/com/cloud/vm/UserVmManagerTest.java
index aed468d..d86e55e 100755
--- a/server/test/com/cloud/vm/UserVmManagerTest.java
+++ b/server/test/com/cloud/vm/UserVmManagerTest.java
@@ -55,6 +55,7 @@ import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationSer
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 
 import com.cloud.capacity.CapacityManager;
 import com.cloud.configuration.ConfigurationManager;
@@ -89,6 +90,7 @@ import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.VMInstanceDao;
 import com.cloud.vm.snapshot.VMSnapshotVO;
 import com.cloud.vm.snapshot.dao.VMSnapshotDao;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
 
 public class UserVmManagerTest {
 
@@ -121,6 +123,8 @@ public class UserVmManagerTest {
     @Mock
     VMTemplateDao _templateDao;
     @Mock
+    TemplateDataStoreDao _templateStoreDao;
+    @Mock
     VolumeDao _volsDao;
     @Mock
     RestoreVMCmd _restoreVMCmd;
@@ -135,6 +139,8 @@ public class UserVmManagerTest {
     @Mock
     VMTemplateVO _templateMock;
     @Mock
+    TemplateDataStoreVO _templateDataStoreMock;
+    @Mock
     VolumeVO _volumeMock;
     @Mock
     List<VolumeVO> _rootVols;
@@ -162,6 +168,7 @@ public class UserVmManagerTest {
         _userVmMgr._vmDao = _vmDao;
         _userVmMgr._vmInstanceDao = _vmInstanceDao;
         _userVmMgr._templateDao = _templateDao;
+        _userVmMgr._templateStoreDao = _templateStoreDao;
         _userVmMgr._volsDao = _volsDao;
         _userVmMgr._usageEventDao = _usageEventDao;
         _userVmMgr._itMgr = _itMgr;
@@ -190,6 +197,7 @@ public class UserVmManagerTest {
         List<VMSnapshotVO> mockList = mock(List.class);
         when(_vmSnapshotDao.findByVm(anyLong())).thenReturn(mockList);
         when(mockList.size()).thenReturn(0);
+        when(_templateStoreDao.findByTemplateZoneReady(anyLong(),anyLong())).thenReturn(_templateDataStoreMock);
 
     }
 


[6/8] git commit: updated refs/heads/4.5 to 31a6517

Posted by bh...@apache.org.
CLOUDSTACK-7774 Description field is missing in Health policy API's

(cherry picked from commit e5d3e496ab22be2bcbb7f92e6c80bfad8e503153)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 1288d533efe1c49c9dd0dbebee84b275b9f61f78
Parents: 1998217
Author: Rajesh Battala <ra...@citrix.com>
Authored: Thu Oct 23 14:14:14 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 12:04:53 2015 +0530

----------------------------------------------------------------------
 .../apache/cloudstack/api/response/LBHealthCheckPolicyResponse.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1288d533/api/src/org/apache/cloudstack/api/response/LBHealthCheckPolicyResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/LBHealthCheckPolicyResponse.java b/api/src/org/apache/cloudstack/api/response/LBHealthCheckPolicyResponse.java
index 8ce7b3d..df3a7a0 100644
--- a/api/src/org/apache/cloudstack/api/response/LBHealthCheckPolicyResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/LBHealthCheckPolicyResponse.java
@@ -101,6 +101,7 @@ public class LBHealthCheckPolicyResponse extends BaseResponse {
         this.healthcheckthresshold = healthcheckpolicy.getHealthcheckThresshold();
         this.unhealthcheckthresshold = healthcheckpolicy.getUnhealthThresshold();
         this.forDisplay = healthcheckpolicy.isDisplay();
+        this.description = healthcheckpolicy.getDescription();
         setObjectName("healthcheckpolicy");
     }
 


[2/8] git commit: updated refs/heads/4.5 to 31a6517

Posted by bh...@apache.org.
CLOUDSTACK-7916: Generate Alerts if System VMs cannot be started.

(cherry picked from commit e87bb20d0c73e6f46f1352e271afec3961067542)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 665aa6b52289306c3085868d0ec2dfe1837bc13e
Parents: a12ab8a
Author: Nitin Mehta <ni...@citrix.com>
Authored: Fri Nov 14 13:35:40 2014 -0800
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:55:47 2015 +0530

----------------------------------------------------------------------
 server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java      | 1 +
 .../cloudstack/secondarystorage/SecondaryStorageManagerImpl.java    | 1 +
 2 files changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/665aa6b5/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index a527160..bb64fa3 100755
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -924,6 +924,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
             }
         }catch (Exception e){
            errorString = e.getMessage();
+           throw e;
         }finally {
             // TODO - For now put all the alerts as creation failure. Distinguish between creation vs start failure in future.
             // Also add failure reason since startvm masks some of them.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/665aa6b5/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
index 9edd600..cc7eb25 100755
--- a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
+++ b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
@@ -722,6 +722,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
             }
         }catch (Exception e){
             errorString = e.getMessage();
+            throw e;
         }finally{
             // TODO - For now put all the alerts as creation failure. Distinguish between creation vs start failure in future.
             // Also add failure reason since startvm masks some of them.


[8/8] git commit: updated refs/heads/4.5 to 31a6517

Posted by bh...@apache.org.
CLOUDSTACK-7754: Templates source_template_id is null when it is created from Snapshot with its corresponding volume removed. Fix it by searching for volumes including removed. Also bring the logic of setting source template id to create() method than execute which was wrongly put in.

(cherry picked from commit e1a993d37b1bf9be24edd46f6d3566826692f853)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 31a6517402d2007a4857d3ae9be2da8a697892b1
Parents: a6f9411
Author: Nitin Mehta <ni...@citrix.com>
Authored: Tue Oct 21 09:57:02 2014 -0700
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 12:07:42 2015 +0530

----------------------------------------------------------------------
 .../com/cloud/template/TemplateManagerImpl.java | 40 +++-----------------
 1 file changed, 6 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/31a65174/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 5641f57..a498dc7 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -1412,29 +1412,6 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
                 }
 
                 privateTemplate = _tmpltDao.findById(templateId);
-                if (snapshotId != null) {
-                    //getting the parent volume
-                    long parentVolumeId = _snapshotDao.findById(snapshotId).getVolumeId();
-                    //Volume can be removed
-                    VolumeVO parentVolume = _volumeDao.findByIdIncludingRemoved(parentVolumeId);
-
-                    if (parentVolume != null && parentVolume.getIsoId() != null && parentVolume.getIsoId() != 0) {
-                        privateTemplate.setSourceTemplateId(parentVolume.getIsoId());
-                        _tmpltDao.update(privateTemplate.getId(), privateTemplate);
-                    } else if (parentVolume != null && parentVolume.getTemplateId() != null) {
-                        privateTemplate.setSourceTemplateId(parentVolume.getTemplateId());
-                        _tmpltDao.update(privateTemplate.getId(), privateTemplate);
-                    }
-                } else if (volumeId != null) {
-                    VolumeVO parentVolume = _volumeDao.findById(volumeId);
-                    if (parentVolume.getIsoId() != null && parentVolume.getIsoId() != 0) {
-                        privateTemplate.setSourceTemplateId(parentVolume.getIsoId());
-                        _tmpltDao.update(privateTemplate.getId(), privateTemplate);
-                    } else if (parentVolume.getTemplateId() != null) {
-                        privateTemplate.setSourceTemplateId(parentVolume.getTemplateId());
-                        _tmpltDao.update(privateTemplate.getId(), privateTemplate);
-                    }
-                }
                 TemplateDataStoreVO srcTmpltStore = _tmplStoreDao.findByStoreTemplate(store.getId(), templateId);
                 UsageEventVO usageEvent =
                         new UsageEventVO(EventTypes.EVENT_TEMPLATE_CREATE, privateTemplate.getAccountId(), zoneId, privateTemplate.getId(), privateTemplate.getName(), null,
@@ -1570,8 +1547,8 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
             if (snapshot == null) {
                 throw new InvalidParameterValueException("Failed to create private template record, unable to find snapshot " + snapshotId);
             }
-
-            volume = _volumeDao.findById(snapshot.getVolumeId());
+            // Volume could be removed so find including removed to record source template id.
+            volume = _volumeDao.findByIdIncludingRemoved(snapshot.getVolumeId());
 
             // check permissions
             _accountMgr.checkAccess(caller, null, true, snapshot);
@@ -1612,15 +1589,10 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
         if (volume != null) {
             VMTemplateVO template = ApiDBUtils.findTemplateById(volume.getTemplateId());
             isExtractable = template != null && template.isExtractable() && template.getTemplateType() != Storage.TemplateType.SYSTEM;
-            if (template != null) {
-                sourceTemplateId = template.getId();
-            } else if (volume.getVolumeType() == Volume.Type.ROOT) { // vm
-                // created
-                // out
-                // of blank
-                // template
-                UserVm userVm = ApiDBUtils.findUserVmById(volume.getInstanceId());
-                sourceTemplateId = userVm.getIsoId();
+            if (volume.getIsoId() != null && volume.getIsoId() != 0) {
+                sourceTemplateId = volume.getIsoId();
+            } else if (volume.getTemplateId() != null) {
+                sourceTemplateId = volume.getTemplateId();
             }
         }
         String templateTag = cmd.getTemplateTag();


[4/8] git commit: updated refs/heads/4.5 to 31a6517

Posted by bh...@apache.org.
CLOUDSTACK-7904: EN-UK: CentOS 6.5 GUI: Key translation fails for some  EN- UK keyboard keys.

(cherry picked from commit 7f2219bcbb4835123bdb24ba733651b9a1f2bdc6)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: b3e84cad2d37ef1d266bf49c0367dabe8589ace0
Parents: be0882b
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Thu Nov 13 18:56:29 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 20 11:59:32 2015 +0530

----------------------------------------------------------------------
 systemvm/js/ajaxkeys.js   | 43 +++++++++++-------------------------------
 systemvm/js/ajaxviewer.js |  4 +++-
 2 files changed, 14 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b3e84cad/systemvm/js/ajaxkeys.js
----------------------------------------------------------------------
diff --git a/systemvm/js/ajaxkeys.js b/systemvm/js/ajaxkeys.js
index 26c2996..3053b7d 100644
--- a/systemvm/js/ajaxkeys.js
+++ b/systemvm/js/ajaxkeys.js
@@ -289,47 +289,26 @@ var	keyboardTables = [
                             ]
            }
            }, {tindex: 2, keyboardType: KEYBOARD_TYPE_UK, mappingTable:
-                 {X11: [
-                          //[223 = `¬¦]
-                          {keycode: 223,		entry : 0x60, 	browser: "IE"},
-                          ],
+                 {X11: [],
                   keyPress: [
-                             //[34 = "]
-                          {keycode: 34, entry:
-                              [{type : KEY_DOWN, code : 0x40, modifiers : 64, shift : true}]
-                          },
+                          //[34 = "]
+                          {keycode: 34,		entry: 0x40,	guestos: "windows"},
                           //[35 = #]
-                          {keycode: 35, entry:
-                              [{type : KEY_DOWN, code : 0x5c, modifiers : 0, shift : false}]
-                          },
+                          {keycode: 35,		entry: 0x5c,	guestos: "windows"},
                           // [64 = @]
-                          {keycode: 64, entry:
-                              [{type : KEY_DOWN, code : 0x22, modifiers : 64, shift : true}]
-                          },
+                          {keycode: 64,		entry: 0x22,	guestos: "windows"},
                           // [92 = \]
-                          {keycode: 92, entry:
-                              [{type : KEY_DOWN, code : 0xa6, modifiers : 0, shift : false}]
-                          },
+                          {keycode: 92,		entry: 0xa6,	guestos: "windows"},
                           // [124 = |]
-                          {keycode: 124, entry:
-                              [{type : KEY_DOWN, code : 0xa6, modifiers : 64, shift : true}]
-                          },
+                          {keycode: 124,	entry: 0xa6,	guestos: "windows"},
                           // [126 = ~]
-                          {keycode: 126, entry:
-                              [{type : KEY_DOWN, code : 0x7c, modifiers : 64, shift : true}]
-                          },
+                          {keycode: 126,	entry: 0x7c,	guestos: "windows"},
                           // [163 = £]
-                          {keycode: 163, entry:
-                              [{type : KEY_DOWN, code : 0x23, modifiers : 64, shift : true}]
-                          },
+                          {keycode: 163,	entry: 0x23,	guestos: "windows"},
                           // [172 = ¬]
-                          {keycode: 172, entry:
-                              [{type : KEY_DOWN, code : 0x7e, modifiers : 64, shift : true}]
-                          },
+                          {keycode: 172,	entry: 0x7e,	guestos: "windows"},
                           // [166 = ¦]
-                          {keycode: 166, entry:
-                              [{type : KEY_DOWN, code : 0x60, modifiers : 896, shift : false}]
-                          }
+                          {keycode: 166,	entry: [{type : KEY_DOWN, code : 0x60, modifiers : 896, shift : false}],	guestos: "windows"}
                           ]
            }
            }]

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b3e84cad/systemvm/js/ajaxviewer.js
----------------------------------------------------------------------
diff --git a/systemvm/js/ajaxviewer.js b/systemvm/js/ajaxviewer.js
index 123f182..db5ed45 100644
--- a/systemvm/js/ajaxviewer.js
+++ b/systemvm/js/ajaxviewer.js
@@ -761,7 +761,9 @@ AjaxViewer.prototype = {
 			for (var j = 0; j < keyPressMaps.length; j++) {
 				var code = keyPressMaps[j].keycode;
 				var mappedEntry = keyPressMaps[j].entry;
-				this.keyboardMappers[keyboardType].jsKeyPressX11KeysymMap[code] = mappedEntry;
+				if(keyPressMaps[j].guestos == undefined || keyPressMaps[j].guestos == this.guestos) {
+					this.keyboardMappers[keyboardType].jsKeyPressX11KeysymMap[code] = mappedEntry;
+				}
 			}
 		}
 	}