> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/switch-infrastructure/config-manager/llms.txt.
> For full documentation content, see https://docs.nvidia.com/switch-infrastructure/config-manager/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/switch-infrastructure/config-manager/_mcp/server.

# VPC Assignment

The VPC Assignment workflow binds an existing VPC's VRF to a specific device and to a specific set of ports on that device. It updates Nautobot's intent — the model of which VRF terminates on which port — without touching the device itself; the device-side change happens when a subsequent deploy applies the resulting intended configuration. Assignment is the second step in the VPC lifecycle, after [VPC Creation](/switch-infrastructure/config-manager/user-guides/vpc-lifecycle/vpc-creation) provisions the VRF.

For the end-to-end assign + render + deploy lifecycle, use [VPC Tenant Change](/switch-infrastructure/config-manager/user-guides/vpc-lifecycle/vpc-tenant-change) — it calls this workflow as a child plus the render and deploy steps.

This workflow is experimental and not intended for general use. Use it only in test or pilot environments.

## Prerequisites

Before running, confirm:

* **VPC exists at the site** with exactly one VRF allocated under `vpc_id` + `namespace_tag`. Multiple VRFs (or zero) under the same VPC ID is treated as an error.
* **Device exists in Nautobot** and is in the site you are assigning at.
* **Port names match Nautobot interface names** on the target device. Already-assigned ports for this VRF are skipped, not re-assigned.

## Running the workflow

VPC Assignment is not exposed in the Config Manager UI today. It is invoked as a child of [VPC Tenant Change](/switch-infrastructure/config-manager/user-guides/vpc-lifecycle/vpc-tenant-change), which orchestrates assignment plus the subsequent re-render and deploy. To run assignment in isolation, submit the workflow through the API with the target VPC, device, ports, and site.

After submission, a status page shows the three stages.

## Execution stages

The workflow runs three stages in order. None require manual approval.

1. **`get_device_and_vrf` — Resolve the device and the VPC's VRF.**

   Loads the target device record and queries Nautobot for the VRF matching `vpc_id` + `namespace_tag` + `site`. The query is asserted to return exactly one VRF — zero or more than one raises `ApplicationError` and halts the workflow.

2. **`assign_vrf_to_device` — Bind the VRF to the device record.**

   Attaches the VRF to the device's VRF list in Nautobot. If the VRF is already assigned to this device, the stage short-circuits with `vrf_assigned=False` (meaning "no change made"); otherwise it returns `vrf_assigned=True`.

3. **`assign_vrf_to_ports` — Bind the VRF to each named port.**

   For each port in `port_names`, assigns the VRF to the interface in Nautobot, running all per-port writes in parallel. Ports that already have this VRF assigned are skipped and recorded in `already_assigned_ports`. The final `assigned_ports` list contains the ports actually changed by this run.

## Verifying outcomes

After the workflow reports success, confirm:

* **All three stages green** on the Config Manager run page.
* **Result shape** — `assigned_ports` lists the ports actually changed; `vrf_assigned=true` means the device-level binding was new this run; `vrf` carries the bound VRF record.
* **Nautobot** shows the VRF on the device and on each named interface.
* **Run a deploy** to push the resulting intended-config change to the device. The simplest path is [VPC Tenant Change](/switch-infrastructure/config-manager/user-guides/vpc-lifecycle/vpc-tenant-change), which combines assignment with the subsequent re-render and deploy.

## Common issues

**`get_device_and_vrf` raises `ApplicationError` "0 VRFs found".**

The VPC has not been created yet at this site. Run [VPC Creation](/switch-infrastructure/config-manager/user-guides/vpc-lifecycle/vpc-creation) first.

**`get_device_and_vrf` raises `ApplicationError` "multiple VRFs found".**

Nautobot has more than one VRF matching `vpc_id` + `namespace_tag` + `site`. Investigate — VPC IDs are expected to be unique within a site. Reconcile the duplicates before re-running.

**`assign_vrf_to_device` reports `vrf_assigned=false`.**

The device was already bound to this VRF. Successful no-op.

**`assign_vrf_to_ports` reports many ports in `already_assigned_ports`.**

Those ports were already bound to this VRF. Successful no-op for those ports — `assigned_ports` lists only the ports newly bound by this run.

## Related guides

* [VPC Creation](/switch-infrastructure/config-manager/user-guides/vpc-lifecycle/vpc-creation) — provision the VRF metadata.
* [VPC Tenant Change](/switch-infrastructure/config-manager/user-guides/vpc-lifecycle/vpc-tenant-change) — assignment + render + deploy in one workflow.
* [VPC Deletion](/switch-infrastructure/config-manager/user-guides/vpc-lifecycle/vpc-deletion) — tear down a VPC (only after VRFs are unassigned).
* [Tenant Deploy](/switch-infrastructure/config-manager/user-guides/configuration-deploy/tenant-deploy) — the tenant-scoped deploy used by VPC Tenant Change to push the resulting config to the device.