Skip to content

Commit aa98a5f

Browse files
author
JMesser81
committed
Added SlbDiagnostics script
Added NC PowerShell examples Added VMM script examples
1 parent b2d9ec4 commit aa98a5f

File tree

6 files changed

+253
-64
lines changed

6 files changed

+253
-64
lines changed

Diagnostics/DumpSlbRestState.ps1

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[CmdletBinding()]
2+
param(
3+
[string][parameter(Mandatory=$false, HelpMessage="Network controller Base REST URI e.g. https://192.168.0.4")]$NcURI
4+
= 'https://sa18n30nc.sa18.nttest.microsoft.com'
5+
)
6+
7+
$headers = @{"Accept"="application/json"}
8+
$content = "application/json; charset=UTF-8"
9+
$network = "$NCURI/Networking/v1"
10+
$slbStateRetry = 30
11+
$maxRetryCount = 20
12+
13+
$method = "Put"
14+
$uri = "$network/diagnostics/slbstate"
15+
16+
$body = '{"properties": { }}'
17+
18+
try
19+
{
20+
21+
$result = Invoke-WebRequest -Headers $headers -ContentType $content -Method $method -Uri $uri -Body $body -DisableKeepAlive -UseBasicParsing -UseDefaultCredentials
22+
$result.Content
23+
$resultObject = ConvertFrom-Json $result.Content
24+
$resultsUri = $network + $resultObject.properties.slbStateResult.resourceRef
25+
26+
$totalWait=0
27+
28+
do
29+
{
30+
$totalWait += $slbStateRetry
31+
Write-Host ">>> Sleeping ... for $slbStateRetry seconds ..."
32+
Start-Sleep -Seconds $slbStateRetry
33+
Write-Host ">>> Polling ... $resultsUri"
34+
$tempResult = Invoke-WebRequest -Headers $headers -Method GET -Uri $resultsUri -UseBasicParsing -UseDefaultCredentials
35+
$tempResultObject = ConvertFrom-Json $tempResult.Content
36+
Write-Host ">>> $(Get-Date -Format G) Current State: $($tempResultObject.properties.provisioningState)"
37+
}
38+
until (($tempResultObject.properties.provisioningState) -ne "Updating" -or $totalWait -gt $slbStateRetry * $maxRetryCount)
39+
40+
$fileName = "stateOp_" + [System.Math]::Truncate((Get-Date -UFormat %s)) + ".txt"
41+
$tempResult.Content > $fileName
42+
Write-Host "Success output written to $fileName" -ForegroundColor Green
43+
}
44+
45+
catch
46+
{
47+
Write-Error "Failed $_"
48+
throw
49+
}

Diagnostics/Troubleshooting.md

+5-64
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,17 @@
11
# Troubleshooting SDN
22

3-
Deploying the Microsoft Windows SDN Stack may require some troubleshooting of problems that arise during fabric and tenant deployment. The instructions provided below is for collecting a set of data which will aid in the troubleshooting and triage process. Please look at the [SDN Troubleshooting](https://technet.microsoft.com/en-us/library/mt715794.aspx) TechNet article for more information on individual commands and triage.
3+
Deploying the Microsoft Windows SDN Stack may require some troubleshooting of problems that arise during fabric and tenant deployment. Please reference the [SDN Troubleshooting Topic](https://technet.microsoft.com/en-us/library/mt715794.aspx) for more details.
44

5-
Make sure you have the most recent diagnostic KBs (download location forthcoming) installed on all of your NC nodes and Hyper-V Hosts. Also, make sure the tools have been installed on the Hyper-V Hosts:
6-
```none
7-
PS> Add-WindowsFeature RSAT-NetworkController –IncludeManagementTools
8-
PS> Import-Module NetworkControllerDiagnostics
9-
```
10-
### Triage and Data Collection
11-
1. Validate that Network Controller is up and running correctly (Executed from one of the NC Nodes):
12-
```none
13-
PS> Debug-WinFabNodeStatus
14-
```
15-
Check that ReplicaStatus is Ready and HealthState is Ok (if any nodes are not in Ready/Ok state, note which one is unhealthy in the bug)
16-
17-
```none
18-
PS> Get-NetworkControllerReplica
19-
```
20-
21-
Check that the Replica Status is Ready for each service (if any service is not in Ready state, note which service is unhealthy and on which node it is running in the bug)
22-
23-
2. Validate the NC Host Agents have made connections to the Network Controller (Execute on each Hyper-V host)
24-
```none
25-
C:\> netstat -anp tcp |findstr 6640
26-
```
27-
28-
There should be three ESTABLISHED connections and one LISTENING socket
29-
- Listening on Hyper-V hosts IP on port 6640
30-
- Two established connections to Hyper-V host IP on port 6640 from NC node(s) on ephemeral ports (> 32000) Connection established bet
31-
- One established connection from Hyper-V host IP to REST IP on port 6640
32-
33-
3. Check the Network Controller’s configuration state (Executed from any Hyper-V host)
34-
```none
35-
PS> Debug-NetworkControllerConfigurationState -NcIpAddress <Enter FQDN or IP – based on cert subject name configured>
36-
```
37-
38-
Look for any resources which have status Warning or Failure
39-
_Caveat: If you deployed using VMM, please use the VMM variant of the script available on GitHub [Debug-NetworkControllerConfigurationStateVmm](https://github.com/Microsoft/SDN/blob/master/Diagnostics/Debug-NetworkControllerConfigurationVMM.ps1)_
40-
41-
4. Check the SLB Configuration State (Executed from an NC node)
42-
```none
43-
PS > Debug-SlbConfigState
44-
```
45-
Output location should be indicated – default is C:\SDNDiagnostics\NetworkControllerState\SlbConfigState.txt
46-
_Caveat: This script does not work for VMM-based deployments_
47-
48-
5. Check policies in Host Agent
49-
```none
50-
C:\> ovsdb-client.exe dump tcp:127.0.0.1:6641 ms_vtep
51-
```
52-
The key table in this output is the ucast_macs_remote table which lists the tenant VM NIC IP and MAC address. Check to see if policy is missing for any given tenant VM IP address.
53-
54-
6. Look for HNV Provider Addresses (PA IPs) on the host
55-
```none
56-
PS > Get-ProviderAddress
57-
```
58-
59-
Attach the full output of all of these commands to the bug.
60-
615
### Collecting Logs and Traces
62-
Next step will probably be log collection. In order to proceed in an investigation, we need both the Host ID and the Port Profile IDs of any VM NICs for which there is no policy available in the Host Agent’s OVSDB ms_vtep database.
6+
If you aren't able to troubleshoot the issue on you're own, the next step will be to collect logs. In order to proceed in an investigation, we need both the Host ID and the Port Profile IDs of any VM NICs for which there is no policy available in the Host Agent’s OVSDB ms_vtep database.
7+
638

64-
1. Collect most recent ETL log files under C:\SDNDiagnostics\Logs directory on all NC nodes and Hyper-V host in question (Zip)
65-
2. Execute this script to get the Host ID
9+
1. Execute this script to get the Host ID
6610
```none
6711
PS > Get-ItemProperty "hklm:\system\currentcontrolset\services\nchostagent\parameters" -Name HostId |fl HostId
6812
```
69-
3. Execute this script (download from GitHub – [Get-AllPortProfiles](https://github.com/Microsoft/SDN/blob/master/Diagnostics/Get-AllPortProfiles.ps1) ) to get the Port Profile IDs for each VM (indicate which VM NIC does not have policies)
70-
71-
Attach this information to the bug as well.
13+
2. Execute this script (download from GitHub – [Get-AllPortProfiles](https://github.com/Microsoft/SDN/blob/master/Diagnostics/Get-AllPortProfiles.ps1) ) to get the Port Profile IDs for each VM (indicate which VM NIC does not have policies)
7214

73-
Lastly, make a note of what was happening before the degradation of service or error occurred.
7415

7516
### Gateways Troubleshooting
7617

NCRESTExamples/OutboundNAT.ps1

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
$uri = "https://10.127.132.211"
2+
3+
#EXAMPLE2: Outbound NAT
4+
5+
$vipip = "10.127.132.34"
6+
$lbid = "5290ff9c-b854-4d3d-a747-c220dd396181_10.127.132.34"
7+
$publicvipln = get-networkcontrollerlogicalnetwork -ConnectionUri $uri -resourceid "5290ff9c-b854-4d3d-a747-c220dd396181"
8+
9+
$lb = Get-NetworkControllerLoadBalancer -Connectionuri $uri -ResourceId $lbid
10+
$fe = Get-NetworkControllerLoadBalancerFrontendIPConfiguration -ConnectionUri $uri -LoadBalancerId $lbid
11+
$backend = Get-NetworkControllerLoadBalancerBackendAddressPool -ConnectionUri $uri -LoadBalancerId $lbid
12+
13+
$onat = @{}
14+
$onat.ResourceId = "onat1"
15+
$onat.properties = @{}
16+
$onat.properties.frontendipconfigurations = @()
17+
$onat.properties.frontendipconfigurations += $fe
18+
$onat.properties.backendaddresspool = $backend
19+
$onat.properties.protocol = "ALL"
20+
$lb.properties.OutboundNatRules += $onat
21+
22+
New-NetworkControllerLoadBalancer -ConnectionUri $uri -ResourceId $lbid -Properties $lb.properties
23+
24+
#Give a network interface outbound NAT access. Repeat for each NIC.
25+
$lb = Get-NetworkControllerLoadBalancer -Connectionuri $uri -ResourceId $lbid
26+
27+
$nic = get-networkcontrollernetworkinterface -connectionuri $uri -resourceid "f5539fc6-d389-42ab-a450-74c738019cba"
28+
$nic.properties.IpConfigurations[0].properties.LoadBalancerBackendAddressPools += $lb.properties.backendaddresspools[0]
29+
30+
new-networkcontrollernetworkinterface -connectionuri $uri -resourceid $nic.resourceid -properties $nic.properties -force
31+
32+

NCRESTExamples/WebTierAcl.ps1

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
$uri = "https://10.127.132.211"
2+
3+
$ruleproperties = new-object Microsoft.Windows.NetworkController.AclRuleProperties
4+
$ruleproperties.Protocol = "TCP"
5+
$ruleproperties.SourcePortRange = "0-65535"
6+
$ruleproperties.DestinationPortRange = "80"
7+
$ruleproperties.Action = "Allow"
8+
$ruleproperties.SourceAddressPrefix = "10.1.1.0/24"
9+
$ruleproperties.DestinationAddressPrefix = "10.1.1.0/24"
10+
$ruleproperties.Priority = "100"
11+
$ruleproperties.Type = "Inbound"
12+
$ruleproperties.Logging = "Enabled"
13+
14+
$aclrule1 = new-object Microsoft.Windows.NetworkController.AclRule
15+
$aclrule1.Properties = $ruleproperties
16+
$aclrule1.ResourceId = "AllowTCP80_Inbound"
17+
18+
$ruleproperties = new-object Microsoft.Windows.NetworkController.AclRuleProperties
19+
$ruleproperties.Protocol = "All"
20+
$ruleproperties.SourcePortRange = "0-65535"
21+
$ruleproperties.DestinationPortRange = "0-65535"
22+
$ruleproperties.Action = "Deny"
23+
$ruleproperties.SourceAddressPrefix = "*"
24+
$ruleproperties.DestinationAddressPrefix = "*"
25+
$ruleproperties.Priority = "110"
26+
$ruleproperties.Type = "Inbound"
27+
$ruleproperties.Logging = "Enabled"
28+
29+
$aclrule2 = new-object Microsoft.Windows.NetworkController.AclRule
30+
$aclrule2.Properties = $ruleproperties
31+
$aclrule2.ResourceId = "BlockAll_Inbound"
32+
33+
$acllistproperties = new-object Microsoft.Windows.NetworkController.AccessControlListProperties
34+
$acllistproperties.AclRules = @($aclrule1, $aclrule2)
35+
$acl = New-NetworkControllerAccessControlList -ResourceId "VNet1_Subnet1_ACL" -Properties $acllistproperties -ConnectionUri $uri
36+
37+
$vnet = Get-NetworkControllerVirtualNetwork -ConnectionUri $uri | where { $_.properties.AddressSpace.AddressPrefixes[0] -eq "10.1.1.0/24" }
38+
$vmsubnet = Get-NetworkControllerVirtualSubnet -ConnectionUri $uri -VirtualNetworkId $vnet.ResourceId | where { $_.Properties.AddressPrefix -eq "10.1.1.0/24" }
39+
40+
$vmsubnet.properties.AccessControlList = $acl
41+
42+
New-NetworkControllerVirtualSubnet -ConnectionUri $uri -VirtualNetworkId $vnet.ResourceId -ResourceId $vmsubnet.ResourceId -Properties $vmsubnet.properties
43+
44+
45+
46+
#$nic = get-networkcontrollernetworkinterface -ConnectionUri $uri -ResourceId "MyVM_Ethernet1"
47+
#$acl = get-networkcontrolleraccesscontrollist -ConnectionUri $uri -resourceid "AllowAllACL"
48+
#$nic.properties.ipconfigurations[0].properties.AccessControlList = $acl
49+
#new-networkcontrollernetworkinterface -ConnectionUri $uri -Properties $nic.properties -ResourceId $nic.resourceid

VMM/scripts/AddVNets.ps1

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
$logicalNetwork = Get-SCLogicalNetwork -ID "9c89d0d7-8e08-4022-823b-4924b7207847" # HNV Provider
2+
3+
4+
$max_vnets = 25
5+
$max_subnets = 5
6+
7+
foreach ($i in 1..$max_vnets)
8+
{
9+
# Create VM Network
10+
$vnetname = "vnet$i"
11+
$vmNetwork = New-SCVMNetwork -Name $vnetname -LogicalNetwork $logicalNetwork -IsolationType "WindowsNetworkVirtualization" -CAIPAddressPoolType "IPV4" -PAIPAddressPoolType "IPV4"
12+
#Write-Output $vmNetwork
13+
14+
foreach ($j in 1..$max_subnets)
15+
{
16+
# Create VM Subnet
17+
$prefix = "10.$i.$j.0/24"
18+
$subnet = New-SCSubnetVLan -Subnet $prefix
19+
$vmsubnet = New-SCVMSubnet -Name "Vnet$i-Subnet_$prefix" -VMNetwork $vmNetwork -SubnetVLan $subnet
20+
#Write-Output $vmsubnet
21+
22+
# Create VM Subnet IP Pool
23+
$allGateways = @()
24+
$allDnsServer = @()
25+
$allDnsSuffixes = @()
26+
$allWinsServers = @()
27+
28+
New-SCStaticIPAddressPool -Name "Vnet$i-Subnet_$prefix IP Pool" -VMSubnet $vmSubnet -Subnet $prefix -IPAddressRangeStart "10.$i.$j.4" -IPAddressRangeEnd "10.$i.$j.254" -DefaultGateway $allGateways -DNSServer $allDnsServer -DNSSuffix "" -DNSSearchSuffix $allDnsSuffixes -RunAsynchronously
29+
}
30+
}
31+
32+
sleep 5
33+
34+
# Remove VNets
35+
foreach ($i in 1..$max_vnets)
36+
{
37+
$vmnetwork = Get-SCVMNetwork -Name "vnet$i"
38+
39+
foreach ($j in 1..$max_subnets)
40+
{
41+
$prefix = "10.$i.$j.0/24"
42+
$vmsubnet = Get-SCVMSubnet -Name "Vnet$i-Subnet_$prefix" -VMNetwork $vmnetwork
43+
$ippool = Get-SCStaticIPAddressPool -Name "Vnet$i-Subnet_$prefix IP Pool" -VMSubnet $vmsubnet
44+
Remove-SCStaticIPAddressPool -StaticIPAddressPool $ippool
45+
46+
# $vmsubnet = Get-SCVMSubnet -Name "Subnet_$prefix"
47+
Remove-SCVMSubnet $vmsubnet
48+
}
49+
50+
# $vmnetwork = Get-SCVMNetwork -Name "vnet$i"
51+
Remove-SCVMNetwork $vmnetwork
52+
}

VMM/scripts/CreateTenantVIP.ps1

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
param(
2+
3+
[Parameter(Mandatory=$false)]
4+
# Name of the Network Controller Network Service
5+
# This value should be the name you gave the Network Controller service
6+
# when you on-boarded the Network Controller to VMM
7+
$LBServiceName = "NC",
8+
9+
[Parameter(Mandatory=$false)]
10+
# Name of the VM instances to which you want to assign the VIP
11+
$VipMemberVMNames = @("Web_VM1", "Web_VM2"),
12+
13+
[Parameter(Mandatory=$false)]
14+
# VIP address you want to assign from the VIP pool.
15+
# Pick any VIP that falls within your VIP IP Pool range.
16+
$VipAddress = "10.127.132.34",
17+
18+
[Parameter(Mandatory=$false)]
19+
# Name of the VIP VM Network
20+
$VipNetworkName = "Public VIP",
21+
22+
[Parameter(Mandatory=$false)]
23+
# The name of the VIP template you created via the VMM Console.
24+
$VipTemplateName = "Web",
25+
26+
[Parameter(Mandatory=$false)]
27+
# Arbitrary but good to match the VIP you're using.
28+
$VipName = "TenantVIPWebTest"
29+
30+
)
31+
32+
Import-Module virtualmachinemanager
33+
34+
$lb = Get-scLoadBalancer | where { $_.Service.Name -eq $LBServiceName};
35+
$vipNetwork = get-scvmnetwork -Name $VipNetworkName;
36+
37+
$vipMemberNics = @();
38+
foreach ($vmName in $VipMemberVMNames)
39+
{
40+
$vm = get-scvirtualmachine -Name $vmName;
41+
# if ($vm.VirtualNetworkAdapters[0].VMNetwork.ID -ne $vipNetwork.ID)
42+
# {
43+
# $vm.VirtualNetworkAdapters[0] | set-scvirtualnetworkadapter -VMNetwork $vipNetwork;
44+
# }
45+
46+
$vipMemberNics += $vm.VirtualNetworkAdapters[0];
47+
}
48+
49+
$existingVip = get-scloadbalancervip -Name $VipName
50+
if ($existingVip -ne $null)
51+
{
52+
# foreach ($mem in $existingVip.VipMembers)
53+
# {
54+
# $mem | remove-scloadbalancervipmember;
55+
# }
56+
57+
$existingVip | remove-scloadbalancervip;
58+
}
59+
60+
$vipt = get-scloadbalancerviptemplate -Name $VipTemplateName;
61+
62+
$vip = New-SCLoadBalancerVIP -Name $VipName -LoadBalancer $lb -IPAddress $VipAddress -LoadBalancerVIPTemplate $vipt -FrontEndVMNetwork $vipNetwork -BackEndVirtualNetworkAdapters $vipMemberNics;
63+
Write-Output "Created VIP " $vip;
64+
65+
$vip = get-scloadbalancervip -Name $VipName;
66+
Write-Output "VIP with members " $vip;

0 commit comments

Comments
 (0)