Need help on Scheduled task for VM snapshot
Open
Nobody has claimed this yet.
question
- Dominant language
- Python
- Stars
- 2.3k
- Forks
- 763
- PR merge metrics
- No merged PRs in 30d
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:
https://github.com/vmware/pyvmomi/issues/452
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The reported failure occurs at si.content.scheduledTaskManager.CreateScheduledTask(vm, spec); start by comparing the ScheduledTaskSpec and MethodAction fields in the shown script with the referenced sample issue. Done means identifying the invalid parameter and documenting or reproducing a corrected scheduled VM snapshot request.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100