mistake The import com.vmware.vim25.CustomFieldDef is never used
Hi, everyone.
I want to make this program with java eclipse. But it is coming all the time mistake :confused: :
The import com.vmware.vim25.CustomFieldDef is never used
The import com.vmware.vim25.Permission is never used
The method waitForMe() from the type Task is deprecated
The method waitForMe() from the type Task is deprecated
The method waitForMe() from the type Task is deprecated
The method waitForMe() from the type Task is deprecated
Is it form the library? In Google I can't get answer. I will be happy if someone can give some explanation.
This is the source code:
Code:
package com.vmware.vim25.co.samples;
import java.net.URL;
import com.vmware.vim25.CustomFieldDef;
import com.vmware.vim25.Permission;
import com.vmware.vim25.mo.Folder;
import com.vmware.vim25.mo.InventoryNavigator;
import com.vmware.vim25.mo.ServiceInstance;
import com.vmware.vim25.mo.Task;
import com.vmware.vim25.mo.VirtualMachine;
/**
* [color="blue"]VMware Infrastructure (vSphere) Java API[/color]
* @author Steve Jin / Modified by Michael Hopf
*/
public class VMpowerOps {
public static void main(String[] args) throws Exception {
String vmname = "Test_VM";
/* other ops: reboot|poweron|poweroff|reset|standby|suspend|shutdown */
String op = "standby";
ServiceInstance si = new ServiceInstance(new URL("https://server1.fireline.de/sdk"), "root", "password", true);
Folder rootFolder = si.getRootFolder();
VirtualMachine vm = (VirtualMachine) new InventoryNavigator(rootFolder).searchManagedEntity("VirtualMachine", vmname);
if(vm==null)
{
System.out.println("No VM " + vmname + " found");
si.getServerConnection().logout();
return;
}
if("reboot".equalsIgnoreCase(op))
{
vm.rebootGuest();
System.out.println(vmname + " guest OS rebooted");
}
else if("poweron".equalsIgnoreCase(op))
{
Task task = vm.powerOnVM_Task(null);
if(task.waitForMe()==Task.SUCCESS)
{
System.out.println(vmname + " powered on");
}
}
else if("poweroff".equalsIgnoreCase(op))
{
Task task = vm.powerOffVM_Task();
if(task.waitForMe()==Task.SUCCESS)
{
System.out.println(vmname + " powered off");
}
}
else if("reset".equalsIgnoreCase(op))
{
Task task = vm.resetVM_Task();
if(task.waitForMe()==Task.SUCCESS)
{
System.out.println(vmname + " reset");
}
}
else if("standby".equalsIgnoreCase(op))
{
vm.standbyGuest();
System.out.println(vmname + " guest OS stoodby");
}
else if("suspend".equalsIgnoreCase(op))
{
Task task = vm.suspendVM_Task();
if(task.waitForMe()==Task.SUCCESS)
{
System.out.println(vmname + " suspended");
}
}
else if("shutdown".equalsIgnoreCase(op))
{
Task task = vm.suspendVM_Task();
if(task.waitForMe()==Task.SUCCESS)
{
System.out.println(vmname + " suspended");
}
}
else
{
System.out.println("Invalid operation. Exiting...");
}
si.getServerConnection().logout();
}
}