static boolean doesNetworkNameExist(VirtualMachine vm,
String netName) throws Exception
{
VirtualMachineRuntimeInfo vmRuntimeInfo = vm.getRuntime();
EnvironmentBrowser envBrowser = vm.getEnvironmentBrowser();
ManagedObjectReference hmor = vmRuntimeInfo.getHost();
HostSystem host = new HostSystem(
vm.getServerConnection(), hmor);
ConfigTarget cfg = envBrowser.queryConfigTarget(host);
VirtualMachineNetworkInfo[] nets = cfg.getNetwork();
for (int i = 0; nets!=null && i < nets.length; i++)
{
NetworkSummary netSummary = nets[i].getNetwork();
if (netSummary.isAccessible() &&