]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Error trying to delete snapshots on Hitachi driver
authormarcusvrn <marcus.nascimento@fit-tecnologia.org.br>
Thu, 5 Mar 2015 18:52:54 +0000 (15:52 -0300)
committermarcusvrn <marcus.nascimento@fit-tecnologia.org.br>
Wed, 11 Mar 2015 11:08:17 +0000 (08:08 -0300)
Patch #133566 (Change-Id: I387018e80c8539565e99454db65d976030002c0f) partially
changed Volumes and Volume Snapshots to objects and modified their attributes.
This change broke HBSD driver, once the 'snapshot_metadata' attribute was
replaced to 'metadata'.

Change-Id: I38edc3b8a924f16ec3cef848cffef5e1b48fef14
Closes-Bug: #1428609

cinder/volume/drivers/hitachi/hbsd_common.py

index 5f8ca164e68ed40d27360e2682fe680d86c0bcc9..6899e25641fbd221a04074a0e2e3a8bdaad3bfae 100644 (file)
@@ -23,8 +23,6 @@ from oslo_config import cfg
 from oslo_utils import excutils
 import six
 
-from cinder.db.sqlalchemy import api
-from cinder.db.sqlalchemy import models
 from cinder import exception
 from cinder.i18n import _LE, _LW
 from cinder.openstack.common import log as logging
@@ -174,9 +172,12 @@ class HBSDCommon(object):
             return None
 
         if obj.get(name):
-            for i in obj[name]:
-                if i['key'] == key:
-                    return i['value']
+            if isinstance(obj[name], dict):
+                return obj[name].get(key)
+            else:
+                for i in obj[name]:
+                    if i['key'] == key:
+                        return i['value']
         return None
 
     def get_is_vvol(self, obj, name):
@@ -186,7 +187,7 @@ class HBSDCommon(object):
         return self.get_is_vvol(volume, 'volume_metadata')
 
     def get_snapshot_is_vvol(self, snapshot):
-        return self.get_is_vvol(snapshot, 'snapshot_metadata')
+        return self.get_is_vvol(snapshot, 'metadata')
 
     def get_copy_method(self, volume):
         method = self.get_value(volume, 'volume_metadata', 'copy_method')
@@ -605,7 +606,7 @@ class HBSDCommon(object):
             is_vvol = self.get_volume_is_vvol(src_ref)
             self.check_volume_status(src_ref, is_vvol)
             size = snapshot['volume_size']
-            snap_metadata = self.get_snapshot_metadata(snapshot['id'])
+            snap_metadata = snapshot.get('metadata')
             method = None if is_vvol else self.get_copy_method(src_ref)
 
             svol, type = self.copy_data(pvol, size, is_vvol, method)
@@ -614,10 +615,8 @@ class HBSDCommon(object):
             snap_metadata['type'] = type
             snap_metadata['ldev'] = svol
 
-        snapshot_metadata = api._metadata_refs(snap_metadata,
-                                               models.SnapshotMetadata)
         return {'provider_location': svol,
-                'snapshot_metadata': snapshot_metadata}
+                'metadata': snap_metadata}
 
     def delete_snapshot(self, snapshot):
         ldev = self.get_ldev(snapshot)