}
public void vncDeActivateVm(VirtualMachine newVm) throws InvalidName, VmConfigFault, DuplicateName, TaskInProgress, FileFault, InvalidState, ConcurrentAccess, InvalidDatastore, InsufficientResourcesFault, RuntimeFault, RemoteException, InterruptedException {
OptionValue currentExtraConfig[]=newVm.getConfig().getExtraConfig();
//Remove extra config
// http://communities.vmware.com/message/1229409
OptionValue newExtraConfig[];
//determine the number of RemoteDisplay flags
int counter=0;
for (int i=0; i <currentExtraConfig.length; i++)
{
if (currentExtraConfig[i].getKey().startsWith("RemoteDisplay.vnc")) {
counter++;
}
// System.out.println(currentExtraConfig[i].getKey());
}
newExtraConfig=new OptionValue[currentExtraConfig.length-counter];
int newcounter=0;
for (int i=0; i <currentExtraConfig.length; i++)
{
if (!currentExtraConfig[i].getKey().startsWith("RemoteDisplay.vnc")) {
newExtraConfig[newcounter]=currentExtraConfig[i];
// System.out.println(newExtraConfig[newcounter].getKey());
newcounter++;
}
}
OptionValue vnc1=new OptionValue() ;vnc1.setKey("RemoteDisplay.vnc.enabled");vnc1.setValue("FALSE");
OptionValue vnc2=new OptionValue() ;vnc2.setKey("RemoteDisplay.vnc.password");vnc2.setValue("");
OptionValue vnc3=new OptionValue() ;vnc3.setKey("RemoteDisplay.vnc.port");vnc3.setValue("0");
OptionValue vnc4=new OptionValue() ;vnc4.setKey("RemoteDisplay.vnc.key");vnc4.setValue("");
OptionValue[] extraConfig= { vnc1, vnc2, vnc3, vnc4 };
VirtualMachineConfigSpec vmConfigSpec2 = new VirtualMachineConfigSpec();
vmConfigSpec2.setExtraConfig(extraConfig);