Skip to content

new modues extension and custom_action - #186

Open
resmo wants to merge 2 commits into
masterfrom
feature/extension
Open

resmo wants to merge 2 commits into
masterfrom
feature/extension

Conversation

@resmo

@resmo resmo commented Aug 23, 2026

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds two new Ansible modules to the ngine_io.cloudstack collection—extension and custom_action—to manage CloudStack Extensions and their Custom Actions, along with new integration test targets and action-group registration.

Changes:

  • Added plugins/modules/extension.py to manage CloudStack extensions, including registration/unregistration with resources.
  • Added plugins/modules/custom_action.py to manage custom actions belonging to an extension.
  • Added integration test targets for both modules and registered them in meta/runtime.yml action groups.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/integration/targets/extension/tasks/main.yml New integration playbook covering extension create/update/details/state/idempotence flows.
tests/integration/targets/extension/meta/main.yml Adds cs_common dependency for the extension integration target.
tests/integration/targets/extension/aliases Registers the extension integration target in cloud/cs and cs/group1.
tests/integration/targets/custom_action/tasks/main.yml New integration playbook covering custom_action lifecycle, parameters/details, and idempotence.
tests/integration/targets/custom_action/meta/main.yml Adds cs_common dependency for the custom_action integration target.
tests/integration/targets/custom_action/aliases Registers the custom_action integration target in cloud/cs and cs/group1.
plugins/modules/extension.py New module implementing CloudStack extension present/absent and register/unregister operations.
plugins/modules/custom_action.py New module implementing custom action present/absent operations and normalization/diffing.
meta/runtime.yml Adds custom_action and extension to the CloudStack action group list.
Suppressed comments (1)

plugins/modules/custom_action.py:490

  • absent_custom_action() currently fails if the referenced extension does not exist (via get_extension_id()->fail_json), but the integration test expects removing a custom action from an unknown extension to be a no-op (not changed).
    def absent_custom_action(self):
        custom_action = self.get_custom_action()
        if custom_action:

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread plugins/modules/extension.py Outdated
Comment thread plugins/modules/custom_action.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Suppressed comments (1)

plugins/modules/custom_action.py:291

  • get_custom_action() should handle the case where get_extension_id() returns None (e.g., state=absent with a missing extension) and return None instead of calling listCustomActions with an invalid extensionid.
    def get_custom_action(self):
        args = {
            "extensionid": self.get_extension_id(),
            "name": self.module.params.get("name"),
        }
        custom_actions = self.query_api("listCustomActions", **args)
        if custom_actions:
            # The name filter of listCustomActions matches exactly.
            self.custom_action = custom_actions["extensioncustomaction"][0]
        return self.custom_action

Comment on lines +260 to +262
def __init__(self, module):
super(AnsibleCloudStackCustomAction, self).__init__(module)
self.returns = {
Comment on lines +275 to +280
def get_extension_id(self):
name = self.module.params.get("extension")
extensions = self.query_api("listExtensions", name=name)
if not extensions:
self.fail_json(msg="Extension %s not found" % name)
return extensions["extension"][0]["id"]
Comment on lines +259 to +270
- name: test register resource in check mode
ngine_io.cloudstack.extension:
name: "{{ cs_resource_prefix }}-ext"
resource_id: "{{ cs_resource_prefix }}-cluster"
resource_type: Cluster
state: register
register: extension
check_mode: true
- name: verify test register resource in check mode
assert:
that:
- extension is changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants