-
Notifications
You must be signed in to change notification settings - Fork 770
Open
Labels
Description
I am trying to create a script to schedule run once snapshots.
I have looked at the samples but found this issue is more helpful:
Hence I have wrote my code:
scheduleTime = "29/03/2021 20:50"
dt = datetime.strptime(scheduleTime, '%d/%m/%Y %H:%M')
spec = vim.scheduler.ScheduledTaskSpec()
spec.name = 'jsmith'
spec.description = "VM Snapshot scheduled for jsmith"
spec.scheduler = vim.scheduler.OnceTaskScheduler()
spec.scheduler.runAt = dt
spec.action = vim.action.MethodAction()
spec.action.name = vim.VirtualMachine.CreateSnapshot
spec.action.argument = [vim.MethodActionArgument()] * 4
spec.action.argument[0].value = "spec.name"
spec.action.argument[1].value = "spec.description"
spec.action.argument[2].value = False
spec.action.argument[3].value = False
spec.enabled = True
si.content.scheduledTaskManager.CreateScheduledTask(vm, spec)
I keep getting this error:
si.content.scheduledTaskManager.CreateScheduledTask(vm, spec)
File "/home/adm-qhan/miniconda3/envs/pyvmomi/lib/python3.7/site-packages/pyVmomi/VmomiSupport.py", line 706, in <lambda>
self.f(*(self.args + (obj,) + args), **kwargs)
File "/home/adm-qhan/miniconda3/envs/pyvmomi/lib/python3.7/site-packages/pyVmomi/VmomiSupport.py", line 512, in _InvokeMethod
return self._stub.InvokeMethod(self, info, args)
File "/home/adm-qhan/miniconda3/envs/pyvmomi/lib/python3.7/site-packages/pyVmomi/SoapAdapter.py", line 1397, in InvokeMethod
raise obj # pylint: disable-msg=E0702
pyVmomi.VmomiSupport.InvalidArgument: (vmodl.fault.InvalidArgument) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
msg = 'A specified parameter was not correct: ',
faultCause = <unset>,
faultMessage = (vmodl.LocalizableMessage) [],
invalidProperty = <unset>
}
Which parameter it could be wrong in this case?