Which networks do the WAN edges at 60 sites advertise into OMP?

You’re an architect, and the requirements are simple. By this afternoon’s discovery review you need one CSV covering 60 sites. For each service VPN, show which prefix each WAN edge sent directly to each vSmart. Keep both routers at a dual-edge site visible, even if one has no observed prefixes. A second engineer should be able to repeat the collection from the same locked-down Windows workstation.

Start with those requirements. Where is the information already held? What can this workstation reach? Which part of the job actually needs code? We have read-only HTTPS access to vManage and Windows PowerShell. The controller already sees the advertisements, the API exposes them, and PowerShell can join the records and write a CSV. We can deliver the workflow without installing a full development stack.

In Part I, we used Windows Batch and Plink to collect information from network devices. This time we can save ourselves the work of opening a session to every edge. vSmart already receives the route advertisements. We can ask vManage for each controller’s view, then use PowerShell to put the site and router names back against the prefixes.

Start with the question you have to answer

Imagine site 120 has two WAN edges. The controller sees 10.20.0.0/24 in VPN 10. Did both edges send it? If we group by site and prefix too early, the answer disappears. Retaining the sending edge and controller in the report lets us answer that question during the review.

This is a controller-side snapshot. A missing row of route data is a reason to check the intended design, OMP peering, policy and the edge’s advertised-route view. It cannot on its own tell you whether an edge attempted an advertisement or whether traffic is forwarding.

See the manual check first

In vManage 20.15, open Monitor → Devices, select the device, then open Real Time → Device Options. For an edge’s own view choose OMP Advertised Routes. For the controller’s view select vSmart and choose OMP Received Routes. An engineer doing a one-off check needn’t open 60 sites. The repetitive work starts when you need to cross-reference the controller results against all inventoried edges and produce the same report again. Cisco monitoring guide

Figure 1

Figure 1. Identify the observation point. Cisco’s genuine vManage screenshot shows the selected device as vsmart-west, system IP 10.1.0.11, device model Controller. That system IP is the kind of identifier we pass as deviceId.

Figure 2

Figure 2. A route count is only the starting point. Cisco’s Real Time screenshot shows OMP Summary with 16 routes received. A count cannot tell us which edge supplied a particular prefix. For our collection, select OMP Received Routes in the same menu. These two pictures are Cisco reference captures.

Build the collection in three steps

1. Authenticate once. PowerShell posts the credentials to /j_security_check, retains the session cookie, then fetches /dataservice/client/token. Subsequent reads reuse the session and token. Windows must trust the certificate for the vManage hostname. Use an account authorised to read inventory and OMP monitoring data. Cisco 20.15 authentication

2. Collect inventory before routes. Read GET /dataservice/device. Build a lookup from each edge’s system-ip to its host-name and site-id. This order matters. If we start from the route table, an inventoried edge that sent no visible prefixes never makes it into the report. Inventory covers the devices vManage returns. Compare the discovered site IDs against your 60-site scope to catch a site that is missing from inventory altogether. Cisco 20.15 device inventory

3. Read each controller once. Send GET /dataservice/device/omp/routes/received?deviceId=<vSmart-system-IP> to vManage. The HTTPS destination stays the same. Changing deviceId changes the controller we observe. Match from-peer to an edge’s system IP, retain originator separately and read vpn-id and prefix. A route relayed by another controller does not prove a direct advertisement from an edge to this controller. Cisco 20.15 monitoring endpoints · Cisco received-route field example

Run the 60-site discovery lab

Open Windows PowerShell 5.1 and create a folder with New-Item -Type Directory OmpLab. Enter it with Set-Location OmpLab. Run notepad .Get-OmpBaseline.ps1, paste the complete script from the listing below, and save it with the .ps1 extension. Use your organisation’s approved script execution policy.

The offline replay models 60 sites in VPN 10. Every tenth site has a second edge. Two edges send no visible routes, and one edge contributes two paths for the same prefix. The live and replay modes share the same inventory join and CSV writer. Replay supplies controlled inputs so you can check how the report handles each case.

Complete PowerShell listing

#requires -Version 5.1
[CmdletBinding(DefaultParameterSetName=’Live’)]
param(
[Parameter(Mandatory, ParameterSetName=’Live’)]
[uri]$VManage,
[Parameter(Mandatory, ParameterSetName=’Replay’)]
[switch]$Replay,
[string]$OutputFolder = ‘.’
)

$ErrorActionPreference = ‘Stop’
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$headers = @{}
$loggedIn = $false

function Read-ApiRows([string]$Path) {
$reply = Invoke-RestMethod -UseBasicParsing -Uri “$base/dataservice/$Path” `
-WebSession $session -Headers $headers -TimeoutSec 90
if ($reply -is [array]) { return $reply }
if ($null -eq $reply -or $reply.data -isnot [array]) {
throw “Expected a JSON record list at $Path. Check authentication and permissions.”
}
if ([string]$reply.pageInfo.moreEntries -eq ‘true’ -or
[string]$reply.pageInfo.hasMoreData -eq ‘true’) {
throw “Partial response at $Path. Retrieve all pages before reporting.”
}
return $reply.data
}

function Read-Inventory {
if (-not $Replay) { return (Read-ApiRows ‘device’) }
[pscustomobject]@{personality=’vsmart’; ‘host-name’=’VSMART-1’; ‘system-ip’=’10.255.0.1’}
foreach ($n in 1..60) {
$count = if ($n % 10 -eq 0) { 2 } else { 1 }
foreach ($e in 1..$count) {
[pscustomobject]@{
personality=’vedge’; ‘site-id’=[string](100+$n)
‘host-name’=(‘BR{0:D2}-E{1}’ -f $n,$e); ‘system-ip’=”10.254.$n.$e”
}
}
}
}

function Read-Routes([string]$ControllerIP) {
if (-not $Replay) {
return (Read-ApiRows “device/omp/routes/received?deviceId=$ControllerIP”)
}
foreach ($edge in @(Read-Inventory)) {
if ($edge.personality -ne ‘vedge’) { continue }
if ($edge.’host-name’ -in ‘BR20-E2′,’BR47-E1’) { continue }
$n = [int]$edge.’site-id’ – 100
$paths = if ($edge.’host-name’ -eq ‘BR10-E1’) { 2 } else { 1 }
foreach ($path in 1..$paths) {
[pscustomobject]@{
‘from-peer’=$edge.’system-ip’; originator=$edge.’system-ip’
‘vpn-id’=’10’; prefix=”10.$n.0.0/24″; ‘path-id’=$path
}
}
}
}

function New-ReportRow($Edge, $Controller, $Route) {
$status = if ($null -eq $Route) { ‘No direct prefixes observed’ } else { ‘Observed’ }
[pscustomobject][ordered]@{
SiteID = $Edge.’site-id’
Edge = $Edge.’host-name’
EdgeSystemIP = $Edge.’system-ip’
VPN = $Route.’vpn-id’
Prefix = $Route.prefix
Originator = $Route.originator
SeenBy = $Controller.’system-ip’
Result = $status
}
}

try {
if (-not $Replay) {
if ($VManage.Scheme -ne ‘https’) { throw ‘Supply an HTTPS URL.’ }
$base = $VManage.GetLeftPart([UriPartial]::Authority)
$credential = Get-Credential -Message ‘Read-only vManage account’
if (-not $credential) { throw ‘Login cancelled.’ }
$form = @{j_username=$credential.UserName; j_password=$credential.GetNetworkCredential().Password}
try {
$login = Invoke-WebRequest -UseBasicParsing -Method Post -Uri “$base/j_security_check” `
-Body $form -WebSession $session -TimeoutSec 30
} finally { $form.Clear() }
$cookie = $session.Cookies.GetCookies([uri]”$base/dataservice/”)[‘JSESSIONID’]
if (-not $cookie -or $login.Content -match ‘(?i)<html’) { throw ‘Login failed.’ }
$loggedIn = $true
$token = (Invoke-WebRequest -UseBasicParsing -Uri “$base/dataservice/client/token” `
-WebSession $session -TimeoutSec 30).Content.Trim()
if (-not $token -or $token.StartsWith(‘<‘)) { throw ‘Invalid session token.’ }
$headers[‘X-XSRF-TOKEN’] = $token
}

$inventory = @(Read-Inventory)
$edges = @($inventory | Where-Object {
$_.personality -in ‘vedge’,’cedge’ -or $_.’device-type’ -in ‘vedge’,’cedge’
})
$controllers = @($inventory | Where-Object {
$_.personality -eq ‘vsmart’ -or $_.’device-type’ -eq ‘vsmart’
})
if (-not $edges.Count -or -not $controllers.Count) { throw ‘Inventory missing edges or vSmart.’ }
$byIP = @{}
foreach ($edge in $edges) {
$ip = [string]$edge.’system-ip’
if (-not $ip -or $byIP.ContainsKey($ip)) { throw “Missing or duplicate edge IP: ‘$ip’.” }
$byIP[$ip] = $edge
}
$sites = @($edges | Select-Object -ExpandProperty ‘site-id’ -Unique)
Write-Host “Inventory: $($sites.Count) sites, $($edges.Count) edges, $($controllers.Count) controllers.”

$rows = foreach ($controller in $controllers) {
$ip = [string]$controller.’system-ip’
if (-not $ip) { throw ‘Controller without a system IP.’ }
$seen = @{}
$skipped = 0
foreach ($r in @(Read-Routes $ip)) {
$peer = [string]$r.’from-peer’
if (-not $peer) { throw “Received route missing from-peer on $ip.” }
if (-not $byIP.ContainsKey($peer)) { $skipped++; continue }
if ($null -eq $r.’vpn-id’ -or -not $r.prefix) { throw “Incomplete route from $peer.” }
$seen[$peer] = $true
New-ReportRow $byIP[$peer] $controller $r
}
foreach ($edge in $edges) {
if (-not $seen.ContainsKey([string]$edge.’system-ip’)) {
New-ReportRow $edge $controller $null
}
}
Write-Host “$ip : $($seen.Count) sending edges; $skipped records outside edge inventory.”
}

$columns = ‘SiteID’,’Edge’,’EdgeSystemIP’,’VPN’,’Prefix’,’Originator’,’SeenBy’,’Result’
$report = @($rows | Sort-Object -Property $columns -Unique)
$mode = if ($Replay) { ‘replay’ } else { ‘live’ }
$folder = New-Item -ItemType Directory -Force -Path $OutputFolder
$file = Join-Path $folder.FullName (“omp-{0}-{1}.csv” -f $mode,(Get-Date -Format ‘yyyyMMdd-HHmmssfff’))
$report | Export-Csv -LiteralPath $file -NoTypeInformation -Encoding UTF8
Write-Host “Saved $($report.Count) rows to $file”
} finally {
if ($loggedIn) {
try {
Invoke-WebRequest -UseBasicParsing -Method Post -WebSession $session -Headers $headers `
-Uri “$base/logout?nocache=$(Get-Random)” -TimeoutSec 30 | Out-Null
} catch { Write-Warning ‘Could not confirm vManage logout.’ }
}
}

.Get-OmpBaseline.ps1 -Replay -OutputFolder .reports
$csv = Get-ChildItem .reportsomp-replay-*.csv |
Sort-Object LastWriteTime -Descending | Select-Object -First 1
$rows = @(Import-Csv -LiteralPath $csv.FullName)
$rows | ConvertTo-Csv -NoTypeInformation

Full CSV output for the 60-site replay. The following rows were calculated independently from the published fixture rules. They are lab data. Use the command above to print the CSV from your own PowerShell run. The controller in this example is 10.255.0.1.

“SiteID”,”Edge”,”EdgeSystemIP”,”VPN”,”Prefix”,”Originator”,”SeenBy”,”Result”
“101”,”BR01-E1″,”10.254.1.1″,”10″,”10.1.0.0/24″,”10.254.1.1″,”10.255.0.1″,”Observed”
“102”,”BR02-E1″,”10.254.2.1″,”10″,”10.2.0.0/24″,”10.254.2.1″,”10.255.0.1″,”Observed”
“103”,”BR03-E1″,”10.254.3.1″,”10″,”10.3.0.0/24″,”10.254.3.1″,”10.255.0.1″,”Observed”
“104”,”BR04-E1″,”10.254.4.1″,”10″,”10.4.0.0/24″,”10.254.4.1″,”10.255.0.1″,”Observed”
“105”,”BR05-E1″,”10.254.5.1″,”10″,”10.5.0.0/24″,”10.254.5.1″,”10.255.0.1″,”Observed”
“106”,”BR06-E1″,”10.254.6.1″,”10″,”10.6.0.0/24″,”10.254.6.1″,”10.255.0.1″,”Observed”
“107”,”BR07-E1″,”10.254.7.1″,”10″,”10.7.0.0/24″,”10.254.7.1″,”10.255.0.1″,”Observed”
“108”,”BR08-E1″,”10.254.8.1″,”10″,”10.8.0.0/24″,”10.254.8.1″,”10.255.0.1″,”Observed”
“109”,”BR09-E1″,”10.254.9.1″,”10″,”10.9.0.0/24″,”10.254.9.1″,”10.255.0.1″,”Observed”
“110”,”BR10-E1″,”10.254.10.1″,”10″,”10.10.0.0/24″,”10.254.10.1″,”10.255.0.1″,”Observed”
“110”,”BR10-E2″,”10.254.10.2″,”10″,”10.10.0.0/24″,”10.254.10.2″,”10.255.0.1″,”Observed”
“111”,”BR11-E1″,”10.254.11.1″,”10″,”10.11.0.0/24″,”10.254.11.1″,”10.255.0.1″,”Observed”
“112”,”BR12-E1″,”10.254.12.1″,”10″,”10.12.0.0/24″,”10.254.12.1″,”10.255.0.1″,”Observed”
“113”,”BR13-E1″,”10.254.13.1″,”10″,”10.13.0.0/24″,”10.254.13.1″,”10.255.0.1″,”Observed”
“114”,”BR14-E1″,”10.254.14.1″,”10″,”10.14.0.0/24″,”10.254.14.1″,”10.255.0.1″,”Observed”
“115”,”BR15-E1″,”10.254.15.1″,”10″,”10.15.0.0/24″,”10.254.15.1″,”10.255.0.1″,”Observed”
“116”,”BR16-E1″,”10.254.16.1″,”10″,”10.16.0.0/24″,”10.254.16.1″,”10.255.0.1″,”Observed”
“117”,”BR17-E1″,”10.254.17.1″,”10″,”10.17.0.0/24″,”10.254.17.1″,”10.255.0.1″,”Observed”
“118”,”BR18-E1″,”10.254.18.1″,”10″,”10.18.0.0/24″,”10.254.18.1″,”10.255.0.1″,”Observed”
“119”,”BR19-E1″,”10.254.19.1″,”10″,”10.19.0.0/24″,”10.254.19.1″,”10.255.0.1″,”Observed”
“120”,”BR20-E1″,”10.254.20.1″,”10″,”10.20.0.0/24″,”10.254.20.1″,”10.255.0.1″,”Observed”
“120”,”BR20-E2″,”10.254.20.2″,””,””,””,”10.255.0.1″,”No direct prefixes observed”
“121”,”BR21-E1″,”10.254.21.1″,”10″,”10.21.0.0/24″,”10.254.21.1″,”10.255.0.1″,”Observed”
“122”,”BR22-E1″,”10.254.22.1″,”10″,”10.22.0.0/24″,”10.254.22.1″,”10.255.0.1″,”Observed”
“123”,”BR23-E1″,”10.254.23.1″,”10″,”10.23.0.0/24″,”10.254.23.1″,”10.255.0.1″,”Observed”
“124”,”BR24-E1″,”10.254.24.1″,”10″,”10.24.0.0/24″,”10.254.24.1″,”10.255.0.1″,”Observed”
“125”,”BR25-E1″,”10.254.25.1″,”10″,”10.25.0.0/24″,”10.254.25.1″,”10.255.0.1″,”Observed”
“126”,”BR26-E1″,”10.254.26.1″,”10″,”10.26.0.0/24″,”10.254.26.1″,”10.255.0.1″,”Observed”
“127”,”BR27-E1″,”10.254.27.1″,”10″,”10.27.0.0/24″,”10.254.27.1″,”10.255.0.1″,”Observed”
“128”,”BR28-E1″,”10.254.28.1″,”10″,”10.28.0.0/24″,”10.254.28.1″,”10.255.0.1″,”Observed”
“129”,”BR29-E1″,”10.254.29.1″,”10″,”10.29.0.0/24″,”10.254.29.1″,”10.255.0.1″,”Observed”
“130”,”BR30-E1″,”10.254.30.1″,”10″,”10.30.0.0/24″,”10.254.30.1″,”10.255.0.1″,”Observed”
“130”,”BR30-E2″,”10.254.30.2″,”10″,”10.30.0.0/24″,”10.254.30.2″,”10.255.0.1″,”Observed”
“131”,”BR31-E1″,”10.254.31.1″,”10″,”10.31.0.0/24″,”10.254.31.1″,”10.255.0.1″,”Observed”
“132”,”BR32-E1″,”10.254.32.1″,”10″,”10.32.0.0/24″,”10.254.32.1″,”10.255.0.1″,”Observed”
“133”,”BR33-E1″,”10.254.33.1″,”10″,”10.33.0.0/24″,”10.254.33.1″,”10.255.0.1″,”Observed”
“134”,”BR34-E1″,”10.254.34.1″,”10″,”10.34.0.0/24″,”10.254.34.1″,”10.255.0.1″,”Observed”
“135”,”BR35-E1″,”10.254.35.1″,”10″,”10.35.0.0/24″,”10.254.35.1″,”10.255.0.1″,”Observed”
“136”,”BR36-E1″,”10.254.36.1″,”10″,”10.36.0.0/24″,”10.254.36.1″,”10.255.0.1″,”Observed”
“137”,”BR37-E1″,”10.254.37.1″,”10″,”10.37.0.0/24″,”10.254.37.1″,”10.255.0.1″,”Observed”
“138”,”BR38-E1″,”10.254.38.1″,”10″,”10.38.0.0/24″,”10.254.38.1″,”10.255.0.1″,”Observed”
“139”,”BR39-E1″,”10.254.39.1″,”10″,”10.39.0.0/24″,”10.254.39.1″,”10.255.0.1″,”Observed”
“140”,”BR40-E1″,”10.254.40.1″,”10″,”10.40.0.0/24″,”10.254.40.1″,”10.255.0.1″,”Observed”
“140”,”BR40-E2″,”10.254.40.2″,”10″,”10.40.0.0/24″,”10.254.40.2″,”10.255.0.1″,”Observed”
“141”,”BR41-E1″,”10.254.41.1″,”10″,”10.41.0.0/24″,”10.254.41.1″,”10.255.0.1″,”Observed”
“142”,”BR42-E1″,”10.254.42.1″,”10″,”10.42.0.0/24″,”10.254.42.1″,”10.255.0.1″,”Observed”
“143”,”BR43-E1″,”10.254.43.1″,”10″,”10.43.0.0/24″,”10.254.43.1″,”10.255.0.1″,”Observed”
“144”,”BR44-E1″,”10.254.44.1″,”10″,”10.44.0.0/24″,”10.254.44.1″,”10.255.0.1″,”Observed”
“145”,”BR45-E1″,”10.254.45.1″,”10″,”10.45.0.0/24″,”10.254.45.1″,”10.255.0.1″,”Observed”
“146”,”BR46-E1″,”10.254.46.1″,”10″,”10.46.0.0/24″,”10.254.46.1″,”10.255.0.1″,”Observed”
“147”,”BR47-E1″,”10.254.47.1″,””,””,””,”10.255.0.1″,”No direct prefixes observed”
“148”,”BR48-E1″,”10.254.48.1″,”10″,”10.48.0.0/24″,”10.254.48.1″,”10.255.0.1″,”Observed”
“149”,”BR49-E1″,”10.254.49.1″,”10″,”10.49.0.0/24″,”10.254.49.1″,”10.255.0.1″,”Observed”
“150”,”BR50-E1″,”10.254.50.1″,”10″,”10.50.0.0/24″,”10.254.50.1″,”10.255.0.1″,”Observed”
“150”,”BR50-E2″,”10.254.50.2″,”10″,”10.50.0.0/24″,”10.254.50.2″,”10.255.0.1″,”Observed”
“151”,”BR51-E1″,”10.254.51.1″,”10″,”10.51.0.0/24″,”10.254.51.1″,”10.255.0.1″,”Observed”
“152”,”BR52-E1″,”10.254.52.1″,”10″,”10.52.0.0/24″,”10.254.52.1″,”10.255.0.1″,”Observed”
“153”,”BR53-E1″,”10.254.53.1″,”10″,”10.53.0.0/24″,”10.254.53.1″,”10.255.0.1″,”Observed”
“154”,”BR54-E1″,”10.254.54.1″,”10″,”10.54.0.0/24″,”10.254.54.1″,”10.255.0.1″,”Observed”
“155”,”BR55-E1″,”10.254.55.1″,”10″,”10.55.0.0/24″,”10.254.55.1″,”10.255.0.1″,”Observed”
“156”,”BR56-E1″,”10.254.56.1″,”10″,”10.56.0.0/24″,”10.254.56.1″,”10.255.0.1″,”Observed”
“157”,”BR57-E1″,”10.254.57.1″,”10″,”10.57.0.0/24″,”10.254.57.1″,”10.255.0.1″,”Observed”
“158”,”BR58-E1″,”10.254.58.1″,”10″,”10.58.0.0/24″,”10.254.58.1″,”10.255.0.1″,”Observed”
“159”,”BR59-E1″,”10.254.59.1″,”10″,”10.59.0.0/24″,”10.254.59.1″,”10.255.0.1″,”Observed”
“160”,”BR60-E1″,”10.254.60.1″,”10″,”10.60.0.0/24″,”10.254.60.1″,”10.255.0.1″,”Observed”
“160”,”BR60-E2″,”10.254.60.2″,”10″,”10.60.0.0/24″,”10.254.60.2″,”10.255.0.1″,”Observed”

Read sites 110, 120 and 147 together. At site 110, both routers sent 10.10.0.0/24. The second path from BR10-E1 leaves its prefix row count at one. At site 120, only BR20-E1 sent 10.20.0.0/24; its partner still gets a row. At site 147, the single inventoried edge has no observed prefix. That calls for checking the site design and its OMP session before drawing a conclusion about reachability.

Two edges advertise the same prefix. Offline replay for site 110.

Two edges advertise the same prefix. Offline replay for site 110.

Edges with no observed prefix. Offline replay for sites 120 and 147.

Edges with no observed prefix. Offline replay for sites 120 and 147.

Reconcile the totals. Fifty-four single-edge sites and six dual-edge sites give 66 edges. The fixture supplies 65 path records from 64 edges. Collapsing one duplicate path and adding two empty edge rows produces 66 report rows. Run these checks on the imported CSV.

$sites = @($rows.SiteID | Sort-Object -Unique)
$observed = @($rows | Where-Object Result -eq ‘Observed’)
$empty = @($rows | Where-Object Result -eq ‘No direct prefixes observed’)
if ($sites.Count -ne 60 -or $rows.Count -ne 66 -or $observed.Count -ne 64) {
throw ‘Site, edge or observed-prefix totals differ from the fixture.’
}
if ((($empty.Edge | Sort-Object) -join ‘,’) -ne ‘BR20-E2,BR47-E1’) {
throw ‘Unexpected edges with no directly observed prefixes.’
}
“Verified $($sites.Count) sites, $($rows.Count) edge rows, $($empty.Count) empty rows.”

Run it against vManage

.Get-OmpBaseline.ps1 -VManage https://vmanage.lab.example -OutputFolder .reports

Replace the example hostname with the name on your vManage certificate. The script prompts for credentials. In your DC and branch lab, select one known prefix in the controller’s OMP Received Routes table. Compare its VPN, sending peer and prefix to the corresponding CSV row. Repeat for the second edge before expanding the discovery scope. The expected lab prefixes are 1.1.1.0/24 and 2.2.2.0/24. The live values come from your controller.

A controller timeout or malformed response stops the export. Treating either as an empty route table would turn a collection failure into an apparent network fault. On a successful run, the console also reports how many records came from peers outside the edge inventory. Review those if the topology includes controller-to-controller peering. For a large table, compare the API row coverage with a known controller view before signing off the baseline.

Conclusion

Network automation is a creative innovation. It allows us to take a question that would otherwise mean hours of manual cross-checking and turn it into a repeatable piece of discovery. A colleague can run the same collection tomorrow, open the CSV and trace a single prefix back to the router and controller that reported it.

Performing the automation itself takes creativity too. Start with what the review needs to establish. In this case the useful decision was to start with inventory: only then could a router with no observed prefix appear in the report. Once we knew where the evidence lived and how to join it, the tools already on the workstation were enough. That’s what I mean by thinking outside of the toolbox.

Leave a Reply

Trending