Skip to content

Commit

Permalink
cloudcscale_floating_ip: add types (#56924)
Browse files Browse the repository at this point in the history
  • Loading branch information
resmo committed Jun 3, 2019
1 parent 6b26882 commit 0c66a5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions lib/ansible/modules/cloud/cloudscale/cloudscale_floating_ip.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# (c) 2017, Gaudenz Steinlin <gaudenz.steinlin@cloudscale.ch>
# Copyright (c) 2017, Gaudenz Steinlin <gaudenz.steinlin@cloudscale.ch>
# 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
Expand All @@ -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) <gaudenz.steinlin@cloudscale.ch>"
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
'''

Expand Down Expand Up @@ -138,7 +144,6 @@
sample: present
'''

import os
import traceback

IPADDRESS_IMP_ERR = None
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit 0c66a5d

Please sign in to comment.