summaryrefslogtreecommitdiff
path: root/plugins/modules/_vyos_l3_interface.py
diff options
context:
space:
mode:
authoransible-zuul[bot] <48994755+ansible-zuul[bot]@users.noreply.github.com>2019-08-09 19:11:48 +0000
committerGitHub <noreply@github.com>2019-08-09 19:11:48 +0000
commit66a01fb3cdcedff9205b2295870a7e1629bbae69 (patch)
treebe8d5d5490ec5c49a2f33b83184e35d58d635895 /plugins/modules/_vyos_l3_interface.py
parentfbe294b702e757252a66f64edf66bce060e87494 (diff)
parent29c342fa51c7a9866366cfc20968be7270e02fc5 (diff)
downloadvyos.vyos-66a01fb3cdcedff9205b2295870a7e1629bbae69.tar.gz
vyos.vyos-66a01fb3cdcedff9205b2295870a7e1629bbae69.zip
Merge pull request #10 from ansible-network/bt_79
79 Reviewed-by: Paul Belanger https://github.com/pabelanger
Diffstat (limited to 'plugins/modules/_vyos_l3_interface.py')
-rw-r--r--plugins/modules/_vyos_l3_interface.py41
1 files changed, 32 insertions, 9 deletions
diff --git a/plugins/modules/_vyos_l3_interface.py b/plugins/modules/_vyos_l3_interface.py
index 430217c3..a504e7c8 100644
--- a/plugins/modules/_vyos_l3_interface.py
+++ b/plugins/modules/_vyos_l3_interface.py
@@ -101,7 +101,10 @@ import re
from copy import deepcopy
from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.network.common.utils import is_masklen, validate_ip_address
+from ansible.module_utils.network.common.utils import (
+ is_masklen,
+ validate_ip_address,
+)
from ansible.module_utils.network.common.utils import remove_default_spec
from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import (
load_config,
@@ -154,30 +157,48 @@ def map_obj_to_commands(updates, module):
obj_in_have = search_obj_in_list(name, have)
if state == "absent" and obj_in_have:
- if not ipv4 and not ipv6 and (obj_in_have["ipv4"] or obj_in_have["ipv6"]):
+ if (
+ not ipv4
+ and not ipv6
+ and (obj_in_have["ipv4"] or obj_in_have["ipv6"])
+ ):
if name == "lo":
commands.append("delete interfaces loopback lo address")
else:
- commands.append("delete interfaces ethernet " + name + " address")
+ commands.append(
+ "delete interfaces ethernet " + name + " address"
+ )
else:
if ipv4 and ipv4 in obj_in_have["ipv4"]:
if name == "lo":
- commands.append("delete interfaces loopback lo address " + ipv4)
+ commands.append(
+ "delete interfaces loopback lo address " + ipv4
+ )
else:
commands.append(
- "delete interfaces ethernet " + name + " address " + ipv4
+ "delete interfaces ethernet "
+ + name
+ + " address "
+ + ipv4
)
if ipv6 and ipv6 in obj_in_have["ipv6"]:
if name == "lo":
- commands.append("delete interfaces loopback lo address " + ipv6)
+ commands.append(
+ "delete interfaces loopback lo address " + ipv6
+ )
else:
commands.append(
- "delete interfaces ethernet " + name + " address " + ipv6
+ "delete interfaces ethernet "
+ + name
+ + " address "
+ + ipv6
)
elif state == "present" and obj_in_have:
if ipv4 and ipv4 not in obj_in_have["ipv4"]:
if name == "lo":
- commands.append("set interfaces loopback lo address " + ipv4)
+ commands.append(
+ "set interfaces loopback lo address " + ipv4
+ )
else:
commands.append(
"set interfaces ethernet " + name + " address " + ipv4
@@ -185,7 +206,9 @@ def map_obj_to_commands(updates, module):
if ipv6 and ipv6 not in obj_in_have["ipv6"]:
if name == "lo":
- commands.append("set interfaces loopback lo address " + ipv6)
+ commands.append(
+ "set interfaces loopback lo address " + ipv6
+ )
else:
commands.append(
"set interfaces ethernet " + name + " address " + ipv6