public void RemovePortGroup(VMware.Vim.HostConfigManager configMgr, string portGroupName) { VMware.Vim.ManagedObjectReference nMob = configMgr.NetworkSystem; //HostNetworkInfo nwSystem = (HostNetworkInfo)this.GetDynamicProperty(nMob, "networkInfo"); vimService.RemovePortGroup(nMob != null ? new VimApi_55.ManagedObjectReference() { type = nMob.Type, Value = nMob.Value } : null, portGroupName); }
public void CreatePortGroup(VMware.Vim.HostConfigManager configMgr, string portGroupName, string vSwitchName) { VMware.Vim.ManagedObjectReference nMob = configMgr.NetworkSystem; HostPortGroupSpec portgrp = new HostPortGroupSpec(); portgrp.name = portGroupName; portgrp.vswitchName = vSwitchName; portgrp.policy = new HostNetworkPolicy(); vimService.AddPortGroup(nMob != null ? new VimApi_55.ManagedObjectReference() { type = nMob.Type, Value = nMob.Value } : null, portgrp); }
public void AddVirtualNic(VMware.Vim.HostConfigManager configMgr, string portGroupName, string IPaddress, string subNetmask) { VMware.Vim.ManagedObjectReference nwSystem = configMgr.NetworkSystem; HostVirtualNicSpec vNicSpec = new HostVirtualNicSpec(); HostIpConfig ipConfig = new HostIpConfig(); ipConfig.dhcp = false; ipConfig.ipAddress = IPaddress; ipConfig.subnetMask = subNetmask; vNicSpec.ip = ipConfig; vimService.AddVirtualNic(nwSystem != null ? new VimApi_55.ManagedObjectReference() { type = nwSystem.Type, Value = nwSystem.Value } : null, portGroupName, vNicSpec); }