cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject git commit: updated refs/heads/master to e1827fc
Date Wed, 25 Feb 2015 11:17:47 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master cc9461bdb -> e1827fc69


CLOUDSTACK-8285: check and update IP capacity states based on allocation state

- Backend should update if state was diabled and now has changed
- UI's fetch latest does not actually fetch latest

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 985a61652eb5dc97503c002e9fc3c3a7ca39b70c)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


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

Branch: refs/heads/master
Commit: e1827fc696b1c4554881e340ae4cbc455495f13f
Parents: cc9461b
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Wed Feb 25 15:52:57 2015 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Wed Feb 25 16:47:40 2015 +0530

----------------------------------------------------------------------
 .../src/com/cloud/alert/AlertManagerImpl.java   | 17 ++++----
 .../com/cloud/server/ManagementServerImpl.java  |  5 +++
 .../com/cloud/storage/StorageManagerImpl.java   | 41 ++++++++------------
 ui/scripts/dashboard.js                         | 14 ++-----
 4 files changed, 33 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1827fc6/server/src/com/cloud/alert/AlertManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java
index 3f599a1..8653069 100644
--- a/server/src/com/cloud/alert/AlertManagerImpl.java
+++ b/server/src/com/cloud/alert/AlertManagerImpl.java
@@ -364,16 +364,16 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager,
Confi
         int totalVlans = _dcDao.countZoneVlans(dcId, false);
         int allocatedVlans = _dcDao.countZoneVlans(dcId, true);
 
+        CapacityState vlanCapacityState = (capacityState == AllocationState.Disabled) ? CapacityState.Disabled
: CapacityState.Enabled;
         if (capacities.size() == 0) {
             CapacityVO newVlanCapacity = new CapacityVO(null, dcId, null, null, allocatedVlans,
totalVlans, Capacity.CAPACITY_TYPE_VLAN);
-            if (capacityState == AllocationState.Disabled) {
-                newVlanCapacity.setCapacityState(CapacityState.Disabled);
-            }
+            newVlanCapacity.setCapacityState(vlanCapacityState);
             _capacityDao.persist(newVlanCapacity);
-        } else if (!(capacities.get(0).getUsedCapacity() == allocatedVlans && capacities.get(0).getTotalCapacity()
== totalVlans)) {
+        } else if (!(capacities.get(0).getUsedCapacity() == allocatedVlans && capacities.get(0).getTotalCapacity()
== totalVlans && capacities.get(0).getCapacityState() == vlanCapacityState)) {
             CapacityVO capacity = capacities.get(0);
             capacity.setUsedCapacity(allocatedVlans);
             capacity.setTotalCapacity(totalVlans);
+            capacity.setCapacityState(vlanCapacityState);
             _capacityDao.update(capacity.getId(), capacity);
         }
 
@@ -402,19 +402,18 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager,
Confi
             allocatedIPs = _publicIPAddressDao.countIPsForNetwork(dcId, true, VlanType.DirectAttached);
         }
 
+        CapacityState ipCapacityState = (capacityState == AllocationState.Disabled) ? CapacityState.Disabled
: CapacityState.Enabled;
         if (capacities.size() == 0) {
             CapacityVO newPublicIPCapacity = new CapacityVO(null, dcId, podId, null, allocatedIPs,
totalIPs, capacityType);
-            if (capacityState == AllocationState.Disabled) {
-                newPublicIPCapacity.setCapacityState(CapacityState.Disabled);
-            }
+            newPublicIPCapacity.setCapacityState(ipCapacityState);
             _capacityDao.persist(newPublicIPCapacity);
-        } else if (!(capacities.get(0).getUsedCapacity() == allocatedIPs && capacities.get(0).getTotalCapacity()
== totalIPs)) {
+        } else if (!(capacities.get(0).getUsedCapacity() == allocatedIPs && capacities.get(0).getTotalCapacity()
== totalIPs && capacities.get(0).getCapacityState() == ipCapacityState)) {
             CapacityVO capacity = capacities.get(0);
             capacity.setUsedCapacity(allocatedIPs);
             capacity.setTotalCapacity(totalIPs);
+            capacity.setCapacityState(ipCapacityState);
             _capacityDao.update(capacity.getId(), capacity);
         }
-
     }
 
     class CapacityChecker extends ManagedContextTimerTask {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1827fc6/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 aa158b4..eabaf23 100644
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -2390,11 +2390,16 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         Long zoneId = cmd.getZoneId();
         Long podId = cmd.getPodId();
         Long clusterId = cmd.getClusterId();
+        Boolean fetchLatest = cmd.getFetchLatest();
 
         if (clusterId != null) {
             throw new InvalidParameterValueException("Currently clusterId param is not suppoerted");
         }
         zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(),
zoneId);
+
+        if (fetchLatest != null && fetchLatest) {
+            _alertMgr.recalculateCapacity();
+        }
         List<SummedCapacity> summedCapacities = new ArrayList<SummedCapacity>();
 
         if (zoneId == null && podId == null) {// Group by Zone, capacity type

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1827fc6/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index bfaa461..d72cc69 100644
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -927,39 +927,32 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
         }
 
         s_logger.debug("Total over provisioned capacity of the pool " + storagePool.getName()
+ " id: " + storagePool.getId() + " is " + totalOverProvCapacity);
+        CapacityState capacityState = CapacityState.Enabled;
+        if (storagePool.getScope() == ScopeType.ZONE) {
+            DataCenterVO dc = ApiDBUtils.findZoneById(storagePool.getDataCenterId());
+            AllocationState allocationState = dc.getAllocationState();
+            capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled
: CapacityState.Enabled;
+        } else {
+            if (storagePool.getClusterId() != null) {
+                ClusterVO cluster = ApiDBUtils.findClusterById(storagePool.getClusterId());
+                if (cluster != null) {
+                    AllocationState allocationState = _configMgr.findClusterAllocationState(cluster);
+                    capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled
: CapacityState.Enabled;
+                }
+            }
+        }
         if (capacities.size() == 0) {
             CapacityVO capacity =
                     new CapacityVO(storagePool.getId(), storagePool.getDataCenterId(), storagePool.getPodId(),
storagePool.getClusterId(), allocated, totalOverProvCapacity,
                             capacityType);
-
-            if (storagePool.getScope() == ScopeType.ZONE) {
-                DataCenterVO dc = ApiDBUtils.findZoneById(storagePool.getDataCenterId());
-                AllocationState allocationState = dc.getAllocationState();
-                CapacityState capacityState = (allocationState == AllocationState.Disabled)
? CapacityState.Disabled : CapacityState.Enabled;
-                capacity.setCapacityState(capacityState);
-            } else {
-                if (storagePool.getClusterId() != null) {
-                    ClusterVO cluster = ApiDBUtils.findClusterById(storagePool.getClusterId());
-                    if (cluster != null) {
-                        AllocationState allocationState = _configMgr.findClusterAllocationState(cluster);
-                        CapacityState capacityState = (allocationState == AllocationState.Disabled)
? CapacityState.Disabled : CapacityState.Enabled;
-                        capacity.setCapacityState(capacityState);
-                    }
-                }
-            }
+            capacity.setCapacityState(capacityState);
             _capacityDao.persist(capacity);
         } else {
             CapacityVO capacity = capacities.get(0);
-            boolean update = false;
-            if (capacity.getTotalCapacity() != totalOverProvCapacity) {
+            if (capacity.getTotalCapacity() != totalOverProvCapacity || allocated != 0L ||
capacity.getCapacityState() != capacityState) {
                 capacity.setTotalCapacity(totalOverProvCapacity);
-                update = true;
-            }
-            if (allocated != 0) {
                 capacity.setUsedCapacity(allocated);
-                update = true;
-            }
-            if (update) {
+                capacity.setCapacityState(capacityState);
                 _capacityDao.update(capacity.getId(), capacity);
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1827fc6/ui/scripts/dashboard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/dashboard.js b/ui/scripts/dashboard.js
index 15e5e52..dff6a91 100644
--- a/ui/scripts/dashboard.js
+++ b/ui/scripts/dashboard.js
@@ -183,20 +183,12 @@
                         });
                     },
                     capacity: function(data) {
-                        var latestData = null;
                         if (window.fetchLatestflag == 1) {
-                            latestData = {
-
-                                fetchLatest: true
-                            }
+                            data.fetchLastest = true;
                         } else {
-                            latestData = {
-                                fetchLatest: false
-                            }
+                            data.fetchLastest = false;
                         }
-
                         window.fetchLatestflag = 0;
-
                         dataFns.alerts(data);
                     },
 
@@ -252,7 +244,7 @@
                         $.ajax({
                             url: createURL('listCapacity'),
                             data: {
-                                fetchLatest: false,
+                                fetchLatest: data.fetchLatest,
                                 sortBy: 'usage',
                                 page: 0,
                                 pageSize: (pageSize > 8? 8: pageSize) 


Mime
View raw message