From 6c51003d205242acd18bdfb6bd3400c5cfdba419 Mon Sep 17 00:00:00 2001 From: GomathiselviS Date: Mon, 23 Nov 2020 10:17:52 -0500 Subject: Enable configuring new interface which is not present in the config (#102) Enable configuring new interface which is not present in the config Reviewed-by: https://github.com/apps/ansible-zuul --- .../module_utils/network/vyos/config/interfaces/interfaces.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'plugins/module_utils') diff --git a/plugins/module_utils/network/vyos/config/interfaces/interfaces.py b/plugins/module_utils/network/vyos/config/interfaces/interfaces.py index 86008e87..484e6000 100644 --- a/plugins/module_utils/network/vyos/config/interfaces/interfaces.py +++ b/plugins/module_utils/network/vyos/config/interfaces/interfaces.py @@ -161,10 +161,10 @@ class Interfaces(ConfigBase): else: for item in want: name = item["name"] + enable_state = item["enabled"] obj_in_have = search_obj_in_list(name, have) - if not obj_in_have: - obj_in_have = {"name": name} + obj_in_have = {"name": name, "enabled": enable_state} if self.state in ("merged", "rendered"): commands.extend(self._state_merged(item, obj_in_have)) @@ -207,6 +207,11 @@ class Interfaces(ConfigBase): for intf in want: intf_in_have = search_obj_in_list(intf["name"], have) + if not intf_in_have: + intf_in_have = { + "name": intf["name"], + "enabled": intf["enabled"], + } commands.extend(self._state_replaced(intf, intf_in_have)) return commands @@ -271,7 +276,6 @@ class Interfaces(ConfigBase): want_copy = deepcopy(remove_empties(want)) have_copy = deepcopy(have) - want_vifs = want_copy.pop("vifs", []) have_vifs = have_copy.pop("vifs", []) @@ -321,7 +325,6 @@ class Interfaces(ConfigBase): vif=want_vif["vlan_id"], ) ) - return commands def _compute_commands( -- cgit v1.2.3