Delete VDisks, VOpts via pypowervm's rm_vg_storage

Recent pypowervm change in branch rm_vg_storage implements the logic
needed by the localdisk driver's delete_disks and
media.ConfigDrivePowerVM's dlt_vopt.

Change-Id: I2f649ceebe2c14d0c28a62db32332ec7e310b99b
This commit is contained in:
Eric Fried
2015-07-22 16:39:48 -05:00
parent 1154279e52
commit 1c411f4b5f
2 changed files with 4 additions and 31 deletions

View File

@@ -15,7 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from oslo_log import log as logging
@@ -104,7 +103,7 @@ class LocalStorage(disk_dvr.DiskAdapter):
return float(vg_wrap.capacity) - float(vg_wrap.available_size)
def delete_disks(self, context, instance, storage_elems):
"""Removes the disks specified by the mappings.
"""Removes the specified disks.
:param context: nova context for operation
:param instance: instance to delete the disk for.
@@ -113,28 +112,8 @@ class LocalStorage(disk_dvr.DiskAdapter):
disconnect_image_disk.
"""
# All of local disk is done against the volume group. So reload
# that (to get new etag) and then do an update against it.
vg_wrap = self._get_vg_wrap()
# We know that the mappings are VSCSIMappings. Remove the storage that
# resides in the scsi map from the volume group.
existing_vds = vg_wrap.virtual_disks
for removal in storage_elems:
LOG.info(_LI('Deleting disk: %s'), removal.name, instance=instance)
# Can't just call direct on remove, because attribs are off.
# May want to evaluate change in pypowervm for this.
match = None
for existing_vd in existing_vds:
if existing_vd.name == removal.name:
match = existing_vd
break
if match is not None:
existing_vds.remove(match)
# Now update the volume group to remove the storage.
vg_wrap.update()
# that (to get new etag) and then update against it.
tsk_stg.rm_vg_storage(self._get_vg_wrap(), vdisks=storage_elems)
def disconnect_image_disk(self, context, instance, lpar_uuid,
disk_type=None):

View File

@@ -261,10 +261,4 @@ class ConfigDrivePowerVM(object):
root_id=self.vios_uuid,
child_type=pvm_stg.VG.schema_type,
child_id=self.vg_uuid)
volgrp = pvm_stg.VG.wrap(vg_rsp)
optical_medias = volgrp.vmedia_repos[0].optical_media
for media_elem in media_elems:
optical_medias.remove(media_elem)
# Now we can do an update...and be done with it.
volgrp.update()
tsk_stg.rm_vg_storage(pvm_stg.VG.wrap(vg_rsp), vopts=media_elems)