From 01197d273057c0c4dd06068aeda31ae840ccd075 Mon Sep 17 00:00:00 2001 From: nit Date: Mon, 1 Nov 2010 13:40:08 +0530 Subject: [PATCH 1/3] bug 6748: Correcting secondary storage space utilization on the dashboard. The fix will update the existing db entry and will create a new entry for the first time only. status 6748: resolved fixed --- .../src/com/cloud/server/StatsCollector.java | 78 ++++++++++--------- 1 file changed, 43 insertions(+), 35 deletions(-) mode change 100644 => 100755 server/src/com/cloud/server/StatsCollector.java diff --git a/server/src/com/cloud/server/StatsCollector.java b/server/src/com/cloud/server/StatsCollector.java old mode 100644 new mode 100755 index 4469a0ceace..50f668cd1a0 --- a/server/src/com/cloud/server/StatsCollector.java +++ b/server/src/com/cloud/server/StatsCollector.java @@ -301,22 +301,49 @@ public class StatsCollector { // a list to store the new capacity entries that will be committed once everything is calculated List newCapacities = new ArrayList(); - // create new entries - for (Long hostId : storageStats.keySet()) { - StorageStats stats = storageStats.get(hostId); - HostVO host = _hostDao.findById(hostId); - host.setTotalSize(stats.getCapacityBytes()); - _hostDao.update(host.getId(), host); - - if (Host.Type.SecondaryStorage.equals(host.getType())) { - CapacityVO capacity = new CapacityVO(host.getId(), host.getDataCenterId(), host.getPodId(), stats.getByteUsed(), stats.getCapacityBytes(), CapacityVO.CAPACITY_TYPE_SECONDARY_STORAGE); - newCapacities.add(capacity); -// _capacityDao.persist(capacity); - } else if (Host.Type.Storage.equals(host.getType())) { - CapacityVO capacity = new CapacityVO(host.getId(), host.getDataCenterId(), host.getPodId(), stats.getByteUsed(), stats.getCapacityBytes(), CapacityVO.CAPACITY_TYPE_STORAGE); - newCapacities.add(capacity); -// _capacityDao.persist(capacity); + // Updating the storage entries and creating new ones if they dont exist. + Transaction txn = Transaction.open(Transaction.CLOUD_DB); + try { + if (s_logger.isTraceEnabled()) { + s_logger.trace("recalculating system storage capacity"); } + txn.start(); + for (Long hostId : storageStats.keySet()) { + StorageStats stats = storageStats.get(hostId); + short capacityType = -1; + HostVO host = _hostDao.findById(hostId); + host.setTotalSize(stats.getCapacityBytes()); + _hostDao.update(host.getId(), host); + + SearchCriteria capacitySC = _capacityDao.createSearchCriteria(); + capacitySC.addAnd("hostOrPoolId", SearchCriteria.Op.EQ, hostId); + capacitySC.addAnd("dataCenterId", SearchCriteria.Op.EQ, host.getDataCenterId()); + + if (Host.Type.SecondaryStorage.equals(host.getType())) { + capacityType = CapacityVO.CAPACITY_TYPE_SECONDARY_STORAGE; + } else if (Host.Type.Storage.equals(host.getType())) { + capacityType = CapacityVO.CAPACITY_TYPE_STORAGE; + } + if(-1 != capacityType){ + capacitySC.addAnd("capacityType", SearchCriteria.Op.EQ, capacityType); + List capacities = _capacityDao.search(capacitySC, null); + if (capacities.size() == 0){ // Create a new one + CapacityVO capacity = new CapacityVO(host.getId(), host.getDataCenterId(), host.getPodId(), stats.getByteUsed(), stats.getCapacityBytes(), capacityType); + _capacityDao.persist(capacity); + }else{ //Update if it already exists. + CapacityVO capacity = capacities.get(0); + capacity.setUsedCapacity(stats.getByteUsed()); + capacity.setTotalCapacity(stats.getCapacityBytes()); + _capacityDao.update(capacity.getId(), capacity); + } + } + }// End of for + txn.commit(); + } catch (Exception ex) { + txn.rollback(); + s_logger.error("Unable to start transaction for storage capacity update"); + }finally { + txn.close(); } for (Long poolId : storagePoolStats.keySet()) { @@ -336,26 +363,7 @@ public class StatsCollector { _storagePoolDao.update(pool.getId(), pool); _storageManager.createCapacityEntry(pool, 0L); - } - - Transaction txn = Transaction.open(Transaction.CLOUD_DB); - try { - if (s_logger.isTraceEnabled()) { - s_logger.trace("recalculating system storage capacity"); - } - txn.start(); - for (CapacityVO newCapacity : newCapacities) { - s_logger.trace("Executing capacity update"); - _capacityDao.persist(newCapacity); - s_logger.trace("Done with capacity update"); - } - txn.commit(); - } catch (Exception ex) { - txn.rollback(); - s_logger.error("Unable to start transaction for storage capacity update"); - }finally { - txn.close(); - } + } } catch (Throwable t) { s_logger.error("Error trying to retrieve storage stats", t); } From 4bfe0154b0550c06191c92b4ee251a19b85008bc Mon Sep 17 00:00:00 2001 From: edison Date: Mon, 1 Nov 2010 10:27:45 -0700 Subject: [PATCH 2/3] bug 6872: add db migration script for 2.1.4-2.1.5: remove not null constraint for storage.pool status 6872: resolved fixed --- setup/db/schema-214to215.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 setup/db/schema-214to215.sql diff --git a/setup/db/schema-214to215.sql b/setup/db/schema-214to215.sql new file mode 100644 index 00000000000..f00c3f72c1a --- /dev/null +++ b/setup/db/schema-214to215.sql @@ -0,0 +1 @@ +ALTER TABLE `cloud`.`storage_pool` MODIFY COLUMN `uuid` varchar(255) UNIQUE; -- remove NOT NULL constraint to allow delete host/pool From 2b0581150868d76c6f34baa27de58685c9442ebd Mon Sep 17 00:00:00 2001 From: Chiradeep Vittal Date: Mon, 1 Nov 2010 13:10:05 -0700 Subject: [PATCH 3/3] bug 6807: firstip determination is more complicated than at first sight status 6807: resolved fixed --- .../cloud/hypervisor/xen/resource/CitrixResourceBase.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 02bded712b4..faca9462c4a 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -961,8 +961,10 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR boolean removeVif = false; if (add && correctVif == null) { addVif = true; + s_logger.info("ipassoc: Need to add a vif to the virtual router since the ip is in a new subnet " + publicIpAddress); } else if (!add && firstIP) { removeVif = true; + s_logger.info("ipassoc: Need to remove a vif to the virtual router since the removed ip is the last one " + publicIpAddress); } if (addVif) { @@ -994,9 +996,11 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR args += " -f"; args += " -l "; args += publicIpAddress + "/" + cidrSize; - } else if (firstIP) { + s_logger.debug("ipassoc: source nat ip: " + publicIpAddress); + } else if (addVif || removeVif || firstIP) { args += " -l "; args += publicIpAddress + "/" + cidrSize; + s_logger.debug("ipassoc: first ip on vif: " + publicIpAddress); } else { args += " -l "; args += publicIpAddress;