From 0c66a5d3ca6061878bfa9f2a1d84b276100f684e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Moser?= Date: Mon, 3 Jun 2019 10:43:32 +0200 Subject: [PATCH] cloudcscale_floating_ip: add types (#56924) --- .../cloudscale/cloudscale_floating_ip.py | 21 ++++++++++++------- .../cloudscale_floating_ip/tasks/main.yml | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/ansible/modules/cloud/cloudscale/cloudscale_floating_ip.py b/lib/ansible/modules/cloud/cloudscale/cloudscale_floating_ip.py index f2bf295189c5a1..fd76a7628c817f 100644 --- a/lib/ansible/modules/cloud/cloudscale/cloudscale_floating_ip.py +++ b/lib/ansible/modules/cloud/cloudscale/cloudscale_floating_ip.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- # -# (c) 2017, Gaudenz Steinlin +# Copyright (c) 2017, Gaudenz Steinlin # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -25,37 +25,43 @@ - It's not possible to request a floating IP without associating it with a server at the same time. - This module requires the ipaddress python library. This library is included in Python since version 3.3. It is available as a module on PyPI for earlier versions. -version_added: 2.5 -author: "Gaudenz Steinlin (@gaudenz) " +version_added: "2.5" +author: "Gaudenz Steinlin (@gaudenz)" options: state: description: - State of the floating IP. default: present choices: [ present, absent ] + type: str ip: description: - Floating IP address to change. - Required to assign the IP to a different server or if I(state) is absent. aliases: [ network ] + type: str ip_version: description: - IP protocol version of the floating IP. choices: [ 4, 6 ] + type: int server: description: - UUID of the server assigned to this floating IP. - Required unless I(state) is absent. + type: str prefix_length: description: - Only valid if I(ip_version) is 6. - Prefix length for the IPv6 network. Currently only a prefix of /56 can be requested. If no I(prefix_length) is present, a single address is created. choices: [ 56 ] + type: int reverse_ptr: description: - Reverse PTR entry for this address. - You cannot set a reverse PTR entry for IPv6 floating networks. Reverse PTR entries are only allowed for single addresses. + type: str extends_documentation_fragment: cloudscale ''' @@ -138,7 +144,6 @@ sample: present ''' -import os import traceback IPADDRESS_IMP_ERR = None @@ -226,12 +231,12 @@ def update_floating_ip(self): def main(): argument_spec = cloudscale_argument_spec() argument_spec.update(dict( - state=dict(default='present', choices=('present', 'absent')), - ip=dict(aliases=('network', )), + state=dict(default='present', choices=('present', 'absent'), type='str'), + ip=dict(aliases=('network', ), type='str'), ip_version=dict(choices=(4, 6), type='int'), - server=dict(), + server=dict(type='str'), prefix_length=dict(choices=(56,), type='int'), - reverse_ptr=dict(), + reverse_ptr=dict(type='str'), )) module = AnsibleModule( diff --git a/test/integration/targets/cloudscale_floating_ip/tasks/main.yml b/test/integration/targets/cloudscale_floating_ip/tasks/main.yml index 13a358e37ecb31..a3bc6d5e19bdfa 100644 --- a/test/integration/targets/cloudscale_floating_ip/tasks/main.yml +++ b/test/integration/targets/cloudscale_floating_ip/tasks/main.yml @@ -17,7 +17,7 @@ register: test02 - include_tasks: floating_ip.yml - with_items: + loop: - { 'ip_version': 4, 'reverse_ptr': '{{ cloudscale_resource_prefix }}-4.example.com' } - { 'ip_version': 6, 'reverse_ptr': '{{ cloudscale_resource_prefix }}-6.example.com' } - { 'ip_version': 6, 'prefix_length': 56 }