create_static_route
Add a static route to a Tier-1 gateway in VMware NSX to define network traffic paths by specifying destination CIDR and next hop IP.
Instructions
Create a static route on a Tier-1 gateway.
Args: tier1_id: The Tier-1 gateway ID. route_id: Unique ID for the static route. network: Destination CIDR (e.g. "10.0.0.0/8"). next_hop: Next hop IP address. target: Optional NSX Manager target name from config. Uses default if omitted.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tier1_id | Yes | ||
| route_id | Yes | ||
| network | Yes | ||
| next_hop | Yes | ||
| target | No |
Implementation Reference
- vmware_nsx/ops/nat_route_mgmt.py:144-170 (handler)The actual implementation of the create_static_route logic, which interacts with the NSX API client.
def create_static_route( client: NsxClient, gateway_id: str, route_id: str, network: str, next_hops: list[dict[str, Any]], gateway_type: str = "tier1", ) -> dict: """Create a static route on a gateway via Policy API (PUT). Args: client: Authenticated NSX API client. gateway_id: Gateway identifier (Tier-0 or Tier-1). route_id: Unique static route identifier. network: Destination CIDR (e.g., "10.0.0.0/8"). next_hops: List of next-hop dicts, each containing: - ip_address (str): Next-hop IP address. - admin_distance (int, optional): Admin distance (default 1). gateway_type: Either "tier0" or "tier1" (default "tier1"). Returns: Created static route dict from NSX API. """ _validate_id(gateway_id) _validate_id(route_id) if not next_hops: - mcp_server/server.py:622-642 (registration)MCP tool registration and wrapper function for create_static_route.
@mcp.tool() def create_static_route( tier1_id: str, route_id: str, network: str, next_hop: str, target: str | None = None, ) -> dict: """Create a static route on a Tier-1 gateway. Args: tier1_id: The Tier-1 gateway ID. route_id: Unique ID for the static route. network: Destination CIDR (e.g. "10.0.0.0/8"). next_hop: Next hop IP address. target: Optional NSX Manager target name from config. Uses default if omitted. """ from vmware_nsx.ops.route_mgmt import create_static_route as _create client = _get_connection(target) return _create(client, tier1_id, route_id, network=network, next_hop=next_hop)