This example shows how you can schedule a backup job, update the schedule, and get a schedule. The example is based on the backup_schedule.py sample.
For a complete and up-to-date version of the sample code, see the vSphere Automation SDK Python samples at GitHub.
... # Connect to vAPI services self.stub_config = vapiconnect.connect( host=args.server, user=args.username, pwd=args.password, skip_verification=args.skipverification) self.schedule_client = Schedules(self.stub_config) ... def create_schedule(self): retention_info = Schedules.RetentionInfo(self.max_count) recurrence_info = Schedules.RecurrenceInfo( days=self.days, hour=self.hour, minute=self.minute) create_spec = Schedules.CreateSpec( location=self.location, location_user=self.location_user, location_password=self.location_password, recurrence_info=recurrence_info, retention_info=retention_info) self.schedule_client.create(self._schedule_id, create_spec) def update_schedule(self): retention_info = Schedules.RetentionInfo(self.max_count) recurrence_info = Schedules.RecurrenceInfo( days=self.days, hour=self.hour, minute=self.minute) update_spec = Schedules.UpdateSpec( location=self.location, location_user=self.location_user, location_password=self.location_password, recurrence_info=recurrence_info, retention_info=retention_info) self.schedule_client.update(self._schedule_id, update_spec) def get_schedule(self): self.schedule_client = Schedules(self.stub_config) schedule_spec = self.schedule_client.get(self._schedule_id) recurrence_info = schedule_spec.recurrence_info retention_info = schedule_spec.retention_info table = [] data = [self._schedule_id, "{}:{}".format(recurrence_info.hour, recurrence_info.minute), " ".join(recurrence_info.days), retention_info.max_count] table.append(data) headers = ["Schedule ID", "Time", "Days", "Retention"] print(tabulate(table, headers)) ...