vmware-nsx-mgmt 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vmware_nsx_mgmt-1.3.0/.gitignore +13 -0
- vmware_nsx_mgmt-1.3.0/Dockerfile +13 -0
- vmware_nsx_mgmt-1.3.0/PKG-INFO +231 -0
- vmware_nsx_mgmt-1.3.0/README-CN.md +277 -0
- vmware_nsx_mgmt-1.3.0/README.md +211 -0
- vmware_nsx_mgmt-1.3.0/RELEASE_NOTES.md +26 -0
- vmware_nsx_mgmt-1.3.0/config.example.yaml +21 -0
- vmware_nsx_mgmt-1.3.0/docker-compose.yml +8 -0
- vmware_nsx_mgmt-1.3.0/examples/mcp-configs/README.md +72 -0
- vmware_nsx_mgmt-1.3.0/examples/mcp-configs/claude-code.json +10 -0
- vmware_nsx_mgmt-1.3.0/examples/mcp-configs/continue.yaml +8 -0
- vmware_nsx_mgmt-1.3.0/examples/mcp-configs/cursor.json +10 -0
- vmware_nsx_mgmt-1.3.0/examples/mcp-configs/goose.json +8 -0
- vmware_nsx_mgmt-1.3.0/examples/mcp-configs/localcowork.json +8 -0
- vmware_nsx_mgmt-1.3.0/examples/mcp-configs/mcp-agent.yaml +9 -0
- vmware_nsx_mgmt-1.3.0/examples/mcp-configs/vscode-copilot.json +11 -0
- vmware_nsx_mgmt-1.3.0/mcp_server/__init__.py +1 -0
- vmware_nsx_mgmt-1.3.0/mcp_server/__main__.py +5 -0
- vmware_nsx_mgmt-1.3.0/mcp_server/server.py +712 -0
- vmware_nsx_mgmt-1.3.0/pyproject.toml +38 -0
- vmware_nsx_mgmt-1.3.0/server.json +21 -0
- vmware_nsx_mgmt-1.3.0/skills/vmware-nsx/SKILL.md +294 -0
- vmware_nsx_mgmt-1.3.0/skills/vmware-nsx/references/capabilities.md +198 -0
- vmware_nsx_mgmt-1.3.0/skills/vmware-nsx/references/cli-reference.md +637 -0
- vmware_nsx_mgmt-1.3.0/skills/vmware-nsx/references/setup-guide.md +401 -0
- vmware_nsx_mgmt-1.3.0/vmware_nsx/__init__.py +3 -0
- vmware_nsx_mgmt-1.3.0/vmware_nsx/cli.py +1175 -0
- vmware_nsx_mgmt-1.3.0/vmware_nsx/config.py +121 -0
- vmware_nsx_mgmt-1.3.0/vmware_nsx/connection.py +180 -0
- vmware_nsx_mgmt-1.3.0/vmware_nsx/doctor.py +143 -0
- vmware_nsx_mgmt-1.3.0/vmware_nsx/notify/__init__.py +1 -0
- vmware_nsx_mgmt-1.3.0/vmware_nsx/notify/audit.py +91 -0
- vmware_nsx_mgmt-1.3.0/vmware_nsx/ops/__init__.py +1 -0
- vmware_nsx_mgmt-1.3.0/vmware_nsx/ops/health.py +197 -0
- vmware_nsx_mgmt-1.3.0/vmware_nsx/ops/inventory.py +228 -0
- vmware_nsx_mgmt-1.3.0/vmware_nsx/ops/nat_route_mgmt.py +313 -0
- vmware_nsx_mgmt-1.3.0/vmware_nsx/ops/networking.py +254 -0
- vmware_nsx_mgmt-1.3.0/vmware_nsx/ops/segment_mgmt.py +348 -0
- vmware_nsx_mgmt-1.3.0/vmware_nsx/ops/troubleshoot.py +194 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vmware-nsx-mgmt
|
|
3
|
+
Version: 1.3.0
|
|
4
|
+
Summary: VMware NSX networking management: segments, gateways, NAT, routing, IPAM
|
|
5
|
+
Author: zw008
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: ai-ops,mcp,networking,nsx,nsx-t,vmware
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: System :: Networking
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Requires-Dist: httpx<1.0,>=0.27
|
|
14
|
+
Requires-Dist: mcp[cli]<2.0,>=1.0
|
|
15
|
+
Requires-Dist: python-dotenv<2.0,>=1.0
|
|
16
|
+
Requires-Dist: pyyaml<7.0,>=6.0
|
|
17
|
+
Requires-Dist: rich<15.0,>=13.0
|
|
18
|
+
Requires-Dist: typer<1.0,>=0.12
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
<!-- mcp-name: io.github.zw008/vmware-nsx -->
|
|
22
|
+
# VMware NSX
|
|
23
|
+
|
|
24
|
+
[English](README.md) | [中文](README-CN.md)
|
|
25
|
+
|
|
26
|
+
VMware NSX networking management: segments, gateways, NAT, routing, IPAM — 31 MCP tools, domain-focused.
|
|
27
|
+
|
|
28
|
+
> NSX Policy API skill for NSX-T 3.0+ and NSX 4.x.
|
|
29
|
+
|
|
30
|
+
[](LICENSE)
|
|
31
|
+
|
|
32
|
+
## Companion Skills
|
|
33
|
+
|
|
34
|
+
| Skill | Scope | Tools | Install |
|
|
35
|
+
|-------|-------|:-----:|---------|
|
|
36
|
+
| **[vmware-nsx](https://github.com/zw008/VMware-NSX)** (this) | Segments, gateways, NAT, routing, IPAM | 31 | `uv tool install vmware-nsx-mgmt` |
|
|
37
|
+
| **[vmware-nsx-security](https://github.com/zw008/VMware-NSX-Security)** | DFW rules, security groups, IDS/IPS | - | `uv tool install vmware-nsx-mgmt-security` |
|
|
38
|
+
| **[vmware-monitor](https://github.com/zw008/VMware-Monitor)** (read-only) | Inventory, health, alarms, events | 8 | `uv tool install vmware-monitor` |
|
|
39
|
+
| **[vmware-aiops](https://github.com/zw008/VMware-AIops)** (full ops) | VM lifecycle, deployment, guest ops, plans | 33 | `uv tool install vmware-aiops` |
|
|
40
|
+
| **[vmware-storage](https://github.com/zw008/VMware-Storage)** | Datastores, iSCSI, vSAN | 11 | `uv tool install vmware-storage` |
|
|
41
|
+
| **[vmware-vks](https://github.com/zw008/VMware-VKS)** | Tanzu Namespaces, TKC cluster lifecycle | 20 | `uv tool install vmware-vks` |
|
|
42
|
+
|
|
43
|
+
## Quick Install
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Via PyPI
|
|
47
|
+
uv tool install vmware-nsx-mgmt
|
|
48
|
+
|
|
49
|
+
# Or pip
|
|
50
|
+
pip install vmware-nsx-mgmt
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
mkdir -p ~/.vmware-nsx
|
|
57
|
+
cp config.example.yaml ~/.vmware-nsx/config.yaml
|
|
58
|
+
# Edit with your NSX Manager credentials
|
|
59
|
+
|
|
60
|
+
echo "VMWARE_NSX_PROD_PASSWORD=your_password" > ~/.vmware-nsx/.env
|
|
61
|
+
chmod 600 ~/.vmware-nsx/.env
|
|
62
|
+
|
|
63
|
+
# Verify
|
|
64
|
+
vmware-nsx doctor
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## What This Skill Does
|
|
68
|
+
|
|
69
|
+
| Category | Tools | Count |
|
|
70
|
+
|----------|-------|:-----:|
|
|
71
|
+
| **Segments** | list, get, create, update, delete, ports | 6 |
|
|
72
|
+
| **Tier-0 Gateways** | list, get, BGP neighbors, route table | 4 |
|
|
73
|
+
| **Tier-1 Gateways** | list, get, create, update, delete, route table | 6 |
|
|
74
|
+
| **NAT** | list, get, create, update, delete | 5 |
|
|
75
|
+
| **Static Routes** | list, create, delete | 3 |
|
|
76
|
+
| **IP Pools** | list, allocations, create, add subnet | 4 |
|
|
77
|
+
| **Health & Troubleshooting** | alarms, transport nodes, edge clusters, manager status, port status, VM-to-segment | 6 |
|
|
78
|
+
|
|
79
|
+
## Common Workflows
|
|
80
|
+
|
|
81
|
+
### Create an App Network (Segment + T1 Gateway + NAT)
|
|
82
|
+
|
|
83
|
+
1. Create gateway: `vmware-nsx gateway create-t1 app-t1 --edge-cluster edge-cluster-01 --tier0 tier0-gw`
|
|
84
|
+
2. Create segment: `vmware-nsx segment create app-web-seg --gateway app-t1 --subnet 10.10.1.1/24 --transport-zone tz-overlay`
|
|
85
|
+
3. Add SNAT: `vmware-nsx nat create app-t1 --action SNAT --source 10.10.1.0/24 --translated 172.16.0.10`
|
|
86
|
+
4. Verify: `vmware-nsx segment list` and `vmware-nsx nat list app-t1`
|
|
87
|
+
|
|
88
|
+
Use `--dry-run` to preview any write command first.
|
|
89
|
+
|
|
90
|
+
### Check Network Health
|
|
91
|
+
|
|
92
|
+
1. Manager status: `vmware-nsx health manager-status`
|
|
93
|
+
2. Transport nodes: `vmware-nsx health transport-nodes`
|
|
94
|
+
3. Edge clusters: `vmware-nsx health edge-clusters`
|
|
95
|
+
4. Alarms: `vmware-nsx health alarms`
|
|
96
|
+
|
|
97
|
+
### Troubleshoot VM Connectivity
|
|
98
|
+
|
|
99
|
+
1. Find VM's segment: `vmware-nsx troubleshoot vm-segment my-vm-01`
|
|
100
|
+
2. Check port status: `vmware-nsx troubleshoot port-status <port-id>`
|
|
101
|
+
3. Check routes: `vmware-nsx gateway routes-t1 app-t1`
|
|
102
|
+
4. Check BGP: `vmware-nsx gateway bgp-neighbors tier0-gw`
|
|
103
|
+
|
|
104
|
+
## MCP Tools (31)
|
|
105
|
+
|
|
106
|
+
| Category | Tools | Type |
|
|
107
|
+
|----------|-------|------|
|
|
108
|
+
| Segments | `list_segments`, `get_segment`, `create_segment`, `update_segment`, `delete_segment`, `list_segment_ports` | Read/Write |
|
|
109
|
+
| Tier-0 GW | `list_tier0_gateways`, `get_tier0_gateway`, `get_tier0_bgp_neighbors`, `get_tier0_route_table` | Read |
|
|
110
|
+
| Tier-1 GW | `list_tier1_gateways`, `get_tier1_gateway`, `create_tier1_gateway`, `update_tier1_gateway`, `delete_tier1_gateway`, `get_tier1_route_table` | Read/Write |
|
|
111
|
+
| NAT | `list_nat_rules`, `get_nat_rule`, `create_nat_rule`, `update_nat_rule`, `delete_nat_rule` | Read/Write |
|
|
112
|
+
| Static Routes | `list_static_routes`, `create_static_route`, `delete_static_route` | Read/Write |
|
|
113
|
+
| IP Pools | `list_ip_pools`, `get_ip_pool_allocations`, `create_ip_pool`, `create_ip_pool_subnet` | Read/Write |
|
|
114
|
+
| Health | `get_nsx_alarms`, `get_transport_node_status`, `get_edge_cluster_status`, `get_manager_cluster_status` | Read |
|
|
115
|
+
| Troubleshoot | `get_logical_port_status`, `find_vm_segment` | Read |
|
|
116
|
+
|
|
117
|
+
## CLI
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Segments
|
|
121
|
+
vmware-nsx segment list
|
|
122
|
+
vmware-nsx segment get app-web-seg
|
|
123
|
+
vmware-nsx segment create app-web-seg --gateway app-t1 --subnet 10.10.1.1/24 --transport-zone tz-overlay
|
|
124
|
+
vmware-nsx segment delete app-web-seg
|
|
125
|
+
|
|
126
|
+
# Gateways
|
|
127
|
+
vmware-nsx gateway list-t0
|
|
128
|
+
vmware-nsx gateway list-t1
|
|
129
|
+
vmware-nsx gateway create-t1 app-t1 --edge-cluster edge-cluster-01 --tier0 tier0-gw
|
|
130
|
+
vmware-nsx gateway bgp-neighbors tier0-gw
|
|
131
|
+
vmware-nsx gateway routes-t1 app-t1
|
|
132
|
+
|
|
133
|
+
# NAT
|
|
134
|
+
vmware-nsx nat list app-t1
|
|
135
|
+
vmware-nsx nat create app-t1 --action SNAT --source 10.10.1.0/24 --translated 172.16.0.10
|
|
136
|
+
vmware-nsx nat delete app-t1 rule-01
|
|
137
|
+
|
|
138
|
+
# Static Routes
|
|
139
|
+
vmware-nsx route list app-t1
|
|
140
|
+
vmware-nsx route create app-t1 --network 192.168.100.0/24 --next-hop 10.10.1.254
|
|
141
|
+
|
|
142
|
+
# IP Pools
|
|
143
|
+
vmware-nsx ippool list
|
|
144
|
+
vmware-nsx ippool create tep-pool
|
|
145
|
+
vmware-nsx ippool add-subnet tep-pool --start 192.168.100.10 --end 192.168.100.50 --cidr 192.168.100.0/24
|
|
146
|
+
|
|
147
|
+
# Health & Troubleshooting
|
|
148
|
+
vmware-nsx health alarms
|
|
149
|
+
vmware-nsx health transport-nodes
|
|
150
|
+
vmware-nsx health manager-status
|
|
151
|
+
vmware-nsx troubleshoot vm-segment my-vm-01
|
|
152
|
+
|
|
153
|
+
# Diagnostics
|
|
154
|
+
vmware-nsx doctor
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## MCP Server
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# Run directly
|
|
161
|
+
uvx --from vmware-nsx-mgmt vmware-nsx-mcp
|
|
162
|
+
|
|
163
|
+
# Or via Docker
|
|
164
|
+
docker compose up -d
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Agent Configuration
|
|
168
|
+
|
|
169
|
+
Add to your AI agent's MCP config:
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"mcpServers": {
|
|
174
|
+
"vmware-nsx": {
|
|
175
|
+
"command": "vmware-nsx-mcp",
|
|
176
|
+
"env": {
|
|
177
|
+
"VMWARE_NSX_CONFIG": "~/.vmware-nsx/config.yaml"
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
More agent config templates (Claude Code, Cursor, Goose, Continue, etc.) in [examples/mcp-configs/](examples/mcp-configs/).
|
|
185
|
+
|
|
186
|
+
## Version Compatibility
|
|
187
|
+
|
|
188
|
+
| NSX Version | Support | Notes |
|
|
189
|
+
|-------------|---------|-------|
|
|
190
|
+
| NSX 4.x | Full | Latest Policy API, all features |
|
|
191
|
+
| NSX-T 3.2 | Full | All features work |
|
|
192
|
+
| NSX-T 3.1 | Full | Minor route table format differences |
|
|
193
|
+
| NSX-T 3.0 | Compatible | IP pool subnet API introduced here |
|
|
194
|
+
| NSX-T 2.5 | Limited | Policy API incomplete; some tools may fail |
|
|
195
|
+
| NSX-V (6.x) | Not supported | Different API (SOAP-based) |
|
|
196
|
+
|
|
197
|
+
### VCF Compatibility
|
|
198
|
+
|
|
199
|
+
| VCF Version | Bundled NSX | Support |
|
|
200
|
+
|-------------|-------------|---------|
|
|
201
|
+
| VCF 5.x | NSX 4.x | Full |
|
|
202
|
+
| VCF 4.3-4.5 | NSX-T 3.1-3.2 | Full |
|
|
203
|
+
|
|
204
|
+
## Safety
|
|
205
|
+
|
|
206
|
+
| Feature | Description |
|
|
207
|
+
|---------|-------------|
|
|
208
|
+
| Read-heavy | 18/31 tools are read-only |
|
|
209
|
+
| Double confirmation | CLI write commands require two prompts |
|
|
210
|
+
| Dry-run mode | All write commands support `--dry-run` preview |
|
|
211
|
+
| Dependency checks | Delete operations validate no connected resources |
|
|
212
|
+
| Input validation | CIDR, IP, VLAN IDs, gateway existence validated |
|
|
213
|
+
| Audit logging | All operations logged to `~/.vmware-nsx/audit.log` |
|
|
214
|
+
| No firewall ops | Cannot create/modify DFW rules or security groups |
|
|
215
|
+
| Credential safety | Passwords only from environment variables |
|
|
216
|
+
| Prompt injection defense | NSX object names sanitized before output |
|
|
217
|
+
|
|
218
|
+
## Troubleshooting
|
|
219
|
+
|
|
220
|
+
| Problem | Cause & Fix |
|
|
221
|
+
|---------|-------------|
|
|
222
|
+
| "Segment not found" | Policy API uses segment `id`, not `display_name`. Run `segment list` to get the exact ID. |
|
|
223
|
+
| NAT creation fails "gateway not found" | NAT requires a Tier-1 (or Tier-0) gateway. Verify with `gateway list-t1`. Gateway must have an edge cluster. |
|
|
224
|
+
| BGP neighbor stuck in Connect/Active | Peer unreachable, ASN mismatch, TCP 179 blocked, or MD5 password mismatch. |
|
|
225
|
+
| Transport node "degraded" | TEP unreachable (check MTU >= 1600), NTP sync issues, or host switch config mismatch. |
|
|
226
|
+
| "Password not found" | Variable naming: `VMWARE_<TARGET_UPPER>_PASSWORD` (hyphens to underscores). Check `~/.vmware-nsx/.env`. |
|
|
227
|
+
| Connection timeout | Use `vmware-nsx doctor --skip-auth` to bypass auth checks on high-latency networks. |
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
<!-- mcp-name: io.github.zw008/vmware-nsx -->
|
|
2
|
+
# VMware NSX
|
|
3
|
+
|
|
4
|
+
[English](README.md) | [中文](README-CN.md)
|
|
5
|
+
|
|
6
|
+
VMware NSX 网络管理:Segment、网关、NAT、路由、IPAM — 31 个 MCP 工具,领域专注。
|
|
7
|
+
|
|
8
|
+
> 基于 NSX Policy API,支持 NSX-T 3.0+ 和 NSX 4.x。
|
|
9
|
+
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
|
|
12
|
+
## 伴生 Skills
|
|
13
|
+
|
|
14
|
+
| Skill | 范围 | 工具数 | 安装 |
|
|
15
|
+
|-------|------|:-----:|------|
|
|
16
|
+
| **[vmware-nsx](https://github.com/zw008/VMware-NSX)**(本 Skill) | Segment、网关、NAT、路由、IPAM | 31 | `uv tool install vmware-nsx-mgmt` |
|
|
17
|
+
| **[vmware-nsx-security](https://github.com/zw008/VMware-NSX-Security)** | DFW 规则、安全组、IDS/IPS | - | `uv tool install vmware-nsx-mgmt-security` |
|
|
18
|
+
| **[vmware-monitor](https://github.com/zw008/VMware-Monitor)**(只读) | 清单、健康、告警、事件 | 8 | `uv tool install vmware-monitor` |
|
|
19
|
+
| **[vmware-aiops](https://github.com/zw008/VMware-AIops)**(完整运维) | VM 生命周期、部署、Guest Ops、计划模式 | 33 | `uv tool install vmware-aiops` |
|
|
20
|
+
| **[vmware-storage](https://github.com/zw008/VMware-Storage)** | 数据存储、iSCSI、vSAN | 11 | `uv tool install vmware-storage` |
|
|
21
|
+
| **[vmware-vks](https://github.com/zw008/VMware-VKS)** | Tanzu 命名空间、TKC 集群生命周期 | 20 | `uv tool install vmware-vks` |
|
|
22
|
+
|
|
23
|
+
## 快速安装
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# 通过 PyPI
|
|
27
|
+
uv tool install vmware-nsx-mgmt
|
|
28
|
+
|
|
29
|
+
# 或 pip
|
|
30
|
+
pip install vmware-nsx-mgmt
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 配置
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
mkdir -p ~/.vmware-nsx
|
|
37
|
+
cp config.example.yaml ~/.vmware-nsx/config.yaml
|
|
38
|
+
# 编辑 config.yaml,填入 NSX Manager 地址和用户名
|
|
39
|
+
|
|
40
|
+
echo "VMWARE_NSX_PROD_PASSWORD=your_password" > ~/.vmware-nsx/.env
|
|
41
|
+
chmod 600 ~/.vmware-nsx/.env
|
|
42
|
+
|
|
43
|
+
# 验证环境
|
|
44
|
+
vmware-nsx doctor
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### config.yaml 示例
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
default_target: nsx-prod
|
|
51
|
+
targets:
|
|
52
|
+
nsx-prod:
|
|
53
|
+
host: nsx-mgr.example.com # NSX Manager IP 或集群 VIP
|
|
54
|
+
user: admin
|
|
55
|
+
password_env: VMWARE_NSX_PROD_PASSWORD
|
|
56
|
+
nsx-lab:
|
|
57
|
+
host: 10.0.0.100
|
|
58
|
+
user: admin
|
|
59
|
+
password_env: VMWARE_NSX_LAB_PASSWORD
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 功能概览
|
|
63
|
+
|
|
64
|
+
| 类别 | 工具 | 数量 |
|
|
65
|
+
|------|------|:----:|
|
|
66
|
+
| **Segment** | 列表、详情、创建、更新、删除、端口列表 | 6 |
|
|
67
|
+
| **Tier-0 网关** | 列表、详情、BGP 邻居、路由表 | 4 |
|
|
68
|
+
| **Tier-1 网关** | 列表、详情、创建、更新、删除、路由表 | 6 |
|
|
69
|
+
| **NAT** | 列表、详情、创建、更新、删除 | 5 |
|
|
70
|
+
| **静态路由** | 列表、创建、删除 | 3 |
|
|
71
|
+
| **IP 池** | 列表、分配详情、创建池、添加子网 | 4 |
|
|
72
|
+
| **健康与排障** | 告警、传输节点状态、Edge 集群状态、Manager 状态、逻辑端口状态、VM 所在 Segment | 6 |
|
|
73
|
+
|
|
74
|
+
## MCP 工具(31 个)
|
|
75
|
+
|
|
76
|
+
| 类别 | 工具 | 类型 |
|
|
77
|
+
|------|------|------|
|
|
78
|
+
| Segment | `list_segments`、`get_segment`、`create_segment`、`update_segment`、`delete_segment`、`list_segment_ports` | 读/写 |
|
|
79
|
+
| Tier-0 网关 | `list_tier0_gateways`、`get_tier0_gateway`、`get_tier0_bgp_neighbors`、`get_tier0_route_table` | 只读 |
|
|
80
|
+
| Tier-1 网关 | `list_tier1_gateways`、`get_tier1_gateway`、`create_tier1_gateway`、`update_tier1_gateway`、`delete_tier1_gateway`、`get_tier1_route_table` | 读/写 |
|
|
81
|
+
| NAT | `list_nat_rules`、`get_nat_rule`、`create_nat_rule`、`update_nat_rule`、`delete_nat_rule` | 读/写 |
|
|
82
|
+
| 静态路由 | `list_static_routes`、`create_static_route`、`delete_static_route` | 读/写 |
|
|
83
|
+
| IP 池 | `list_ip_pools`、`get_ip_pool_allocations`、`create_ip_pool`、`create_ip_pool_subnet` | 读/写 |
|
|
84
|
+
| 健康 | `get_nsx_alarms`、`get_transport_node_status`、`get_edge_cluster_status`、`get_manager_cluster_status` | 只读 |
|
|
85
|
+
| 排障 | `get_logical_port_status`、`find_vm_segment` | 只读 |
|
|
86
|
+
|
|
87
|
+
### 工具说明
|
|
88
|
+
|
|
89
|
+
**Segment**
|
|
90
|
+
- `list_segments` — 列出所有 Segment,含类型、子网、网关、传输区域
|
|
91
|
+
- `get_segment` — 获取 Segment 详情,含端口和子网配置
|
|
92
|
+
- `create_segment` — 创建 Overlay 或 VLAN Segment
|
|
93
|
+
- `update_segment` — 更新 Segment 属性(描述、标签、DHCP)
|
|
94
|
+
- `delete_segment` — 删除 Segment(检查已连接端口)
|
|
95
|
+
- `list_segment_ports` — 列出 Segment 上的逻辑端口及状态
|
|
96
|
+
|
|
97
|
+
**Tier-0 网关**
|
|
98
|
+
- `list_tier0_gateways` — 列出所有 Tier-0 网关,含 HA 模式和 Edge 集群
|
|
99
|
+
- `get_tier0_gateway` — 获取 Tier-0 详情:接口、路由配置、BGP
|
|
100
|
+
- `get_tier0_bgp_neighbors` — 列出 BGP 邻居会话及状态
|
|
101
|
+
- `get_tier0_route_table` — 获取 Tier-0 路由表
|
|
102
|
+
|
|
103
|
+
**Tier-1 网关**
|
|
104
|
+
- `list_tier1_gateways` — 列出所有 Tier-1 网关,含关联的 Tier-0
|
|
105
|
+
- `get_tier1_gateway` — 获取 Tier-1 详情:接口、路由通告
|
|
106
|
+
- `create_tier1_gateway` — 创建 Tier-1 网关并关联 Edge 集群和 Tier-0
|
|
107
|
+
- `update_tier1_gateway` — 更新 Tier-1 属性(路由通告、标签)
|
|
108
|
+
- `delete_tier1_gateway` — 删除 Tier-1 网关(检查已连接 Segment)
|
|
109
|
+
- `get_tier1_route_table` — 获取 Tier-1 路由表
|
|
110
|
+
|
|
111
|
+
**NAT**
|
|
112
|
+
- `list_nat_rules` — 列出网关上的 NAT 规则
|
|
113
|
+
- `get_nat_rule` — 获取 NAT 规则详情
|
|
114
|
+
- `create_nat_rule` — 创建 SNAT/DNAT/反射 NAT 规则
|
|
115
|
+
- `update_nat_rule` — 更新 NAT 规则属性
|
|
116
|
+
- `delete_nat_rule` — 删除 NAT 规则
|
|
117
|
+
|
|
118
|
+
**静态路由**
|
|
119
|
+
- `list_static_routes` — 列出网关上的静态路由
|
|
120
|
+
- `create_static_route` — 添加静态路由
|
|
121
|
+
- `delete_static_route` — 删除静态路由
|
|
122
|
+
|
|
123
|
+
**IP 池**
|
|
124
|
+
- `list_ip_pools` — 列出 IP 地址池及使用统计
|
|
125
|
+
- `get_ip_pool_allocations` — 查看已分配的 IP 地址
|
|
126
|
+
- `create_ip_pool` — 创建新的 IP 地址池
|
|
127
|
+
- `create_ip_pool_subnet` — 向 IP 池添加子网范围
|
|
128
|
+
|
|
129
|
+
**健康与排障**
|
|
130
|
+
- `get_nsx_alarms` — 列出活跃的 NSX 告警
|
|
131
|
+
- `get_transport_node_status` — 传输节点连接和配置状态
|
|
132
|
+
- `get_edge_cluster_status` — Edge 集群成员状态
|
|
133
|
+
- `get_manager_cluster_status` — NSX Manager 集群健康状态
|
|
134
|
+
- `get_logical_port_status` — 逻辑端口管理/运行状态
|
|
135
|
+
- `find_vm_segment` — 查找 VM 连接到哪个 Segment
|
|
136
|
+
|
|
137
|
+
## 常见工作流
|
|
138
|
+
|
|
139
|
+
### 创建应用网络(Segment + T1 网关 + NAT)
|
|
140
|
+
|
|
141
|
+
1. 创建网关:`vmware-nsx gateway create-t1 app-t1 --edge-cluster edge-cluster-01 --tier0 tier0-gw`
|
|
142
|
+
2. 创建 Segment:`vmware-nsx segment create app-web-seg --gateway app-t1 --subnet 10.10.1.1/24 --transport-zone tz-overlay`
|
|
143
|
+
3. 添加 SNAT:`vmware-nsx nat create app-t1 --action SNAT --source 10.10.1.0/24 --translated 172.16.0.10`
|
|
144
|
+
4. 验证:`vmware-nsx segment list` 和 `vmware-nsx nat list app-t1`
|
|
145
|
+
|
|
146
|
+
任何写操作前可加 `--dry-run` 预览。
|
|
147
|
+
|
|
148
|
+
### 检查网络健康
|
|
149
|
+
|
|
150
|
+
1. Manager 状态:`vmware-nsx health manager-status`
|
|
151
|
+
2. 传输节点:`vmware-nsx health transport-nodes`
|
|
152
|
+
3. Edge 集群:`vmware-nsx health edge-clusters`
|
|
153
|
+
4. 告警:`vmware-nsx health alarms`
|
|
154
|
+
|
|
155
|
+
### 排查 VM 连通性
|
|
156
|
+
|
|
157
|
+
1. 查找 VM 所在 Segment:`vmware-nsx troubleshoot vm-segment my-vm-01`
|
|
158
|
+
2. 检查端口状态:`vmware-nsx troubleshoot port-status <port-id>`
|
|
159
|
+
3. 检查路由:`vmware-nsx gateway routes-t1 app-t1`
|
|
160
|
+
4. 检查 BGP:`vmware-nsx gateway bgp-neighbors tier0-gw`
|
|
161
|
+
|
|
162
|
+
## CLI
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Segment
|
|
166
|
+
vmware-nsx segment list
|
|
167
|
+
vmware-nsx segment get app-web-seg
|
|
168
|
+
vmware-nsx segment create app-web-seg --gateway app-t1 --subnet 10.10.1.1/24 --transport-zone tz-overlay
|
|
169
|
+
vmware-nsx segment delete app-web-seg
|
|
170
|
+
|
|
171
|
+
# 网关
|
|
172
|
+
vmware-nsx gateway list-t0
|
|
173
|
+
vmware-nsx gateway list-t1
|
|
174
|
+
vmware-nsx gateway create-t1 app-t1 --edge-cluster edge-cluster-01 --tier0 tier0-gw
|
|
175
|
+
vmware-nsx gateway bgp-neighbors tier0-gw
|
|
176
|
+
vmware-nsx gateway routes-t1 app-t1
|
|
177
|
+
|
|
178
|
+
# NAT(写操作有双重确认 + --dry-run 预览)
|
|
179
|
+
vmware-nsx nat list app-t1
|
|
180
|
+
vmware-nsx nat create app-t1 --action SNAT --source 10.10.1.0/24 --translated 172.16.0.10
|
|
181
|
+
vmware-nsx nat delete app-t1 rule-01
|
|
182
|
+
|
|
183
|
+
# 静态路由
|
|
184
|
+
vmware-nsx route list app-t1
|
|
185
|
+
vmware-nsx route create app-t1 --network 192.168.100.0/24 --next-hop 10.10.1.254
|
|
186
|
+
|
|
187
|
+
# IP 池
|
|
188
|
+
vmware-nsx ippool list
|
|
189
|
+
vmware-nsx ippool create tep-pool
|
|
190
|
+
vmware-nsx ippool add-subnet tep-pool --start 192.168.100.10 --end 192.168.100.50 --cidr 192.168.100.0/24
|
|
191
|
+
|
|
192
|
+
# 健康与排障
|
|
193
|
+
vmware-nsx health alarms
|
|
194
|
+
vmware-nsx health transport-nodes
|
|
195
|
+
vmware-nsx health manager-status
|
|
196
|
+
vmware-nsx troubleshoot vm-segment my-vm-01
|
|
197
|
+
|
|
198
|
+
# 环境诊断
|
|
199
|
+
vmware-nsx doctor
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## MCP Server
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# 直接运行
|
|
206
|
+
uvx --from vmware-nsx-mgmt vmware-nsx-mcp
|
|
207
|
+
|
|
208
|
+
# 或通过 Docker
|
|
209
|
+
docker compose up -d
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Agent 配置
|
|
213
|
+
|
|
214
|
+
将以下内容添加到 AI Agent 的 MCP 配置文件:
|
|
215
|
+
|
|
216
|
+
```json
|
|
217
|
+
{
|
|
218
|
+
"mcpServers": {
|
|
219
|
+
"vmware-nsx": {
|
|
220
|
+
"command": "vmware-nsx-mcp",
|
|
221
|
+
"env": {
|
|
222
|
+
"VMWARE_NSX_CONFIG": "~/.vmware-nsx/config.yaml"
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
更多 Agent 配置模板(Claude Code、Cursor、Goose、Continue 等)见 [examples/mcp-configs/](examples/mcp-configs/)。
|
|
230
|
+
|
|
231
|
+
## 版本兼容性
|
|
232
|
+
|
|
233
|
+
| NSX 版本 | 支持 | 说明 |
|
|
234
|
+
|----------|------|------|
|
|
235
|
+
| NSX 4.x | 完整 | 最新 Policy API,全部功能 |
|
|
236
|
+
| NSX-T 3.2 | 完整 | 所有功能可用 |
|
|
237
|
+
| NSX-T 3.1 | 完整 | 路由表格式略有差异 |
|
|
238
|
+
| NSX-T 3.0 | 兼容 | IP 池子网 API 在此版本引入 |
|
|
239
|
+
| NSX-T 2.5 | 有限 | Policy API 不完整,部分工具可能失败 |
|
|
240
|
+
| NSX-V (6.x) | 不支持 | 完全不同的 API(基于 SOAP) |
|
|
241
|
+
|
|
242
|
+
### VCF 兼容性
|
|
243
|
+
|
|
244
|
+
| VCF 版本 | 捆绑 NSX | 支持 |
|
|
245
|
+
|----------|----------|------|
|
|
246
|
+
| VCF 5.x | NSX 4.x | 完整 |
|
|
247
|
+
| VCF 4.3-4.5 | NSX-T 3.1-3.2 | 完整 |
|
|
248
|
+
|
|
249
|
+
## 安全
|
|
250
|
+
|
|
251
|
+
| 功能 | 说明 |
|
|
252
|
+
|------|------|
|
|
253
|
+
| 只读为主 | 31 个工具中 18 个只读 |
|
|
254
|
+
| 双重确认 | CLI 写操作需两次确认 |
|
|
255
|
+
| --dry-run | 所有写操作支持预览模式 |
|
|
256
|
+
| 依赖检查 | 删除操作验证无关联资源 |
|
|
257
|
+
| 输入验证 | CIDR、IP、VLAN ID、网关存在性验证 |
|
|
258
|
+
| 审计日志 | 所有操作记录到 `~/.vmware-nsx/audit.log`(JSON Lines) |
|
|
259
|
+
| 无防火墙操作 | 无法创建/修改 DFW 规则或安全组 |
|
|
260
|
+
| 凭据安全 | 密码只从环境变量读取,不存于配置文件 |
|
|
261
|
+
| Prompt 注入防护 | NSX 对象名称经过控制字符清理 |
|
|
262
|
+
| TLS 说明 | 默认对自签名证书禁用 TLS 验证;生产环境建议启用 |
|
|
263
|
+
|
|
264
|
+
## 常见问题排查
|
|
265
|
+
|
|
266
|
+
| 问题 | 原因与解决 |
|
|
267
|
+
|------|-----------|
|
|
268
|
+
| "Segment not found" | Policy API 使用 Segment `id` 而非 `display_name`。运行 `segment list` 获取准确 ID。 |
|
|
269
|
+
| NAT 创建报 "gateway not found" | NAT 需要 Tier-1(或 Tier-0)网关。用 `gateway list-t1` 确认,网关必须有 Edge 集群。 |
|
|
270
|
+
| BGP 邻居停在 Connect/Active | 对端不可达、ASN 不匹配、TCP 179 被阻止、或 MD5 密码不匹配。 |
|
|
271
|
+
| 传输节点 "degraded" | TEP 不可达(检查 MTU >= 1600)、NTP 同步问题、或主机交换机配置不匹配。 |
|
|
272
|
+
| "Password not found" 错误 | 变量名规则:`VMWARE_<目标名大写>_PASSWORD`(连字符→下划线)。检查 `~/.vmware-nsx/.env`。 |
|
|
273
|
+
| 连接 NSX Manager 超时 | 使用 `vmware-nsx doctor --skip-auth` 跳过高延迟网络的认证检查。 |
|
|
274
|
+
|
|
275
|
+
## 许可证
|
|
276
|
+
|
|
277
|
+
[MIT](LICENSE)
|