diff options
-rw-r--r-- | nova/virt/powervm/blockdev.py | 75 | ||||
-rw-r--r-- | nova/virt/powervm/operator.py | 15 |
2 files changed, 82 insertions, 8 deletions
diff --git a/nova/virt/powervm/blockdev.py b/nova/virt/powervm/blockdev.py index dc539814e..580b6677a 100644 --- a/nova/virt/powervm/blockdev.py +++ b/nova/virt/powervm/blockdev.py @@ -34,7 +34,74 @@ CONF = cfg.CONF class PowerVMDiskAdapter(object): - pass + """PowerVM disk adapter interface + Provides a contract to implement multiple ways to generate + and attach volumes to virtual machines using local and/or + external storage + """ + + def create_volume(self, size): + """Creates a volume with a minimum size + + :param size: size of the volume in bytes + :returns: string -- the name of the disk device. + """ + pass + + def delete_volume(self, volume_info): + """Removes the disk and its associated vSCSI connection + + :param volume_info: dictionary with volume info including name of + disk device in /dev/ + """ + pass + + def create_volume_from_image(self, context, instance, image_id): + """Creates a Volume and copies the specified image to it + + :param context: nova context used to retrieve image from glance + :param instance: instance to create the volume for + :param image_id: image_id reference used to locate image in glance + :returns: dictionary with the name of the created + disk device in 'device_name' key + """ + pass + + def create_image_from_volume(self, device_name, context, + image_id, image_meta): + """Capture the contents of a volume and upload to glance + + :param device_name: device in /dev/ to capture + :param context: nova context for operation + :param image_id: image reference to pre-created image in glance + :param image_meta: metadata for new image + """ + pass + + def migrate_volume(self, lv_name, src_host, dest, image_path, + instance_name=None): + """Copy a logical volume to file, compress, and transfer + + :param lv_name: volume device name + :param src_host: source IP or DNS name. + :param dest: destination IP or DNS name + :param image_path: path to remote image storage directory + :param instance_name: name of instance that is being migrated + :returns: file path on destination of image file that was moved + """ + pass + + def attach_volume_to_host(self, *args, **kargs): + """ + Attaches volume to host using info passed in *args and **kargs + """ + pass + + def detach_volume_from_host(self, *args, **kargs): + """ + Detaches volume from host using info passed in *args and **kargs + """ + pass class PowerVMLocalVolumeAdapter(PowerVMDiskAdapter): @@ -65,11 +132,13 @@ class PowerVMLocalVolumeAdapter(PowerVMDiskAdapter): """ return self._create_logical_volume(size) - def delete_volume(self, disk_name): + def delete_volume(self, volume_info): """Removes the Logical Volume and its associated vSCSI connection - :param disk_name: name of Logical Volume device in /dev/ + :param volume_info: Dictionary with volume info including name of + Logical Volume device in /dev/ via device_name key """ + disk_name = volume_info["device_name"] LOG.debug(_("Removing the logical volume '%s'") % disk_name) self._remove_logical_volume(disk_name) diff --git a/nova/virt/powervm/operator.py b/nova/virt/powervm/operator.py index 43fa27160..03a13f261 100644 --- a/nova/virt/powervm/operator.py +++ b/nova/virt/powervm/operator.py @@ -360,14 +360,19 @@ class PowerVMOperator(object): LOG.debug(_("Shutting down the instance '%s'") % instance_name) self._operator.stop_lpar(instance_name) + #dperaza: LPAR should be deleted first so that vhost is + #cleanly removed and detached from disk device. + LOG.debug(_("Deleting the LPAR instance '%s'") % instance_name) + self._operator.remove_lpar(instance_name) + if disk_name and destroy_disks: # TODO(mrodden): we should also detach from the instance # before we start deleting things... - self._disk_adapter.detach_volume_from_host(disk_name) - self._disk_adapter.delete_volume(disk_name) - - LOG.debug(_("Deleting the LPAR instance '%s'") % instance_name) - self._operator.remove_lpar(instance_name) + volume_info = {'device_name': disk_name} + #Volume info dictionary might need more info that is lost when + #volume is detached from host so that it can be deleted + self._disk_adapter.detach_volume_from_host(volume_info) + self._disk_adapter.delete_volume(volume_info) except Exception: LOG.exception(_("PowerVM instance cleanup failed")) raise exception.PowerVMLPARInstanceCleanupFailed( |