Add missing VolumeAttachStatus enum field
VolumeAttachStatus has been defined already, This change just replace the missing string volume attach status with volume attach enum field. Change-Id: I1e873d66138b88745bdb325f124b6bd781c7d621 Partial-Implements: bp cinder-object-fields
This commit is contained in:
parent
8efee51cae
commit
f01ae575da
@ -24,6 +24,7 @@ from cinder.api import validation
|
|||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import objects
|
from cinder import objects
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder.policies import attachments as attachment_policy
|
from cinder.policies import attachments as attachment_policy
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
from cinder.volume import api as volume_api
|
from cinder.volume import api as volume_api
|
||||||
@ -271,7 +272,8 @@ class AttachmentsController(wsgi.Controller):
|
|||||||
attachment_ref.volume_id)
|
attachment_ref.volume_id)
|
||||||
context.authorize(attachment_policy.COMPLETE_POLICY,
|
context.authorize(attachment_policy.COMPLETE_POLICY,
|
||||||
target_obj=attachment_ref)
|
target_obj=attachment_ref)
|
||||||
attachment_ref.update({'attach_status': 'attached'})
|
attachment_ref.update(
|
||||||
|
{'attach_status': fields.VolumeAttachStatus.ATTACHED})
|
||||||
attachment_ref.save()
|
attachment_ref.save()
|
||||||
volume_ref.update({'status': 'in-use', 'attach_status': 'attached'})
|
volume_ref.update({'status': 'in-use', 'attach_status': 'attached'})
|
||||||
volume_ref.save()
|
volume_ref.save()
|
||||||
|
@ -2091,7 +2091,7 @@ def attachment_destroy(context, attachment_id):
|
|||||||
utcnow = timeutils.utcnow()
|
utcnow = timeutils.utcnow()
|
||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
updated_values = {'attach_status': 'deleted',
|
updated_values = {'attach_status': fields.VolumeAttachStatus.DELETED,
|
||||||
'deleted': True,
|
'deleted': True,
|
||||||
'deleted_at': utcnow,
|
'deleted_at': utcnow,
|
||||||
'updated_at': literal_column('updated_at')}
|
'updated_at': literal_column('updated_at')}
|
||||||
|
@ -2163,7 +2163,7 @@ class API(base.Base):
|
|||||||
ctxt.authorize(attachment_policy.DELETE_POLICY,
|
ctxt.authorize(attachment_policy.DELETE_POLICY,
|
||||||
target_obj=attachment)
|
target_obj=attachment)
|
||||||
volume = objects.Volume.get_by_id(ctxt, attachment.volume_id)
|
volume = objects.Volume.get_by_id(ctxt, attachment.volume_id)
|
||||||
if attachment.attach_status == 'reserved':
|
if attachment.attach_status == fields.VolumeAttachStatus.RESERVED:
|
||||||
self.db.volume_detached(ctxt.elevated(), attachment.volume_id,
|
self.db.volume_detached(ctxt.elevated(), attachment.volume_id,
|
||||||
attachment.get('id'))
|
attachment.get('id'))
|
||||||
self.db.volume_admin_metadata_delete(ctxt.elevated(),
|
self.db.volume_admin_metadata_delete(ctxt.elevated(),
|
||||||
|
@ -4508,7 +4508,7 @@ class VolumeManager(manager.CleanableManager,
|
|||||||
# TODO(jdg): object method here
|
# TODO(jdg): object method here
|
||||||
self.db.volume_attachment_update(
|
self.db.volume_attachment_update(
|
||||||
context, attachment.get('id'),
|
context, attachment.get('id'),
|
||||||
{'attach_status': 'error_detaching'})
|
{'attach_status': fields.VolumeAttachStatus.ERROR_DETACHING})
|
||||||
else:
|
else:
|
||||||
self.db.volume_detached(context.elevated(), vref.id,
|
self.db.volume_detached(context.elevated(), vref.id,
|
||||||
attachment.get('id'))
|
attachment.get('id'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user