From 918d33eee9fdeedb143f316fd7df42c3ae23cab6 Mon Sep 17 00:00:00 2001
From: apoorvad <apps.desh@gmail.com>
Date: Wed, 9 Dec 2015 09:42:21 -0800
Subject: [PATCH] Retype functionality in Tintri driver

At this point default retype behavior is as follows. If a volume changes
type on the same backend then that volume will be migrated. Since Tintri
VMstore does not differentiate between volume types, we can avoid this
migration by implementing retype functionality.

Change-Id: I40b28327e13821d6fb45f89b15267b21ed4c2e8c
closes-bug: 1524435
---
 cinder/tests/unit/test_tintri.py | 6 ++++++
 cinder/volume/drivers/tintri.py  | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/cinder/tests/unit/test_tintri.py b/cinder/tests/unit/test_tintri.py
index e9781f53b7d..c4abe165db1 100644
--- a/cinder/tests/unit/test_tintri.py
+++ b/cinder/tests/unit/test_tintri.py
@@ -245,3 +245,9 @@ class TintriDriverTestCase(test.TestCase):
         volume = fake_volume.fake_volume_obj(self.context)
         volume.provider_location = self._provider_location
         self._driver.unmanage(volume)
+
+    def test_retype(self):
+        volume = fake_volume.fake_volume_obj(self.context)
+        retype, update = self._driver.retype(None, volume, None, None, None)
+        self.assertTrue(retype)
+        self.assertIsNone(update)
diff --git a/cinder/volume/drivers/tintri.py b/cinder/volume/drivers/tintri.py
index 4ca21b0885a..0997668303f 100644
--- a/cinder/volume/drivers/tintri.py
+++ b/cinder/volume/drivers/tintri.py
@@ -704,6 +704,14 @@ class TintriDriver(driver.ManageableVD,
         raise exception.ManageExistingInvalidReference(
             existing_ref=vol_ref, reason=_('Volume not found.'))
 
+    def retype(self, context, volume, new_type, diff, host):
+        """Retype from one volume type to another.
+
+        At this point Tintri VMstore does not differentiate between
+        volume types on the same array. This is a no-op for us.
+        """
+        return True, None
+
 
 class TClient(object):
     """REST client for Tintri storage."""