spec_value = volume_types.get_volume_type_extra_specs(type_id,
spec_key)
if not spec_value:
- LOG.debug("Returning default spec value: %s." % default_value)
+ LOG.debug("Returning default spec value: %s.", default_value)
return default_value
if possible_values is None:
return spec_value
if spec_value in possible_values:
- LOG.debug("Returning spec value %s" % spec_value)
+ LOG.debug("Returning spec value %s", spec_value)
return spec_value
- LOG.debug("Invalid spec value: %s specified." % spec_value)
+ LOG.debug("Invalid spec value: %s specified.", spec_value)
class ImageDiskType:
self._volumeops = volumeops.VMwareVolumeOps(self.session,
max_objects)
LOG.info(_LI("Successfully setup driver: %(driver)s for "
- "server: %(ip)s.") %
+ "server: %(ip)s."),
{'driver': driver,
'ip': self.configuration.vmware_host_ip})
raise exceptions.VimException(msg)
LOG.debug("Selected datastore: %(datastore)s with %(host_count)d "
- "connected host(s) for the volume." %
+ "connected host(s) for the volume.",
{'datastore': best_summary, 'host_count': max_host_count})
return best_summary
except exceptions.VimException as excep:
LOG.warn(_LW("Unable to find suitable datastore for volume"
" of size: %(vol)s GB under host: %(host)s. "
- "More details: %(excep)s") %
+ "More details: %(excep)s"),
{'vol': volume['size'],
'host': host, 'excep': excep})
if selected_host:
except exceptions.VimException as excep:
LOG.warn(_LW("Unable to find suitable datastore for "
"volume: %(vol)s under host: %(host)s. "
- "More details: %(excep)s") %
+ "More details: %(excep)s"),
{'vol': volume['name'],
'host': host.obj, 'excep': excep})
if backing:
return backing
retrv_result = self.volumeops.continue_retrieval(retrv_result)
- msg = _("Unable to create volume: %s in the inventory.")
- LOG.error(msg % volume['name'])
- raise exceptions.VimException(msg % volume['name'])
+ msg = _("Unable to create volume: %s in the "
+ "inventory.") % volume['name']
+ LOG.error(msg)
+ raise exceptions.VimException(msg)
def _initialize_connection(self, volume, connector):
"""Get information of volume's backing.
instance = vim_util.get_moref(connector['instance'],
'VirtualMachine')
LOG.debug("The instance: %s for which initialize connection "
- "is called, exists." % instance)
+ "is called, exists.", instance)
# Get host managing the instance
host = self.volumeops.get_host(instance)
if not backing:
# Create a backing in case it does not exist under the
# host managing the instance.
LOG.info(_LI("There is no backing for the volume: %s. "
- "Need to create one.") % volume['name'])
+ "Need to create one."), volume['name'])
backing = self._create_backing(volume, host)
else:
# Relocate volume is necessary
if not backing:
# Create a backing in case it does not exist. It is a bad use
# case to boot from an empty volume.
- LOG.warn(_LW("Trying to boot from an empty volume: %s.") %
+ LOG.warn(_LW("Trying to boot from an empty volume: %s."),
volume['name'])
# Create backing
backing = self._create_backing_in_inventory(volume)
'volume_id': volume['id']}
LOG.info(_LI("Returning connection_info: %(info)s for volume: "
- "%(volume)s with connector: %(connector)s.") %
+ "%(volume)s with connector: %(connector)s."),
{'info': connection_info,
'volume': volume['name'],
'connector': connector})
volume = snapshot['volume']
if volume['status'] != 'available':
- msg = _("Snapshot of volume not supported in state: %s.")
- LOG.error(msg % volume['status'])
- raise exception.InvalidVolume(msg % volume['status'])
+ msg = _("Snapshot of volume not supported in "
+ "state: %s.") % volume['status']
+ LOG.error(msg)
+ raise exception.InvalidVolume(msg)
backing = self.volumeops.get_backing(snapshot['volume_name'])
if not backing:
LOG.info(_LI("There is no backing, so will not create "
- "snapshot: %s.") % snapshot['name'])
+ "snapshot: %s."), snapshot['name'])
return
self.volumeops.create_snapshot(backing, snapshot['name'],
snapshot['display_description'])
- LOG.info(_LI("Successfully created snapshot: %s.") % snapshot['name'])
+ LOG.info(_LI("Successfully created snapshot: %s."), snapshot['name'])
def create_snapshot(self, snapshot):
"""Creates a snapshot.
volume = snapshot['volume']
if volume['status'] != 'available':
- msg = _("Delete snapshot of volume not supported in state: %s.")
- LOG.error(msg % volume['status'])
- raise exception.InvalidVolume(msg % volume['status'])
+ msg = _("Delete snapshot of volume not supported in "
+ "state: %s.") % volume['status']
+ LOG.error(msg)
+ raise exception.InvalidVolume(msg)
backing = self.volumeops.get_backing(snapshot['volume_name'])
if not backing:
LOG.info(_LI("There is no backing, and so there is no "
- "snapshot: %s.") % snapshot['name'])
+ "snapshot: %s."), snapshot['name'])
else:
self.volumeops.delete_snapshot(backing, snapshot['name'])
- LOG.info(_LI("Successfully deleted snapshot: %s.") %
+ LOG.info(_LI("Successfully deleted snapshot: %s."),
snapshot['name'])
def delete_snapshot(self, snapshot):
self._extend_volumeops_virtual_disk(volume['size'], dest_vmdk_path,
datacenter)
LOG.info(_LI("Successfully cloned new backing: %(back)s from "
- "source VMDK file: %(vmdk)s.") %
+ "source VMDK file: %(vmdk)s."),
{'back': backing, 'vmdk': src_vmdk_path})
def _create_cloned_volume(self, volume, src_vref):
if not backing:
LOG.info(_LI("There is no backing for the source volume: "
"%(svol)s. Not creating any backing for the "
- "volume: %(vol)s.") %
+ "volume: %(vol)s."),
{'svol': src_vref['name'],
'vol': volume['name']})
return
if not backing:
LOG.info(_LI("There is no backing for the source snapshot: "
"%(snap)s. Not creating any backing for the "
- "volume: %(vol)s.") %
+ "volume: %(vol)s."),
{'snap': snapshot['name'],
'vol': volume['name']})
return
if not snapshot_moref:
LOG.info(_LI("There is no snapshot point for the snapshotted "
"volume: %(snap)s. Not creating any backing for "
- "the volume: %(vol)s.") %
+ "the volume: %(vol)s."),
{'snap': snapshot['name'], 'vol': volume['name']})
return
src_vmdk_path = self.volumeops.get_vmdk_path(snapshot_moref)
size_gb = volume['size']
LOG.debug("Selected datastore %(ds)s for new volume of size "
- "%(size)s GB." % {'ds': summary.name, 'size': size_gb})
+ "%(size)s GB.", {'ds': summary.name, 'size': size_gb})
# prepare create spec for backing vm
profile_id = self._get_storage_profile_id(volume)
# fetching image from glance will also create the backing
timeout = self.configuration.vmware_image_transfer_timeout_secs
host_ip = self.configuration.vmware_host_ip
- LOG.debug("Fetching glance image: %(id)s to server: %(host)s." %
+ LOG.debug("Fetching glance image: %(id)s to server: %(host)s.",
{'id': image_id, 'host': host_ip})
image_transfer.download_stream_optimized_image(
context,
excep)
backing = self.volumeops.get_backing(volume['name'])
if backing:
- LOG.exception(_LE("Deleting the backing: %s") % backing)
+ LOG.exception(_LE("Deleting the backing: %s"), backing)
# delete the backing
self.volumeops.delete_backing(backing)
- LOG.info(_LI("Done copying image: %(id)s to volume: %(vol)s.") %
+ LOG.info(_LI("Done copying image: %(id)s to volume: %(vol)s."),
{'id': image_id, 'vol': volume['name']})
def _extend_vmdk_virtual_disk(self, name, new_size_in_gb):
:param image_service: Glance image service
:param image_id: Glance image id
"""
- LOG.debug("Copy glance image: %s to create new volume." % image_id)
+ LOG.debug("Copy glance image: %s to create new volume.", image_id)
# Verify glance image is vmdk disk format
metadata = image_service.show(context, image_id)
raise exception.InvalidVolume(msg)
# validate disk format is vmdk
- LOG.debug("Copy Volume: %s to new image." % volume['name'])
+ LOG.debug("Copy Volume: %s to new image.", volume['name'])
VMwareEsxVmdkDriver._validate_disk_format(image_meta['disk_format'])
# get backing vm of volume and its vmdk path
backing = self.volumeops.get_backing(volume['name'])
if not backing:
- LOG.info(_LI("Backing not found, creating for volume: %s") %
+ LOG.info(_LI("Backing not found, creating for volume: %s"),
volume['name'])
backing = self._create_backing_in_inventory(volume)
vmdk_file_path = self.volumeops.get_vmdk_path(backing)
image_name=image_meta['name'],
image_version=1,
is_public=True)
- LOG.info(_LI("Done copying volume %(vol)s to a new image %(img)s") %
+ LOG.info(_LI("Done copying volume %(vol)s to a new image %(img)s"),
{'vol': volume['name'], 'img': image_meta['name']})
def _in_use(self, volume):
try:
self._extend_vmdk_virtual_disk(vol_name, new_size)
LOG.info(_LI("Done extending volume %(vol)s "
- "to size %(size)s GB.") %
+ "to size %(size)s GB."),
{'vol': vol_name, 'size': new_size})
return
except exceptions.VimFaultException:
"place the extended volume %s."), vol_name)
LOG.info(_LI("Selected datastore %(ds)s to place extended volume of "
- "size %(size)s GB.") % {'ds': summary.name,
- 'size': new_size})
+ "size %(size)s GB."), {'ds': summary.name,
+ 'size': new_size})
try:
backing = self.volumeops.get_backing(vol_name)
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Not able to relocate volume %s for "
"extending."), vol_name)
- LOG.info(_LI("Done extending volume %(vol)s to size %(size)s GB.") %
+ LOG.info(_LI("Done extending volume %(vol)s to size %(size)s GB."),
{'vol': vol_name, 'size': new_size})
@contextlib.contextmanager
self._ds_sel = hub.DatastoreSelector(self.volumeops, self.session)
LOG.info(_LI("Successfully setup driver: %(driver)s for server: "
- "%(ip)s.") % {'driver': self.__class__.__name__,
- 'ip': self.configuration.vmware_host_ip})
+ "%(ip)s."), {'driver': self.__class__.__name__,
+ 'ip': self.configuration.vmware_host_ip})
def _get_volume_group_folder(self, datacenter):
"""Get volume group folder.
(folder, summary) = self._get_folder_ds_summary(volume,
resource_pool,
datastores)
- LOG.info(_LI("Relocating volume: %(backing)s to %(ds)s and %(rp)s.") %
+ LOG.info(_LI("Relocating volume: %(backing)s to %(ds)s and %(rp)s."),
{'backing': backing, 'ds': summary, 'rp': resource_pool})
# Relocate the backing to the datastore and folder
self.volumeops.relocate_backing(backing, summary.datastore,
# the size of the source volume to the volume size.
if volume['size'] > src_vsize:
self._extend_vmdk_virtual_disk(volume['name'], volume['size'])
- LOG.info(_LI("Successfully created clone: %s.") % clone)
+ LOG.info(_LI("Successfully created clone: %s."), clone)
def _create_volume_from_snapshot(self, volume, snapshot):
"""Creates a volume from a snapshot.
if not backing:
LOG.info(_LI("There is no backing for the snapshotted volume: "
"%(snap)s. Not creating any backing for the "
- "volume: %(vol)s.") %
+ "volume: %(vol)s."),
{'snap': snapshot['name'], 'vol': volume['name']})
return
snapshot_moref = self.volumeops.get_snapshot(backing,
if not snapshot_moref:
LOG.info(_LI("There is no snapshot point for the snapshotted "
"volume: %(snap)s. Not creating any backing for "
- "the volume: %(vol)s.") %
+ "the volume: %(vol)s."),
{'snap': snapshot['name'], 'vol': volume['name']})
return
clone_type = VMwareVcVmdkDriver._get_clone_type(volume)
backing = self.volumeops.get_backing(src_vref['name'])
if not backing:
LOG.info(_LI("There is no backing for the source volume: %(src)s. "
- "Not creating any backing for volume: %(vol)s.") %
+ "Not creating any backing for volume: %(vol)s."),
{'src': src_vref['name'], 'vol': volume['name']})
return
clone_type = VMwareVcVmdkDriver._get_clone_type(volume)
if clone_type == volumeops.LINKED_CLONE_TYPE:
if src_vref['status'] != 'available':
msg = _("Linked clone of source volume not supported "
- "in state: %s.")
- LOG.error(msg % src_vref['status'])
- raise exception.InvalidVolume(msg % src_vref['status'])
+ "in state: %s.") % src_vref['status']
+ LOG.error(msg)
+ raise exception.InvalidVolume(msg)
# For performing a linked clone, we snapshot the volume and
# then create the linked clone out of this snapshot point.
name = 'snapshot-%s' % volume['id']
# Result not obtained, continue retrieving results.
retrieve_result = self.continue_retrieval(retrieve_result)
- LOG.debug("Did not find any backing with name: %s" % name)
+ LOG.debug("Did not find any backing with name: %s", name)
def delete_backing(self, backing):
"""Delete the backing.
:param backing: Managed object reference to the backing
"""
- LOG.debug("Deleting the VM backing: %s." % backing)
+ LOG.debug("Deleting the VM backing: %s.", backing)
task = self._session.invoke_api(self._session.vim, 'Destroy_Task',
backing)
- LOG.debug("Initiated deletion of VM backing: %s." % backing)
+ LOG.debug("Initiated deletion of VM backing: %s.", backing)
self._session.wait_for_task(task)
- LOG.info(_LI("Deleted the VM backing: %s.") % backing)
+ LOG.info(_LI("Deleted the VM backing: %s."), backing)
# TODO(kartikaditya) Keep the methods not specific to volume in
# a different file
exists, else create one and return the reference
"""
LOG.debug("Creating folder: %(child_folder_name)s under parent "
- "folder: %(parent_folder)s." %
+ "folder: %(parent_folder)s.",
{'child_folder_name': child_folder_name,
'parent_folder': parent_folder})
child_folder = self._session.invoke_api(self._session.vim,
'CreateFolder', parent_folder,
name=child_folder_name)
- LOG.debug("Created child folder: %s." % child_folder)
+ LOG.debug("Created child folder: %s.", child_folder)
return child_folder
def extend_virtual_disk(self, requested_size_in_gb, name, dc_ref,
task = self._session.invoke_api(self._session.vim, 'RelocateVM_Task',
backing, spec=relocate_spec)
- LOG.debug("Initiated relocation of volume backing: %s." % backing)
+ LOG.debug("Initiated relocation of volume backing: %s.", backing)
self._session.wait_for_task(task)
LOG.info(_LI("Successfully relocated volume backing: %(backing)s "
- "to datastore: %(ds)s and resource pool: %(rp)s.") %
+ "to datastore: %(ds)s and resource pool: %(rp)s."),
{'backing': backing, 'ds': datastore, 'rp': resource_pool})
def move_backing_to_folder(self, backing, folder):
:param backing: Reference to the backing
:param folder: Reference to the folder
"""
- LOG.debug("Moving backing: %(backing)s to folder: %(fol)s." %
+ LOG.debug("Moving backing: %(backing)s to folder: %(fol)s.",
{'backing': backing, 'fol': folder})
task = self._session.invoke_api(self._session.vim,
'MoveIntoFolder_Task', folder,
list=[backing])
LOG.debug("Initiated move of volume backing: %(backing)s into the "
- "folder: %(fol)s." % {'backing': backing, 'fol': folder})
+ "folder: %(fol)s.", {'backing': backing, 'fol': folder})
self._session.wait_for_task(task)
LOG.info(_LI("Successfully moved volume "
"backing: %(backing)s into the "
- "folder: %(fol)s.") % {'backing': backing, 'fol': folder})
+ "folder: %(fol)s."), {'backing': backing, 'fol': folder})
def create_snapshot(self, backing, name, description, quiesce=False):
"""Create snapshot of the backing with given name and description.
:param quiesce: Whether to quiesce the backing when taking snapshot
:return: Created snapshot entity reference
"""
- LOG.debug("Snapshoting backing: %(backing)s with name: %(name)s." %
+ LOG.debug("Snapshoting backing: %(backing)s with name: %(name)s.",
{'backing': backing, 'name': name})
task = self._session.invoke_api(self._session.vim,
'CreateSnapshot_Task',
description=description,
memory=False, quiesce=quiesce)
LOG.debug("Initiated snapshot of volume backing: %(backing)s "
- "named: %(name)s." % {'backing': backing, 'name': name})
+ "named: %(name)s.", {'backing': backing, 'name': name})
task_info = self._session.wait_for_task(task)
snapshot = task_info.result
LOG.info(_LI("Successfully created snapshot: %(snap)s for volume "
- "backing: %(backing)s.") %
+ "backing: %(backing)s."),
{'snap': snapshot, 'backing': backing})
return snapshot
:param name: Snapshot name
"""
LOG.debug("Deleting the snapshot: %(name)s from backing: "
- "%(backing)s." %
+ "%(backing)s.",
{'name': name, 'backing': backing})
snapshot = self.get_snapshot(backing, name)
if not snapshot:
LOG.info(_LI("Did not find the snapshot: %(name)s for backing: "
- "%(backing)s. Need not delete anything.") %
+ "%(backing)s. Need not delete anything."),
{'name': name, 'backing': backing})
return
task = self._session.invoke_api(self._session.vim,
'RemoveSnapshot_Task',
snapshot, removeChildren=False)
LOG.debug("Initiated snapshot: %(name)s deletion for backing: "
- "%(backing)s." %
+ "%(backing)s.",
{'name': name, 'backing': backing})
self._session.wait_for_task(task)
LOG.info(_LI("Successfully deleted snapshot: %(name)s of backing: "
- "%(backing)s.") % {'backing': backing, 'name': name})
+ "%(backing)s."), {'backing': backing, 'name': name})
def _get_folder(self, backing):
"""Get parent folder of the backing.
task = self._session.invoke_api(self._session.vim, 'CloneVM_Task',
backing, folder=folder, name=name,
spec=clone_spec)
- LOG.debug("Initiated clone of backing: %s." % name)
+ LOG.debug("Initiated clone of backing: %s.", name)
task_info = self._session.wait_for_task(task)
new_backing = task_info.result
- LOG.info(_LI("Successfully created clone: %s.") % new_backing)
+ LOG.info(_LI("Successfully created clone: %s."), new_backing)
return new_backing
def _reconfigure_backing(self, backing, reconfig_spec):
:param file_path: Datastore path of the file or folder
"""
- LOG.debug("Deleting file: %(file)s under datacenter: %(dc)s." %
+ LOG.debug("Deleting file: %(file)s under datacenter: %(dc)s.",
{'file': file_path, 'dc': datacenter})
fileManager = self._session.vim.service_content.fileManager
task = self._session.invoke_api(self._session.vim,
fileManager,
name=file_path,
datacenter=datacenter)
- LOG.debug("Initiated deletion via task: %s." % task)
+ LOG.debug("Initiated deletion via task: %s.", task)
self._session.wait_for_task(task)
- LOG.info(_LI("Successfully deleted file: %s.") % file_path)
+ LOG.info(_LI("Successfully deleted file: %s."), file_path)
def get_path_name(self, backing):
"""Get path name of the backing.
destName=dest_vmdk_file_path,
destDatacenter=dc_ref,
force=True)
- LOG.debug("Initiated copying disk data via task: %s." % task)
+ LOG.debug("Initiated copying disk data via task: %s.", task)
self._session.wait_for_task(task)
- LOG.info(_LI("Successfully copied disk at: %(src)s to: %(dest)s.") %
+ LOG.info(_LI("Successfully copied disk at: %(src)s to: %(dest)s."),
{'src': src_vmdk_file_path, 'dest': dest_vmdk_file_path})
def delete_vmdk_file(self, vmdk_file_path, dc_ref):
:param vmdk_file_path: VMDK file path to be deleted
:param dc_ref: Reference to datacenter that contains this VMDK file
"""
- LOG.debug("Deleting vmdk file: %s." % vmdk_file_path)
+ LOG.debug("Deleting vmdk file: %s.", vmdk_file_path)
diskMgr = self._session.vim.service_content.virtualDiskManager
task = self._session.invoke_api(self._session.vim,
'DeleteVirtualDisk_Task',
diskMgr,
name=vmdk_file_path,
datacenter=dc_ref)
- LOG.debug("Initiated deleting vmdk file via task: %s." % task)
+ LOG.debug("Initiated deleting vmdk file via task: %s.", task)
self._session.wait_for_task(task)
- LOG.info(_LI("Deleted vmdk file: %s.") % vmdk_file_path)
+ LOG.info(_LI("Deleted vmdk file: %s."), vmdk_file_path)