Using DSC to deploy Hyper-V converged virtual network – Creating a converged virtual switch (Part 2)

In an earlier article, I had introduced DSC resources that can be used to deploy a Hyper-V converged virtual network. In this series of articles, we will build the converged network configuration for what is shown below.

Here is a recap of configuration needed.

  1. Create a host network team.
  2. Create a VM switch using the host team (today’s article).
  3. Create host VM adapters in the management OS to connect to the VM switch and assign VLANs and bandwidth settings.
  4.  Assign IP addresses and DNS addresses, as required.

In the earlier article, we created a network team named HostTeam. In today’s article, we will see how to create a converged virtual switch using this host team adapter.

Creating a converged virtual switch using cVMSwitch DSC resource

If you have not downloaded the new DSC resource modules yet, you can do so from my Github repo or using the Install-Module cmdlet in WMF 5.0. To create a converged virtual switch, we will need the cVMSwitch resource from the cHyper-V module.

The cVMSwitch resource is a fork from the xVMSwitch resource in the xHyper-V resource module. To be able to create a converged virtual switch, we need to set the MinimumBandwidthMode property. This is what the cVMSwitch resource enables.

The Name property is a mandatory one which identifies the VM switch and the Type property defines the type of switch – External or Internal or Private – to be created. The AllowManagementOS boolean property can be used to specify if a VM network adapter in the management OS or root partition should be created. The MinimumBandwidthMode property defines how the bandwidth reservation must be done. If you specify Absolute, the subsequent VM network adapter settings can be used to specify the absolute bandwidth reservation (in mbps). By using Weight as the MinimumBandwidthMode, you can specify a percentage value as the bandwidth reservation for the VM network adapters. We will see more about this in the next article. Finally, the NetAdapterName can be used to specify which host network adapter should be used to create an external VM switch. In our demonstration, this is the HostTeam adapter created using the cNetworkTeam resource.

Let us see the configuration script that creates the external converged VM switch for us.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Configuration DemoNetworkTeam {
   Import-DscResource -Module cWindowsOS -Name cNetworkTeam
   Import-DscResource -Module cHyper-V -Name cVMSwitch

   Node Localhost {
         #Create Network Team named HostTeam and add NIC1 and NIC2 as members
         cNetworkTeam NetworkTeam {
             Name = 'HostTeam'
             TeamingMode = 'SwitchIndependent'
             LoadBalancingAlgorithm = 'HyperVPort'
             TeamMembers = 'NIC1','NIC2'
             Ensure = 'Present'
         }     
         #Create a VM Switch from HostTeam adapter and set the Bandwidth mode to weight
         cVMSwitch HostSwitch {
             Name = 'HostSwitch'
             Type = 'External'
             AllowManagementOS = $true
             MinimumBandwidthMode = 'Weight'
             NetAdapterName = 'HostTeam'
             Ensure = 'Present'
             DependsOn = '[cNetworkTeam]NetworkTeam'
         }
	}
}

In the above configuration, I have included both network team and the VM switch creation. I have also added the DependsOn property in the HostSwitch configuration to specify that the VM switch should be created only if the network team named HostTeam exists. Since I set the MinimumBandwidthMode to Weight, subsequent VM network adapter creation must specify the percentage of bandwidth reserve instead of absolute value.

This is it. For the converged virtual network, we have created the network team and the VM switch. In the later articles, we will see how to create the VM network adapters in the management OS and complete the converged virtual network configuration.

Share on: