cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sanjaytripa...@apache.org
Subject git commit: updated refs/heads/4.3 to 3964a56
Date Fri, 03 Jan 2014 12:57:27 GMT
Updated Branches:
  refs/heads/4.3 741634b87 -> 3964a566f


CLOUDSTACK-5701: physical size is not getting updated in snapshot_store_ref table.


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

Branch: refs/heads/4.3
Commit: 3964a566f7e6bf5db837973b2f065796764d2269
Parents: 741634b
Author: Sanjay Tripathi <sanjay.tripathi@citrix.com>
Authored: Fri Jan 3 18:16:41 2014 +0530
Committer: Sanjay Tripathi <sanjay.tripathi@citrix.com>
Committed: Fri Jan 3 18:20:31 2014 +0530

----------------------------------------------------------------------
 .../cloudstack/storage/to/SnapshotObjectTO.java |  9 +++++++++
 .../storage/snapshot/SnapshotObject.java        |  1 +
 .../datastore/ObjectInDataStoreManagerImpl.java |  1 +
 .../xen/resource/XenServerStorageProcessor.java | 21 ++++++++++++++++++--
 scripts/vm/hypervisor/xenserver/vmopsSnapshot   | 17 ++++++++++++++--
 5 files changed, 45 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3964a566/core/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java b/core/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
index 55e34e4..aa2a4f5 100644
--- a/core/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
+++ b/core/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
@@ -38,6 +38,7 @@ public class SnapshotObjectTO implements DataTO {
     private long id;
     private boolean quiescevm;
     private String[] parents;
+    private Long physicalSize = (long) 0;
 
 
     public SnapshotObjectTO() {
@@ -94,6 +95,14 @@ public class SnapshotObjectTO implements DataTO {
         this.path = path;
     }
 
+    public Long getPhysicalSize() {
+        return this.physicalSize;
+    }
+
+    public void setPhysicalSize(Long physicalSize ) {
+        this.physicalSize = physicalSize;
+    }
+
     public VolumeObjectTO getVolume() {
         return volume;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3964a566/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
index ee02eed..63ca1bd 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
@@ -281,6 +281,7 @@ public class SnapshotObject implements SnapshotInfo {
             } else if (answer instanceof CopyCmdAnswer) {
                 SnapshotObjectTO snapshotTO = (SnapshotObjectTO) ((CopyCmdAnswer) answer).getNewData();
                 snapshotStore.setInstallPath(snapshotTO.getPath());
+                snapshotStore.setSize(snapshotTO.getPhysicalSize());
                 if (snapshotTO.getParentSnapshotPath() == null) {
                     snapshotStore.setParentSnapshotId(0L);
                 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3964a566/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
b/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
index d9a5164..9d47ce6 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
@@ -114,6 +114,7 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager
{
                 ss.setDataStoreId(dataStore.getId());
                 ss.setRole(dataStore.getRole());
                 ss.setVolumeId(snapshotInfo.getVolumeId());
+                ss.setSize(snapshotInfo.getSize()); // this is the virtual size of snapshot
in primary storage.
                 SnapshotDataStoreVO snapshotDataStoreVO = snapshotDataStoreDao.findParent(dataStore.getRole(),
dataStore.getId(),snapshotInfo.getVolumeId());
                 if (snapshotDataStoreVO != null) {
                     ss.setParentSnapshotId(snapshotDataStoreVO.getSnapshotId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3964a566/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
index b8e0b6a..5df37ea 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
@@ -1167,6 +1167,16 @@ public class XenServerStorageProcessor implements StorageProcessor
{
 
     }
 
+    protected Long getSnapshotSize(Connection conn, String primaryStorageSRUuid, String snapshotUuid,
Boolean isISCSI, int wait) {
+        String physicalSize = hypervisorResource.callHostPluginAsync(conn, "vmopsSnapshot",
"getSnapshotSize", wait,
+                "primaryStorageSRUuid", primaryStorageSRUuid, "snapshotUuid", snapshotUuid,
"isISCSI", isISCSI.toString());
+        if (physicalSize == null || physicalSize.isEmpty()) {
+            return (long) 0;
+        } else {
+            return Long.parseLong(physicalSize);
+        }
+    }
+
     protected String backupSnapshot(Connection conn, String primaryStorageSRUuid, String
localMountPoint, String path, String secondaryStorageMountPath, String snapshotUuid, String
prevBackupUuid, Boolean isISCSI, int wait) {
         String backupSnapshotUuid = null;
 
@@ -1196,7 +1206,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
             if (status != null && status.equalsIgnoreCase("1") && backupSnapshotUuid
!= null) {
                 s_logger.debug("Successfully copied backupUuid: " + backupSnapshotUuid
                         + " to secondary storage");
-                return backupSnapshotUuid;
+                return results;
             } else {
                 errMsg = "Could not copy backupUuid: " + backupSnapshotUuid
                         + " from primary storage " + primaryStorageSRUuid + " to secondary
storage "
@@ -1291,6 +1301,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
         // By default assume failure
         String details = null;
         String snapshotBackupUuid = null;
+        Long physicalSize = null;
         Map<String, String> options = cmd.getOptions();
         boolean fullbackup = Boolean.parseBoolean(options.get("fullSnapshot"));
         try {
@@ -1340,6 +1351,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
                     snapshotSr = hypervisorResource.createNfsSRbyURI(conn, new URI(snapshotMountpoint),
false);
                     VDI backedVdi = hypervisorResource.cloudVDIcopy(conn, snapshotVdi, snapshotSr,
wait);
                     snapshotBackupUuid = backedVdi.getUuid(conn);
+                    String primarySRuuid = snapshotSr.getUuid(conn);
+                    physicalSize = getSnapshotSize(conn, primarySRuuid, snapshotBackupUuid,
isISCSI, wait);
 
                     if( destStore instanceof SwiftTO) {
                         try {
@@ -1390,9 +1403,12 @@ public class XenServerStorageProcessor implements StorageProcessor
{
                         throw new CloudRuntimeException("S3 upload of snapshots " + snapshotPaUuid
+ " failed");
                     }
                 } else {
-                    snapshotBackupUuid = backupSnapshot(conn, primaryStorageSRUuid, localMountPoint,
folder,
+                    String results = backupSnapshot(conn, primaryStorageSRUuid, localMountPoint,
folder,
                             secondaryStorageMountPath, snapshotUuid, prevBackupUuid, isISCSI,
wait);
 
+                    String[] tmp = results.split("#");
+                    snapshotBackupUuid = tmp[1];
+                    physicalSize = Long.parseLong(tmp[2]);
                     finalPath = folder + File.separator + snapshotBackupUuid;
                 }
             }
@@ -1401,6 +1417,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
 
             SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
             newSnapshot.setPath(finalPath);
+            newSnapshot.setPhysicalSize(physicalSize);
             if (fullbackup) {
                 newSnapshot.setParentSnapshotPath(null);
             } else {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3964a566/scripts/vm/hypervisor/xenserver/vmopsSnapshot
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/vmopsSnapshot b/scripts/vm/hypervisor/xenserver/vmopsSnapshot
index a9a5a72..5fd69a6 100755
--- a/scripts/vm/hypervisor/xenserver/vmopsSnapshot
+++ b/scripts/vm/hypervisor/xenserver/vmopsSnapshot
@@ -487,6 +487,18 @@ def getVhdParent(session, args):
 
     return  baseCopyUuid
 
+def getSnapshotSize(session, args):
+    primaryStorageSRUuid      = args['primaryStorageSRUuid']
+    snapshotUuid              = args['snapshotUuid']
+    isISCSI                   = getIsTrueString(args['isISCSI'])
+
+    primarySRPath = getPrimarySRPath(primaryStorageSRUuid, isISCSI)
+    logging.debug("primarySRPath: " + primarySRPath)
+
+    snapshotVHD  = getVHD(snapshotUuid, isISCSI)
+    snapshotPath = os.path.join(primarySRPath, snapshotVHD)
+    physicalSize = vhdutil.getSizePhys(snapshotPath)
+    return str(physicalSize)
 
 def backupSnapshot(session, args):
     logging.debug("Called backupSnapshot with " + str(args))
@@ -515,6 +527,7 @@ def backupSnapshot(session, args):
     prevBackupUuid = prevBackupUuid.split("/")[-1]
     # Check existence of snapshot on primary storage
     isfile(baseCopyPath, isISCSI)
+    physicalSize = vhdutil.getSizePhys(baseCopyPath)
     if prevBackupUuid:
         # Check existence of prevBackupFile
         prevBackupVHD = getBackupVHD(prevBackupUuid)
@@ -535,7 +548,7 @@ def backupSnapshot(session, args):
         # If there was a previous snapshot
         setParent(prevBackupFile, backupFile)
 
-    txt = "1#" + backupUuid
+    txt = "1#" + backupUuid + "#" + str(physicalSize)
     return txt
 
 @echo
@@ -596,6 +609,6 @@ def revert_memory_snapshot(session, args):
     return "0"
 
 if __name__ == "__main__":
-    XenAPIPlugin.dispatch({"getVhdParent":getVhdParent,  "create_secondary_storage_folder":create_secondary_storage_folder,
"delete_secondary_storage_folder":delete_secondary_storage_folder, "post_create_private_template":post_create_private_template,
"backupSnapshot": backupSnapshot, "deleteSnapshotBackup": deleteSnapshotBackup, "unmountSnapshotsDir":
unmountSnapshotsDir, "revert_memory_snapshot":revert_memory_snapshot})
+    XenAPIPlugin.dispatch({"getVhdParent":getVhdParent,  "create_secondary_storage_folder":create_secondary_storage_folder,
"delete_secondary_storage_folder":delete_secondary_storage_folder, "post_create_private_template":post_create_private_template,
"backupSnapshot": backupSnapshot, "deleteSnapshotBackup": deleteSnapshotBackup, "unmountSnapshotsDir":
unmountSnapshotsDir, "revert_memory_snapshot":revert_memory_snapshot, "getSnapshotSize":getSnapshotSize})
     
 


Mime
View raw message