|
5 | 5 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
6 | 6 |
|
7 | 7 | from __future__ import absolute_import, division, print_function |
| 8 | + |
8 | 9 | __metaclass__ = type |
9 | 10 |
|
10 | 11 |
|
|
72 | 73 | description: |
73 | 74 | - Name of the filter used to search for the template or iso. |
74 | 75 | - Used for params I(iso) or I(template) on I(state=present). |
75 | | - - The filter C(all) was added in 2.6. |
76 | 76 | type: str |
77 | 77 | default: executable |
78 | 78 | choices: [ all, featured, self, selfexecutable, sharedexecutable, executable, community ] |
|
120 | 120 | type: int |
121 | 121 | root_disk_size: |
122 | 122 | 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)." |
125 | 125 | type: int |
126 | 126 | security_groups: |
127 | 127 | description: |
|
141 | 141 | - Only considered when I(state=started) or instance is running. |
142 | 142 | - Requires root admin privileges. |
143 | 143 | type: str |
144 | | - pod: |
| 144 | + pod: |
145 | 145 | description: |
146 | 146 | - Pod on which an instance should be deployed or started on. |
147 | 147 | - Only considered when I(state=started) or instance is running. |
|
425 | 425 | ''' |
426 | 426 |
|
427 | 427 | import base64 |
428 | | -from ansible.module_utils.basic import AnsibleModule |
| 428 | + |
429 | 429 | 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) |
435 | 434 |
|
436 | 435 |
|
437 | 436 | class AnsibleCloudStackInstance(AnsibleCloudStack): |
@@ -1039,22 +1038,22 @@ def restore_instance(self): |
1039 | 1038 | instance = self.poll_job(res, 'virtualmachine') |
1040 | 1039 | return instance |
1041 | 1040 |
|
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: |
1047 | 1046 | security_groups = [] |
1048 | | - for securitygroup in instance['securitygroup']: |
| 1047 | + for securitygroup in resource['securitygroup']: |
1049 | 1048 | security_groups.append(securitygroup['name']) |
1050 | 1049 | self.result['security_groups'] = security_groups |
1051 | | - if 'affinitygroup' in instance: |
| 1050 | + if 'affinitygroup' in resource: |
1052 | 1051 | affinity_groups = [] |
1053 | | - for affinitygroup in instance['affinitygroup']: |
| 1052 | + for affinitygroup in resource['affinitygroup']: |
1054 | 1053 | affinity_groups.append(affinitygroup['name']) |
1055 | 1054 | 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']: |
1058 | 1057 | if nic['isdefault']: |
1059 | 1058 | if 'ipaddress' in nic: |
1060 | 1059 | self.result['default_ip'] = nic['ipaddress'] |
|
0 commit comments