Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 183671

[vR0 7.5]- Create scheduled task on vCenter for Virtual Machine Object

$
0
0

Hi everyone,

 

we try to create a vCenter scheduled task (capture below) on a Virtual Machine from vRO :

 

 

So that, we will use this object :

 

VcScheduledTaskManager.createObjectScheduledTask(VcManagedObject,VcScheduledTaskSpec);

 

to find "VcManagedObject" we do that like this :

 

// INPUT
// vcVirtual Machine

// Find the managed entity on which the action is performed.
managedObjectReference = vcVirtualMachine.moref;
System.debug("managedObjectReference found : " + managedObjectReference + " for the Virtual Machine : " + vcVirtualMachine.name);

 

now to create "VcScheduledTaskSpec" we need this :

 

so, in vRO :

 

// INPUT
// emailRequester

// Define the scheduled task specification.
scheduledTaskSpec = new VcScheduledTaskSpec();
scheduledTaskSpec.name = "Restart Virtual Machine";
scheduledTaskSpec.description = "Restart Virtual Machine Scheduled - Created from OneCloud Portal";
scheduledTaskSpec.enabled = true;
scheduledTaskSpec.scheduler= TaskScheduler;
scheduledTaskSpec.action = vcAction;
scheduledTaskSpec.notification = emailRequester;
System.debug("scheduledTaskSpec found : " + scheduledTaskSpec);

 

To create the "TaskScheduler" :

 

// INPUT
// taskRunAt - date
// taskExpireTime - date

// Create a OnceTaskScheduler and set the time to
// run the Task Action at in the Scheduler.
TaskScheduler = new VcOnceTaskScheduler();
TaskScheduler.activeTime = taskRunAt;
TaskScheduler.expireTime = taskExpireTime;
TaskScheduler.runAt = taskRunAt;
System.debug("TaskScheduler found : " + TaskScheduler);

 

now we need to have a VcAction and we don't undesrtand how to build this object.............

 

If you have an idea or if you know how to build a vcAction, we take

 

Thx for your help.


Viewing all articles
Browse latest Browse all 183671


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>