/** * Gets a Network object from the collection of Networks based on a String, which is the name of * the network. Returns null if not found <br> * Used in the DeployThread to convert the name of the network back to the Network object * * @param name the name of the network to find * @return the Network object, or null if not found * @see GuiDeployWizard * @see CommandEngine#networks */ public Network getNetworkFromString(String name) { Network network = null; for (Network each : networks) { if (each.getName().equals(name)) { network = each; } } return network; }
/** * Find Distributed Virtual Port Group name in the same Datacenter as the VM * * @param virtualMachine - VM object * @param name - the name of the Port Group * @return returns DistributedVirtualPortgroup object for the provided vDS PortGroup * @throws VSphereException */ public DistributedVirtualPortgroup getDistributedVirtualPortGroupByName( VirtualMachine virtualMachine, String name) throws VSphereException { try { Datacenter datacenter = getDataCenter(virtualMachine); for (Network network : datacenter.getNetworks()) { if (network instanceof DistributedVirtualPortgroup && (name.isEmpty() || network.getName().contentEquals(name))) { return (DistributedVirtualPortgroup) network; } } } catch (Exception e) { throw new VSphereException(e); } return null; }