|
135 | 135 | - Only considered when I(state=started) or instance is running. |
136 | 136 | - Requires root admin privileges. |
137 | 137 | type: str |
| 138 | + cluster: |
| 139 | + description: |
| 140 | + - Cluster on which an instance should be deployed or started on. |
| 141 | + - Only considered when I(state=started) or instance is running. |
| 142 | + - Requires root admin privileges. |
| 143 | + type: str |
| 144 | + pod: |
| 145 | + description: |
| 146 | + - Pod on which an instance should be deployed or started on. |
| 147 | + - Only considered when I(state=started) or instance is running. |
| 148 | + - Requires root admin privileges. |
| 149 | + type: str |
138 | 150 | domain: |
139 | 151 | description: |
140 | 152 | - Domain the instance is related to. |
@@ -469,11 +481,43 @@ def get_host_id(self): |
469 | 481 | hosts = self.query_api('listHosts', **args) |
470 | 482 | if hosts: |
471 | 483 | for h in hosts['host']: |
472 | | - if h['name'] == host_name: |
| 484 | + if host_name in [h['name'], h['id']]: |
473 | 485 | return h['id'] |
474 | 486 |
|
475 | 487 | self.fail_json(msg="Host '%s' not found" % host_name) |
476 | 488 |
|
| 489 | + def get_cluster_id(self): |
| 490 | + cluster_name = self.module.params.get('cluster') |
| 491 | + if not cluster_name: |
| 492 | + return None |
| 493 | + |
| 494 | + args = { |
| 495 | + 'zoneid': self.get_zone(key='id') |
| 496 | + } |
| 497 | + clusters = self.query_api('listClusters', **args) |
| 498 | + if clusters: |
| 499 | + for c in clusters['cluster']: |
| 500 | + if cluster_name in [c['name'], c['id']]: |
| 501 | + return c['id'] |
| 502 | + |
| 503 | + self.fail_json(msg="Cluster '%s' not found" % cluster_name) |
| 504 | + |
| 505 | + def get_pod_id(self): |
| 506 | + pod_name = self.module.params.get('pod') |
| 507 | + if not pod_name: |
| 508 | + return None |
| 509 | + |
| 510 | + args = { |
| 511 | + 'zoneid': self.get_zone(key='id') |
| 512 | + } |
| 513 | + pods = self.query_api('listPods', **args) |
| 514 | + if pods: |
| 515 | + for p in pods['pod']: |
| 516 | + if pod_name in [p['name'], p['id']]: |
| 517 | + return p['id'] |
| 518 | + |
| 519 | + self.fail_json(msg="Pod '%s' not found" % pod_name) |
| 520 | + |
477 | 521 | def get_template_or_iso(self, key=None): |
478 | 522 | template = self.module.params.get('template') |
479 | 523 | iso = self.module.params.get('iso') |
@@ -740,6 +784,8 @@ def deploy_instance(self, start_vm=True): |
740 | 784 | args['details'] = self.get_details() |
741 | 785 | args['securitygroupnames'] = self.module.params.get('security_groups') |
742 | 786 | args['hostid'] = self.get_host_id() |
| 787 | + args['clusterid'] = self.get_cluster_id() |
| 788 | + args['podid'] = self.get_pod_id() |
743 | 789 |
|
744 | 790 | template_iso = self.get_template_or_iso() |
745 | 791 | if 'hypervisor' not in template_iso: |
@@ -1038,6 +1084,8 @@ def main(): |
1038 | 1084 | keyboard=dict(type='str', choices=['de', 'de-ch', 'es', 'fi', 'fr', 'fr-be', 'fr-ch', 'is', 'it', 'jp', 'nl-be', 'no', 'pt', 'uk', 'us']), |
1039 | 1085 | hypervisor=dict(), |
1040 | 1086 | host=dict(), |
| 1087 | + cluster=dict(), |
| 1088 | + pod=dict(), |
1041 | 1089 | security_groups=dict(type='list', elements='str', aliases=['security_group']), |
1042 | 1090 | affinity_groups=dict(type='list', elements='str', aliases=['affinity_group']), |
1043 | 1091 | domain=dict(), |
|
0 commit comments