summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGomathiselviS <gomathiselvi@gmail.com>2020-11-23 10:17:52 -0500
committerGitHub <noreply@github.com>2020-11-23 15:17:52 +0000
commit6c51003d205242acd18bdfb6bd3400c5cfdba419 (patch)
treea8485e201f85ad05392009bcb4b5a340ad814f3e /plugins
parent869415457a84114c3efdee4bc381ed77e93ee569 (diff)
downloadvyos.vyos-6c51003d205242acd18bdfb6bd3400c5cfdba419.tar.gz
vyos.vyos-6c51003d205242acd18bdfb6bd3400c5cfdba419.zip
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
Diffstat (limited to 'plugins')
-rw-r--r--plugins/module_utils/network/vyos/config/interfaces/interfaces.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/plugins/module_utils/network/vyos/config/interfaces/interfaces.py b/plugins/module_utils/network/vyos/config/interfaces/interfaces.py
index 86008e8..484e600 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(