本文整理汇总了Python中ovs.lib.vdisk.VDiskController.delete_volume方法的典型用法代码示例。如果您正苦于以下问题:Python VDiskController.delete_volume方法的具体用法?Python VDiskController.delete_volume怎么用?Python VDiskController.delete_volume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ovs.lib.vdisk.VDiskController
的用法示例。
在下文中一共展示了VDiskController.delete_volume方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_volume
# 需要导入模块: from ovs.lib.vdisk import VDiskController [as 别名]
# 或者: from ovs.lib.vdisk.VDiskController import delete_volume [as 别名]
def create_volume(self, volume):
"""Creates a volume.
Called on "cinder create ..." or "nova volume-create ..."
:param volume: volume reference (sqlalchemy Model)
"""
_debug_vol_info("CREATE", volume)
hostname = str(volume.host)
name = volume.display_name
if not name:
name = volume.name
mountpoint = self._get_hostname_mountpoint(hostname)
location = '{}/{}.raw'.format(mountpoint, name)
size = volume.size
LOG.info('DO_CREATE_VOLUME %s %s' % (location, size))
VDiskController.create_volume(location = location,
size = size)
volume['provider_location'] = location
try:
ovs_disk = self._find_ovs_model_disk_by_location(location,
hostname)
except RuntimeError:
VDiskController.delete_volume(location = location)
raise
ovs_disk.cinder_id = volume.id
ovs_disk.name = name
ovs_disk.save()
return {'provider_location': volume['provider_location']}
示例2: copy_image_to_volume
# 需要导入模块: from ovs.lib.vdisk import VDiskController [as 别名]
# 或者: from ovs.lib.vdisk.VDiskController import delete_volume [as 别名]
def copy_image_to_volume(self, context, volume, image_service, image_id):
"""Copy image to volume
Called on "nova volume-create --image-id ..."
or "cinder create --image-id"
Downloads image from glance server into local .raw
:param volume: volume reference (sqlalchemy Model)
"""
_debug_vol_info("CP_IMG_TO_VOL", volume)
LOG.info("CP_IMG_TO_VOL %s %s" % (image_service, image_id))
name = volume.display_name
if not name:
name = volume.name
volume.display_name = volume.name
# downloading from an existing image
destination_path = volume.provider_location
if destination_path:
try:
LOG.info("CP_IMG_TO_VOL Deleting existing empty raw file %s " % destination_path)
VDiskController.delete_volume(location=destination_path)
LOG.info("CP_IMG_TO_VOL Downloading image to %s" % destination_path)
image_utils.fetch_to_raw(context, image_service, image_id, destination_path, "1M", size=volume["size"])
LOG.info("CP_IMG_TO_VOL Resizing volume to size %s" % volume["size"])
self.extend_volume(volume=volume, size_gb=volume["size"])
except Exception as ex:
LOG.error("CP_IMG_TO_VOL Internal error %s " % unicode(ex))
self.delete_volume(volume)
raise
ovs_disk = self._find_ovs_model_disk_by_location(volume.provider_location, str(volume.host))
ovs_disk.name = name
ovs_disk.save()
示例3: delete_volume
# 需要导入模块: from ovs.lib.vdisk import VDiskController [as 别名]
# 或者: from ovs.lib.vdisk.VDiskController import delete_volume [as 别名]
def delete_volume(self, volume):
"""Deletes a logical volume.
Called on "cinder delete ... "
:param volume: volume reference (sqlalchemy Model)
"""
_debug_vol_info("DELETE", volume)
location = volume.provider_location
if location is not None:
LOG.info('DO_DELETE_VOLUME %s' % (location))
VDiskController.delete_volume(location = location)