Skip to content

Commit

Permalink
VMware Plugin: Add option to enable CBT
Browse files Browse the repository at this point in the history
Add the plugin option enable_cbt, when set set to yes, the plugin
will enable CBT if possible and it is not yet enabled.
  • Loading branch information
sduehr authored and BareosBot committed Oct 6, 2023
1 parent 9971051 commit 4549b97
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions core/src/plugins/filed/python/vmware/BareosFdPluginVMware.py
Expand Up @@ -114,6 +114,7 @@ def __init__(self, plugindef):
"config_file",
"snapshot_retries",
"snapshot_retry_wait",
"enable_cbt",
]
self.allowed_options = (
self.mandatory_options_default
Expand Down Expand Up @@ -368,6 +369,9 @@ def check_plugin_options(self, mandatory_options=None):
)
return bareosfd.bRC_Error

if self.options.get("enable_cbt") == "yes":
self.vadp.enable_cbt = True

for options in self.options:
bareosfd.DebugMessage(
100,
Expand Down Expand Up @@ -1010,6 +1014,7 @@ def __init__(self):
self.snapshot_retries = 3
self.snapshot_retry_wait = 5
self.snapshot_prefix = "BareosTmpSnap_jobId"
self.enable_cbt = False

def connect_vmware(self):
# this prevents from repeating on second call
Expand Down Expand Up @@ -1169,15 +1174,32 @@ def prepare_vm_backup(self):
return bareosfd.bRC_Error

if not self.vm.config.changeTrackingEnabled:
bareosfd.DebugMessage(
100,
"Error vm %s is not cbt enabled\n" % (StringCodec.encode(self.vm.name)),
)
bareosfd.JobMessage(
bareosfd.M_FATAL,
"Error vm %s is not cbt enabled\n" % (StringCodec.encode(self.vm.name)),
)
return bareosfd.bRC_Error
if self.enable_cbt:
bareosfd.JobMessage(
bareosfd.M_INFO,
"Error vm %s is not cbt enabled, enabling it now.\n"
% (StringCodec.encode(self.vm.name)),
)
if self.vm.snapshot is not None:
bareosfd.JobMessage(
bareosfd.M_FATAL,
"Error VM %s must not have any snapshots before enabling CBT\n"
% (StringCodec.encode(self.vm.name)),
)
return bareosfd.bRC_Error

cspec = vim.vm.ConfigSpec()
cspec.changeTrackingEnabled = True
task = self.vm.ReconfigVM_Task(cspec)
pyVim.task.WaitForTask(task)

else:
bareosfd.JobMessage(
bareosfd.M_FATAL,
"Error vm %s is not cbt enabled\n"
% (StringCodec.encode(self.vm.name)),
)
return bareosfd.bRC_Error

bareosfd.DebugMessage(
100,
Expand Down

0 comments on commit 4549b97

Please sign in to comment.