Hyper-V virtual Fiber Channel sample
This sample demonstrates how to use the Hyper-V WMI Fiber Channel APIs to create, configure, and remove storage area networks and virtual Fiber Channel ports.The sample demonstrates how to perform each of the following operations:
- Create a virtual storage area network (SAN) and assign resources to it using the CreatePool method.
- Delete a virtual SAN using the DeletePool method.
- Modify the settings of a virtual SAN using the ModifyPoolSettings method.
- Modify the resources assigned to a virtual SAN using the ModifyPoolResources method.
- Create a virtual Fiber Channel port for a virtual machine using the Msvm_VirtualSystemManagementService.AddResourceSettings method.
- Delete a virtual Fiber Channel port from a virtual machine using the Msvm_VirtualSystemManagementService.RemoveResourceSettings method.
- Configure the world wide name generator to generate world wide names in a specified range using the Msvm_VirtualSystemManagementService.ModifyServiceSettings method to modify the MinimumWWPNAddress, MaximumWWPNAddress, and (optionally) CurrentWWNNAddress properties of the Msvm_VirtualSystemManagementServiceSettingData class.
- Enumerate the virtual Fiber Channel ports for a virtual machine using the Msvm_FcPortAllocationSettingData and Msvm_ExternalFcPort classes.
This sample is written in C# and requires some experience with WMI programming.
The Windows-classic-samples repo includes a variety of code samples that demonstrate the use of various new programming features for managing Hyper-V that are available starting in Windows 8.1 and/or Windows Server 2012 R2. This repo provides a Visual Studio solution (SLN) file for each sample, along with the source files, assets, resources, and metadata needed to compile and run the sample. For more information about the programming models, platforms, languages, and APIs demonstrated in this sample, please refer to the Hyper-V WMI provider (V2) documentation.
To get a copy of Windows, go to Downloads and tools.
Related technologies
Hyper-V virtual Fiber Channels API
Operating system requirements
Client
Windows 8
Server
Windows Server 2012
Build the sample
-
Start Visual Studio and select File > Open > Project/Solution.
-
Go to the directory named for the sample, and double-click the Microsoft Visual Studio Solution (.sln) file titled FibreChannel.sln.
-
Press F7 (or F6 for Microsoft Visual Studio 2013) or use Build > Build Solution to build the sample.
Run the sample
Note This sample must be run as an administrator.
This sample can be run in several different modes. To obtain a list of the operations, use the following command line:
FibreChannelSamples.exe /?
To debug the app and then run it from Visual Studio, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
Create a virtual SAN
To run this sample in this mode, follow these steps.
-
Enter the debug command line arguments for the project. The usage of this sample is:
FibreChannelSamples.exe CreateSan SanName **(WWPN **** WWNN +) ["SAN Notes"]
where the parameters are as follows:
- SanName is the name to be applied to the SAN.
- WWPN is the port name and WWNN is the node name for the SAN. You can include one or more pairs of these arguments in sequence.
- SAN Notes are the notes for the SAN. The notes must be contained inside of quotation marks. This parameter is optional and a standard note will be added if it is not specified.
-
To debug the app and then run it from Visual Studio, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
-
The final result of the operation will be displayed in the console window.
Delete a virtual SAN
To run this sample in this mode, follow these steps.
-
Enter the debug command line arguments for the project. The usage of this sample is:
FibreChannelSamples.exe DeleteSan SanName
where SanName is the name of the SAN to delete.
-
To debug the app and then run it from Visual Studio, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
-
The final result of the operation will be displayed in the console window.
Modify the settings of a virtual SAN
To run this sample in this mode, follow these steps.
-
Enter the debug command line arguments for the project. The usage of this sample is:
FibreChannelSamples.exe ModifySanName SanName **** NewSanName
where the parameters are as follows:
- SanName is the current name of the SAN to be modified.
- NewSanName is the new name to be applied to the SAN.
-
To debug the app and then run it from Visual Studio, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
-
The final result of the operation will be displayed in the console window.
Modify the resources assigned to a virtual SAN
To run this sample in this mode, follow these steps.
-
Enter the debug command line arguments for the project. The usage of this sample is:
FibreChannelSamples.exe ModifySanPorts SanName **(**WWPN **** WWNN +)
where the parameters are as follows:
- SanName is the name of the SAN to be modified.
- WWPN is the new port name and WWNN is the new node name to be applied to the SAN. You can include one or more pairs of these arguments in sequence.
-
To debug the app and then run it from Visual Studio, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
-
The final result of the operation will be displayed in the console window.
Create a virtual Fiber Channel port for a virtual machine
To run this sample in this mode, follow these steps.
-
Enter the debug command line arguments for the project. The usage of this sample is:
FibreChannelSamples.exe CreateVirtualFcPort VmName **** SanName **** [WWPN-A|WWNN-A|WWPN-B|WWNN-B]
where the parameters are as follows:
- VmName is the name of the virtual machine to create the virtual Fiber Channel port for.
- SanName is the name of the SAN.
- WWPN-A WWNN-A WWPN-B WWNN-B are the port and node names for the virtual Fiber Channel port. These arguments are optional. If they are not included, these names will be auto-generated.
-
To debug the app and then run it from Visual Studio, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
-
The final result of the operation will be displayed in the console window.
Delete a virtual Fiber Channel port from a virtual machine
To run this sample in this mode, follow these steps.
-
Enter the debug command line arguments for the project. The usage of this sample is:
FibreChannelSamples.exe DeleteVirtualFcPort VmName **** WWPN-A **** WWNN-A **** WWPN-B **** WWNN-B
where the parameters are as follows:
- VmName is the name of the virtual machine to delete the virtual Fiber Channel port from.
- WWPN-A WWNN-A WWPN-B WWNN-B are the port and node names of the virtual Fiber Channel port to delete.
-
To debug the app and then run it from Visual Studio, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
-
The final result of the operation will be displayed in the console window.
Configure the world wide name generator
To run this sample in this mode, follow these steps.
-
Enter the debug command line arguments for the project. The usage of this sample is:
FibreChannelSamples.exe ConfigureWwnGenerator Min WWPN **** Max WWPN **** New WWNN
where the parameters are as follows:
- Min WWPN is the new minimum world wide port name to use for the MinimumWWPNAddress property.
- Max WWPN is the new maximum world wide port name to use for the MaximumWWPNAddress property.
- New WWNN is the world wide node name to use for the CurrentWWNNAddress property.
-
To debug the app and then run it from Visual Studio, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
-
The final result of the operation will be displayed in the console window.
Enumerate the virtual Fiber Channel ports for a virtual machine
To run this sample in this mode, follow these steps.
-
Enter the debug command line arguments for the project. The usage of this sample is:
FibreChannelSamples.exe EnumerateFcPorts
-
To debug the app and then run it from Visual Studio, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
-
The final result of the operation will be displayed in the console window.