Re: [ovs-dev] [PATCH] WMI Script that updates Hyper-V friendly port names
On Thu, Sep 25, 2014 at 06:18:19AM +, Alin Serdean wrote: The following script leverage's the advantages of WMI infrastructure offered in Hyper-V. This scripts allows the user to change the Msvm_EthernetPortAllocationSettingData property of a VM network adapter connected to a Hyper-V Virtual Switch. Usage: import-module .\OVS.psm1 $vnic = Get-VMNetworkAdapter VM1 Connect-VMNetworkAdapter -VMNetworkAdapter $vnic -SwitchName external $vnic | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-1 VM1 - is a VM on top of a Hyper-V external - is a Hyper-V Virtual Switch Signed-off-by: Alessandro Pilotti apilo...@cloudbasesolutions.com Signed-off-by: Alin Gabriel Serdean aserd...@cloudbasesolutions.com Applied, thanks! ___ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev
Re: [ovs-dev] [PATCH] WMI Script that updates Hyper-V friendly port names
Hello Nithin, I will update the documentation as soon as I can. Also I need to add the visualddk flag explanation. Thanks, Alin. -Mesaj original- De la: Nithin Raju [mailto:nit...@vmware.com] Trimis: Saturday, September 27, 2014 5:16 AM Către: Alin Serdean Cc: dev@openvswitch.org Subiect: Re: [ovs-dev] [PATCH] WMI Script that updates Hyper-V friendly port names Thanks Alin. I tested this script and it works! It would be great if we can document the usage in INSTALL.Windows - both for one vNIC case and 2 vNIC case. It does not have to be part of this checkin. Tested-by: Nithin Raju nit...@vmware.com Acked-by: Nithin Raju nit...@vmware.com -- Nithin On Sep 26, 2014, at 6:20 AM, Alin Serdean aserd...@cloudbasesolutions.com wrote: Hello Nithin, Yes it works if a VM has multiple network adapters. Invocation is different though. Example for a VM with 2 network adapters: $vnic = Get-VMNetworkAdapter test_2_1 $vnic[0] Connect-VMNetworkAdapter -VMNetworkAdapter $vnic[0] -SwitchName external $vnic[0] | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-1 Connect-VMNetworkAdapter -VMNetworkAdapter $vnic[1] -SwitchName external $vnic[1] | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-2 $vnic[1] Regards, Alin. -Mesaj original- De la: Nithin Raju [mailto:nit...@vmware.com] Trimis: Friday, September 26, 2014 9:35 AM Către: Alin Serdean Cc: dev@openvswitch.org Subiect: Re: [ovs-dev] [PATCH] WMI Script that updates Hyper-V friendly port names On Sep 24, 2014, at 11:18 PM, Alin Serdean aserd...@cloudbasesolutions.com wrote: The following script leverage's the advantages of WMI infrastructure offered in Hyper-V. This scripts allows the user to change the Msvm_EthernetPortAllocationSettingData property of a VM network adapter connected to a Hyper-V Virtual Switch. Usage: import-module .\OVS.psm1 $vnic = Get-VMNetworkAdapter VM1 Connect-VMNetworkAdapter -VMNetworkAdapter $vnic -SwitchName external $vnic | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-1 VM1 - is a VM on top of a Hyper-V external - is a Hyper-V Virtual Switch hi Alin, Will this code work if the VM has multiple adapters? It is OK if it does not, but I was just curious about it. I'll give this a shot tomorrow. thanks, Nithin Thanks, -- Nithin ___ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev
Re: [ovs-dev] [PATCH] WMI Script that updates Hyper-V friendly port names
On Sep 27, 2014, at 4:18 AM, Alin Serdean aserd...@cloudbasesolutions.com wrote: Hello Nithin, I will update the documentation as soon as I can. Also I need to add the visualddk flag explanation. Thanks, Alin. Thanks Alin. One more thing is that I had to change my PowerShell security settings to Unrestricted in order to import the script. I was wondering if there was any to be able to run this script in Restricted mode. thanks, Nithin ___ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev
Re: [ovs-dev] [PATCH] WMI Script that updates Hyper-V friendly port names
On Sep 24, 2014, at 11:18 PM, Alin Serdean aserd...@cloudbasesolutions.com wrote: The following script leverage's the advantages of WMI infrastructure offered in Hyper-V. This scripts allows the user to change the Msvm_EthernetPortAllocationSettingData property of a VM network adapter connected to a Hyper-V Virtual Switch. Usage: import-module .\OVS.psm1 $vnic = Get-VMNetworkAdapter VM1 Connect-VMNetworkAdapter -VMNetworkAdapter $vnic -SwitchName external $vnic | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-1 VM1 - is a VM on top of a Hyper-V external - is a Hyper-V Virtual Switch hi Alin, Will this code work if the VM has multiple adapters? It is OK if it does not, but I was just curious about it. I'll give this a shot tomorrow. thanks, Nithin ___ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev
Re: [ovs-dev] [PATCH] WMI Script that updates Hyper-V friendly port names
Hello Nithin, Yes it works if a VM has multiple network adapters. Invocation is different though. Example for a VM with 2 network adapters: $vnic = Get-VMNetworkAdapter test_2_1 $vnic[0] Connect-VMNetworkAdapter -VMNetworkAdapter $vnic[0] -SwitchName external $vnic[0] | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-1 Connect-VMNetworkAdapter -VMNetworkAdapter $vnic[1] -SwitchName external $vnic[1] | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-2 $vnic[1] Regards, Alin. -Mesaj original- De la: Nithin Raju [mailto:nit...@vmware.com] Trimis: Friday, September 26, 2014 9:35 AM Către: Alin Serdean Cc: dev@openvswitch.org Subiect: Re: [ovs-dev] [PATCH] WMI Script that updates Hyper-V friendly port names On Sep 24, 2014, at 11:18 PM, Alin Serdean aserd...@cloudbasesolutions.com wrote: The following script leverage's the advantages of WMI infrastructure offered in Hyper-V. This scripts allows the user to change the Msvm_EthernetPortAllocationSettingData property of a VM network adapter connected to a Hyper-V Virtual Switch. Usage: import-module .\OVS.psm1 $vnic = Get-VMNetworkAdapter VM1 Connect-VMNetworkAdapter -VMNetworkAdapter $vnic -SwitchName external $vnic | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-1 VM1 - is a VM on top of a Hyper-V external - is a Hyper-V Virtual Switch hi Alin, Will this code work if the VM has multiple adapters? It is OK if it does not, but I was just curious about it. I'll give this a shot tomorrow. thanks, Nithin ___ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev
Re: [ovs-dev] [PATCH] WMI Script that updates Hyper-V friendly port names
Hi Alin, Can you please add a short description of how you see this script is used in the sequence of actions to add or delete a port to the switch? I assume that the script will set the friendly name of a port even if the port is not connected (yet), is it correct? Thank you, Eitan -Original Message- From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Alin Serdean Sent: Friday, September 26, 2014 6:20 AM To: Nithin Raju Cc: dev@openvswitch.org Subject: Re: [ovs-dev] [PATCH] WMI Script that updates Hyper-V friendly port names Hello Nithin, Yes it works if a VM has multiple network adapters. Invocation is different though. Example for a VM with 2 network adapters: $vnic = Get-VMNetworkAdapter test_2_1 $vnic[0] Connect-VMNetworkAdapter -VMNetworkAdapter $vnic[0] -SwitchName external $vnic[0] | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-1 Connect-VMNetworkAdapter -VMNetworkAdapter $vnic[1] -SwitchName external $vnic[1] | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-2 $vnic[1] Regards, Alin. -Mesaj original- De la: Nithin Raju [mailto:nit...@vmware.com] Trimis: Friday, September 26, 2014 9:35 AM Către: Alin Serdean Cc: dev@openvswitch.org Subiect: Re: [ovs-dev] [PATCH] WMI Script that updates Hyper-V friendly port names On Sep 24, 2014, at 11:18 PM, Alin Serdean aserd...@cloudbasesolutions.com wrote: The following script leverage's the advantages of WMI infrastructure offered in Hyper-V. This scripts allows the user to change the Msvm_EthernetPortAllocationSettingData property of a VM network adapter connected to a Hyper-V Virtual Switch. Usage: import-module .\OVS.psm1 $vnic = Get-VMNetworkAdapter VM1 Connect-VMNetworkAdapter -VMNetworkAdapter $vnic -SwitchName external $vnic | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-1 VM1 - is a VM on top of a Hyper-V external - is a Hyper-V Virtual Switch hi Alin, Will this code work if the VM has multiple adapters? It is OK if it does not, but I was just curious about it. I'll give this a shot tomorrow. thanks, Nithin ___ dev mailing list dev@openvswitch.org https://urldefense.proofpoint.com/v1/url?u=http://openvswitch.org/mailman/listinfo/devk=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=yTvML8OxA42Jb6ViHe7fUXbvPVOYDPVq87w43doxtlY%3D%0Am=ocm6OWCWKfg6G2HklatNQ9PA1gHAXgz3eT%2BK9C%2Bpa%2BE%3D%0As=ff2a803be7f24dd75e2674f9a590b8f5ad6edd54ccf35c3781ef811191b7c4c2 ___ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev
Re: [ovs-dev] [PATCH] WMI Script that updates Hyper-V friendly port names
Thanks Alin. I tested this script and it works! It would be great if we can document the usage in INSTALL.Windows - both for one vNIC case and 2 vNIC case. It does not have to be part of this checkin. Tested-by: Nithin Raju nit...@vmware.com Acked-by: Nithin Raju nit...@vmware.com -- Nithin On Sep 26, 2014, at 6:20 AM, Alin Serdean aserd...@cloudbasesolutions.com wrote: Hello Nithin, Yes it works if a VM has multiple network adapters. Invocation is different though. Example for a VM with 2 network adapters: $vnic = Get-VMNetworkAdapter test_2_1 $vnic[0] Connect-VMNetworkAdapter -VMNetworkAdapter $vnic[0] -SwitchName external $vnic[0] | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-1 Connect-VMNetworkAdapter -VMNetworkAdapter $vnic[1] -SwitchName external $vnic[1] | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-2 $vnic[1] Regards, Alin. -Mesaj original- De la: Nithin Raju [mailto:nit...@vmware.com] Trimis: Friday, September 26, 2014 9:35 AM Către: Alin Serdean Cc: dev@openvswitch.org Subiect: Re: [ovs-dev] [PATCH] WMI Script that updates Hyper-V friendly port names On Sep 24, 2014, at 11:18 PM, Alin Serdean aserd...@cloudbasesolutions.com wrote: The following script leverage's the advantages of WMI infrastructure offered in Hyper-V. This scripts allows the user to change the Msvm_EthernetPortAllocationSettingData property of a VM network adapter connected to a Hyper-V Virtual Switch. Usage: import-module .\OVS.psm1 $vnic = Get-VMNetworkAdapter VM1 Connect-VMNetworkAdapter -VMNetworkAdapter $vnic -SwitchName external $vnic | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-1 VM1 - is a VM on top of a Hyper-V external - is a Hyper-V Virtual Switch hi Alin, Will this code work if the VM has multiple adapters? It is OK if it does not, but I was just curious about it. I'll give this a shot tomorrow. thanks, Nithin Thanks, -- Nithin ___ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev
[ovs-dev] [PATCH] WMI Script that updates Hyper-V friendly port names
The following script leverage's the advantages of WMI infrastructure offered in Hyper-V. This scripts allows the user to change the Msvm_EthernetPortAllocationSettingData property of a VM network adapter connected to a Hyper-V Virtual Switch. Usage: import-module .\OVS.psm1 $vnic = Get-VMNetworkAdapter VM1 Connect-VMNetworkAdapter -VMNetworkAdapter $vnic -SwitchName external $vnic | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-1 VM1 - is a VM on top of a Hyper-V external - is a Hyper-V Virtual Switch Signed-off-by: Alessandro Pilotti apilo...@cloudbasesolutions.com Signed-off-by: Alin Gabriel Serdean aserd...@cloudbasesolutions.com --- datapath-windows/misc/OVS.psm1 | 76 ++ 1 file changed, 76 insertions(+) create mode 100644 datapath-windows/misc/OVS.psm1 diff --git a/datapath-windows/misc/OVS.psm1 b/datapath-windows/misc/OVS.psm1 new file mode 100644 index 000..52ed3ba --- /dev/null +++ b/datapath-windows/misc/OVS.psm1 @@ -0,0 +1,76 @@ +# +Copyright 2014 Cloudbase Solutions Srl + +Licensed under the Apache License, Version 2.0 (the License); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an AS IS BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +# + +$hvassembly = [System.Reflection.Assembly]::LoadWithPartialName(Microsoft.HyperV.PowerShell) + +function Set-VMNetworkAdapterOVSPort +{ +[CmdletBinding()] +param +( +[parameter(Mandatory=$true, ValueFromPipeline=$true)] +[Microsoft.HyperV.PowerShell.VMNetworkAdapter]$VMNetworkAdapter, + +[parameter(Mandatory=$true)] +[string]$OVSPortName +) +process +{ +$ns = root\virtualization\v2 +$EscapedId = $VMNetworkAdapter.Id.Replace('\', '\\') +$sd = gwmi -namespace $ns -class Msvm_EthernetPortAllocationSettingData -Filter InstanceId like '$EscapedId%' + +if($sd) +{ +$sd.ElementName = $OVSPortName + +$vsms = gwmi -namespace $ns -class Msvm_VirtualSystemManagementService +$retVal = $vsms.ModifyResourceSettings(@($sd.GetText(1))) +try +{ +Check-WMIReturnValue $retVal +} +catch +{ +throw Assigning OVS port '$OVSPortName' failed +} +} +} +} + +function Check-WMIReturnValue($retVal) +{ +if ($retVal.ReturnValue -ne 0) +{ +if ($retVal.ReturnValue -eq 4096) +{ +do +{ +$job = [wmi]$retVal.Job +} +while ($job.JobState -eq 4) + +if ($job.JobState -ne 7) +{ +throw Job Failed +} +} +else +{ +throw Job Failed +} +} +} -- 1.9.1 ___ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev