61
61
over this global flag.
62
62
type: bool
63
63
default: true
64
+ override_intf_types:
65
+ description:
66
+ - A list of interface types which will be deleted/defaulted in overridden/deleted state. If this list is empty, then during
67
+ overridden/deleted state, all interface types will be defaulted/deleted. If this list includes specific interface types,
68
+ then only those interface types that are included in the list will be deleted/defaulted.
69
+ type: list
70
+ required: false
71
+ elements: str
72
+ choices: ["pc", "vpc", "sub_int", "lo", "eth", "svi", "st_fex", "aa_fex"]
73
+ default: []
64
74
config:
65
75
description:
66
76
- A dictionary of interface operations
@@ -3978,6 +3988,7 @@ def dcnm_intf_get_diff_overridden(self, cfg):
3978
3988
# the given switch may be part of a VPC pair. In that case we
3979
3989
# need to get interface information using one switch which returns interfaces
3980
3990
# from both the switches
3991
+
3981
3992
if not any (
3982
3993
d .get ("serialNo" , None ) == self .ip_sn [address ]
3983
3994
for d in self .have_all
@@ -4006,6 +4017,27 @@ def dcnm_intf_get_diff_overridden(self, cfg):
4006
4017
sno = have ["serialNo" ]
4007
4018
fabric = have ["fabricName" ]
4008
4019
4020
+ # Check if this interface type is to be overridden.
4021
+ if self .module .params ["override_intf_types" ] != []:
4022
+ # Check if it is SUBINTERFACE. For sub-interfaces ifType will be retuened as INTERFACE_ETHERNET. So
4023
+ # for such interfaces, check if SUBINTERFACE is included in override list instead of have['ifType']
4024
+ if (have ["ifType" ] == "INTERFACE_ETHERNET" ) and (
4025
+ (str (have ["isPhysical" ]).lower () == "none" )
4026
+ or (str (have ["isPhysical" ]).lower () == "false" )
4027
+ ):
4028
+ # This is a SUBINTERFACE.
4029
+ if (
4030
+ "SUBINTERFACE"
4031
+ not in self .module .params ["override_intf_types" ]
4032
+ ):
4033
+ continue
4034
+ else :
4035
+ if (
4036
+ have ["ifType" ]
4037
+ not in self .module .params ["override_intf_types" ]
4038
+ ):
4039
+ continue
4040
+
4009
4041
if (have ["ifType" ] == "INTERFACE_ETHERNET" ) and (
4010
4042
(str (have ["isPhysical" ]).lower () != "none" )
4011
4043
and (str (have ["isPhysical" ]).lower () == "true" )
@@ -4217,8 +4249,11 @@ def dcnm_intf_get_diff_overridden(self, cfg):
4217
4249
delem ["serialNumber" ] = sno
4218
4250
delem ["ifName" ] = intf ["ifName" ]
4219
4251
delem ["fabricName" ] = self .fabric
4220
- self .diff_deploy .append (delem )
4221
- self .changed_dict [0 ]["deploy" ].append (copy .deepcopy (delem ))
4252
+
4253
+ # Deploy only if requested for
4254
+ if str (deploy ).lower () == "true" :
4255
+ self .diff_deploy .append (delem )
4256
+ self .changed_dict [0 ]["deploy" ].append (copy .deepcopy (delem ))
4222
4257
4223
4258
self .dcnm_intf_compare_want_and_have ("overridden" )
4224
4259
@@ -4843,7 +4878,7 @@ def dcnm_intf_send_message_to_dcnm(self):
4843
4878
self .module .params ["state" ] == "deleted"
4844
4879
):
4845
4880
self .result ["changed" ] = (
4846
- delete or create or deploy or delete_deploy
4881
+ delete or create or replace or deploy or delete_deploy
4847
4882
)
4848
4883
else :
4849
4884
if delete or create or replace or deploy or delete_deploy :
@@ -4865,6 +4900,7 @@ def dcnm_intf_update_inventory_data(self):
4865
4900
"""
4866
4901
4867
4902
inv_data = get_fabric_inventory_details (self .module , self .fabric )
4903
+
4868
4904
self .inventory_data .update (inv_data )
4869
4905
4870
4906
if self .module .params ["state" ] != "query" :
@@ -4938,6 +4974,13 @@ def dcnm_intf_update_inventory_data(self):
4938
4974
4939
4975
def dcnm_translate_playbook_info (self , config , ip_sn , hn_sn ):
4940
4976
4977
+ # Transalte override_intf_types to proper types that can be directly used in overridden state.
4978
+
4979
+ for if_type in self .module .params ["override_intf_types" ][:]:
4980
+ self .module .params ["override_intf_types" ].append (
4981
+ self .int_types [if_type ]
4982
+ )
4983
+ self .module .params ["override_intf_types" ].remove (if_type )
4941
4984
for cfg in config :
4942
4985
index = 0
4943
4986
if cfg .get ("switch" , None ) is None :
@@ -4972,6 +5015,22 @@ def main():
4972
5015
default = "merged" ,
4973
5016
choices = ["merged" , "replaced" , "overridden" , "deleted" , "query" ],
4974
5017
),
5018
+ override_intf_types = dict (
5019
+ required = False ,
5020
+ type = "list" ,
5021
+ elements = "str" ,
5022
+ choices = [
5023
+ "pc" ,
5024
+ "vpc" ,
5025
+ "sub_int" ,
5026
+ "lo" ,
5027
+ "eth" ,
5028
+ "svi" ,
5029
+ "st_fex" ,
5030
+ "aa_fex" ,
5031
+ ],
5032
+ default = [],
5033
+ ),
4975
5034
check_deploy = dict (type = "bool" , default = False ),
4976
5035
)
4977
5036
0 commit comments