Java 类com.vmware.vim25.mo.ScheduledTask 实例源码

项目:vijava    文件:CreateScheduledTasks.java   
static boolean taskNameExists(ScheduledTaskManager stm, 
    String vmname)
{
  ScheduledTask[] tasks = stm.getScheduledTasks();
  boolean found = false;
  for(int i=0; tasks!=null && i<tasks.length; i++)
  {
    if(vmname.equals(tasks[i].getInfo().getName()))
    {
      found = true;
      System.out.println("The task name " + vmname 
          + " exists. \nPlease pick a new one.");
      break;
     }
  }
  return found;
}
项目:vijava    文件:CreateScheduledTasks.java   
public static void main(String [] args) throws Exception
 {
   if(args.length != 4)
   {
     System.out.println("Usage: java CreateScheduledTasks " 
    + "<url> <username> <password> <vmname>");
  return;
   }

   ServiceInstance si = new ServiceInstance(
              new URL(args[0]), args[1], args[2], true);
   Folder rootFolder = si.getRootFolder();

   InventoryNavigator inv = new InventoryNavigator(rootFolder);
   String vmname = args[3];
   VirtualMachine vm = (VirtualMachine)inv.searchManagedEntity(
           "VirtualMachine", vmname);
if(vm==null)
{
  System.out.println("Cannot find the VM " + vmname 
    + "\nExisting...");
  si.getServerConnection().logout();
  return;
}

   ScheduledTaskManager stm = si.getScheduledTaskManager();
   if(stm!=null)
   {
     //to save space, we just check one name here
     if(taskNameExists(stm, "ViMaster_OneTime"))
     {
       si.getServerConnection().logout();
       return;
     }

     // Note: the time should be fetched from server,
     // just to make sure it's synchronized.
     ScheduledTaskSpec oneSpec = createOneTimeSchedulerSpec(
         "ViMaster_OneTime", si.currentTime());

     ScheduledTaskSpec weekSpec = createWeeklySchedulerSpec(
         "ViMaster_Weekly");

     ScheduledTask st = stm.createScheduledTask(vm, oneSpec);
     ScheduledTask st1 = stm.createScheduledTask(vm, weekSpec);
  // sleep two minutes before deleting 
  // the one time scheduled task.
     // An one time scheduled task has not to be deleted after
     // it's run. It can be run any time again by calling the 
     // runScheduledTask() method.
     Thread.sleep(2*60*1000);
     st.removeScheduledTask();
   }
   else
   {
     System.out.println("SchduledTaskManager is not "
       + "available on this target.");
   }

si.getServerConnection().logout();
  }
项目:jcloud-vsphere    文件:ScheduledTaskManagerApi.java   
/**
 * @since SDK4.0
 */
ScheduledTask createObjectScheduledTask(ManagedObject obj, ScheduledTaskSpec spec) throws InvalidName, DuplicateName, RuntimeFault, RemoteException;
项目:jcloud-vsphere    文件:ScheduledTaskManagerApi.java   
/**
 * @since SDK4.0
 */
List<ScheduledTask> retrieveObjectScheduledTask(ManagedObject obj) throws RuntimeFault, RemoteException;
项目:jcloud-vsphere    文件:ScheduledTaskManagerApi.java   
List<ScheduledTask> getScheduledTasks();
项目:jcloud-vsphere    文件:ScheduledTaskManagerApi.java   
ScheduledTask createScheduledTask(ManagedEntity entity, ScheduledTaskSpec spec) throws InvalidName, DuplicateName, RuntimeFault, RemoteException;
项目:jcloud-vsphere    文件:ScheduledTaskManagerApi.java   
List<ScheduledTask> retrieveEntityScheduledTask(ManagedEntity entity) throws RuntimeFault, RemoteException;