Merge "Fix missing size value in snapshot instance"
This commit is contained in:
commit
c4ba394a87
@ -1309,6 +1309,12 @@ def _extract_share_instance_values(values):
|
||||
return share_instance_values, share_values
|
||||
|
||||
|
||||
def _change_size_to_instance_size(snap_instance_values):
|
||||
if 'size' in snap_instance_values:
|
||||
snap_instance_values['instance_size'] = snap_instance_values['size']
|
||||
snap_instance_values.pop('size')
|
||||
|
||||
|
||||
def _extract_snapshot_instance_values(values):
|
||||
fields = ['status', 'progress', 'provider_location']
|
||||
snapshot_instance_values, snapshot_values = (
|
||||
@ -2315,6 +2321,8 @@ def share_snapshot_instance_create(context, snapshot_id, values, session=None):
|
||||
session = session or get_session()
|
||||
values = copy.deepcopy(values)
|
||||
|
||||
_change_size_to_instance_size(values)
|
||||
|
||||
if not values.get('id'):
|
||||
values['id'] = uuidutils.generate_uuid()
|
||||
values.update({'snapshot_id': snapshot_id})
|
||||
@ -2332,6 +2340,7 @@ def share_snapshot_instance_update(context, instance_id, values):
|
||||
session = get_session()
|
||||
instance_ref = share_snapshot_instance_get(context, instance_id,
|
||||
session=session)
|
||||
_change_size_to_instance_size(values)
|
||||
|
||||
# NOTE(u_glide): Ignore updates to custom properties
|
||||
for extra_key in models.ShareSnapshotInstance._extra_keys:
|
||||
@ -4700,6 +4709,8 @@ def share_group_snapshot_member_create(context, values):
|
||||
if not values.get('id'):
|
||||
values['id'] = six.text_type(uuidutils.generate_uuid())
|
||||
|
||||
_change_size_to_instance_size(values)
|
||||
|
||||
session = get_session()
|
||||
with session.begin():
|
||||
member.update(values)
|
||||
@ -4712,6 +4723,7 @@ def share_group_snapshot_member_create(context, values):
|
||||
@require_context
|
||||
def share_group_snapshot_member_update(context, member_id, values):
|
||||
session = get_session()
|
||||
_change_size_to_instance_size(values)
|
||||
with session.begin():
|
||||
member = share_group_snapshot_member_get(
|
||||
context, member_id, session=session)
|
||||
|
@ -751,6 +751,14 @@ class ShareSnapshotInstance(BASE, ManilaBase):
|
||||
# with share drivers
|
||||
return self.share_instance_id
|
||||
|
||||
@property
|
||||
def size(self):
|
||||
# NOTE(silvacarlose) for backwards compatibility
|
||||
if self.instance_size is None:
|
||||
return self.snapshot.size
|
||||
else:
|
||||
return self.instance_size
|
||||
|
||||
id = Column(String(36), primary_key=True)
|
||||
deleted = Column(String(36), default='False')
|
||||
snapshot_id = Column(String(36), nullable=True)
|
||||
@ -760,7 +768,7 @@ class ShareSnapshotInstance(BASE, ManilaBase):
|
||||
progress = Column(String(255))
|
||||
provider_location = Column(String(255))
|
||||
share_proto = Column(String(255))
|
||||
size = Column(Integer)
|
||||
instance_size = Column('size', Integer)
|
||||
share_group_snapshot_id = Column(String(36), nullable=True)
|
||||
user_id = Column(String(255))
|
||||
project_id = Column(String(255))
|
||||
|
6
releasenotes/notes/fix-py3-netapp-a9815186ddc865d4.yaml
Normal file
6
releasenotes/notes/fix-py3-netapp-a9815186ddc865d4.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixed the size value not being present in share snapshot
|
||||
instances, which caused the NetApp driver to crash when
|
||||
creating a share from a snapshot using python3.
|
Loading…
Reference in New Issue
Block a user