Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ jobs:
defaults:
run:
working-directory: ansible_collections/ngine_io/cloudstack
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version:
- 3.8
- "3.10"
group:
- 1
- 2
ansible-branch:
- devel
- stable-2.14
container-version:
- 1.4.0
- 1.2.0
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/sanity.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Sanity
on:
push:
branches:
- master
schedule:
- cron: "5 12 * * 2"
pull_request:
workflow_call:
workflow_dispatch:

jobs:
sanity:
Expand All @@ -11,13 +16,14 @@ jobs:
run:
working-directory: ansible_collections/ngine_io/cloudstack
strategy:
fail-fast: false
matrix:
ansible:
- stable-2.12
- stable-2.11
- stable-2.10
- stable-2.13
- stable-2.14
- devel
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v3
Expand All @@ -27,7 +33,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
python-version: "3.10"

- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
Expand Down
19 changes: 9 additions & 10 deletions plugins/modules/cs_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function

__metaclass__ = type


Expand Down Expand Up @@ -190,11 +191,9 @@

# import cloudstack common
from ansible.module_utils.basic import AnsibleModule
from ..module_utils.cloudstack import (
AnsibleCloudStack,
cs_argument_spec,
cs_required_together
)

from ..module_utils.cloudstack import (AnsibleCloudStack, cs_argument_spec,
cs_required_together)


class AnsibleCloudStackAccount(AnsibleCloudStack):
Expand Down Expand Up @@ -385,12 +384,12 @@ def absent_account(self):
self.poll_job(res, 'account')
return account

def get_result(self, account):
super(AnsibleCloudStackAccount, self).get_result(account)
if account:
if 'accounttype' in account:
def get_result(self, resource):
super(AnsibleCloudStackAccount, self).get_result(resource)
if resource:
if 'accounttype' in resource:
for key, value in self.account_types.items():
if value == account['accounttype']:
if value == resource['accounttype']:
self.result['account_type'] = key
break
return self.result
Expand Down
13 changes: 6 additions & 7 deletions plugins/modules/cs_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function

__metaclass__ = type


Expand Down Expand Up @@ -134,11 +135,9 @@
'''

from ansible.module_utils.basic import AnsibleModule
from ..module_utils.cloudstack import (
AnsibleCloudStack,
cs_argument_spec,
cs_required_together
)

from ..module_utils.cloudstack import (AnsibleCloudStack, cs_argument_spec,
cs_required_together)


class AnsibleCloudStackConfiguration(AnsibleCloudStack):
Expand Down Expand Up @@ -232,8 +231,8 @@ def present_configuration(self):
configuration = res['configuration']
return configuration

def get_result(self, configuration):
self.result = super(AnsibleCloudStackConfiguration, self).get_result(configuration)
def get_result(self, resource):
self.result = super(AnsibleCloudStackConfiguration, self).get_result(resource)
if self.account:
self.result['account'] = self.account['name']
self.result['domain'] = self.domain['path']
Expand Down
21 changes: 10 additions & 11 deletions plugins/modules/cs_disk_offering.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# Copyright (c) 2017, René Moser <mail@renemoser.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import (absolute_import, division, print_function)
from __future__ import absolute_import, division, print_function

__metaclass__ = type


Expand Down Expand Up @@ -215,11 +216,9 @@
'''

from ansible.module_utils.basic import AnsibleModule
from ..module_utils.cloudstack import (
AnsibleCloudStack,
cs_argument_spec,
cs_required_together,
)

from ..module_utils.cloudstack import (AnsibleCloudStack, cs_argument_spec,
cs_required_together)


class AnsibleCloudStackDiskOffering(AnsibleCloudStack):
Expand Down Expand Up @@ -319,12 +318,12 @@ def _update_offering(self, disk_offering):
disk_offering = res['diskoffering']
return disk_offering

def get_result(self, disk_offering):
super(AnsibleCloudStackDiskOffering, self).get_result(disk_offering)
if disk_offering:
def get_result(self, resource):
super(AnsibleCloudStackDiskOffering, self).get_result(resource)
if resource:
# Prevent confusion, the api returns a tags key for storage tags.
if 'tags' in disk_offering:
self.result['storage_tags'] = disk_offering['tags'].split(',') or [disk_offering['tags']]
if 'tags' in resource:
self.result['storage_tags'] = resource['tags'].split(',') or [resource['tags']]
if 'tags' in self.result:
del self.result['tags']

Expand Down
19 changes: 9 additions & 10 deletions plugins/modules/cs_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function

__metaclass__ = type


Expand Down Expand Up @@ -211,11 +212,9 @@
'''

from ansible.module_utils.basic import AnsibleModule
from ..module_utils.cloudstack import (
AnsibleCloudStack,
cs_argument_spec,
cs_required_together
)

from ..module_utils.cloudstack import (AnsibleCloudStack, cs_argument_spec,
cs_required_together)


class AnsibleCloudStackFirewall(AnsibleCloudStack):
Expand Down Expand Up @@ -376,14 +375,14 @@ def remove_firewall_rule(self):
self.poll_job(res, 'firewallrule')
return firewall_rule

def get_result(self, firewall_rule):
super(AnsibleCloudStackFirewall, self).get_result(firewall_rule)
if firewall_rule:
def get_result(self, resource):
super(AnsibleCloudStackFirewall, self).get_result(resource)
if resource:
self.result['type'] = self.module.params.get('type')
if self.result['type'] == 'egress':
self.result['network'] = self.get_network(key='displaytext')
if 'cidrlist' in firewall_rule:
self.result['cidrs'] = firewall_rule['cidrlist'].split(',') or [firewall_rule['cidrlist']]
if 'cidrlist' in resource:
self.result['cidrs'] = resource['cidrlist'].split(',') or [resource['cidrlist']]
return self.result


Expand Down
22 changes: 11 additions & 11 deletions plugins/modules/cs_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function

__metaclass__ = type


Expand Down Expand Up @@ -322,14 +323,13 @@
sample: zone01
'''

from ansible.module_utils.basic import AnsibleModule
from ..module_utils.cloudstack import (
AnsibleCloudStack,
cs_argument_spec,
cs_required_together,
)
import time

from ansible.module_utils.basic import AnsibleModule

from ..module_utils.cloudstack import (AnsibleCloudStack, cs_argument_spec,
cs_required_together)


class AnsibleCloudStackHost(AnsibleCloudStack):

Expand Down Expand Up @@ -560,11 +560,11 @@ def _poll_for_maintenance(self):
return host
self.fail_json(msg="Polling for maintenance timed out")

def get_result(self, host):
super(AnsibleCloudStackHost, self).get_result(host)
if host:
self.result['allocation_state'] = host['resourcestate'].lower()
self.result['host_tags'] = host['hosttags'].split(',') if host.get('hosttags') else []
def get_result(self, resource):
super(AnsibleCloudStackHost, self).get_result(resource)
if resource:
self.result['allocation_state'] = resource['resourcestate'].lower()
self.result['host_tags'] = resource['hosttags'].split(',') if resource.get('hosttags') else []
return self.result


Expand Down
39 changes: 19 additions & 20 deletions plugins/modules/cs_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function

__metaclass__ = type


Expand Down Expand Up @@ -72,7 +73,6 @@
description:
- Name of the filter used to search for the template or iso.
- Used for params I(iso) or I(template) on I(state=present).
- The filter C(all) was added in 2.6.
type: str
default: executable
choices: [ all, featured, self, selfexecutable, sharedexecutable, executable, community ]
Expand Down Expand Up @@ -120,8 +120,8 @@
type: int
root_disk_size:
description:
- Root disk size in GByte required if deploying instance with KVM hypervisor and want resize the root disk size at startup
(need CloudStack >= 4.4, cloud-initramfs-growroot installed and enabled in the template)
- "Root disk size in GByte required if deploying instance with KVM hypervisor and want resize the root disk size at startup
(needs CloudStack >= 4.4, cloud-initramfs-growroot installed and enabled in the template)."
type: int
security_groups:
description:
Expand All @@ -141,7 +141,7 @@
- Only considered when I(state=started) or instance is running.
- Requires root admin privileges.
type: str
pod:
pod:
description:
- Pod on which an instance should be deployed or started on.
- Only considered when I(state=started) or instance is running.
Expand Down Expand Up @@ -425,13 +425,12 @@
'''

import base64
from ansible.module_utils.basic import AnsibleModule

from ansible.module_utils._text import to_bytes, to_text
from ..module_utils.cloudstack import (
AnsibleCloudStack,
cs_argument_spec,
cs_required_together
)
from ansible.module_utils.basic import AnsibleModule

from ..module_utils.cloudstack import (AnsibleCloudStack, cs_argument_spec,
cs_required_together)


class AnsibleCloudStackInstance(AnsibleCloudStack):
Expand Down Expand Up @@ -1039,22 +1038,22 @@ def restore_instance(self):
instance = self.poll_job(res, 'virtualmachine')
return instance

def get_result(self, instance):
super(AnsibleCloudStackInstance, self).get_result(instance)
if instance:
self.result['user_data'] = self._get_instance_user_data(instance)
if 'securitygroup' in instance:
def get_result(self, resource):
super(AnsibleCloudStackInstance, self).get_result(resource)
if resource:
self.result['user_data'] = self._get_instance_user_data(resource)
if 'securitygroup' in resource:
security_groups = []
for securitygroup in instance['securitygroup']:
for securitygroup in resource['securitygroup']:
security_groups.append(securitygroup['name'])
self.result['security_groups'] = security_groups
if 'affinitygroup' in instance:
if 'affinitygroup' in resource:
affinity_groups = []
for affinitygroup in instance['affinitygroup']:
for affinitygroup in resource['affinitygroup']:
affinity_groups.append(affinitygroup['name'])
self.result['affinity_groups'] = affinity_groups
if 'nic' in instance:
for nic in instance['nic']:
if 'nic' in resource:
for nic in resource['nic']:
if nic['isdefault']:
if 'ipaddress' in nic:
self.result['default_ip'] = nic['ipaddress']
Expand Down
Loading