Skip to content

Commit 727f004

Browse files
committed
NE: add prepare-nic / release-nic in README.md
1 parent 7f82846 commit 727f004

1 file changed

Lines changed: 63 additions & 3 deletions

File tree

  • framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/network

framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/network/README.md

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ hosts. Use it as a working example.
5454
- [add-port-forward / delete-port-forward](#add-port-forward--delete-port-forward)
5555
- [apply-fw-rules](#apply-fw-rules)
5656
- [apply-network-acl](#apply-network-acl)
57+
- [prepare-nic / release-nic](#prepare-nic--release-nic)
5758
- [add-dhcp-entry / remove-dhcp-entry](#add-dhcp-entry--remove-dhcp-entry)
5859
- [config-dhcp-subnet / remove-dhcp-subnet](#config-dhcp-subnet--remove-dhcp-subnet)
5960
- [set-dhcp-options](#set-dhcp-options)
@@ -324,7 +325,7 @@ ID, namespace name, etc.).
324325
{"host":"192.168.1.10","device_id":"vrf-42","namespace":"cs-net-42"}
325326
```
326327

327-
**Exit 0:** JSON written to stdout is persisted.
328+
**Exit 0:** JSON written to stdout is persisted.
328329
**Exit non-zero:** Existing details are kept unchanged; a warning is logged.
329330

330331
---
@@ -450,9 +451,9 @@ The `extension.details` blob is removed from CloudStack after a successful retur
450451
**Called:** When a public IP is associated with or disassociated from a
451452
network (source NAT, static NAT, PF, LB allocation).
452453

453-
**Purpose:**
454+
**Purpose:**
454455
- `assign-ip` — attach the public IP to the device; add the necessary routing
455-
entry so the device can receive traffic for this IP.
456+
entry so the device can receive traffic for this IP.
456457
- `release-ip` — detach the public IP; remove routing.
457458

458459
**Payload fields (`payload` object):**
@@ -640,6 +641,56 @@ Rules are applied in ascending `number` order.
640641

641642
---
642643

644+
### `prepare-nic` / `release-nic`
645+
646+
**Called:** On every NIC attach (`prepare`) and detach (`release`) regardless
647+
of which services the extension provides.
648+
649+
**Purpose:**
650+
- `prepare-nic` — set up per-NIC state before the VM boots: create the port
651+
binding on the device (OVN `Logical_Switch_Port`, dnsmasq entry, …).
652+
- `release-nic` — tear down per-NIC state after the VM is destroyed: remove the
653+
port binding and associated metadata.
654+
655+
These commands fire for **all** NICs on extension-managed networks, not just
656+
those belonging to DHCP/DNS-enabled offerings.
657+
658+
**`prepare-nic` payload fields (`payload` object):**
659+
660+
| Field | Description |
661+
|---|---|
662+
| `network_id` | Network ID. |
663+
| `vlan` | Guest VLAN tag. |
664+
| `mac` | VM NIC MAC address. |
665+
| `ip` | VM NIC IPv4 address. |
666+
| `nic_ip6_address` | NIC IPv6 address, when configured. |
667+
| `nic_ip6_gateway` | NIC IPv6 gateway, when available. |
668+
| `nic_ip6_cidr` | NIC IPv6 CIDR, when available. |
669+
| `nic_uuid` | NIC UUID — matches `external_ids:iface-id` written by the KVM agent for OVN port binding. |
670+
| `default_nic` | Stringified boolean — `"false"` for secondary NICs. |
671+
| `hostname` | VM hostname. |
672+
| `gateway` | Guest network gateway. |
673+
| `cidr` | Guest network CIDR. |
674+
| `extension_ip` | Extension IP. |
675+
| `vpc_id` | Present for VPC tier networks. |
676+
677+
**`release-nic` payload fields (`payload` object):**
678+
679+
| Field | Description |
680+
|---|---|
681+
| `network_id` | Network ID. |
682+
| `vlan` | Guest VLAN tag. |
683+
| `mac` | VM NIC MAC address. |
684+
| `ip` | VM NIC IPv4 address. |
685+
| `nic_ip6_address` | NIC IPv6 address, when configured. |
686+
| `nic_ip6_gateway` | NIC IPv6 gateway, when available. |
687+
| `nic_ip6_cidr` | NIC IPv6 CIDR, when available. |
688+
| `nic_uuid` | NIC UUID. |
689+
| `extension_ip` | Extension IP. |
690+
| `vpc_id` | Present for VPC tier networks. |
691+
692+
---
693+
643694
### `add-dhcp-entry` / `remove-dhcp-entry`
644695

645696
**Called:** When a VM NIC is reserved (`add`) or released (`remove`) on a
@@ -1047,6 +1098,7 @@ Hook scripts should parse the payload file directly.
10471098
| **Dhcp** | `add-dhcp-entry`, `remove-dhcp-entry`, `config-dhcp-subnet`, `remove-dhcp-subnet`, `set-dhcp-options` |
10481099
| **Dns** | `add-dns-entry`, `config-dns-subnet`, `remove-dns-subnet` |
10491100
| **UserData** | `save-vm-data`, `save-password`, `save-userdata`, `save-sshkey`, `save-hypervisor-hostname` |
1101+
| *(NIC lifecycle — all)* | `prepare-nic`, `release-nic` |
10501102
| *(network lifecycle — all)* | `ensure-network-device`, `implement-network`, `shutdown-network`, `destroy-network`, `restore-network` |
10511103
| *(VPC lifecycle)* | `ensure-network-device`, `implement-vpc`, `shutdown-vpc`, `update-vpc-source-nat-ip` |
10521104
| *(operator)* | `custom-action` |
@@ -1279,6 +1331,14 @@ case "${COMMAND}" in
12791331
# TODO: parse $ACL_JSON and apply to VPC tier
12801332
;;
12811333

1334+
prepare-nic)
1335+
# TODO: create port binding mac=$(payload_field mac) ip=$(payload_field ip) nic_uuid=$(payload_field nic_uuid)
1336+
;;
1337+
1338+
release-nic)
1339+
# TODO: remove port binding mac=$(payload_field mac) ip=$(payload_field ip)
1340+
;;
1341+
12821342
add-dhcp-entry)
12831343
# TODO: add static lease mac=$(payload_field mac) ip=$(payload_field ip)
12841344
;;

0 commit comments

Comments
 (0)