You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/adminguide/extensions/custom_actions.rst
+10-2Lines changed: 10 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,13 +58,21 @@ Custom actions can be attached to the following resource types:
58
58
59
59
For network and VPC custom actions, CloudStack dispatches the action to the external provider that serves the ``CustomAction`` service for the selected resource.
60
60
61
+
For ``NetworkOrchestrator`` extensions, the action is executed as ``custom-action`` using the standard payload-file invocation model:
The payload file contains top-level keys such as ``action``, ``action-params``, ``physical-network-extension-details``, and ``network-extension-details``. Unlike other network extension commands, the custom action request does not wrap its command-specific values inside a nested ``payload`` object.
68
+
61
69
62
70
Running Custom Action
63
71
~~~~~~~~~~~~~~~~~~~~~
64
72
65
-
All enabled custom actions can then be triggered for a resource of the type the action is defined for or provided while running, using the **Run Action** view or runCustomAction API.
73
+
All enabled custom actions can then be triggered for a resource of the type the action is defined for or provided while running, using the **Run Action** view or the relevant custom action API.
66
74
67
-
The same API is used for VM, network, and VPC custom actions. The available actions shown in the UI depend on the selected resource type and the extension bound to that resource.
75
+
For network and VPC custom actions, CloudStack passes the full request in the payload file and returns the script's ``stdout`` to the caller. The available actions shown in the UI depend on the selected resource type and the extension bound to that resource.
Copy file name to clipboardExpand all lines: source/adminguide/extensions/developer.rst
+68-7Lines changed: 68 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,15 +97,21 @@ Sample Invocation:
97
97
NetworkOrchestrator Invocation
98
98
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99
99
100
-
NetworkOrchestrator extensions use service-specific command names and named CLI arguments instead of the payload-file format above. Depending on the declared services, CloudStack can invoke commands such as ``ensure-network-device``, ``implement-network``, ``shutdown-network``, ``destroy-network``, ``assign-ip``, ``add-static-nat``, ``add-port-forward``, ``apply-fw-rules``, ``apply-lb-rules``, ``apply-network-acl``, ``implement-vpc``, ``shutdown-vpc``, or ``custom-action``.
100
+
NetworkOrchestrator extensions also use the payload-file invocation model:
101
101
102
-
CloudStack always passes registration and runtime state using named arguments such as:
- ``--physical-network-extension-details`` for details stored on the physical-network registration.
108
+
- ``<extensionPath>/<extensionName>.sh``
105
109
106
-
- ``--network-extension-details`` for per-network or per-VPC state maintained by the extension.
110
+
- ``<extensionPath>`` itself, if it is an executable file
107
111
108
-
Some commands may also receive temporary file paths for larger payloads.
112
+
Depending on the declared services, CloudStack can invoke commands such as ``ensure-network-device``, ``implement-network``, ``shutdown-network``, ``destroy-network``, ``restore-network``, ``implement-vpc``, ``shutdown-vpc``, ``update-vpc-source-nat-ip``, ``assign-ip``, ``release-ip``, ``add-static-nat``, ``delete-static-nat``, ``add-port-forward``, ``delete-port-forward``, ``apply-fw-rules``, ``apply-network-acl``, ``add-dhcp-entry``, ``remove-dhcp-entry``, ``config-dhcp-subnet``, ``remove-dhcp-subnet``, ``set-dhcp-options``, ``add-dns-entry``, ``config-dns-subnet``, ``remove-dns-subnet``, ``save-vm-data``, ``save-password``, ``save-userdata``, ``save-sshkey``, ``save-hypervisor-hostname``, ``apply-lb-rules``, and ``custom-action``.
113
+
114
+
The command name determines the operation. The payload file carries registration details, stored network or VPC state, and command-specific fields.
109
115
110
116
Input Format (Payload)
111
117
^^^^^^^^^^^^^^^^^^^^^^
@@ -150,7 +156,21 @@ Example:
150
156
151
157
The schema varies depending on the resource and action. Use this to perform context-specific logic.
152
158
153
-
For NetworkOrchestrator extensions, CloudStack passes command-specific CLI arguments such as network IDs, VPC IDs, VLAN tags, IP addresses, action parameters, and JSON strings in named options. The exact input depends on the command being invoked and the services declared in ``network.services``.
159
+
For NetworkOrchestrator extensions, CloudStack writes a JSON payload file and passes its path as the second argument. For standard network and VPC commands, the payload has this envelope:
160
+
161
+
.. code-block:: json
162
+
163
+
{
164
+
"physical-network-extension-details": {},
165
+
"network-extension-details": {},
166
+
"payload": {}
167
+
}
168
+
169
+
``physical-network-extension-details`` contains the registration details stored against the physical network, enriched with values such as the physical network name. ``network-extension-details`` contains the per-network or per-VPC state saved by the extension, including the output previously returned by ``ensure-network-device``. ``payload`` contains the command-specific fields.
170
+
171
+
Frequently used payload fields include ``network_id``, ``vpc_id``, ``vlan``, ``gateway``, ``cidr``, ``extension_ip``, ``public_ip``, ``public_cidr``, ``public_vlan``, ``public_gateway``, ``private_ip``, ``nic_uuid``, ``dns``, and ``domain``.
172
+
173
+
For ``custom-action``, CloudStack still uses a payload file, but the command-specific values are placed at the top level instead of under ``payload``. The request includes keys such as ``action``, ``action-params``, ``physical-network-extension-details``, and ``network-extension-details``.
154
174
155
175
Output Format
156
176
^^^^^^^^^^^^^
@@ -167,7 +187,7 @@ Orchestrator extensions should write a response JSON to ``stdout``. Example:
167
187
For custom actions, CloudStack will display the ``message`` in the UI if the output JSON includes ``"printmessage": "true"``.
168
188
The ``message`` field can be a string, a JSON object or a JSON array.
169
189
170
-
For NetworkOrchestrator extensions, most commands signal success or failure by exit code. Some commands return command-specific data on ``stdout``, such as the JSON returned by ``ensure-network-device`` or the output of a ``custom-action``. Keep the output aligned with the command contract implemented by the extension.
190
+
For NetworkOrchestrator extensions, all commands must exit with code ``0`` on success and a non-zero code on failure. ``ensure-network-device`` is special: it must write a single-line JSON object to ``stdout`` and CloudStack persists that JSON for later calls. ``custom-action`` may also return output on ``stdout``. Other commands should not rely on ``stdout`` for normal operation because CloudStack ignores it apart from debug logging.
171
191
172
192
Declaring Network Services and Capabilities
173
193
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -176,6 +196,44 @@ Declaring Network Services and Capabilities
176
196
177
197
Use ``network.service.capabilities`` to provide a JSON object describing capability values for the declared services. CloudStack uses these capabilities when listing supported providers and validating network or VPC offerings.
178
198
199
+
For example, ``Firewall`` capabilities can declare values such as ``SupportedProtocols``, ``SupportedEgressProtocols``, and ``SupportedTrafficDirection``; ``Lb`` can declare ``SupportedLBAlgorithms`` and ``SupportedProtocols``; and ``SourceNat`` can declare ``SupportedSourceNatTypes``.
200
+
201
+
CloudStack Setup for NetworkOrchestrator
202
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
203
+
204
+
After creating a ``NetworkOrchestrator`` extension, the usual setup flow is:
205
+
206
+
1. Deploy the executable to the path returned by ``listExtensions`` on every management server.
207
+
2. Register the extension with a ``PhysicalNetwork`` using ``registerExtension`` and pass any device-specific details required by the script.
208
+
3. Enable the generated network service provider on that physical network.
209
+
4. Create network or VPC offerings that map supported services to the extension name.
210
+
5. When registration details need to change, update them with ``updateRegisteredExtension`` instead of deleting and recreating the mapping.
211
+
212
+
Service-to-Command Mapping
213
+
^^^^^^^^^^^^^^^^^^^^^^^^^^
214
+
215
+
NetworkOrchestrator scripts only need to implement the commands for the services they advertise in ``network.services``.
216
+
217
+
- ``SourceNat`` and ``Gateway`` trigger ``assign-ip`` and ``release-ip``.
218
+
- ``StaticNat`` triggers ``add-static-nat`` and ``delete-static-nat``.
219
+
- ``PortForwarding`` triggers ``add-port-forward`` and ``delete-port-forward``.
220
+
- ``Firewall`` triggers ``apply-fw-rules``.
221
+
- ``Lb`` triggers ``apply-lb-rules``.
222
+
- ``NetworkACL`` triggers ``apply-network-acl``.
223
+
- ``Dhcp`` triggers ``add-dhcp-entry``, ``remove-dhcp-entry``, ``config-dhcp-subnet``, ``remove-dhcp-subnet``, and ``set-dhcp-options``.
224
+
- ``Dns`` triggers ``add-dns-entry``, ``config-dns-subnet``, and ``remove-dns-subnet``.
225
+
- ``UserData`` triggers ``save-vm-data``, ``save-password``, ``save-userdata``, ``save-sshkey``, and ``save-hypervisor-hostname``.
226
+
- Network lifecycle operations always include ``ensure-network-device``, ``implement-network``, ``shutdown-network``, ``destroy-network``, and ``restore-network``.
227
+
- VPC lifecycle operations include ``ensure-network-device``, ``implement-vpc``, ``shutdown-vpc``, and ``update-vpc-source-nat-ip``.
228
+
- Operator-triggered actions use ``custom-action``.
229
+
230
+
VPC and Extension IP Notes
231
+
^^^^^^^^^^^^^^^^^^^^^^^^^^
232
+
233
+
For VPC-backed networks, CloudStack includes ``vpc_id`` in tier-level payloads and invokes VPC-level lifecycle commands without a ``network_id``. Use that value when the implementation needs to keep all tiers of a VPC on the same device.
234
+
235
+
``extension_ip`` is the IP address the external device presents on the guest side. When the extension provides ``SourceNat`` or ``Gateway``, it typically matches the network gateway. When the extension only provides services such as ``Dhcp``, ``Dns``, or ``UserData``, CloudStack can allocate a dedicated guest-side IP for the device and pass it as ``extension_ip``.
236
+
179
237
Action Lifecycle
180
238
^^^^^^^^^^^^^^^^
181
239
@@ -242,6 +300,8 @@ You can define new custom actions for users or admin-triggered workflows.
242
300
243
301
For NetworkOrchestrator extensions, advertise the ``CustomAction`` service in ``network.services`` if the extension should receive custom actions for network or VPC resources.
244
302
303
+
For network extension custom actions, the script should read the payload file passed on the command line and parse the top-level keys rather than looking for a nested ``payload`` object.
304
+
245
305
CloudStack UI will render forms dynamically based on these definitions.
246
306
247
307
Best Practices
@@ -254,6 +314,7 @@ Best Practices
254
314
- Use exit code and ``stdout`` for signaling success/failure
255
315
- Keep ``network.services`` and ``network.service.capabilities`` aligned with the services your NetworkOrchestrator implementation actually handles
256
316
- Use resource registration details for environment-specific settings and rotate them with ``updateRegisteredExtension`` instead of recreating mappings when possible
317
+
- Keep non-``ensure-network-device`` commands quiet on ``stdout`` unless the command contract explicitly returns output, such as ``custom-action``
Copy file name to clipboardExpand all lines: source/adminguide/extensions/troubleshooting.rst
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,13 @@ Verify Payload Handling
47
47
48
48
- Improper parsing of the payload is a common cause of failure—log any parsing errors in your extension binary for debugging.
49
49
50
-
- NetworkOrchestrator extensions use command-specific CLI arguments in addition to JSON strings such as ``--physical-network-extension-details`` and ``--network-extension-details``. Verify that the script accepts the expected command names and argument format for the services it implements.
50
+
- NetworkOrchestrator extensions receive ``<command> <payload_file> <timeout_seconds>``. Verify that the script accepts the command name and reads the JSON payload file rather than expecting named CLI options.
51
+
52
+
- For standard network and VPC commands, confirm that the payload file contains the expected top-level keys: ``physical-network-extension-details``, ``network-extension-details``, and ``payload``.
53
+
54
+
- For ``custom-action``, confirm that the request uses top-level keys such as ``action`` and ``action-params`` instead of a nested ``payload`` object.
55
+
56
+
- For ``ensure-network-device``, confirm that the script prints a single-line JSON object to ``stdout``. For other commands, unexpected ``stdout`` output is usually a sign that the script is not following the current command contract.
51
57
52
58
Check Resource Registration and Provider State
53
59
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -58,6 +64,8 @@ Check Resource Registration and Provider State
58
64
59
65
- For NetworkOrchestrator extensions, confirm that a network service provider with the same name as the extension exists on the target physical network and is in the expected state before creating network or VPC offerings.
60
66
67
+
- If the provider exists but operations still fail, verify that the provider was enabled after registration and that the intended offering maps each supported service to the extension name.
68
+
61
69
Verify Declared Network Services
62
70
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63
71
@@ -95,4 +103,6 @@ Check Logs for Errors
95
103
96
104
4. Provider and service resolution for network and VPC operations
97
105
106
+
5. Failures while decoding nested payload values such as firewall rules, ACL rules, restore data, or VM metadata blobs
0 commit comments