Skip to content

Commit

Permalink
Merge pull request #3 from peusebiu/fix_vmedia
Browse files Browse the repository at this point in the history
fixed vmedia_mount_remove_all()
  • Loading branch information
andaaron authored Nov 14, 2018
2 parents 8158f80 + 5308fa2 commit 837b926
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion imcsdk/apis/server/vmedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,21 @@ def vmedia_mount_remove_all(handle, server_id=1):
Examples:
vmedia_mount_remove_all(handle)
"""
from imcsdk.mometa.comm.CommSavedVMediaMap import CommSavedVMediaMapConsts

# Get all current virtually mapped ISOs
virt_media_maps = handle.query_children(in_dn=_get_vmedia_mo_dn(handle,
server_id))
# Loop over each mapped ISO
for virt_media in virt_media_maps:
# Remove the saved mapping
if virt_media.get_class_id() == "CommSavedVMediaMap":
virt_media.admin_action = CommSavedVMediaMapConsts.ADMIN_ACTION_DELETE_VOLUME
handle.set_mo(virt_media)
# Remove the mapped ISO
handle.remove_mo(virt_media)
elif virt_media.get_class_id() == "CommVmediaMap":
handle.remove_mo(virt_media)

# Raise error if all mappings not removed
if len(handle.query_children(in_dn="sys/svc-ext/vmedia-svc")) > 0:
raise ImcOperationError('Remove Virtual Media',
Expand Down

0 comments on commit 837b926

Please sign in to comment.