cloudstack: implement common argument spec handling

pull/18777/head
Rene Moser 9 years ago committed by Matt Clay
parent 6e4c78d165
commit a134a71187

@ -343,8 +343,8 @@ class AnsibleCloudStackAccount(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(required=True),
state = dict(choices=['present', 'absent', 'enabled', 'disabled', 'locked', 'unlocked'], default='present'),
account_type = dict(choices=['user', 'root_admin', 'domain_admin'], default='user'),
@ -357,16 +357,11 @@ def main():
password = dict(default=None),
timezone = dict(default=None),
poll_async = dict(choices=BOOLEANS, default=True),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
),
))
module = AnsibleModule(
argument_spec=argument_spec,
required_together=cs_required_together(),
supports_check_mode=True
)

@ -200,8 +200,8 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(required=True),
affinty_type = dict(default=None),
description = dict(default=None),
@ -209,16 +209,11 @@ def main():
domain = dict(default=None),
account = dict(default=None),
poll_async = dict(choices=BOOLEANS, default=True),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
),
))
module = AnsibleModule(
argument_spec=argument_spec,
required_together=cs_required_together(),
supports_check_mode=True
)

@ -239,23 +239,18 @@ class AnsibleCloudStackDomain(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
path = dict(required=True),
state = dict(choices=['present', 'absent'], default='present'),
network_domain = dict(default=None),
clean_up = dict(choices=BOOLEANS, default=False),
poll_async = dict(choices=BOOLEANS, default=True),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
),
))
module = AnsibleModule(
argument_spec=argument_spec,
required_together=cs_required_together(),
supports_check_mode=True
)

@ -391,8 +391,8 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
ip_address = dict(default=None),
network = dict(default=None),
cidr = dict(default='0.0.0.0/0'),
@ -407,20 +407,19 @@ def main():
account = dict(default=None),
project = dict(default=None),
poll_async = dict(choices=BOOLEANS, default=True),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
))
required_together = cs_required_together()
required_together.extend([
['icmp_type', 'icmp_code'],
])
module = AnsibleModule(
argument_spec=argument_spec,
required_together=required_together,
required_one_of = (
['ip_address', 'network'],
),
required_together = (
['icmp_type', 'icmp_code'],
['api_key', 'api_secret', 'api_url'],
),
mutually_exclusive = (
['icmp_type', 'start_port'],
['icmp_type', 'end_port'],

@ -818,8 +818,8 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
return self.result
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(required=True),
display_name = dict(default=None),
group = dict(default=None),
@ -850,20 +850,19 @@ def main():
force = dict(choices=BOOLEANS, default=False),
tags = dict(type='list', aliases=[ 'tag' ], default=None),
poll_async = dict(choices=BOOLEANS, default=True),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
))
required_together = cs_required_together()
required_together.extend([
['cpu', 'cpu_speed', 'memory'],
])
module = AnsibleModule(
argument_spec=argument_spec,
required_together=required_together,
mutually_exclusive = (
['template', 'iso'],
),
required_together = (
['api_key', 'api_secret', 'api_url'],
['cpu', 'cpu_speed', 'memory'],
),
supports_check_mode=True
)

@ -170,23 +170,18 @@ class AnsibleCloudStackInstanceGroup(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(required=True),
state = dict(default='present', choices=['present', 'absent']),
domain = dict(default=None),
account = dict(default=None),
project = dict(default=None),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
),
))
module = AnsibleModule(
argument_spec=argument_spec,
required_together=cs_required_together(),
supports_check_mode=True
)

@ -224,8 +224,8 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
ip_address = dict(required=False),
state = dict(choices=['present', 'absent'], default='present'),
zone = dict(default=None),
@ -234,16 +234,11 @@ def main():
network = dict(default=None),
project = dict(default=None),
poll_async = dict(choices=BOOLEANS, default=True),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
),
))
module = AnsibleModule(
argument_spec=argument_spec,
required_together=cs_required_together(),
supports_check_mode=True
)

@ -295,8 +295,8 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(required=True),
url = dict(default=None),
os_type = dict(default=None),
@ -311,16 +311,11 @@ def main():
is_featured = dict(choices=BOOLEANS, default=False),
is_dynamically_scalable = dict(choices=BOOLEANS, default=False),
state = dict(choices=['present', 'absent'], default='present'),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
),
))
module = AnsibleModule(
argument_spec=argument_spec,
required_together=cs_required_together(),
supports_check_mode=True
)

@ -522,8 +522,8 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(required=True),
display_text = dict(default=None),
network_offering = dict(default=None),
@ -547,18 +547,16 @@ def main():
domain = dict(default=None),
account = dict(default=None),
poll_async = dict(type='bool', choices=BOOLEANS, default=True),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
))
required_together = cs_required_together()
required_together.extend([
['start_ip', 'netmask', 'gateway'],
['start_ipv6', 'cidr_ipv6', 'gateway_ipv6'],
),
])
module = AnsibleModule(
argument_spec=argument_spec,
required_together=required_together,
supports_check_mode=True
)

@ -368,8 +368,8 @@ class AnsibleCloudStackPortforwarding(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
ip_address = dict(required=True),
protocol= dict(choices=['tcp', 'udp'], default='tcp'),
public_port = dict(type='int', required=True),
@ -385,16 +385,11 @@ def main():
account = dict(default=None),
project = dict(default=None),
poll_async = dict(choices=BOOLEANS, default=True),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
),
))
module = AnsibleModule(
argument_spec=argument_spec,
required_together=cs_required_together(),
supports_check_mode=True
)

@ -259,24 +259,19 @@ class AnsibleCloudStackProject(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(required=True),
display_text = dict(default=None),
state = dict(choices=['present', 'absent', 'active', 'suspended' ], default='present'),
domain = dict(default=None),
account = dict(default=None),
poll_async = dict(type='bool', choices=BOOLEANS, default=True),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
),
))
module = AnsibleModule(
argument_spec=argument_spec,
required_together=cs_required_together(),
supports_check_mode=True
)

@ -150,22 +150,17 @@ class AnsibleCloudStackSecurityGroup(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(required=True),
description = dict(default=None),
state = dict(choices=['present', 'absent'], default='present'),
project = dict(default=None),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
),
))
module = AnsibleModule(
argument_spec=argument_spec,
required_together=cs_required_together(),
supports_check_mode=True
)

@ -370,8 +370,8 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
security_group = dict(required=True),
type = dict(choices=['ingress', 'egress'], default='ingress'),
cidr = dict(default='0.0.0.0/0'),
@ -384,17 +384,15 @@ def main():
state = dict(choices=['present', 'absent'], default='present'),
project = dict(default=None),
poll_async = dict(choices=BOOLEANS, default=True),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
))
required_together = cs_required_together()
required_together.extend([
['icmp_type', 'icmp_code'],
['api_key', 'api_secret', 'api_url'],
),
])
module = AnsibleModule(
argument_spec=argument_spec,
required_together=required_together,
mutually_exclusive = (
['icmp_type', 'start_port'],
['icmp_type', 'end_port'],

@ -205,24 +205,19 @@ class AnsibleCloudStackSshKey(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(required=True),
public_key = dict(default=None),
domain = dict(default=None),
account = dict(default=None),
project = dict(default=None),
state = dict(choices=['present', 'absent'], default='present'),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
),
))
module = AnsibleModule(
argument_spec=argument_spec,
required_together=cs_required_together(),
supports_check_mode=True
)

@ -259,8 +259,8 @@ class AnsibleCloudStackStaticNat(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
ip_address = dict(required=True),
vm = dict(default=None),
vm_guest_ip = dict(default=None),
@ -270,16 +270,11 @@ def main():
account = dict(default=None),
project = dict(default=None),
poll_async = dict(choices=BOOLEANS, default=True),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
),
))
module = AnsibleModule(
argument_spec=argument_spec,
required_together=cs_required_together(),
supports_check_mode=True
)

@ -529,8 +529,8 @@ class AnsibleCloudStackTemplate(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(required=True),
display_text = dict(default=None),
url = dict(default=None),
@ -560,20 +560,19 @@ def main():
account = dict(default=None),
project = dict(default=None),
poll_async = dict(type='bool', choices=BOOLEANS, default=True),
api_key = dict(default=None),
api_secret = dict(default=None),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
))
required_together = cs_required_together()
required_together.extend([
['format', 'url', 'hypervisor'],
])
module = AnsibleModule(
argument_spec=argument_spec,
required_together=required_together,
mutually_exclusive = (
['url', 'vm'],
),
required_together = (
['api_key', 'api_secret', 'api_url'],
['format', 'url', 'hypervisor'],
),
supports_check_mode=True
)

@ -404,8 +404,8 @@ class AnsibleCloudStackUser(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
username = dict(required=True),
account = dict(default=None),
state = dict(choices=['present', 'absent', 'enabled', 'disabled', 'locked', 'unlocked'], default='present'),
@ -416,16 +416,11 @@ def main():
password = dict(default=None),
timezone = dict(default=None),
poll_async = dict(choices=BOOLEANS, default=True),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
['api_key', 'api_secret', 'api_url'],
),
))
module = AnsibleModule(
argument_spec=argument_spec,
required_together=cs_required_together(),
supports_check_mode=True
)

@ -256,8 +256,8 @@ class AnsibleCloudStackVmSnapshot(AnsibleCloudStack):
def main():
module = AnsibleModule(
argument_spec = dict(
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(required=True, aliases=['display_name']),
vm = dict(required=True),
description = dict(default=None),
@ -267,18 +267,17 @@ def main():
domain = dict(default=None),
account = dict(default=None),
project = dict(default=None),
poll_async = dict(choices=BOOLEANS, default=True),
api_key = dict(default=None),
api_secret = dict(default=None, no_log=True),
api_url = dict(default=None),
api_http_method = dict(choices=['get', 'post'], default='get'),
api_timeout = dict(type='int', default=10),
api_region = dict(default='cloudstack'),
),
required_together = (
poll_async = dict(type='bool', choices=BOOLEANS, default=True),
))
required_together = cs_required_together()
required_together.extend([
['icmp_type', 'icmp_code'],
['api_key', 'api_secret', 'api_url'],
),
])
module = AnsibleModule(
argument_spec=argument_spec,
required_together=required_together,
supports_check_mode=True
)

Loading…
Cancel
Save