Skip to content

Commit 5897e78

Browse files
committed
Doc for network extension
1 parent 3df7828 commit 5897e78

4 files changed

Lines changed: 138 additions & 13 deletions

File tree

source/adminguide/extensions.rst

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Extensions
1818
==========
1919

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.
2121

2222
In the UI, extensions can be managed under *Extensions* menu.
2323

@@ -26,7 +26,7 @@ In the UI, extensions can be managed under *Extensions* menu.
2626
Overview
2727
^^^^^^^^
2828

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.
3030

3131
Extensions are managed through the API and UI, with support for configuration, resource mappings, and action execution.
3232

@@ -41,7 +41,7 @@ Administrators can define and manage the following components of an extension:
4141

4242
- Configuration Details: Key-value properties used by the extension at runtime.
4343

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.
4545

4646
Path and Availabilty
4747
^^^^^^^^^^^^^^^^^^^^
@@ -80,6 +80,25 @@ An Orchestrator extension enables CloudStack to delegate VM orchestration to an
8080

8181
|extension.png|
8282

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+
83102

84103
CloudStack provides built-in Orchestrator Extensions for Proxmox, Hyper-V, and MaaS, which work with their respective environments out of the box.
85104

source/adminguide/extensions/custom_actions.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
Custom Actions
1818
^^^^^^^^^^^^^^
1919

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.
2123

2224
|add-custom-action.png|
2325

@@ -43,12 +45,27 @@ A single parameter can have the following details:
4345

4446
- **valueoptions**: Options for the value of the parameter. This is allowed only for NUMBER and STRING type.
4547

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+
4661

4762
Running Custom Action
4863
~~~~~~~~~~~~~~~~~~~~~
4964

5065
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.
5166

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.
68+
5269
|run-custom-action-instance.png|
5370

5471
|run-custom-action.png|

source/adminguide/extensions/developer.rst

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@
1616
Writing Extensions for CloudStack
1717
=================================
1818

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.
2031

2132

2233
Create a New Extension
@@ -26,11 +37,12 @@ You must first register a new extension using the API or UI:
2637

2738
.. code-block:: bash
2839
29-
cloudmonkey createExtension name=myext path=myext-executable
40+
cloudmonkey createExtension name=myext type=Orchestrator path=myext-executable
3041
3142
Arguments:
3243

3344
- ``name``: Unique name
45+
- ``type``: ``Orchestrator`` or ``NetworkOrchestrator``
3446
- ``path``: Relative path to the executable. Root path will be `/usr/share/cloudstack-management/extensions/<extension_name>`
3547

3648
The path must be:
@@ -43,10 +55,28 @@ If no explicit path is provided during extension creation, CloudStack will scaff
4355

4456
CloudStack checks extension readiness periodically and shows its state in the UI/API.
4557

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+
~~~~~~~~~~~~~~~~~~~~~~~
4878

49-
Your extension must support the following invocation structure:
79+
Orchestrator extensions must support the following invocation structure:
5080

5181
.. code-block:: bash
5282
@@ -64,10 +94,23 @@ Sample Invocation:
6494
6595
/usr/share/cloudstack-management/extensions/myext/myext.py deploy /var/lib/cloudstack/management/extensions/myext/162345.json 60
6696
97+
NetworkOrchestrator Invocation
98+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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``.
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+
67110
Input Format (Payload)
68111
^^^^^^^^^^^^^^^^^^^^^^
69112

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.
71114

72115
Example:
73116

@@ -107,10 +150,12 @@ Example:
107150
108151
The schema varies depending on the resource and action. Use this to perform context-specific logic.
109152

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+
110155
Output Format
111156
^^^^^^^^^^^^^
112157

113-
Your extension should write a response JSON to ``stdout``. Example:
158+
Orchestrator extensions should write a response JSON to ``stdout``. Example:
114159

115160
.. code-block:: json
116161
@@ -122,11 +167,20 @@ Your extension should write a response JSON to ``stdout``. Example:
122167
For custom actions, CloudStack will display the ``message`` in the UI if the output JSON includes ``"printmessage": "true"``.
123168
The ``message`` field can be a string, a JSON object or a JSON array.
124169

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+
125179
Action Lifecycle
126180
^^^^^^^^^^^^^^^^
127181

128182
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.
130184
3. The extension processes the input and responds within the timeout.
131185
4. CloudStack continues action workflow based on the result.
132186

@@ -182,9 +236,12 @@ Custom Actions
182236
You can define new custom actions for users or admin-triggered workflows.
183237

184238
- Register via UI or ``addCustomAction`` API
239+
- Choose a resource type that matches the extension type: ``VirtualMachine`` for Orchestrator, ``Network`` or ``Vpc`` for NetworkOrchestrator
185240
- Define input parameters (name, type, required)
186241
- Implement the handler for the custom action in your executable.
187242

243+
For NetworkOrchestrator extensions, advertise the ``CustomAction`` service in ``network.services`` if the extension should receive custom actions for network or VPC resources.
244+
188245
CloudStack UI will render forms dynamically based on these definitions.
189246

190247
Best Practices
@@ -195,6 +252,8 @@ Best Practices
195252
- Avoid hard dependencies on CloudStack internals
196253
- Implement logging for troubleshooting
197254
- 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
198257

199258
Extension Examples
200259
^^^^^^^^^^^^^^^^^^
@@ -231,10 +290,12 @@ Extension Examples
231290
else:
232291
print(json.dumps({"success": False, "result": {"message": "Unknown action"}}))
233292
234-
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:
235294

236295
/usr/share/cloudstack-common/scripts/vm/hypervisor/external/provisioner/provisioner.sh
237296

238297
It serves as a template with minimal required action handlers, making it a useful starting point for building new extensions.
239298

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+
240301
Additionally, CloudStack includes in-built extensions for Proxmox and Hyper-V that demonstrate how to implement extensions in different languages - Bash and Python.

source/adminguide/extensions/troubleshooting.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Validate the Extension Path
2828

2929
- Ensure files are stored at: `/usr/share/cloudstack-management/extensions/<extension_name>`
3030

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+
3133
- 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.
3234

3335
- Alerts are generated if the extension path is not ready.
@@ -45,13 +47,37 @@ Verify Payload Handling
4547

4648
- Improper parsing of the payload is a common cause of failure—log any parsing errors in your extension binary for debugging.
4749

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+
4872
Refer to Base Extension Scripts
4973
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5074

5175
- For guidance on implementing supported actions, refer to the base scripts present for each extension type.
5276

5377
- For Orchestrator-type extensions, see: `/usr/share/cloudstack-common/scripts/vm/hypervisor/external/provisioner/provisioner.sh`
5478

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+
5581
- These scripts provide examples of how to handle standard actions like start, stop, status, etc.
5682

5783
Check Logs for Errors
@@ -67,4 +93,6 @@ Check Logs for Errors
6793

6894
3. Output parsing
6995

96+
4. Provider and service resolution for network and VPC operations
97+
7098
- Any exceptions or exit code issues.

0 commit comments

Comments
 (0)