Skip to content

Commit 0590751

Browse files
authored
ci: fix sanity tests (#113)
1 parent 44f183c commit 0590751

31 files changed

+257
-272
lines changed

.github/workflows/integration.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ jobs:
1313
defaults:
1414
run:
1515
working-directory: ansible_collections/ngine_io/cloudstack
16-
runs-on: ubuntu-latest
16+
runs-on: ubuntu-20.04
1717
strategy:
1818
fail-fast: false
1919
matrix:
2020
python-version:
21-
- 3.8
21+
- "3.10"
2222
group:
2323
- 1
2424
- 2
2525
ansible-branch:
26-
- devel
26+
- stable-2.14
2727
container-version:
2828
- 1.4.0
2929
- 1.2.0

.github/workflows/sanity.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
name: Sanity
22
on:
3+
push:
4+
branches:
5+
- master
36
schedule:
47
- cron: "5 12 * * 2"
58
pull_request:
9+
workflow_call:
10+
workflow_dispatch:
611

712
jobs:
813
sanity:
@@ -11,13 +16,14 @@ jobs:
1116
run:
1217
working-directory: ansible_collections/ngine_io/cloudstack
1318
strategy:
19+
fail-fast: false
1420
matrix:
1521
ansible:
1622
- stable-2.12
17-
- stable-2.11
18-
- stable-2.10
23+
- stable-2.13
24+
- stable-2.14
1925
- devel
20-
runs-on: ubuntu-latest
26+
runs-on: ubuntu-20.04
2127
steps:
2228
- name: Check out code
2329
uses: actions/checkout@v3
@@ -27,7 +33,7 @@ jobs:
2733
- name: Set up Python
2834
uses: actions/setup-python@v4
2935
with:
30-
python-version: "3.x"
36+
python-version: "3.10"
3137

3238
- name: Install ansible-base (${{ matrix.ansible }})
3339
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check

plugins/modules/cs_account.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
66

77
from __future__ import absolute_import, division, print_function
8+
89
__metaclass__ = type
910

1011

@@ -190,11 +191,9 @@
190191

191192
# import cloudstack common
192193
from ansible.module_utils.basic import AnsibleModule
193-
from ..module_utils.cloudstack import (
194-
AnsibleCloudStack,
195-
cs_argument_spec,
196-
cs_required_together
197-
)
194+
195+
from ..module_utils.cloudstack import (AnsibleCloudStack, cs_argument_spec,
196+
cs_required_together)
198197

199198

200199
class AnsibleCloudStackAccount(AnsibleCloudStack):
@@ -385,12 +384,12 @@ def absent_account(self):
385384
self.poll_job(res, 'account')
386385
return account
387386

388-
def get_result(self, account):
389-
super(AnsibleCloudStackAccount, self).get_result(account)
390-
if account:
391-
if 'accounttype' in account:
387+
def get_result(self, resource):
388+
super(AnsibleCloudStackAccount, self).get_result(resource)
389+
if resource:
390+
if 'accounttype' in resource:
392391
for key, value in self.account_types.items():
393-
if value == account['accounttype']:
392+
if value == resource['accounttype']:
394393
self.result['account_type'] = key
395394
break
396395
return self.result

plugins/modules/cs_configuration.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
66

77
from __future__ import absolute_import, division, print_function
8+
89
__metaclass__ = type
910

1011

@@ -134,11 +135,9 @@
134135
'''
135136

136137
from ansible.module_utils.basic import AnsibleModule
137-
from ..module_utils.cloudstack import (
138-
AnsibleCloudStack,
139-
cs_argument_spec,
140-
cs_required_together
141-
)
138+
139+
from ..module_utils.cloudstack import (AnsibleCloudStack, cs_argument_spec,
140+
cs_required_together)
142141

143142

144143
class AnsibleCloudStackConfiguration(AnsibleCloudStack):
@@ -232,8 +231,8 @@ def present_configuration(self):
232231
configuration = res['configuration']
233232
return configuration
234233

235-
def get_result(self, configuration):
236-
self.result = super(AnsibleCloudStackConfiguration, self).get_result(configuration)
234+
def get_result(self, resource):
235+
self.result = super(AnsibleCloudStackConfiguration, self).get_result(resource)
237236
if self.account:
238237
self.result['account'] = self.account['name']
239238
self.result['domain'] = self.domain['path']

plugins/modules/cs_disk_offering.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
# Copyright (c) 2017, René Moser <[email protected]>
66
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
77

8-
from __future__ import (absolute_import, division, print_function)
8+
from __future__ import absolute_import, division, print_function
9+
910
__metaclass__ = type
1011

1112

@@ -215,11 +216,9 @@
215216
'''
216217

217218
from ansible.module_utils.basic import AnsibleModule
218-
from ..module_utils.cloudstack import (
219-
AnsibleCloudStack,
220-
cs_argument_spec,
221-
cs_required_together,
222-
)
219+
220+
from ..module_utils.cloudstack import (AnsibleCloudStack, cs_argument_spec,
221+
cs_required_together)
223222

224223

225224
class AnsibleCloudStackDiskOffering(AnsibleCloudStack):
@@ -319,12 +318,12 @@ def _update_offering(self, disk_offering):
319318
disk_offering = res['diskoffering']
320319
return disk_offering
321320

322-
def get_result(self, disk_offering):
323-
super(AnsibleCloudStackDiskOffering, self).get_result(disk_offering)
324-
if disk_offering:
321+
def get_result(self, resource):
322+
super(AnsibleCloudStackDiskOffering, self).get_result(resource)
323+
if resource:
325324
# Prevent confusion, the api returns a tags key for storage tags.
326-
if 'tags' in disk_offering:
327-
self.result['storage_tags'] = disk_offering['tags'].split(',') or [disk_offering['tags']]
325+
if 'tags' in resource:
326+
self.result['storage_tags'] = resource['tags'].split(',') or [resource['tags']]
328327
if 'tags' in self.result:
329328
del self.result['tags']
330329

plugins/modules/cs_firewall.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
66

77
from __future__ import absolute_import, division, print_function
8+
89
__metaclass__ = type
910

1011

@@ -211,11 +212,9 @@
211212
'''
212213

213214
from ansible.module_utils.basic import AnsibleModule
214-
from ..module_utils.cloudstack import (
215-
AnsibleCloudStack,
216-
cs_argument_spec,
217-
cs_required_together
218-
)
215+
216+
from ..module_utils.cloudstack import (AnsibleCloudStack, cs_argument_spec,
217+
cs_required_together)
219218

220219

221220
class AnsibleCloudStackFirewall(AnsibleCloudStack):
@@ -376,14 +375,14 @@ def remove_firewall_rule(self):
376375
self.poll_job(res, 'firewallrule')
377376
return firewall_rule
378377

379-
def get_result(self, firewall_rule):
380-
super(AnsibleCloudStackFirewall, self).get_result(firewall_rule)
381-
if firewall_rule:
378+
def get_result(self, resource):
379+
super(AnsibleCloudStackFirewall, self).get_result(resource)
380+
if resource:
382381
self.result['type'] = self.module.params.get('type')
383382
if self.result['type'] == 'egress':
384383
self.result['network'] = self.get_network(key='displaytext')
385-
if 'cidrlist' in firewall_rule:
386-
self.result['cidrs'] = firewall_rule['cidrlist'].split(',') or [firewall_rule['cidrlist']]
384+
if 'cidrlist' in resource:
385+
self.result['cidrs'] = resource['cidrlist'].split(',') or [resource['cidrlist']]
387386
return self.result
388387

389388

plugins/modules/cs_host.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
66

77
from __future__ import absolute_import, division, print_function
8+
89
__metaclass__ = type
910

1011

@@ -322,14 +323,13 @@
322323
sample: zone01
323324
'''
324325

325-
from ansible.module_utils.basic import AnsibleModule
326-
from ..module_utils.cloudstack import (
327-
AnsibleCloudStack,
328-
cs_argument_spec,
329-
cs_required_together,
330-
)
331326
import time
332327

328+
from ansible.module_utils.basic import AnsibleModule
329+
330+
from ..module_utils.cloudstack import (AnsibleCloudStack, cs_argument_spec,
331+
cs_required_together)
332+
333333

334334
class AnsibleCloudStackHost(AnsibleCloudStack):
335335

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

563-
def get_result(self, host):
564-
super(AnsibleCloudStackHost, self).get_result(host)
565-
if host:
566-
self.result['allocation_state'] = host['resourcestate'].lower()
567-
self.result['host_tags'] = host['hosttags'].split(',') if host.get('hosttags') else []
563+
def get_result(self, resource):
564+
super(AnsibleCloudStackHost, self).get_result(resource)
565+
if resource:
566+
self.result['allocation_state'] = resource['resourcestate'].lower()
567+
self.result['host_tags'] = resource['hosttags'].split(',') if resource.get('hosttags') else []
568568
return self.result
569569

570570

plugins/modules/cs_instance.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
66

77
from __future__ import absolute_import, division, print_function
8+
89
__metaclass__ = type
910

1011

@@ -72,7 +73,6 @@
7273
description:
7374
- Name of the filter used to search for the template or iso.
7475
- Used for params I(iso) or I(template) on I(state=present).
75-
- The filter C(all) was added in 2.6.
7676
type: str
7777
default: executable
7878
choices: [ all, featured, self, selfexecutable, sharedexecutable, executable, community ]
@@ -120,8 +120,8 @@
120120
type: int
121121
root_disk_size:
122122
description:
123-
- Root disk size in GByte required if deploying instance with KVM hypervisor and want resize the root disk size at startup
124-
(need CloudStack >= 4.4, cloud-initramfs-growroot installed and enabled in the template)
123+
- "Root disk size in GByte required if deploying instance with KVM hypervisor and want resize the root disk size at startup
124+
(needs CloudStack >= 4.4, cloud-initramfs-growroot installed and enabled in the template)."
125125
type: int
126126
security_groups:
127127
description:
@@ -141,7 +141,7 @@
141141
- Only considered when I(state=started) or instance is running.
142142
- Requires root admin privileges.
143143
type: str
144-
pod:
144+
pod:
145145
description:
146146
- Pod on which an instance should be deployed or started on.
147147
- Only considered when I(state=started) or instance is running.
@@ -425,13 +425,12 @@
425425
'''
426426

427427
import base64
428-
from ansible.module_utils.basic import AnsibleModule
428+
429429
from ansible.module_utils._text import to_bytes, to_text
430-
from ..module_utils.cloudstack import (
431-
AnsibleCloudStack,
432-
cs_argument_spec,
433-
cs_required_together
434-
)
430+
from ansible.module_utils.basic import AnsibleModule
431+
432+
from ..module_utils.cloudstack import (AnsibleCloudStack, cs_argument_spec,
433+
cs_required_together)
435434

436435

437436
class AnsibleCloudStackInstance(AnsibleCloudStack):
@@ -1039,22 +1038,22 @@ def restore_instance(self):
10391038
instance = self.poll_job(res, 'virtualmachine')
10401039
return instance
10411040

1042-
def get_result(self, instance):
1043-
super(AnsibleCloudStackInstance, self).get_result(instance)
1044-
if instance:
1045-
self.result['user_data'] = self._get_instance_user_data(instance)
1046-
if 'securitygroup' in instance:
1041+
def get_result(self, resource):
1042+
super(AnsibleCloudStackInstance, self).get_result(resource)
1043+
if resource:
1044+
self.result['user_data'] = self._get_instance_user_data(resource)
1045+
if 'securitygroup' in resource:
10471046
security_groups = []
1048-
for securitygroup in instance['securitygroup']:
1047+
for securitygroup in resource['securitygroup']:
10491048
security_groups.append(securitygroup['name'])
10501049
self.result['security_groups'] = security_groups
1051-
if 'affinitygroup' in instance:
1050+
if 'affinitygroup' in resource:
10521051
affinity_groups = []
1053-
for affinitygroup in instance['affinitygroup']:
1052+
for affinitygroup in resource['affinitygroup']:
10541053
affinity_groups.append(affinitygroup['name'])
10551054
self.result['affinity_groups'] = affinity_groups
1056-
if 'nic' in instance:
1057-
for nic in instance['nic']:
1055+
if 'nic' in resource:
1056+
for nic in resource['nic']:
10581057
if nic['isdefault']:
10591058
if 'ipaddress' in nic:
10601059
self.result['default_ip'] = nic['ipaddress']

0 commit comments

Comments
 (0)