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.rst
+22-3Lines changed: 22 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@
17
17
Extensions
18
18
==========
19
19
20
-
Extensions are a new mechanism introduced in Apache CloudStack to allow administrators to extend the platform's functionality by integrating external systems or custom workflows. Currently, CloudStack supports a single extension type called Orchestrator.
20
+
Extensions are a new mechanism introduced in Apache CloudStack to allow administrators to extend the platform's functionality by integrating external systems or custom workflows. Currently, CloudStack supports two extension types: Orchestrator and NetworkOrchestrator.
21
21
22
22
In the UI, extensions can be managed under *Extensions* menu.
23
23
@@ -26,7 +26,7 @@ In the UI, extensions can be managed under *Extensions* menu.
26
26
Overview
27
27
^^^^^^^^
28
28
29
-
An extension in CloudStack is defined as an external binary (written in any programming language) that implements specific actions CloudStack can invoke. This allows operators to manage resource lifecycle operations outside CloudStack, such as provisioning VMs in third-party systems or triggering external automation pipelines.
29
+
An extension in CloudStack is defined as an external binary (written in any programming language) that implements specific actions CloudStack can invoke. This allows operators to manage resource lifecycle operations outside CloudStack, such as provisioning VMs in third-party systems, orchestrating network and VPC services on external devices, or triggering external automation pipelines.
30
30
31
31
Extensions are managed through the API and UI, with support for configuration, resource mappings, and action execution.
32
32
@@ -41,7 +41,7 @@ Administrators can define and manage the following components of an extension:
41
41
42
42
- Configuration Details: Key-value properties used by the extension at runtime.
43
43
44
-
- Resource Mappings: Association between extensions and CloudStack resources such as clusters, etc.
44
+
- Resource Mappings: Association between extensions and CloudStack resources such as clusters and physical networks.
45
45
46
46
Path and Availabilty
47
47
^^^^^^^^^^^^^^^^^^^^
@@ -80,6 +80,25 @@ An Orchestrator extension enables CloudStack to delegate VM orchestration to an
80
80
81
81
|extension.png|
82
82
83
+
NetworkOrchestrator Extension
84
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
85
+
86
+
A NetworkOrchestrator extension enables CloudStack to delegate guest network and VPC service orchestration to an external network system. Key features include:
87
+
88
+
- Physical Network Mapping: NetworkOrchestrator extensions are registered with a CloudStack physical network instead of a cluster.
89
+
90
+
- Provider-based Integration: When a NetworkOrchestrator extension is registered with a physical network, CloudStack creates an external network service provider using the extension name. Network and VPC offerings can then use that provider.
91
+
92
+
- Capability-driven Services: Supported services are declared through the extension details ``network.services`` and optional per-service capabilities in ``network.service.capabilities``. CloudStack uses these declarations when exposing supported services and validating offering capabilities.
93
+
94
+
- Network and VPC Lifecycle: Depending on the declared services, the extension can handle operations for guest networks, VPCs, public IPs, NAT, load balancing, DHCP, DNS, userdata, network ACLs, and related restart or reapply flows.
95
+
96
+
- Registration Details: Resource-specific details such as device endpoints, credentials, host lists, or interface mappings can be stored on the physical-network registration and updated later through the UI or the ``updateRegisteredExtension`` API.
97
+
98
+
- Network and VPC Custom Actions: Admins can define custom actions for ``Network`` and ``Vpc`` resources when the extension advertises the ``CustomAction`` service.
99
+
100
+
- Reference Implementation: A Linux network namespace based implementation is available in `cloudstack-extensions <https://github.com/apache/cloudstack-extensions/tree/network-namespace/Network-Namespace>`_. This reference backend has been validated with KVM-based smoke tests.
101
+
83
102
84
103
CloudStack provides built-in Orchestrator Extensions for Proxmox, Hyper-V, and MaaS, which work with their respective environments out of the box.
Copy file name to clipboardExpand all lines: source/adminguide/extensions/custom_actions.rst
+18-1Lines changed: 18 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,9 @@
17
17
Custom Actions
18
18
^^^^^^^^^^^^^^
19
19
20
-
In addition to standard instance operations, extensions support custom actions. These can be configured via UI in the extension details view or the addCustomAction API. The extension binary or script must implement handlers for these action names and process any provided parameters.
20
+
In addition to standard lifecycle operations, extensions support custom actions. These can be configured via UI in the extension details view or the addCustomAction API. The extension binary or script must implement handlers for these action names and process any provided parameters.
21
+
22
+
For Orchestrator extensions, custom actions typically target ``VirtualMachine`` resources. For NetworkOrchestrator extensions, custom actions can target ``Network`` and ``Vpc`` resources when the extension advertises the ``CustomAction`` network service.
21
23
22
24
|add-custom-action.png|
23
25
@@ -43,12 +45,27 @@ A single parameter can have the following details:
43
45
44
46
- **valueoptions**: Options for the value of the parameter. This is allowed only for NUMBER and STRING type.
45
47
48
+
Supported Resource Types
49
+
~~~~~~~~~~~~~~~~~~~~~~~~
50
+
51
+
Custom actions can be attached to the following resource types:
52
+
53
+
- ``VirtualMachine`` for Orchestrator extensions.
54
+
55
+
- ``Network`` for NetworkOrchestrator extensions.
56
+
57
+
- ``Vpc`` for NetworkOrchestrator extensions.
58
+
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
+
46
61
47
62
Running Custom Action
48
63
~~~~~~~~~~~~~~~~~~~~~
49
64
50
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.
51
66
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.
Copy file name to clipboardExpand all lines: source/adminguide/extensions/developer.rst
+70-9Lines changed: 70 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,18 @@
16
16
Writing Extensions for CloudStack
17
17
=================================
18
18
19
-
The CloudStack Extensions Framework allows developers and operators to write extensions using any programming language or script. From CloudStack’s perspective, an extension is simply an executable capable of handling specific actions and processing input payloads. CloudStack invokes the executable by passing the action name and the path to a JSON-formatted payload file as command-line arguments. The extension processes the payload, performs the required operations on an external system, and returns the result as a JSON response written to `stdout`.
19
+
The CloudStack Extensions Framework allows developers and operators to write extensions using any programming language or script. From CloudStack’s perspective, an extension is an executable capable of handling CloudStack actions and integrating with an external system.
20
+
21
+
Extension Types
22
+
^^^^^^^^^^^^^^^
23
+
24
+
CloudStack currently supports two extension types:
25
+
26
+
- ``Orchestrator`` for external instance lifecycle management. These extensions are registered with ``Cluster`` resources.
27
+
28
+
- ``NetworkOrchestrator`` for external guest network and VPC service orchestration. These extensions are registered with ``PhysicalNetwork`` resources.
29
+
30
+
Both types share the same extension lifecycle in the UI and API, but their invocation model and supported resource mappings differ.
20
31
21
32
22
33
Create a New Extension
@@ -26,11 +37,12 @@ You must first register a new extension using the API or UI:
- ``type``: ``Orchestrator`` or ``NetworkOrchestrator``
34
46
- ``path``: Relative path to the executable. Root path will be `/usr/share/cloudstack-management/extensions/<extension_name>`
35
47
36
48
The path must be:
@@ -43,10 +55,28 @@ If no explicit path is provided during extension creation, CloudStack will scaff
43
55
44
56
CloudStack checks extension readiness periodically and shows its state in the UI/API.
45
57
46
-
Extension Structure
47
-
^^^^^^^^^^^^^^^^^^^
58
+
For ``NetworkOrchestrator`` extensions, define supported services in the extension detail ``network.services`` and optionally declare per-service capabilities in ``network.service.capabilities``. CloudStack uses these values when exposing supported providers and validating network and VPC offerings.
59
+
60
+
Register Extension With a Resource
61
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62
+
63
+
After creating an extension, register it with the CloudStack resource it serves:
64
+
65
+
- ``Orchestrator`` extensions are registered with ``Cluster`` resources.
66
+
67
+
- ``NetworkOrchestrator`` extensions are registered with ``PhysicalNetwork`` resources.
68
+
69
+
Resource-level details supplied during registration are useful for endpoints, credentials, host lists, interface mappings, or other device-specific settings. These registration details can later be changed with the ``updateRegisteredExtension`` API without removing the existing mapping.
70
+
71
+
When a ``NetworkOrchestrator`` extension is registered with a physical network, CloudStack creates a network service provider using the extension name. Network and VPC offerings can then use that provider name.
72
+
73
+
Invocation Model
74
+
^^^^^^^^^^^^^^^^
75
+
76
+
Orchestrator Invocation
77
+
~~~~~~~~~~~~~~~~~~~~~~~
48
78
49
-
Your extension must support the following invocation structure:
79
+
Orchestrator extensions must support the following invocation structure:
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``.
101
+
102
+
CloudStack always passes registration and runtime state using named arguments such as:
103
+
104
+
- ``--physical-network-extension-details`` for details stored on the physical-network registration.
105
+
106
+
- ``--network-extension-details`` for per-network or per-VPC state maintained by the extension.
107
+
108
+
Some commands may also receive temporary file paths for larger payloads.
109
+
67
110
Input Format (Payload)
68
111
^^^^^^^^^^^^^^^^^^^^^^
69
112
70
-
CloudStack provides input via a JSON file, which your executable must read and parse.
113
+
For Orchestrator extensions, CloudStack provides input via a JSON file, which your executable must read and parse.
71
114
72
115
Example:
73
116
@@ -107,10 +150,12 @@ Example:
107
150
108
151
The schema varies depending on the resource and action. Use this to perform context-specific logic.
109
152
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``.
154
+
110
155
Output Format
111
156
^^^^^^^^^^^^^
112
157
113
-
Your extension should write a response JSON to ``stdout``. Example:
158
+
Orchestrator extensions should write a response JSON to ``stdout``. Example:
114
159
115
160
.. code-block:: json
116
161
@@ -122,11 +167,20 @@ Your extension should write a response JSON to ``stdout``. Example:
122
167
For custom actions, CloudStack will display the ``message`` in the UI if the output JSON includes ``"printmessage": "true"``.
123
168
The ``message`` field can be a string, a JSON object or a JSON array.
124
169
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.
171
+
172
+
Declaring Network Services and Capabilities
173
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
174
+
175
+
``NetworkOrchestrator`` extensions should declare their supported services in the extension detail ``network.services`` as a comma-separated list. Example values include ``SourceNat``, ``StaticNat``, ``PortForwarding``, ``Firewall``, ``Lb``, ``Dhcp``, ``Dns``, ``UserData``, ``NetworkACL``, ``Gateway``, ``Vpn``, and ``CustomAction``.
176
+
177
+
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
+
125
179
Action Lifecycle
126
180
^^^^^^^^^^^^^^^^
127
181
128
182
1. A CloudStack action (e.g., deploy VM) triggers a corresponding extension action.
129
-
2. CloudStack invokes the extension’s executable with appropriate parameters.
183
+
2. CloudStack invokes the extension’s executable using the protocol defined by the extension type.
130
184
3. The extension processes the input and responds within the timeout.
131
185
4. CloudStack continues action workflow based on the result.
132
186
@@ -182,9 +236,12 @@ Custom Actions
182
236
You can define new custom actions for users or admin-triggered workflows.
183
237
184
238
- Register via UI or ``addCustomAction`` API
239
+
- Choose a resource type that matches the extension type: ``VirtualMachine`` for Orchestrator, ``Network`` or ``Vpc`` for NetworkOrchestrator
185
240
- Define input parameters (name, type, required)
186
241
- Implement the handler for the custom action in your executable.
187
242
243
+
For NetworkOrchestrator extensions, advertise the ``CustomAction`` service in ``network.services`` if the extension should receive custom actions for network or VPC resources.
244
+
188
245
CloudStack UI will render forms dynamically based on these definitions.
189
246
190
247
Best Practices
@@ -195,6 +252,8 @@ Best Practices
195
252
- Avoid hard dependencies on CloudStack internals
196
253
- Implement logging for troubleshooting
197
254
- Use exit code and ``stdout`` for signaling success/failure
255
+
- Keep ``network.services`` and ``network.service.capabilities`` aligned with the services your NetworkOrchestrator implementation actually handles
256
+
- Use resource registration details for environment-specific settings and rotate them with ``updateRegisteredExtension`` instead of recreating mappings when possible
For a clearer understanding of how to implement an extension, developers can refer to the base shell script scaffolded by CloudStack for orchestrator-type extensions. This script is located at:
293
+
For a clearer understanding of how to implement an Orchestrator extension, developers can refer to the base shell script scaffolded by CloudStack for orchestrator-type extensions. This script is located at:
It serves as a template with minimal required action handlers, making it a useful starting point for building new extensions.
239
298
299
+
For NetworkOrchestrator extensions, refer to the Network Extension Script Protocol in the CloudStack source tree and the reference implementation in `cloudstack-extensions <https://github.com/apache/cloudstack-extensions/tree/network-namespace/Network-Namespace>`_.
300
+
240
301
Additionally, CloudStack includes in-built extensions for Proxmox and Hyper-V that demonstrate how to implement extensions in different languages - Bash and Python.
Copy file name to clipboardExpand all lines: source/adminguide/extensions/troubleshooting.rst
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,8 @@ Validate the Extension Path
28
28
29
29
- Ensure files are stored at: `/usr/share/cloudstack-management/extensions/<extension_name>`
30
30
31
+
- For NetworkOrchestrator extensions, ensure the configured path resolves either to an executable file or to a directory that contains an executable named `<extension_name>.sh`.
32
+
31
33
- CloudStack runs a background task at regular intervals to verify path readiness. If the path is not ready, its state will appear as Not Ready in the UI or API responses.
32
34
33
35
- Alerts are generated if the extension path is not ready.
@@ -45,13 +47,37 @@ Verify Payload Handling
45
47
46
48
- Improper parsing of the payload is a common cause of failure—log any parsing errors in your extension binary for debugging.
47
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.
51
+
52
+
Check Resource Registration and Provider State
53
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54
+
55
+
- Orchestrator extensions must be registered with a ``Cluster`` resource. NetworkOrchestrator extensions must be registered with a ``PhysicalNetwork`` resource.
56
+
57
+
- If resource-specific configuration changes are needed after registration, use the UI or the ``updateRegisteredExtension`` API instead of unregistering and recreating the mapping.
58
+
59
+
- 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
+
61
+
Verify Declared Network Services
62
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63
+
64
+
- NetworkOrchestrator extensions should declare supported services in the extension detail ``network.services``.
65
+
66
+
- Per-service capabilities should be declared in ``network.service.capabilities``.
67
+
68
+
- If the expected provider services do not appear while creating a network or VPC offering, verify that these details were saved correctly and that any JSON value was quoted correctly when creating or updating the extension.
69
+
70
+
- Common declared services include ``SourceNat``, ``StaticNat``, ``PortForwarding``, ``Firewall``, ``Lb``, ``Dhcp``, ``Dns``, ``UserData``, ``NetworkACL``, and ``CustomAction``. Additional services such as ``Gateway`` or ``Vpn`` can also be declared when supported by the implementation.
71
+
48
72
Refer to Base Extension Scripts
49
73
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
50
74
51
75
- For guidance on implementing supported actions, refer to the base scripts present for each extension type.
52
76
53
77
- For Orchestrator-type extensions, see: `/usr/share/cloudstack-common/scripts/vm/hypervisor/external/provisioner/provisioner.sh`
54
78
79
+
- For NetworkOrchestrator-type extensions, refer to the Network Extension Script Protocol in the CloudStack source tree and the reference implementation in `cloudstack-extensions <https://github.com/apache/cloudstack-extensions/tree/network-namespace/Network-Namespace>`_.
80
+
55
81
- These scripts provide examples of how to handle standard actions like start, stop, status, etc.
56
82
57
83
Check Logs for Errors
@@ -67,4 +93,6 @@ Check Logs for Errors
67
93
68
94
3. Output parsing
69
95
96
+
4. Provider and service resolution for network and VPC operations
0 commit comments