mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cloudstack: use new get_result() handling
This commit is contained in:
parent
41315b2cd9
commit
65dc7af166
17 changed files with 207 additions and 416 deletions
|
@ -139,6 +139,11 @@ local_action:
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
|
id:
|
||||||
|
description: UUID of the account.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: 87b1e0ce-4e01-11e4-bb66-0050569e64b8
|
||||||
name:
|
name:
|
||||||
description: Name of the account.
|
description: Name of the account.
|
||||||
returned: success
|
returned: success
|
||||||
|
@ -149,7 +154,7 @@ account_type:
|
||||||
returned: success
|
returned: success
|
||||||
type: string
|
type: string
|
||||||
sample: user
|
sample: user
|
||||||
account_state:
|
state:
|
||||||
description: State of the account.
|
description: State of the account.
|
||||||
returned: success
|
returned: success
|
||||||
type: string
|
type: string
|
||||||
|
@ -179,7 +184,10 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackAccount(AnsibleCloudStack):
|
class AnsibleCloudStackAccount(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackAccount, self).__init__(module)
|
||||||
|
self.returns = {
|
||||||
|
'networkdomain': 'network_domain',
|
||||||
|
}
|
||||||
self.account = None
|
self.account = None
|
||||||
self.account_types = {
|
self.account_types = {
|
||||||
'user': 0,
|
'user': 0,
|
||||||
|
@ -328,20 +336,13 @@ class AnsibleCloudStackAccount(AnsibleCloudStack):
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, account):
|
def get_result(self, account):
|
||||||
|
super(AnsibleCloudStackAccount, self).get_result(account)
|
||||||
if account:
|
if account:
|
||||||
if 'name' in account:
|
|
||||||
self.result['name'] = account['name']
|
|
||||||
if 'accounttype' in account:
|
if 'accounttype' in account:
|
||||||
for key,value in self.account_types.items():
|
for key,value in self.account_types.items():
|
||||||
if value == account['accounttype']:
|
if value == account['accounttype']:
|
||||||
self.result['account_type'] = key
|
self.result['account_type'] = key
|
||||||
break
|
break
|
||||||
if 'state' in account:
|
|
||||||
self.result['account_state'] = account['state']
|
|
||||||
if 'domain' in account:
|
|
||||||
self.result['domain'] = account['domain']
|
|
||||||
if 'networkdomain' in account:
|
|
||||||
self.result['network_domain'] = account['networkdomain']
|
|
||||||
return self.result
|
return self.result
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,11 @@ EXAMPLES = '''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
|
id:
|
||||||
|
description: UUID of the affinity group.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: 87b1e0ce-4e01-11e4-bb66-0050569e64b8
|
||||||
name:
|
name:
|
||||||
description: Name of affinity group.
|
description: Name of affinity group.
|
||||||
returned: success
|
returned: success
|
||||||
|
@ -110,7 +115,10 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackAffinityGroup, self).__init__(module)
|
||||||
|
self.returns = {
|
||||||
|
'type': 'affinity_type',
|
||||||
|
}
|
||||||
self.affinity_group = None
|
self.affinity_group = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -191,21 +199,6 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
||||||
return affinity_group
|
return affinity_group
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, affinity_group):
|
|
||||||
if affinity_group:
|
|
||||||
if 'name' in affinity_group:
|
|
||||||
self.result['name'] = affinity_group['name']
|
|
||||||
if 'description' in affinity_group:
|
|
||||||
self.result['description'] = affinity_group['description']
|
|
||||||
if 'type' in affinity_group:
|
|
||||||
self.result['affinity_type'] = affinity_group['type']
|
|
||||||
if 'domain' in affinity_group:
|
|
||||||
self.result['domain'] = affinity_group['domain']
|
|
||||||
if 'account' in affinity_group:
|
|
||||||
self.result['account'] = affinity_group['account']
|
|
||||||
return self.result
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
|
|
|
@ -80,7 +80,7 @@ local_action:
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
id:
|
id:
|
||||||
description: ID of the domain.
|
description: UUID of the domain.
|
||||||
returned: success
|
returned: success
|
||||||
type: string
|
type: string
|
||||||
sample: 87b1e0ce-4e01-11e4-bb66-0050569e64b8
|
sample: 87b1e0ce-4e01-11e4-bb66-0050569e64b8
|
||||||
|
@ -119,7 +119,12 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackDomain(AnsibleCloudStack):
|
class AnsibleCloudStackDomain(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackDomain, self).__init__(module)
|
||||||
|
self.returns = {
|
||||||
|
'path': 'path',
|
||||||
|
'networkdomain': 'network_domain',
|
||||||
|
'parentdomainname': 'parent_domain',
|
||||||
|
}
|
||||||
self.domain = None
|
self.domain = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,20 +237,6 @@ class AnsibleCloudStackDomain(AnsibleCloudStack):
|
||||||
return domain
|
return domain
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, domain):
|
|
||||||
if domain:
|
|
||||||
if 'id' in domain:
|
|
||||||
self.result['id'] = domain['id']
|
|
||||||
if 'name' in domain:
|
|
||||||
self.result['name'] = domain['name']
|
|
||||||
if 'path' in domain:
|
|
||||||
self.result['path'] = domain['path']
|
|
||||||
if 'parentdomainname' in domain:
|
|
||||||
self.result['parent_domain'] = domain['parentdomainname']
|
|
||||||
if 'networkdomain' in domain:
|
|
||||||
self.result['network_domain'] = domain['networkdomain']
|
|
||||||
return self.result
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
|
|
@ -151,6 +151,11 @@ EXAMPLES = '''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
|
id:
|
||||||
|
description: UUID of the rule.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: 04589590-ac63-4ffc-93f5-b698b8ac38b6
|
||||||
ip_address:
|
ip_address:
|
||||||
description: IP address of the rule if C(type=ingress)
|
description: IP address of the rule if C(type=ingress)
|
||||||
returned: success
|
returned: success
|
||||||
|
@ -211,7 +216,16 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackFirewall(AnsibleCloudStack):
|
class AnsibleCloudStackFirewall(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackFirewall, self).__init__(module)
|
||||||
|
self.returns = {
|
||||||
|
'cidrlist': 'cidr',
|
||||||
|
'startport': 'start_port',
|
||||||
|
'endpoint': 'end_port',
|
||||||
|
'protocol': 'protocol',
|
||||||
|
'ipaddress': 'ip_address',
|
||||||
|
'icmpcode': 'icmp_code',
|
||||||
|
'icmptype': 'icmp_type',
|
||||||
|
}
|
||||||
self.firewall_rule = None
|
self.firewall_rule = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -368,22 +382,9 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, firewall_rule):
|
def get_result(self, firewall_rule):
|
||||||
|
super(AnsibleCloudStackFirewall, self).get_result(firewall_rule)
|
||||||
if firewall_rule:
|
if firewall_rule:
|
||||||
self.result['type'] = self.module.params.get('type')
|
self.result['type'] = self.module.params.get('type')
|
||||||
if 'cidrlist' in firewall_rule:
|
|
||||||
self.result['cidr'] = firewall_rule['cidrlist']
|
|
||||||
if 'startport' in firewall_rule:
|
|
||||||
self.result['start_port'] = int(firewall_rule['startport'])
|
|
||||||
if 'endport' in firewall_rule:
|
|
||||||
self.result['end_port'] = int(firewall_rule['endport'])
|
|
||||||
if 'protocol' in firewall_rule:
|
|
||||||
self.result['protocol'] = firewall_rule['protocol']
|
|
||||||
if 'ipaddress' in firewall_rule:
|
|
||||||
self.result['ip_address'] = firewall_rule['ipaddress']
|
|
||||||
if 'icmpcode' in firewall_rule:
|
|
||||||
self.result['icmp_code'] = int(firewall_rule['icmpcode'])
|
|
||||||
if 'icmptype' in firewall_rule:
|
|
||||||
self.result['icmp_type'] = int(firewall_rule['icmptype'])
|
|
||||||
if 'networkid' in firewall_rule:
|
if 'networkid' in firewall_rule:
|
||||||
self.result['network'] = self.get_network(key='displaytext', network=firewall_rule['networkid'])
|
self.result['network'] = self.get_network(key='displaytext', network=firewall_rule['networkid'])
|
||||||
return self.result
|
return self.result
|
||||||
|
|
|
@ -244,7 +244,7 @@ EXAMPLES = '''
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
id:
|
id:
|
||||||
description: ID of the instance.
|
description: UUID of the instance.
|
||||||
returned: success
|
returned: success
|
||||||
type: string
|
type: string
|
||||||
sample: 04589590-ac63-4ffc-93f5-b698b8ac38b6
|
sample: 04589590-ac63-4ffc-93f5-b698b8ac38b6
|
||||||
|
@ -375,7 +375,20 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackInstance(AnsibleCloudStack):
|
class AnsibleCloudStackInstance(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackInstance, self).__init__(module)
|
||||||
|
self.returns = {
|
||||||
|
'group': 'group',
|
||||||
|
'hypervisor': 'hypervisor',
|
||||||
|
'instancename': 'instance_name',
|
||||||
|
'publicip': 'public_ip',
|
||||||
|
'passwordenabled': 'password_enabled',
|
||||||
|
'password': 'password',
|
||||||
|
'serviceofferingname': 'service_offering',
|
||||||
|
'isoname': 'iso',
|
||||||
|
'templatename': 'template',
|
||||||
|
'keypair': 'ssh_key',
|
||||||
|
'securitygroup': 'security_group',
|
||||||
|
}
|
||||||
self.instance = None
|
self.instance = None
|
||||||
self.template = None
|
self.template = None
|
||||||
self.iso = None
|
self.iso = None
|
||||||
|
@ -752,52 +765,8 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, instance):
|
def get_result(self, instance):
|
||||||
|
super(AnsibleCloudStackInstance, self).get_result(instance)
|
||||||
if instance:
|
if instance:
|
||||||
if 'id' in instance:
|
|
||||||
self.result['id'] = instance['id']
|
|
||||||
if 'name' in instance:
|
|
||||||
self.result['name'] = instance['name']
|
|
||||||
if 'displayname' in instance:
|
|
||||||
self.result['display_name'] = instance['displayname']
|
|
||||||
if 'group' in instance:
|
|
||||||
self.result['group'] = instance['group']
|
|
||||||
if 'domain' in instance:
|
|
||||||
self.result['domain'] = instance['domain']
|
|
||||||
if 'account' in instance:
|
|
||||||
self.result['account'] = instance['account']
|
|
||||||
if 'project' in instance:
|
|
||||||
self.result['project'] = instance['project']
|
|
||||||
if 'hypervisor' in instance:
|
|
||||||
self.result['hypervisor'] = instance['hypervisor']
|
|
||||||
if 'instancename' in instance:
|
|
||||||
self.result['instance_name'] = instance['instancename']
|
|
||||||
if 'publicip' in instance:
|
|
||||||
self.result['public_ip'] = instance['publicip']
|
|
||||||
if 'passwordenabled' in instance:
|
|
||||||
self.result['password_enabled'] = instance['passwordenabled']
|
|
||||||
if 'password' in instance:
|
|
||||||
self.result['password'] = instance['password']
|
|
||||||
if 'serviceofferingname' in instance:
|
|
||||||
self.result['service_offering'] = instance['serviceofferingname']
|
|
||||||
if 'zonename' in instance:
|
|
||||||
self.result['zone'] = instance['zonename']
|
|
||||||
if 'templatename' in instance:
|
|
||||||
self.result['template'] = instance['templatename']
|
|
||||||
if 'isoname' in instance:
|
|
||||||
self.result['iso'] = instance['isoname']
|
|
||||||
if 'keypair' in instance:
|
|
||||||
self.result['ssh_key'] = instance['keypair']
|
|
||||||
if 'created' in instance:
|
|
||||||
self.result['created'] = instance['created']
|
|
||||||
if 'state' in instance:
|
|
||||||
self.result['state'] = instance['state']
|
|
||||||
if 'tags' in instance:
|
|
||||||
self.result['tags'] = []
|
|
||||||
for tag in instance['tags']:
|
|
||||||
result_tag = {}
|
|
||||||
result_tag['key'] = tag['key']
|
|
||||||
result_tag['value'] = tag['value']
|
|
||||||
self.result['tags'].append(result_tag)
|
|
||||||
if 'securitygroup' in instance:
|
if 'securitygroup' in instance:
|
||||||
security_groups = []
|
security_groups = []
|
||||||
for securitygroup in instance['securitygroup']:
|
for securitygroup in instance['securitygroup']:
|
||||||
|
|
|
@ -71,7 +71,7 @@ EXAMPLES = '''
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
id:
|
id:
|
||||||
description: ID of the instance group.
|
description: UUID of the instance group.
|
||||||
returned: success
|
returned: success
|
||||||
type: string
|
type: string
|
||||||
sample: 04589590-ac63-4ffc-93f5-b698b8ac38b6
|
sample: 04589590-ac63-4ffc-93f5-b698b8ac38b6
|
||||||
|
@ -115,7 +115,7 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackInstanceGroup(AnsibleCloudStack):
|
class AnsibleCloudStackInstanceGroup(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackInstanceGroup, self).__init__(module)
|
||||||
self.instance_group = None
|
self.instance_group = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,23 +169,6 @@ class AnsibleCloudStackInstanceGroup(AnsibleCloudStack):
|
||||||
return instance_group
|
return instance_group
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, instance_group):
|
|
||||||
if instance_group:
|
|
||||||
if 'id' in instance_group:
|
|
||||||
self.result['id'] = instance_group['id']
|
|
||||||
if 'created' in instance_group:
|
|
||||||
self.result['created'] = instance_group['created']
|
|
||||||
if 'name' in instance_group:
|
|
||||||
self.result['name'] = instance_group['name']
|
|
||||||
if 'project' in instance_group:
|
|
||||||
self.result['project'] = instance_group['project']
|
|
||||||
if 'domain' in instance_group:
|
|
||||||
self.result['domain'] = instance_group['domain']
|
|
||||||
if 'account' in instance_group:
|
|
||||||
self.result['account'] = instance_group['account']
|
|
||||||
return self.result
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
|
|
|
@ -86,6 +86,11 @@ EXAMPLES = '''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
|
id:
|
||||||
|
description: UUID of the Public IP address.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: a6f7a5fc-43f8-11e5-a151-feff819cdc9f
|
||||||
ip_address:
|
ip_address:
|
||||||
description: Public IP address.
|
description: Public IP address.
|
||||||
returned: success
|
returned: success
|
||||||
|
@ -126,6 +131,13 @@ from ansible.module_utils.cloudstack import *
|
||||||
|
|
||||||
class AnsibleCloudStackIPAddress(AnsibleCloudStack):
|
class AnsibleCloudStackIPAddress(AnsibleCloudStack):
|
||||||
|
|
||||||
|
def __init__(self, module):
|
||||||
|
super(AnsibleCloudStackIPAddress, self).__init__(module)
|
||||||
|
self.returns = {
|
||||||
|
'ipaddress': 'ip_address',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#TODO: Add to parent class, duplicated in cs_network
|
#TODO: Add to parent class, duplicated in cs_network
|
||||||
def get_network(self, key=None, network=None):
|
def get_network(self, key=None, network=None):
|
||||||
if not network:
|
if not network:
|
||||||
|
@ -211,23 +223,6 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
|
||||||
return ip_address
|
return ip_address
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, ip_address):
|
|
||||||
if ip_address:
|
|
||||||
if 'zonename' in ip_address:
|
|
||||||
self.result['zone'] = ip_address['zonename']
|
|
||||||
if 'domain' in ip_address:
|
|
||||||
self.result['domain'] = ip_address['domain']
|
|
||||||
if 'account' in ip_address:
|
|
||||||
self.result['account'] = ip_address['account']
|
|
||||||
if 'project' in ip_address:
|
|
||||||
self.result['project'] = ip_address['project']
|
|
||||||
if 'ipaddress' in ip_address:
|
|
||||||
self.result['ip_address'] = ip_address['ipaddress']
|
|
||||||
if 'id' in ip_address:
|
|
||||||
self.result['id'] = ip_address['id']
|
|
||||||
return self.result
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
|
|
|
@ -140,6 +140,11 @@ EXAMPLES = '''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
|
id:
|
||||||
|
description: UUID of the ISO.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: a6f7a5fc-43f8-11e5-a151-feff819cdc9f
|
||||||
name:
|
name:
|
||||||
description: Name of the ISO.
|
description: Name of the ISO.
|
||||||
returned: success
|
returned: success
|
||||||
|
@ -205,7 +210,12 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackIso(AnsibleCloudStack):
|
class AnsibleCloudStackIso(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackIso, self).__init__(module)
|
||||||
|
self.returns = {
|
||||||
|
'checksum': 'checksum',
|
||||||
|
'status': 'status',
|
||||||
|
'isready': 'is_ready',
|
||||||
|
}
|
||||||
self.iso = None
|
self.iso = None
|
||||||
|
|
||||||
def register_iso(self):
|
def register_iso(self):
|
||||||
|
@ -283,30 +293,6 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
||||||
return iso
|
return iso
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, iso):
|
|
||||||
if iso:
|
|
||||||
if 'displaytext' in iso:
|
|
||||||
self.result['displaytext'] = iso['displaytext']
|
|
||||||
if 'name' in iso:
|
|
||||||
self.result['name'] = iso['name']
|
|
||||||
if 'zonename' in iso:
|
|
||||||
self.result['zone'] = iso['zonename']
|
|
||||||
if 'checksum' in iso:
|
|
||||||
self.result['checksum'] = iso['checksum']
|
|
||||||
if 'status' in iso:
|
|
||||||
self.result['status'] = iso['status']
|
|
||||||
if 'isready' in iso:
|
|
||||||
self.result['is_ready'] = iso['isready']
|
|
||||||
if 'created' in iso:
|
|
||||||
self.result['created'] = iso['created']
|
|
||||||
if 'project' in iso:
|
|
||||||
self.result['project'] = iso['project']
|
|
||||||
if 'domain' in iso:
|
|
||||||
self.result['domain'] = iso['domain']
|
|
||||||
if 'account' in iso:
|
|
||||||
self.result['account'] = iso['account']
|
|
||||||
return self.result
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
|
|
@ -197,7 +197,7 @@ EXAMPLES = '''
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
id:
|
id:
|
||||||
description: ID of the network.
|
description: UUID of the network.
|
||||||
returned: success
|
returned: success
|
||||||
type: string
|
type: string
|
||||||
sample: 04589590-ac63-4ffc-93f5-b698b8ac38b6
|
sample: 04589590-ac63-4ffc-93f5-b698b8ac38b6
|
||||||
|
@ -331,7 +331,24 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackNetwork(AnsibleCloudStack):
|
class AnsibleCloudStackNetwork(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackNetwork, self).__init__(module)
|
||||||
|
self.returns = {
|
||||||
|
'networkdomain': 'network domain',
|
||||||
|
'networkofferingname': 'network_offering',
|
||||||
|
'ispersistent': 'is_persistent',
|
||||||
|
'acltype': 'acl_type',
|
||||||
|
'type': 'type',
|
||||||
|
'traffictype': 'traffic_type',
|
||||||
|
'ip6gateway': 'gateway_ipv6',
|
||||||
|
'ip6cidr': 'cidr_ipv6',
|
||||||
|
'gateway': 'gateway',
|
||||||
|
'cidr': 'cidr',
|
||||||
|
'netmask': 'netmask',
|
||||||
|
'broadcastdomaintype': 'broadcast_domaintype',
|
||||||
|
'dns1': 'dns1',
|
||||||
|
'dns2': 'dns2',
|
||||||
|
}
|
||||||
|
|
||||||
self.network = None
|
self.network = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -503,61 +520,6 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
|
||||||
return network
|
return network
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, network):
|
|
||||||
if network:
|
|
||||||
if 'id' in network:
|
|
||||||
self.result['id'] = network['id']
|
|
||||||
if 'name' in network:
|
|
||||||
self.result['name'] = network['name']
|
|
||||||
if 'displaytext' in network:
|
|
||||||
self.result['displaytext'] = network['displaytext']
|
|
||||||
if 'dns1' in network:
|
|
||||||
self.result['dns1'] = network['dns1']
|
|
||||||
if 'dns2' in network:
|
|
||||||
self.result['dns2'] = network['dns2']
|
|
||||||
if 'cidr' in network:
|
|
||||||
self.result['cidr'] = network['cidr']
|
|
||||||
if 'broadcastdomaintype' in network:
|
|
||||||
self.result['broadcast_domaintype'] = network['broadcastdomaintype']
|
|
||||||
if 'netmask' in network:
|
|
||||||
self.result['netmask'] = network['netmask']
|
|
||||||
if 'gateway' in network:
|
|
||||||
self.result['gateway'] = network['gateway']
|
|
||||||
if 'ip6cidr' in network:
|
|
||||||
self.result['cidr_ipv6'] = network['ip6cidr']
|
|
||||||
if 'ip6gateway' in network:
|
|
||||||
self.result['gateway_ipv6'] = network['ip6gateway']
|
|
||||||
if 'state' in network:
|
|
||||||
self.result['state'] = network['state']
|
|
||||||
if 'type' in network:
|
|
||||||
self.result['type'] = network['type']
|
|
||||||
if 'traffictype' in network:
|
|
||||||
self.result['traffic_type'] = network['traffictype']
|
|
||||||
if 'zonename' in network:
|
|
||||||
self.result['zone'] = network['zonename']
|
|
||||||
if 'domain' in network:
|
|
||||||
self.result['domain'] = network['domain']
|
|
||||||
if 'account' in network:
|
|
||||||
self.result['account'] = network['account']
|
|
||||||
if 'project' in network:
|
|
||||||
self.result['project'] = network['project']
|
|
||||||
if 'acltype' in network:
|
|
||||||
self.result['acl_type'] = network['acltype']
|
|
||||||
if 'networkdomain' in network:
|
|
||||||
self.result['network_domain'] = network['networkdomain']
|
|
||||||
if 'networkofferingname' in network:
|
|
||||||
self.result['network_offering'] = network['networkofferingname']
|
|
||||||
if 'ispersistent' in network:
|
|
||||||
self.result['is_persistent'] = network['ispersistent']
|
|
||||||
if 'tags' in network:
|
|
||||||
self.result['tags'] = []
|
|
||||||
for tag in network['tags']:
|
|
||||||
result_tag = {}
|
|
||||||
result_tag['key'] = tag['key']
|
|
||||||
result_tag['value'] = tag['value']
|
|
||||||
self.result['tags'].append(result_tag)
|
|
||||||
return self.result
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
|
|
@ -148,6 +148,11 @@ EXAMPLES = '''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
|
id:
|
||||||
|
description: UUID of the public IP address.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: a6f7a5fc-43f8-11e5-a151-feff819cdc9f
|
||||||
ip_address:
|
ip_address:
|
||||||
description: Public IP address.
|
description: Public IP address.
|
||||||
returned: success
|
returned: success
|
||||||
|
@ -212,7 +217,22 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackPortforwarding(AnsibleCloudStack):
|
class AnsibleCloudStackPortforwarding(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackPortforwarding, self).__init__(module)
|
||||||
|
self.returns = {
|
||||||
|
'virtualmachinedisplayname': 'vm_display_name',
|
||||||
|
'virtualmachinename': 'vm_name',
|
||||||
|
'ipaddress': 'ip_address',
|
||||||
|
'vmguestip': 'vm_guest_ip',
|
||||||
|
'publicip': 'public_ip',
|
||||||
|
'protocol': 'protocol',
|
||||||
|
}
|
||||||
|
# these values will be casted to int
|
||||||
|
self.returns_to_int = {
|
||||||
|
'publicport': 'public_port',
|
||||||
|
'publicendport': 'public_end_port',
|
||||||
|
'privateport': 'private_port',
|
||||||
|
'private_end_port': 'private_end_port',
|
||||||
|
}
|
||||||
self.portforwarding_rule = None
|
self.portforwarding_rule = None
|
||||||
self.vm_default_nic = None
|
self.vm_default_nic = None
|
||||||
|
|
||||||
|
@ -338,34 +358,12 @@ class AnsibleCloudStackPortforwarding(AnsibleCloudStack):
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, portforwarding_rule):
|
def get_result(self, portforwarding_rule):
|
||||||
|
super(AnsibleCloudStackPortforwarding, self).get_result(portforwarding_rule)
|
||||||
if portforwarding_rule:
|
if portforwarding_rule:
|
||||||
if 'id' in portforwarding_rule:
|
# Bad bad API does not always return int when it should.
|
||||||
self.result['id'] = portforwarding_rule['id']
|
for search_key, return_key in returns_to_int.iteritems():
|
||||||
if 'virtualmachinedisplayname' in portforwarding_rule:
|
if search_key in resource:
|
||||||
self.result['vm_display_name'] = portforwarding_rule['virtualmachinedisplayname']
|
self.result[return_key] = int(resource[search_key])
|
||||||
if 'virtualmachinename' in portforwarding_rule:
|
|
||||||
self.result['vm_name'] = portforwarding_rule['virtualmachinename']
|
|
||||||
if 'ipaddress' in portforwarding_rule:
|
|
||||||
self.result['ip_address'] = portforwarding_rule['ipaddress']
|
|
||||||
if 'vmguestip' in portforwarding_rule:
|
|
||||||
self.result['vm_guest_ip'] = portforwarding_rule['vmguestip']
|
|
||||||
if 'publicport' in portforwarding_rule:
|
|
||||||
self.result['public_port'] = int(portforwarding_rule['publicport'])
|
|
||||||
if 'publicendport' in portforwarding_rule:
|
|
||||||
self.result['public_end_port'] = int(portforwarding_rule['publicendport'])
|
|
||||||
if 'privateport' in portforwarding_rule:
|
|
||||||
self.result['private_port'] = int(portforwarding_rule['privateport'])
|
|
||||||
if 'privateendport' in portforwarding_rule:
|
|
||||||
self.result['private_end_port'] = int(portforwarding_rule['privateendport'])
|
|
||||||
if 'protocol' in portforwarding_rule:
|
|
||||||
self.result['protocol'] = portforwarding_rule['protocol']
|
|
||||||
if 'tags' in portforwarding_rule:
|
|
||||||
self.result['tags'] = []
|
|
||||||
for tag in portforwarding_rule['tags']:
|
|
||||||
result_tag = {}
|
|
||||||
result_tag['key'] = tag['key']
|
|
||||||
result_tag['value'] = tag['value']
|
|
||||||
self.result['tags'].append(result_tag)
|
|
||||||
return self.result
|
return self.result
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ EXAMPLES = '''
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
id:
|
id:
|
||||||
description: ID of the project.
|
description: UUID of the project.
|
||||||
returned: success
|
returned: success
|
||||||
type: string
|
type: string
|
||||||
sample: 04589590-ac63-4ffc-93f5-b698b8ac38b6
|
sample: 04589590-ac63-4ffc-93f5-b698b8ac38b6
|
||||||
|
@ -143,10 +143,6 @@ from ansible.module_utils.cloudstack import *
|
||||||
|
|
||||||
class AnsibleCloudStackProject(AnsibleCloudStack):
|
class AnsibleCloudStackProject(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
|
||||||
AnsibleCloudStack.__init__(self, module)
|
|
||||||
self.project = None
|
|
||||||
|
|
||||||
|
|
||||||
def get_project(self):
|
def get_project(self):
|
||||||
if not self.project:
|
if not self.project:
|
||||||
|
@ -261,27 +257,6 @@ class AnsibleCloudStackProject(AnsibleCloudStack):
|
||||||
return project
|
return project
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, project):
|
|
||||||
if project:
|
|
||||||
if 'name' in project:
|
|
||||||
self.result['name'] = project['name']
|
|
||||||
if 'displaytext' in project:
|
|
||||||
self.result['displaytext'] = project['displaytext']
|
|
||||||
if 'account' in project:
|
|
||||||
self.result['account'] = project['account']
|
|
||||||
if 'domain' in project:
|
|
||||||
self.result['domain'] = project['domain']
|
|
||||||
if 'state' in project:
|
|
||||||
self.result['state'] = project['state']
|
|
||||||
if 'tags' in project:
|
|
||||||
self.result['tags'] = []
|
|
||||||
for tag in project['tags']:
|
|
||||||
result_tag = {}
|
|
||||||
result_tag['key'] = tag['key']
|
|
||||||
result_tag['value'] = tag['value']
|
|
||||||
self.result['tags'].append(result_tag)
|
|
||||||
return self.result
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
|
|
@ -64,6 +64,11 @@ EXAMPLES = '''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
|
id:
|
||||||
|
description: UUID of the security group.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: a6f7a5fc-43f8-11e5-a151-feff819cdc9f
|
||||||
name:
|
name:
|
||||||
description: Name of security group.
|
description: Name of security group.
|
||||||
returned: success
|
returned: success
|
||||||
|
@ -89,7 +94,7 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackSecurityGroup(AnsibleCloudStack):
|
class AnsibleCloudStackSecurityGroup(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackSecurityGroup, self).__init__(module)
|
||||||
self.security_group = None
|
self.security_group = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,14 +148,6 @@ class AnsibleCloudStackSecurityGroup(AnsibleCloudStack):
|
||||||
return security_group
|
return security_group
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, security_group):
|
|
||||||
if security_group:
|
|
||||||
if 'name' in security_group:
|
|
||||||
self.result['name'] = security_group['name']
|
|
||||||
if 'description' in security_group:
|
|
||||||
self.result['description'] = security_group['description']
|
|
||||||
return self.result
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
|
|
@ -138,6 +138,11 @@ EXAMPLES = '''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
|
id:
|
||||||
|
description: UUID of the of the rule.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: a6f7a5fc-43f8-11e5-a151-feff819cdc9f
|
||||||
security_group:
|
security_group:
|
||||||
description: security group of the rule.
|
description: security group of the rule.
|
||||||
returned: success
|
returned: success
|
||||||
|
@ -188,7 +193,16 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
|
class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackSecurityGroupRule, self).__init__(module)
|
||||||
|
self.returns = {
|
||||||
|
'icmptype': 'icmp_type',
|
||||||
|
'icmpcode': 'icmp_code',
|
||||||
|
'endport': 'end_port',
|
||||||
|
'start_port': 'start_port',
|
||||||
|
'protocol': 'protocol',
|
||||||
|
'cidr': 'cidr',
|
||||||
|
'securitygroupname': 'user_security_group',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def _tcp_udp_match(self, rule, protocol, start_port, end_port):
|
def _tcp_udp_match(self, rule, protocol, start_port, end_port):
|
||||||
|
@ -348,29 +362,13 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, security_group_rule):
|
def get_result(self, security_group_rule):
|
||||||
|
super(AnsibleCloudStackSecurityGroupRule, self).get_result(security_group_rule)
|
||||||
self.result['type'] = self.module.params.get('type')
|
self.result['type'] = self.module.params.get('type')
|
||||||
self.result['security_group'] = self.module.params.get('security_group')
|
self.result['security_group'] = self.module.params.get('security_group')
|
||||||
|
|
||||||
if security_group_rule:
|
|
||||||
rule = security_group_rule
|
|
||||||
if 'securitygroupname' in rule:
|
|
||||||
self.result['user_security_group'] = rule['securitygroupname']
|
|
||||||
if 'cidr' in rule:
|
|
||||||
self.result['cidr'] = rule['cidr']
|
|
||||||
if 'protocol' in rule:
|
|
||||||
self.result['protocol'] = rule['protocol']
|
|
||||||
if 'startport' in rule:
|
|
||||||
self.result['start_port'] = rule['startport']
|
|
||||||
if 'endport' in rule:
|
|
||||||
self.result['end_port'] = rule['endport']
|
|
||||||
if 'icmpcode' in rule:
|
|
||||||
self.result['icmp_code'] = rule['icmpcode']
|
|
||||||
if 'icmptype' in rule:
|
|
||||||
self.result['icmp_type'] = rule['icmptype']
|
|
||||||
return self.result
|
return self.result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
|
|
|
@ -77,6 +77,11 @@ EXAMPLES = '''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
|
id:
|
||||||
|
description: UUID of the SSH public key.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: a6f7a5fc-43f8-11e5-a151-feff819cdc9f
|
||||||
name:
|
name:
|
||||||
description: Name of the SSH public key.
|
description: Name of the SSH public key.
|
||||||
returned: success
|
returned: success
|
||||||
|
@ -112,7 +117,11 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackSshKey(AnsibleCloudStack):
|
class AnsibleCloudStackSshKey(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackSshKey, self).__init__(module)
|
||||||
|
self.returns = {
|
||||||
|
'privatekey': 'private_key',
|
||||||
|
'fingerprint': 'fingerprint',
|
||||||
|
}
|
||||||
self.ssh_key = None
|
self.ssh_key = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -189,16 +198,6 @@ class AnsibleCloudStackSshKey(AnsibleCloudStack):
|
||||||
return self.ssh_key
|
return self.ssh_key
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, ssh_key):
|
|
||||||
if ssh_key:
|
|
||||||
if 'fingerprint' in ssh_key:
|
|
||||||
self.result['fingerprint'] = ssh_key['fingerprint']
|
|
||||||
if 'name' in ssh_key:
|
|
||||||
self.result['name'] = ssh_key['name']
|
|
||||||
if 'privatekey' in ssh_key:
|
|
||||||
self.result['private_key'] = ssh_key['privatekey']
|
|
||||||
return self.result
|
|
||||||
|
|
||||||
|
|
||||||
def _get_ssh_fingerprint(self, public_key):
|
def _get_ssh_fingerprint(self, public_key):
|
||||||
key = sshpubkeys.SSHKey(public_key)
|
key = sshpubkeys.SSHKey(public_key)
|
||||||
|
|
|
@ -93,6 +93,11 @@ EXAMPLES = '''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
|
id:
|
||||||
|
description: UUID of the ip_address.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: a6f7a5fc-43f8-11e5-a151-feff819cdc9f
|
||||||
ip_address:
|
ip_address:
|
||||||
description: Public IP address.
|
description: Public IP address.
|
||||||
returned: success
|
returned: success
|
||||||
|
@ -149,7 +154,13 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackStaticNat(AnsibleCloudStack):
|
class AnsibleCloudStackStaticNat(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackPortforwarding, self).__init__(module)
|
||||||
|
self.returns = {
|
||||||
|
'virtualmachinedisplayname': 'vm_display_name',
|
||||||
|
'virtualmachinename': 'vm_name',
|
||||||
|
'ipaddress': 'ip_address',
|
||||||
|
'vmipaddress': 'vm_guest_ip',
|
||||||
|
}
|
||||||
self.vm_default_nic = None
|
self.vm_default_nic = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -246,26 +257,6 @@ class AnsibleCloudStackStaticNat(AnsibleCloudStack):
|
||||||
return ip_address
|
return ip_address
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, ip_address):
|
|
||||||
if ip_address:
|
|
||||||
if 'zonename' in ip_address:
|
|
||||||
self.result['zone'] = ip_address['zonename']
|
|
||||||
if 'domain' in ip_address:
|
|
||||||
self.result['domain'] = ip_address['domain']
|
|
||||||
if 'account' in ip_address:
|
|
||||||
self.result['account'] = ip_address['account']
|
|
||||||
if 'project' in ip_address:
|
|
||||||
self.result['project'] = ip_address['project']
|
|
||||||
if 'virtualmachinedisplayname' in ip_address:
|
|
||||||
self.result['vm_display_name'] = ip_address['virtualmachinedisplayname']
|
|
||||||
if 'virtualmachinename' in ip_address:
|
|
||||||
self.result['vm'] = ip_address['virtualmachinename']
|
|
||||||
if 'vmipaddress' in ip_address:
|
|
||||||
self.result['vm_guest_ip'] = ip_address['vmipaddress']
|
|
||||||
if 'ipaddress' in ip_address:
|
|
||||||
self.result['ip_address'] = ip_address['ipaddress']
|
|
||||||
return self.result
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
|
|
@ -219,6 +219,11 @@ EXAMPLES = '''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
|
id:
|
||||||
|
description: UUID of the template.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: a6f7a5fc-43f8-11e5-a151-feff819cdc9f
|
||||||
name:
|
name:
|
||||||
description: Name of the template.
|
description: Name of the template.
|
||||||
returned: success
|
returned: success
|
||||||
|
@ -344,7 +349,23 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackTemplate(AnsibleCloudStack):
|
class AnsibleCloudStackTemplate(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackTemplate, self).__init__(module)
|
||||||
|
self.returns = {
|
||||||
|
'checksum': 'checksum',
|
||||||
|
'status': 'status',
|
||||||
|
'isready': 'is_ready',
|
||||||
|
'templatetag': 'template_tag',
|
||||||
|
'sshkeyenabled': 'sshkey_enabled',
|
||||||
|
'passwordenabled': 'password_enabled',
|
||||||
|
'tempaltetype': 'template_type',
|
||||||
|
'ostypename': 'os_type',
|
||||||
|
'crossZones': 'cross_zones',
|
||||||
|
'isextractable': 'is_extractable',
|
||||||
|
'isfeatured': 'is_featured',
|
||||||
|
'ispublic': 'is_public',
|
||||||
|
'format': 'format',
|
||||||
|
'hypervisor': 'hypervisor',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def _get_args(self):
|
def _get_args(self):
|
||||||
|
@ -497,60 +518,6 @@ class AnsibleCloudStackTemplate(AnsibleCloudStack):
|
||||||
return template
|
return template
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, template):
|
|
||||||
if template:
|
|
||||||
if 'displaytext' in template:
|
|
||||||
self.result['displaytext'] = template['displaytext']
|
|
||||||
if 'name' in template:
|
|
||||||
self.result['name'] = template['name']
|
|
||||||
if 'hypervisor' in template:
|
|
||||||
self.result['hypervisor'] = template['hypervisor']
|
|
||||||
if 'zonename' in template:
|
|
||||||
self.result['zone'] = template['zonename']
|
|
||||||
if 'checksum' in template:
|
|
||||||
self.result['checksum'] = template['checksum']
|
|
||||||
if 'format' in template:
|
|
||||||
self.result['format'] = template['format']
|
|
||||||
if 'isready' in template:
|
|
||||||
self.result['is_ready'] = template['isready']
|
|
||||||
if 'ispublic' in template:
|
|
||||||
self.result['is_public'] = template['ispublic']
|
|
||||||
if 'isfeatured' in template:
|
|
||||||
self.result['is_featured'] = template['isfeatured']
|
|
||||||
if 'isextractable' in template:
|
|
||||||
self.result['is_extractable'] = template['isextractable']
|
|
||||||
# and yes! it is really camelCase!
|
|
||||||
if 'crossZones' in template:
|
|
||||||
self.result['cross_zones'] = template['crossZones']
|
|
||||||
if 'ostypename' in template:
|
|
||||||
self.result['os_type'] = template['ostypename']
|
|
||||||
if 'templatetype' in template:
|
|
||||||
self.result['template_type'] = template['templatetype']
|
|
||||||
if 'passwordenabled' in template:
|
|
||||||
self.result['password_enabled'] = template['passwordenabled']
|
|
||||||
if 'sshkeyenabled' in template:
|
|
||||||
self.result['sshkey_enabled'] = template['sshkeyenabled']
|
|
||||||
if 'status' in template:
|
|
||||||
self.result['status'] = template['status']
|
|
||||||
if 'created' in template:
|
|
||||||
self.result['created'] = template['created']
|
|
||||||
if 'templatetag' in template:
|
|
||||||
self.result['template_tag'] = template['templatetag']
|
|
||||||
if 'tags' in template:
|
|
||||||
self.result['tags'] = []
|
|
||||||
for tag in template['tags']:
|
|
||||||
result_tag = {}
|
|
||||||
result_tag['key'] = tag['key']
|
|
||||||
result_tag['value'] = tag['value']
|
|
||||||
self.result['tags'].append(result_tag)
|
|
||||||
if 'domain' in template:
|
|
||||||
self.result['domain'] = template['domain']
|
|
||||||
if 'account' in template:
|
|
||||||
self.result['account'] = template['account']
|
|
||||||
if 'project' in template:
|
|
||||||
self.result['project'] = template['project']
|
|
||||||
return self.result
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
|
|
@ -104,6 +104,11 @@ EXAMPLES = '''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
---
|
---
|
||||||
|
id:
|
||||||
|
description: UUID of the snapshot.
|
||||||
|
returned: success
|
||||||
|
type: string
|
||||||
|
sample: a6f7a5fc-43f8-11e5-a151-feff819cdc9f
|
||||||
name:
|
name:
|
||||||
description: Name of the snapshot.
|
description: Name of the snapshot.
|
||||||
returned: success
|
returned: success
|
||||||
|
@ -170,7 +175,11 @@ from ansible.module_utils.cloudstack import *
|
||||||
class AnsibleCloudStackVmSnapshot(AnsibleCloudStack):
|
class AnsibleCloudStackVmSnapshot(AnsibleCloudStack):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
AnsibleCloudStack.__init__(self, module)
|
super(AnsibleCloudStackVmSnapshot, self).__init__(module)
|
||||||
|
self.returns = {
|
||||||
|
'type': 'type',
|
||||||
|
'current': 'current',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_snapshot(self):
|
def get_snapshot(self):
|
||||||
|
@ -246,30 +255,6 @@ class AnsibleCloudStackVmSnapshot(AnsibleCloudStack):
|
||||||
self.module.fail_json(msg="snapshot not found, could not revert VM")
|
self.module.fail_json(msg="snapshot not found, could not revert VM")
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, snapshot):
|
|
||||||
if snapshot:
|
|
||||||
if 'displayname' in snapshot:
|
|
||||||
self.result['displayname'] = snapshot['displayname']
|
|
||||||
if 'created' in snapshot:
|
|
||||||
self.result['created'] = snapshot['created']
|
|
||||||
if 'current' in snapshot:
|
|
||||||
self.result['current'] = snapshot['current']
|
|
||||||
if 'state' in snapshot:
|
|
||||||
self.result['state'] = snapshot['state']
|
|
||||||
if 'type' in snapshot:
|
|
||||||
self.result['type'] = snapshot['type']
|
|
||||||
if 'name' in snapshot:
|
|
||||||
self.result['name'] = snapshot['name']
|
|
||||||
if 'description' in snapshot:
|
|
||||||
self.result['description'] = snapshot['description']
|
|
||||||
if 'domain' in snapshot:
|
|
||||||
self.result['domain'] = snapshot['domain']
|
|
||||||
if 'account' in snapshot:
|
|
||||||
self.result['account'] = snapshot['account']
|
|
||||||
if 'project' in snapshot:
|
|
||||||
self.result['project'] = snapshot['project']
|
|
||||||
return self.result
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
|
Loading…
Reference in a new issue