Change in vdsm[master]: vm: Unify disk replication terms

nsoffer at redhat.com nsoffer at redhat.com
Fri Apr 24 14:26:22 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: vm: Unify disk replication terms
......................................................................

vm: Unify disk replication terms

There is no source and destination drives when replication a volume, so
the term "drive" is more correct than "srcDrive". This not only more
correct, but help to streamline the code.

When setting Drive.diskReplicate, we refer to the dict as "replica"
instead of "dstDisk", which is a leftover from older code.

Change-Id: I0fa2f30f39eee73b107f5c055f5be790ed33da6a
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 24 insertions(+), 24 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/16/40216/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 38701b0..ec7ce9c 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -2990,45 +2990,45 @@
                 (snapFlags & libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE
                     == libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE)}
 
-    def _setDiskReplica(self, srcDrive, dstDisk):
+    def _setDiskReplica(self, drive, replica):
         """
         This utility method is used to set the disk replication information
         both in the live object used by vdsm and the vm configuration
         dictionary that is stored on disk (so that the information is not
         lost across restarts).
         """
-        if srcDrive.isDiskReplicationInProgress():
+        if drive.isDiskReplicationInProgress():
             raise RuntimeError("Disk '%s' already has an ongoing "
-                               "replication" % srcDrive.name)
+                               "replication" % drive.name)
 
         for device in self.conf["devices"]:
             if (device['type'] == hwclass.DISK
-                    and device.get("name") == srcDrive.name):
+                    and device.get("name") == drive.name):
                 with self._confLock:
-                    device['diskReplicate'] = dstDisk
+                    device['diskReplicate'] = replica
                 self.saveState()
                 break
         else:
-            raise LookupError("No such drive: '%s'" % srcDrive.name)
+            raise LookupError("No such drive: '%s'" % drive.name)
 
-        srcDrive.diskReplicate = dstDisk
+        drive.diskReplicate = replica
 
-    def _delDiskReplica(self, srcDrive):
+    def _delDiskReplica(self, drive):
         """
         This utility method is the inverse of _setDiskReplica, look at the
         _setDiskReplica description for more information.
         """
         for device in self.conf["devices"]:
             if (device['type'] == hwclass.DISK
-                    and device.get("name") == srcDrive.name):
+                    and device.get("name") == drive.name):
                 with self._confLock:
                     del device['diskReplicate']
                 self.saveState()
                 break
         else:
-            raise LookupError("No such drive: '%s'" % srcDrive.name)
+            raise LookupError("No such drive: '%s'" % drive.name)
 
-        del srcDrive.diskReplicate
+        del drive.diskReplicate
 
     def diskReplicateStart(self, srcDisk, dstDisk):
         try:
@@ -3088,29 +3088,29 @@
 
     def diskReplicateFinish(self, srcDisk, dstDisk):
         try:
-            srcDrive = self._findDriveByUUIDs(srcDisk)
+            drive = self._findDriveByUUIDs(srcDisk)
         except LookupError:
             return errCode['imageErr']
 
-        if srcDrive.hasVolumeLeases:
+        if drive.hasVolumeLeases:
             return errCode['noimpl']
 
-        if srcDrive.transientDisk:
+        if drive.transientDisk:
             return errCode['transientErr']
 
-        if not srcDrive.isDiskReplicationInProgress():
+        if not drive.isDiskReplicationInProgress():
             return errCode['replicaErr']
 
         # Looking for the replication blockJob info (checking its presence)
-        blkJobInfo = self._dom.blockJobInfo(srcDrive.name, 0)
+        blkJobInfo = self._dom.blockJobInfo(drive.name, 0)
 
         if (not isinstance(blkJobInfo, dict)
                 or 'cur' not in blkJobInfo or 'end' not in blkJobInfo):
             self.log.error("Replication job not found for disk %s (%s)",
-                           srcDrive.name, srcDisk)
+                           drive.name, srcDisk)
 
             # Making sure that we don't have any stale information
-            self._delDiskReplica(srcDrive)
+            self._delDiskReplica(drive)
             return errCode['replicaErr']
 
         # Checking if we reached the replication mode ("mirroring" in libvirt
@@ -3123,7 +3123,7 @@
         # Updating the destination disk device and name, the device is used by
         # prepareVolumePath (required to fill the new information as the path)
         # and the name is used by updateDriveParameters.
-        dstDiskCopy.update({'device': srcDrive.device, 'name': srcDrive.name})
+        dstDiskCopy.update({'device': drive.device, 'name': drive.name})
         dstDiskCopy['path'] = self.cif.prepareVolumePath(dstDiskCopy)
 
         if srcDisk != dstDisk:
@@ -3141,16 +3141,16 @@
             self.log.debug("Stopping the disk replication remaining on the "
                            "source drive: %s", dstDisk)
             blockJobFlags = 0
-            diskToTeardown = srcDrive.diskReplicate
+            diskToTeardown = drive.diskReplicate
 
         try:
             # Stopping the replication
-            self._dom.blockJobAbort(srcDrive.name, blockJobFlags)
+            self._dom.blockJobAbort(drive.name, blockJobFlags)
         except Exception:
             self.log.exception("Unable to stop the replication for"
-                               " the drive: %s", srcDrive.name)
+                               " the drive: %s", drive.name)
             try:
-                self.cif.teardownVolumePath(srcDrive.diskReplicate)
+                self.cif.teardownVolumePath(drive.diskReplicate)
             except Exception:
                 # There is nothing we can do at this point other than logging
                 self.log.exception("Unable to teardown the replication "
@@ -3165,7 +3165,7 @@
                                    diskToTeardown)
             self.updateDriveParameters(dstDiskCopy)
         finally:
-            self._delDiskReplica(srcDrive)
+            self._delDiskReplica(drive)
             self.startDisksStatsCollection()
 
         return {'status': doneCode}


-- 
To view, visit https://gerrit.ovirt.org/40216
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0fa2f30f39eee73b107f5c055f5be790ed33da6a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list