private static boolean migrateVM(String targetVMName, String newHostName, boolean tryAnotherVM, boolean tryAnotherHost) throws Exception { ServiceInstance si = new ServiceInstance(new URL(url), username, password, true); try { Folder rootFolder = si.getRootFolder(); HostSystem newHost = (HostSystem)new InventoryNavigator(rootFolder) .searchManagedEntity("HostSystem", newHostName); return migrateVM(si, rootFolder, newHost, targetVMName, newHostName, tryAnotherVM, tryAnotherHost); } finally { si.getServerConnection().logout(); } }
private static synchronized boolean doMigrateVM(String targetVMName, String newHostName) throws Exception { ServiceInstance si = new ServiceInstance(new URL(url), username, password, true); try { Folder rootFolder = si.getRootFolder(); InventoryNavigator in = new InventoryNavigator(rootFolder); HostSystem newHost = (HostSystem)in.searchManagedEntity("HostSystem", newHostName); if (newHost == null) { throw new TestException("Could not find host " + newHostName + " as a target host for vMotion."); } return migrateVM(si, rootFolder, newHost, targetVMName, newHostName); } finally { si.getServerConnection().logout(); } }
public static void HydraTask_migrateNetDownVM() throws Exception { SharedMap sMap = VMotionBB.getBB().getSharedMap(); Boolean bool = (Boolean)sMap.get("connectionDropped"); if (bool == null || !bool) { return; } initializeParams(); if (!validateParams()) { return; } ServiceInstance si = new ServiceInstance(new URL(url), username, password, true); try { Folder rootFolder = si.getRootFolder(); HostSystem newHost = (HostSystem)new InventoryNavigator(rootFolder) .searchManagedEntity("HostSystem", hostNames[0]); migrateVM(si, rootFolder, newHost, vmNames[0], hostNames[0], false, false); } finally { si.getServerConnection().logout(); } }
private Optional<ResourcePool> tryFindResourcePool(Folder folder, String hostname) { Iterable<ResourcePool> resourcePools = ImmutableSet.<ResourcePool>of(); try { ManagedEntity[] resourcePoolEntities = new InventoryNavigator(folder).searchManagedEntities("ResourcePool"); resourcePools = Iterables.transform(Arrays.asList(resourcePoolEntities), new Function<ManagedEntity, ResourcePool>() { public ResourcePool apply(ManagedEntity input) { return (ResourcePool) input; } }); Optional<ResourcePool> optionalResourcePool = Iterables.tryFind(resourcePools, VSpherePredicate.isResourcePoolOf(hostname)); return optionalResourcePool; } catch (Exception e) { logger.error("Problem in finding a valid resource pool", e); } return Optional.absent(); }
private Set<? extends Location> getClusters() { Set<Location> hosts = Sets.newHashSet(); try (VSphereServiceInstance instance = serviceInstance.get();) { ManagedEntity[] clusterEntities = new InventoryNavigator(instance.getInstance().getRootFolder()).searchManagedEntities("ClusterComputeResource"); for (ManagedEntity cluster : clusterEntities) { Location location = new LocationImpl(LocationScope.ZONE, cluster.getName(), cluster.getName(), null, ImmutableSet.of(""), Maps.<String, Object>newHashMap()); hosts.add(location); } hosts.add(new LocationImpl(LocationScope.ZONE, "default", "default", null, ImmutableSet.of(""), Maps.<String, Object>newHashMap())); return hosts; } catch (Exception e) { logger.error("Problem in finding a valid cluster", e); Throwables.propagateIfPossible(e); } return hosts; }
@Override public Optional<VirtualMachine> load(String vmName) { Optional<VirtualMachine> results = Optional.absent(); try (VSphereServiceInstance instance = serviceInstance.get();) { VirtualMachine vm = (VirtualMachine) new InventoryNavigator(instance.getInstance().getRootFolder()).searchManagedEntity("VirtualMachine", vmName); if (VSpherePredicate.isTemplatePredicate.apply(vm)) { results = Optional.of(vm); } } catch (Exception e) { logger.error("Can't find template " + vmName, e); Throwables.propagateIfPossible(e); } return results; }
private List<ManagedEntity> getHostMachines(Folder rootFolder, List<Map<String, Object>> hostConfigs) { List<ManagedEntity> hostEntities = new ArrayList<ManagedEntity>(); for (Map<String, Object> hostConfig : hostConfigs) { String hostName = (String) hostConfig.get("host"); try { if ("*".equals(hostName)) { hostEntities = Arrays.asList(new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem")); } else { ManagedEntity hostSystem = new InventoryNavigator(rootFolder).searchManagedEntity("HostSystem", hostName); if (hostSystem != null) { hostEntities.add(hostSystem); } else { logger.error("Could not find Host with name " + hostName); } } } catch (InvalidProperty invalidProperty) { logger.error("Unable to get the host details", invalidProperty); } catch (RuntimeFault runtimeFault) { logger.error("Unable to get the host details", runtimeFault); } catch (RemoteException e) { logger.error("Unable to get the host details", e); } } return hostEntities; }
@Bean @ConditionalOnProperty("vsphere.host") InventoryNavigator inventoryNavigator(@Value("${vsphere.host}") String host, @Value("${vsphere.username}") String username, @Value("${vsphere.password}") String password) throws MalformedURLException, RemoteException { URL url = new URL(String.format("https://%s/sdk", host)); ServiceInstance serviceInstance = new ServiceInstance(url, username, password, true); return new InventoryNavigator(serviceInstance.getRootFolder()); }
@Autowired public VSphereMetricsForwarder(InventoryNavigator inventoryNavigator, @Value("${cf.instance.Name:default}") String cfInstanceName, @Value("${datastores:}") String[] datastores) { this.inventoryNavigator = inventoryNavigator; this.cfInstanceName = cfInstanceName; this.insights = NewRelic.getAgent().getInsights(); this.datastores = Lists.newArrayList(datastores); }
private Iterable<VirtualMachine> listNodes(VSphereServiceInstance instance) { Iterable<VirtualMachine> vms = ImmutableSet.of(); try { Folder nodesFolder = instance.getInstance().getRootFolder(); ManagedEntity[] managedEntities = new InventoryNavigator(nodesFolder).searchManagedEntities("VirtualMachine"); vms = Iterables.transform(Arrays.asList(managedEntities), new Function<ManagedEntity, VirtualMachine>() { public VirtualMachine apply(ManagedEntity input) { return (VirtualMachine) input; } }); } catch (Throwable e) { logger.error("Can't find vm", e); } return vms; }
@Override public Iterable<VirtualMachine> listNodesByIds(Iterable<String> ids) { Iterable<VirtualMachine> vms = ImmutableSet.of(); try (VSphereServiceInstance instance = serviceInstance.get();) { Folder nodesFolder = instance.getInstance().getRootFolder(); List<List<String>> list = new ArrayList<List<String>>(); Iterator<String> idsIterator = ids.iterator(); while (idsIterator.hasNext()) { list.add(Lists.newArrayList("VirtualMachine", idsIterator.next())); } String[][] typeInfo = ListsUtils.ListToArray(list); ManagedEntity[] managedEntities = new InventoryNavigator(nodesFolder).searchManagedEntities( typeInfo, true); vms = Iterables.transform(Arrays.asList(managedEntities), new Function<ManagedEntity, VirtualMachine>() { public VirtualMachine apply(ManagedEntity input) { return (VirtualMachine) input; } }); } catch (Throwable e) { logger.error("Can't find vms ", e); } return vms; // Iterable<VirtualMachine> nodes = listNodes(); // Iterable<VirtualMachine> selectedNodes = Iterables.filter(nodes, VSpherePredicate.isNodeIdInList(ids)); // return selectedNodes; }
private HostSystem getSystemHost() { Iterable<HostSystem> hosts = ImmutableSet.<HostSystem>of(); try { VSphereServiceInstance instance = serviceInstance.get(); ManagedEntity[] hostEntities = new InventoryNavigator(instance.getInstance().getRootFolder()).searchManagedEntities("HostSystem"); hosts = Iterables.transform(Arrays.asList(hostEntities), new Function<ManagedEntity, HostSystem>() { public HostSystem apply(ManagedEntity input) { return (HostSystem) input; } }); HostSystem curHostSystem = null; long maxMemory = Integer.MIN_VALUE; for (HostSystem hostSystem : hosts) { int currentMemory = hostSystem.getSummary().getQuickStats().getOverallMemoryUsage(); long currentTotalMemory = hostSystem.getConfig().getSystemResources().getConfig().getMemoryAllocation().getLimit(); if (currentTotalMemory - currentMemory > maxMemory) { curHostSystem = hostSystem; maxMemory = currentTotalMemory - currentMemory; } } return curHostSystem; } catch (Exception e) { logger.error("Problem in finding a valid host: " + e.toString(), e); } return null; }
@Override public Folder apply(final String folderName) { try { if (Strings.isNullOrEmpty(folderName)) return (Folder) master.getParent(); VSphereServiceInstance instance = serviceInstance.get(); ManagedEntity entity = new InventoryNavigator(instance.getInstance().getRootFolder()).searchManagedEntity("Folder", folderName); return (Folder) entity; } catch (Exception e) { logger.error("Problem in finding a valid Folder with name " + folderName, e); } return (Folder) master.getParent(); }
@Nullable @Override public VSphereHost apply(@Nullable String dataCenter) { try (VSphereServiceInstance instance = serviceInstance.get();) { ManagedEntity[] clusterEntities = new InventoryNavigator(instance.getInstance().getRootFolder()).searchManagedEntities("ClusterComputeResource"); Iterable<ClusterComputeResource> clusterComputeResources = Iterables.transform(Arrays.asList(clusterEntities), new Function<ManagedEntity, ClusterComputeResource>() { public ClusterComputeResource apply(ManagedEntity input) { return (ClusterComputeResource) input; } }); HostSystem curHostSystem = null; for (ClusterComputeResource cluster : clusterComputeResources) { if (cluster.getName().equals(dataCenter) || dataCenter.equals("default")) { HostSystem[] hostSystems = cluster.getHosts(); long maxMemory = Integer.MIN_VALUE; for (HostSystem hostSystem : hostSystems) { int currentMemory = hostSystem.getSummary().getQuickStats().getOverallMemoryUsage(); long currentTotalMemory = hostSystem.getConfig().getSystemResources().getConfig().getMemoryAllocation().getLimit(); if (currentTotalMemory - currentMemory > maxMemory) { curHostSystem = hostSystem; maxMemory = currentTotalMemory - currentMemory; } } break; } } return new VSphereHost(curHostSystem.getName(), serviceInstance.get()); // return this.systemHostToVSphereHost.apply(curHostSystem); } catch (Exception e) { logger.error("Problem in finding a valid host: " + e.toString(), e); } return null; }
@Override public DistributedVirtualPortgroup apply(final String vlanName) { try { VSphereServiceInstance instance = serviceInstance.get(); ManagedEntity entity = new InventoryNavigator(instance.getInstance().getRootFolder()).searchManagedEntity("DistributedVirtualPortgroup", vlanName); return (DistributedVirtualPortgroup) entity; } catch (Exception e) { logger.error("Problem in finding a valid DistributedVirtualPortgroup with name " + vlanName, e); } return null; }
public VSphereHost(String hostName, VSphereServiceInstance serviceInstance) { this.serviceInstance = checkNotNull(serviceInstance, "serviceInstance"); try { ManagedEntity hostEntity = new InventoryNavigator(serviceInstance.getInstance().getRootFolder()).searchManagedEntity("HostSystem", hostName); this.host = checkNotNull((HostSystem)hostEntity, "host"); } catch (RemoteException e) { e.printStackTrace(); } }
/** * TODO: メソッドコメントを記述 * * @param <T> * @param rootEntity * @param type * @param name * @return */ public <T extends ManagedEntity> T search(ManagedEntity rootEntity, Class<T> type, String name) { InventoryNavigator navigator = new InventoryNavigator(rootEntity); ManagedEntity entity; try { entity = navigator.searchManagedEntity(type.getSimpleName(), name); } catch (RemoteException e) { throw new RuntimeException(e); } return type.cast(entity); }
/** * TODO: メソッドコメントを記述 * * @param rootEntity * @param name * @return */ public ManagedEntity searchByName(ManagedEntity rootEntity, String name) { InventoryNavigator navigator = new InventoryNavigator(rootEntity); ManagedEntity entity; try { entity = navigator.searchManagedEntity("ManagedEntity", name); } catch (RemoteException e) { throw new RuntimeException(e); } return entity; }
/** * TODO: メソッドコメントを記述 * * @param <T> * @param rootEntity * @param type * @return */ public <T extends ManagedEntity> ManagedEntity[] searchByType(ManagedEntity rootEntity, Class<T> type) { InventoryNavigator navigator = new InventoryNavigator(rootEntity); ManagedEntity[] entities; try { entities = navigator.searchManagedEntities(type.getSimpleName()); } catch (RemoteException e) { throw new RuntimeException(e); } return entities; }
/** * TODO: メソッドコメントを記述 * * @param rootEntity * @return */ public ManagedEntity[] searchAll(ManagedEntity rootEntity) { InventoryNavigator navigator = new InventoryNavigator(rootEntity); ManagedEntity[] entities; try { entities = navigator.searchManagedEntities(true); } catch (RemoteException e) { throw new RuntimeException(e); } return entities; }
public VmwareDistributedVirtualSwitch getVmwareDvs(String name, Datacenter dc, String dcName) throws RemoteException { if (dvswitches.containsKey(name)) { return dvswitches.get(name); } String description = "<dvs " + name + ", datacenter " + dcName + ", vCenter " + vcenterUrl + ">."; InventoryNavigator inventoryNavigator = new InventoryNavigator(dc); VmwareDistributedVirtualSwitch dvs = null; try { dvs = (VmwareDistributedVirtualSwitch)inventoryNavigator.searchManagedEntity( "VmwareDistributedVirtualSwitch", name); } catch (RemoteException e ) { operationalStatus = "Failed to retrieve " + description; s_logger.error(operationalStatus); throw new RemoteException(operationalStatus, e); } if (dvs == null) { operationalStatus = "Failed to retrieve " + description; s_logger.error(operationalStatus); throw new RemoteException(operationalStatus); } s_logger.info("Found " + description); dvswitches.put(name, dvs); return dvs; }
public static void main(String[] args) throws Exception { String vmName = "Rawc1.2_Win7x32bit_Target"; ServiceInstance si = new ServiceInstance(new URL("https://8.8.8.8/sdk"), "administrator", "vmware", true); VirtualMachine vm = (VirtualMachine) new InventoryNavigator(si.getRootFolder()).searchManagedEntity("VirtualMachine", vmName); VirtualMachineDeviceManager vmdm = new VirtualMachineDeviceManager(vm); vmdm.createNetworkAdapter(VirtualNetworkAdapterType.VirtualE1000, "dvPortGroup", "00:50:56:00:12:14", true, true); // vmdm.createNetworkAdapter(VirtualNetworkAdapterType.VirtualVmxnet3, null, "VM Network", true, false); // vmdm.createNewHardDisk(2048, VirtualDiskType.thin, VirtualDiskMode.persistent); // vmdm.addHardDisk("[psorl-iscsi01] tobin-win7-a/Rawc1.2_Win7x32bit_Target.vmdk", VirtualDiskMode.persistent); // vmdm.createNewHardDrive(1000, VirtualDiskType.flatMonolithic, VirtualDiskMode.persistent, false, false, null); // vmdm.createNewHardDrive(1000, VirtualDiskType.flatMonolithic, VirtualDiskMode.persistent, false, false, null); // List<VirtualDevice> devs = new ArrayList<VirtualDevice>(); // devs.add( vmdm.findHardDisk("Hard disk 2")); // devs.add( vmdm.findHardDisk("Hard disk 3")); // devs.add( vmdm.findHardDisk("Hard disk 4")); // devs.add( vmdm.findHardDisk("Hard disk 5")); // // // CAUTION: the second parameter is true, and remove disk files in datastore. // vmdm.removeDevices(devs, true); si.getServerConnection().logout(); }
public static void main(String[] args) throws Exception { CommandLineParser clp = new CommandLineParser( constructOptions(), args); String urlStr = clp.get_option("url"); String username = clp.get_option("username"); String password = clp.get_option("password"); String hostname = clp.get_option("hostname"); ServiceInstance si = new ServiceInstance(new URL(urlStr), username, password, true); HostSystem host = (HostSystem) new InventoryNavigator(si .getRootFolder()).searchManagedEntity("HostSystem", hostname); if (host == null) { System.out.println("Host cannot be found"); return; } HostAutoStartManager hasm = host.getHostAutoStartManager(); if (hasm == null) { System.out .println("HostAutoStartManager is not available."); return; } AutoStartDefaults asd = new AutoStartDefaults(); asd.setStartDelay(new Integer(100)); asd.setEnabled(Boolean.TRUE); asd.setStopDelay(new Integer(60)); HostAutoStartManagerConfig spec = new HostAutoStartManagerConfig(); spec.setDefaults(asd); hasm.reconfigureAutostart(spec); System.out .println("Done with reconfiguring the autostart options."); }
public static void main(String[] args) throws Exception { ServiceInstance si = new ServiceInstance(new URL("http://10.20.143.205/sdk"), "root", "password", true); Folder rootFolder = si.getRootFolder(); ManagedEntity[] vms = new InventoryNavigator(rootFolder).searchManagedEntities("VirtualMachine"); ManagedEntity[] hosts = new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem"); CacheInstance vicf = new CacheInstance(si); vicf.watch(vms, new String[] {"name", "runtime.powerState", "summary"}); vicf.watch(hosts, new String[] {"name", "summary"}); vicf.start(); //check if the caching is ready to use; otherwise wait while(!vicf.isReady()) { Thread.sleep(1000); } Thread[] vrs = new VimReader[2]; for(int i=0; i<vrs.length; i++) { vrs[i] = new VimReader("Thread " + i, vicf, vms, hosts); vrs[i].start(); } for(int i=0; i<vrs.length; i++) { vrs[i].join(); } si.getServerConnection().logout(); }
public static void main(String[] args) throws Exception { if(args.length!=3) { System.out.println("Usage: java CimTicket <url> " + "<username> <password>"); return; } String urlStr = args[0]; String username = args[1]; String password = args[2]; ServiceInstance si = new ServiceInstance(new URL(urlStr), username, password, true); Folder rootFolder = si.getRootFolder(); HostSystem host = (HostSystem) new InventoryNavigator( rootFolder).searchManagedEntities("HostSystem")[0]; System.out.println(host.getName()); HostServiceTicket ticket = host.acquireCimServicesTicket(); System.out.println("\nHost Name:" + ticket.getHost()); System.out.println("sessionId=" + ticket.getSessionId()); System.out.println("sslThumpprint=" + ticket.getSslThumbprint()); System.out.println("serviceVersion=" + ticket.getServiceVersion()); System.out.println("service=" + ticket.getService()); System.out.println("port=" + ticket.getPort()); retrieveCimInfo(urlStr, ticket.getSessionId()); si.getServerConnection().logout(); }
public boolean existsNFSStore(String name, String host, String address, String path) throws Exception { if(address == null || path == null || address.isEmpty() || path.isEmpty()) { return false; } ServiceInstance si = new ServiceInstance(new URL(this._url), this._user, this._password, true); if(host == null || host.isEmpty()) { si.getServerConnection().logout(); throw new Exception("invalid host name"); } try { HostSystem _host = (HostSystem) new InventoryNavigator(si.getRootFolder()).searchManagedEntity("HostSystem", host); if(_host == null) { si.getServerConnection().logout(); throw new Exception("host system not found"); } HostDatastoreSystem _hds = _host.getHostDatastoreSystem(); for(Datastore _ds : _hds.getDatastores()) { DatastoreInfo _info = _ds.getInfo(); if(_info instanceof NasDatastoreInfo) { NasDatastoreInfo _nasinfo = (NasDatastoreInfo) _info; if(name.equalsIgnoreCase(_nasinfo.getNas().getName())) { return true; } else if(address.equalsIgnoreCase(_nasinfo.getNas().getRemoteHost()) && path.equalsIgnoreCase(_nasinfo.getNas().getRemotePath())) { return true; } } } } catch(Exception _ex) { } finally { si.getServerConnection().logout(); } return false; }
public void run() { int vmToUse = -1; int attempts = 0; try { synchronized (vmList) { while (attempts < vmList.size()) { lastVMIndex = (lastVMIndex == (vmList.size() - 1)) ? 0 : ++lastVMIndex; vmToUse = lastVMIndex; if (!vmsInVMotion[vmToUse]) { vmsInVMotion[vmToUse] = Boolean.TRUE; lastHostIndex[vmToUse] = (lastHostIndex[vmToUse] == (vmList .get(vmToUse).size() - 1)) ? 1 : ++lastHostIndex[vmToUse]; break; } ++attempts; } } if (attempts == vmList.size()) { vmToUse = -1; // avoid logic in finally block return; // No vm available for vMotion. } String targetVMName = vmList.get(vmToUse).get(0); String newHostName = vmList.get(vmToUse).get(lastHostIndex[vmToUse]); Folder rootFolder = si.getRootFolder(); InventoryNavigator in = new InventoryNavigator(rootFolder); HostSystem newHost = (HostSystem)in.searchManagedEntity("HostSystem", newHostName); if (newHost == null) { log(WARNING, "Could not resolve host " + newHostName + ", vMotion to this host cannot be performed."); return; } //dummyVMotion(si, rootFolder, newHost, targetVMName, newHostName); migrateVM(si, rootFolder, newHost, targetVMName, newHostName); } catch (Exception e) { log(WARNING, "Found ", e); } finally { if (vmToUse != -1) { synchronized (vmList) { vmsInVMotion[vmToUse] = Boolean.FALSE; } } } }
private static boolean migrateVM(ServiceInstance si, Folder rootFolder, HostSystem newHost, String targetVMName, String newHostName) throws Exception { log("Selected host [vm] for vMotion: " + newHostName + " [" + targetVMName + "]"); VirtualMachine vm = (VirtualMachine)new InventoryNavigator(rootFolder) .searchManagedEntity("VirtualMachine", targetVMName); if (vm == null) { log(WARNING, "Could not resolve VM " + targetVMName + ", vMotion of this VM cannot be performed."); return false; } ComputeResource cr = (ComputeResource)newHost.getParent(); String[] checks = new String[] { "cpu", "software" }; HostVMotionCompatibility[] vmcs = si.queryVMotionCompatibility(vm, new HostSystem[] { newHost }, checks); String[] comps = vmcs[0].getCompatibility(); if (checks.length != comps.length) { log(WARNING, "CPU/software NOT compatible, vMotion failed."); return false; } long start = System.currentTimeMillis(); Task task = vm.migrateVM_Task(cr.getResourcePool(), newHost, VirtualMachineMovePriority.highPriority, VirtualMachinePowerState.poweredOn); if (task.waitForMe() == Task.SUCCESS) { long end = System.currentTimeMillis(); log("vMotion of " + targetVMName + " to " + newHostName + " completed in " + (end - start) + "ms. Task result: " + task.getTaskInfo().getResult()); return true; } else { TaskInfo info = task.getTaskInfo(); log(WARNING, "vMotion of " + targetVMName + " to " + newHostName + " failed. Error details: " + info.getError().getFault()); return false; } }
@Override public InventoryNavigator create() throws IOException { ServiceInstance serviceInstance = new ServiceInstance(this.url, this.username, this.password, true); return new InventoryNavigator(serviceInstance.getRootFolder()); }
public InventoryNavigator getInventoryNavigator() { return inventoryNavigator; }
public void setInventoryNavigator(InventoryNavigator _inventoryNavigator) { inventoryNavigator = _inventoryNavigator; }
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(); }