Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Skip independent disks, as that disk type is implicitly excluded
Browse files Browse the repository at this point in the history
from snapshot so that they can not be handled by CBT based backup

Fixes #492: WMware plugin tries to backup independent disk resulting backup job failure
  • Loading branch information
sduehr authored and Marco van Wieringen committed Jul 17, 2015
1 parent cae6f7b commit 04ba4d7
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions vmware_plugin/BareosFdPluginVMware.py
Expand Up @@ -526,6 +526,8 @@ def __init__(self):
self.restore_objects_by_diskpath = {}
self.restore_objects_by_objectname = {}
self.options = None
self.skip_disk_modes = ['independent_nonpersistent',
'independent_persistent']

def connect_vmware(self, context):
# this prevents from repeating on second call
Expand Down Expand Up @@ -642,7 +644,7 @@ def prepare_vm_backup(self, context):
bareosfd.DebugMessage(
context, 100, "Getting Disk Devices on VM %s from snapshot\n" %
(vmname))
self.get_vm_snap_disk_devices()
self.get_vm_snap_disk_devices(context)
if not self.disk_devices:
bareosfd.JobMessage(
context, bJobMessageType['M_FATAL'],
Expand Down Expand Up @@ -696,7 +698,7 @@ def prepare_vm_restore(self, context):
bareosfd.DebugMessage(
context, 100, "Getting Disk Devices on VM %s\n" %
(vmname))
self.get_vm_disk_devices()
self.get_vm_disk_devices(context)
if not self.disk_devices:
bareosfd.JobMessage(
context, bJobMessageType['M_FATAL'],
Expand Down Expand Up @@ -735,8 +737,7 @@ def get_vm_details_dc_folder_vmname(self, context):

if vm_path not in vmListWithFolder:
bareosfd.JobMessage(
context,
bJobMessageType['M_FATAL'],
context, bJobMessageType['M_FATAL'],
"No VM with Folder/Name %s found in DC %s\n" %
(vm_path, self.options['dc']))
return False
Expand Down Expand Up @@ -811,28 +812,34 @@ def remove_vm_snapshot(self, context):
self.vmomi_WaitForTasks([rmsnap_task])
return True

def get_vm_snap_disk_devices(self):
def get_vm_snap_disk_devices(self, context):
'''
Get the disk devices from the created snapshot
Assumption: Snapshot successfully created
'''
self.disk_devices = []
for hw_device in self.create_snap_result.config.hardware.device:
if hw_device._wsdlName == 'VirtualDisk':
self.disk_devices.append(
{'deviceKey': hw_device.key,
'fileName': hw_device.backing.fileName,
'fileNameRoot': self.get_vm_disk_root_filename(
hw_device.backing),
'changeId': hw_device.backing.changeId})
self.get_disk_devices(context, self.create_snap_result.config.hardware.device)

def get_vm_disk_devices(self):
def get_vm_disk_devices(self, context):
'''
Get the disk devices from vm
'''
self.get_disk_devices(context, self.vm.config.hardware.device)

def get_disk_devices(self, context, devicespec):
'''
Get disk devices from a devicespec
'''
self.disk_devices = []
for hw_device in self.vm.config.hardware.device:
if hw_device._wsdlName == 'VirtualDisk':
for hw_device in devicespec:
if type(hw_device) == vim.vm.device.VirtualDisk:
if hw_device.backing.diskMode in self.skip_disk_modes:
bareosfd.JobMessage(
context, bJobMessageType['M_INFO'],
"Skipping Disk %s because mode is %s\n" %
(self.get_vm_disk_root_filename(hw_device.backing),
hw_device.backing.diskMode))
continue

self.disk_devices.append(
{'deviceKey': hw_device.key,
'fileName': hw_device.backing.fileName,
Expand Down

0 comments on commit 04ba4d7

Please sign in to comment.