@@ -1266,14 +1266,18 @@ def dcnm_links_get_intra_fabric_link_spec(self, cfg):
12661266 link_spec ["profile" ]["mtu" ] = dict (required = True , type = "int" )
12671267 else :
12681268 link_spec ["profile" ]["mtu" ] = dict (type = "int" , default = 1500 )
1269- link_spec ["profile" ]["peer1_description" ] = dict (
1270- type = "str" , default = ""
1271- )
1272- link_spec ["profile" ]["peer2_description" ] = dict (
1273- type = "str" , default = ""
1274- )
1275- link_spec ["profile" ]["peer1_cmds" ] = dict (type = "list" , default = [])
1276- link_spec ["profile" ]["peer2_cmds" ] = dict (type = "list" , default = [])
1269+ else :
1270+ link_spec ["profile" ]["mtu" ] = dict (type = "int" , default = 1500 )
1271+
1272+ link_spec ["profile" ]["peer1_description" ] = dict (
1273+ type = "str" , default = ""
1274+ )
1275+ link_spec ["profile" ]["peer2_description" ] = dict (
1276+ type = "str" , default = ""
1277+ )
1278+
1279+ link_spec ["profile" ]["peer1_cmds" ] = dict (type = "list" , default = [])
1280+ link_spec ["profile" ]["peer2_cmds" ] = dict (type = "list" , default = [])
12771281
12781282 if (
12791283 (cfg [0 ]["template" ] == self .templates ["int_intra_fabric_num_link" ])
@@ -1775,14 +1779,20 @@ def dcnm_links_get_intra_fabric_links_payload(self, link, link_payload):
17751779 link_payload (dict): Link payload information populated with appropriate data from playbook config
17761780 """
17771781
1782+ link_payload ["nvPairs" ] = {}
17781783 if (
17791784 link ["template" ]
17801785 != self .templates ["int_pre_provision_intra_fabric_link" ]
17811786 ):
1782- link_payload ["nvPairs" ] = {}
17831787 link_payload ["nvPairs" ]["ADMIN_STATE" ] = link ["profile" ].get (
17841788 "admin_state"
17851789 )
1790+
1791+ if (
1792+ link ["template" ]
1793+ != self .templates ["int_pre_provision_intra_fabric_link" ]
1794+ or link .get ("profile" ) is not None
1795+ ):
17861796 link_payload ["nvPairs" ]["MTU" ] = link ["profile" ].get ("mtu" )
17871797 link_payload ["nvPairs" ]["PEER1_DESC" ] = link ["profile" ].get (
17881798 "peer1_description"
@@ -2053,23 +2063,29 @@ def dcnm_links_update_intra_fabric_links_information(
20532063 ):
20542064 return
20552065
2056- if cfg ["profile" ].get ("admin_state" , None ) is None :
2057- wlink ["nvPairs" ]["ADMIN_STATE" ] = hlink ["nvPairs" ]["ADMIN_STATE" ]
2058- if cfg ["profile" ].get ("mtu" , None ) is None :
2059- wlink ["nvPairs" ]["MTU" ] = hlink ["nvPairs" ]["MTU" ]
2060- if cfg ["profile" ].get ("peer1_description" , None ) is None :
2061- wlink ["nvPairs" ]["PEER1_DESC" ] = hlink ["nvPairs" ]["PEER1_DESC" ]
2062- if cfg ["profile" ].get ("peer2_description" , None ) is None :
2063- wlink ["nvPairs" ]["PEER2_DESC" ] = hlink ["nvPairs" ]["PEER2_DESC" ]
2064-
2065- # Note down that 'want' is updated with information from 'have'. We will need
2066- # this to properly merge 'want' and 'have' during diff_merge.
2067- if cfg ["profile" ].get ("peer1_cmds" , None ) is None :
2068- wlink ["nvPairs" ]["PEER1_CONF" ] = hlink ["nvPairs" ]["PEER1_CONF" ]
2069- wlink ["peer1_conf_defaulted" ] = True
2070- if cfg ["profile" ].get ("peer2_cmds" , None ) is None :
2071- wlink ["nvPairs" ]["PEER2_CONF" ] = hlink ["nvPairs" ]["PEER2_CONF" ]
2072- wlink ["peer2_conf_defaulted" ] = True
2066+ if cfg ["template" ] != self .templates ["int_pre_provision_intra_fabric_link" ]:
2067+ if cfg ["profile" ].get ("admin_state" , None ) is None :
2068+ wlink ["nvPairs" ]["ADMIN_STATE" ] = hlink ["nvPairs" ]["ADMIN_STATE" ]
2069+ if (
2070+ cfg ["template" ]
2071+ != self .templates ["int_pre_provision_intra_fabric_link" ]
2072+ or cfg .get ("profile" ) is not None
2073+ ):
2074+ if cfg ["profile" ].get ("mtu" , None ) is None :
2075+ wlink ["nvPairs" ]["MTU" ] = hlink ["nvPairs" ]["MTU" ]
2076+ if cfg ["profile" ].get ("peer1_description" , None ) is None :
2077+ wlink ["nvPairs" ]["PEER1_DESC" ] = hlink ["nvPairs" ]["PEER1_DESC" ]
2078+ if cfg ["profile" ].get ("peer2_description" , None ) is None :
2079+ wlink ["nvPairs" ]["PEER2_DESC" ] = hlink ["nvPairs" ]["PEER2_DESC" ]
2080+
2081+ # Note down that 'want' is updated with information from 'have'. We will need
2082+ # this to properly merge 'want' and 'have' during diff_merge.
2083+ if cfg ["profile" ].get ("peer1_cmds" , None ) is None :
2084+ wlink ["nvPairs" ]["PEER1_CONF" ] = hlink ["nvPairs" ]["PEER1_CONF" ]
2085+ wlink ["peer1_conf_defaulted" ] = True
2086+ if cfg ["profile" ].get ("peer2_cmds" , None ) is None :
2087+ wlink ["nvPairs" ]["PEER2_CONF" ] = hlink ["nvPairs" ]["PEER2_CONF" ]
2088+ wlink ["peer2_conf_defaulted" ] = True
20732089
20742090 if (
20752091 (
@@ -2379,6 +2395,13 @@ def dcnm_links_get_have(self):
23792395 for link in self .want :
23802396 have = self .dcnm_links_get_links_info_from_dcnm (link )
23812397 if (have != []) and (have not in self .have ):
2398+ # we do not get information about PEER_CONF, PEER_DESC, MTU from DCNM
2399+ if have ["templateName" ] == self .templates ["int_pre_provision_intra_fabric_link" ]:
2400+ have ["nvPairs" ]["PEER1_CONF" ] = have ["nvPairs" ].get ("PEER1_CONF" , "" )
2401+ have ["nvPairs" ]["PEER2_CONF" ] = have ["nvPairs" ].get ("PEER2_CONF" , "" )
2402+ have ["nvPairs" ]["MTU" ] = have ["nvPairs" ].get ("MTU" , 1500 )
2403+ have ["nvPairs" ]["PEER1_DESC" ] = have ["nvPairs" ].get ("PEER1_DESC" , "" )
2404+ have ["nvPairs" ]["PEER2_DESC" ] = have ["nvPairs" ].get ("PEER2_DESC" , "" )
23822405 self .have .append (have )
23832406
23842407 def dcnm_links_compare_inter_fabric_link_params (self , wlink , hlink ):
@@ -2833,65 +2856,93 @@ def dcnm_links_compare_intra_fabric_link_params(self, wlink, hlink):
28332856
28342857 # Compare common info for all templates first
28352858 if (
2836- str (wlink ["nvPairs" ]["ADMIN_STATE" ]).lower ()
2837- != str (hlink ["nvPairs" ]["ADMIN_STATE" ]).lower ()
2859+ wlink ["templateName" ] != self .templates ["int_pre_provision_intra_fabric_link" ]
28382860 ):
2839- mismatch_reasons .append (
2840- {
2841- "ADMIN_STATE_MISMATCH" : [
2842- str (wlink ["nvPairs" ]["ADMIN_STATE" ]).lower (),
2843- str (hlink ["nvPairs" ]["ADMIN_STATE" ]).lower (),
2844- ]
2845- }
2846- )
2861+ if (
2862+ str (wlink ["nvPairs" ]["ADMIN_STATE" ]).lower ()
2863+ != str (hlink ["nvPairs" ]["ADMIN_STATE" ]).lower ()
2864+ ):
2865+ mismatch_reasons .append (
2866+ {
2867+ "ADMIN_STATE_MISMATCH" : [
2868+ str (wlink ["nvPairs" ]["ADMIN_STATE" ]).lower (),
2869+ str (hlink ["nvPairs" ]["ADMIN_STATE" ]).lower (),
2870+ ]
2871+ }
2872+ )
28472873 if (
2848- str (wlink ["nvPairs" ]["MTU" ]).lower ()
2849- != str (hlink ["nvPairs" ]["MTU" ]).lower ()
2874+ wlink ["templateName" ]
2875+ != self .templates ["int_pre_provision_intra_fabric_link" ]
2876+ or wlink ["nvPairs" ].get ("MTU" ) is not None
28502877 ):
2851- mismatch_reasons .append (
2852- {
2853- "MTU_MISMATCH" : [
2854- wlink ["nvPairs" ]["MTU" ],
2855- hlink ["nvPairs" ]["MTU" ],
2856- ]
2857- }
2858- )
2859- if wlink ["nvPairs" ]["PEER1_DESC" ] != hlink ["nvPairs" ]["PEER1_DESC" ]:
2860- mismatch_reasons .append (
2861- {
2862- "PEER1_DESC_MISMATCH" : [
2863- wlink ["nvPairs" ]["PEER1_DESC" ],
2864- hlink ["nvPairs" ]["PEER1_DESC" ],
2865- ]
2866- }
2867- )
2868- if wlink ["nvPairs" ]["PEER2_DESC" ] != hlink ["nvPairs" ]["PEER2_DESC" ]:
2869- mismatch_reasons .append (
2870- {
2871- "PEER2_DESC_MISMATCH" : [
2872- wlink ["nvPairs" ]["PEER2_DESC" ],
2873- hlink ["nvPairs" ]["PEER2_DESC" ],
2874- ]
2875- }
2876- )
2877- if wlink ["nvPairs" ]["PEER1_CONF" ] != hlink ["nvPairs" ]["PEER1_CONF" ]:
2878- mismatch_reasons .append (
2879- {
2880- "PEER1_CONF_MISMATCH" : [
2881- wlink ["nvPairs" ]["PEER1_CONF" ],
2882- hlink ["nvPairs" ]["PEER1_CONF" ],
2883- ]
2884- }
2885- )
2886- if wlink ["nvPairs" ]["PEER2_CONF" ] != hlink ["nvPairs" ]["PEER2_CONF" ]:
2887- mismatch_reasons .append (
2888- {
2889- "PEER2_CONF_MISMATCH" : [
2890- wlink ["nvPairs" ]["PEER2_CONF" ],
2891- hlink ["nvPairs" ]["PEER2_CONF" ],
2892- ]
2893- }
2894- )
2878+ if (
2879+ str (wlink ["nvPairs" ]["MTU" ]).lower ()
2880+ != str (hlink ["nvPairs" ]["MTU" ]).lower ()
2881+ ):
2882+ mismatch_reasons .append (
2883+ {
2884+ "MTU_MISMATCH" : [
2885+ wlink ["nvPairs" ]["MTU" ],
2886+ hlink ["nvPairs" ]["MTU" ],
2887+ ]
2888+ }
2889+ )
2890+ if (
2891+ wlink ["templateName" ]
2892+ != self .templates ["int_pre_provision_intra_fabric_link" ]
2893+ or wlink ["nvPairs" ].get ("PEER1_DESC" ) is not None
2894+ ):
2895+ if wlink ["nvPairs" ]["PEER1_DESC" ] != hlink ["nvPairs" ]["PEER1_DESC" ]:
2896+ mismatch_reasons .append (
2897+ {
2898+ "PEER1_DESC_MISMATCH" : [
2899+ wlink ["nvPairs" ]["PEER1_DESC" ],
2900+ hlink ["nvPairs" ]["PEER1_DESC" ],
2901+ ]
2902+ }
2903+ )
2904+ if (
2905+ wlink ["templateName" ]
2906+ != self .templates ["int_pre_provision_intra_fabric_link" ]
2907+ or wlink ["nvPairs" ].get ("PEER2_DESC" ) is not None
2908+ ):
2909+ if wlink ["nvPairs" ]["PEER2_DESC" ] != hlink ["nvPairs" ]["PEER2_DESC" ]:
2910+ mismatch_reasons .append (
2911+ {
2912+ "PEER2_DESC_MISMATCH" : [
2913+ wlink ["nvPairs" ]["PEER2_DESC" ],
2914+ hlink ["nvPairs" ]["PEER2_DESC" ],
2915+ ]
2916+ }
2917+ )
2918+ if (
2919+ wlink ["templateName" ]
2920+ != self .templates ["int_pre_provision_intra_fabric_link" ]
2921+ or wlink ["nvPairs" ].get ("PEER1_CONF" ) is not None
2922+ ):
2923+ if wlink ["nvPairs" ]["PEER1_CONF" ] != hlink ["nvPairs" ]["PEER1_CONF" ]:
2924+ mismatch_reasons .append (
2925+ {
2926+ "PEER1_CONF_MISMATCH" : [
2927+ wlink ["nvPairs" ]["PEER1_CONF" ],
2928+ hlink ["nvPairs" ]["PEER1_CONF" ],
2929+ ]
2930+ }
2931+ )
2932+ if (
2933+ wlink ["templateName" ]
2934+ != self .templates ["int_pre_provision_intra_fabric_link" ]
2935+ or wlink ["nvPairs" ].get ("PEER2_DESC" ) is not None
2936+ ):
2937+ if wlink ["nvPairs" ]["PEER2_CONF" ] != hlink ["nvPairs" ]["PEER2_CONF" ]:
2938+ mismatch_reasons .append (
2939+ {
2940+ "PEER2_CONF_MISMATCH" : [
2941+ wlink ["nvPairs" ]["PEER2_CONF" ],
2942+ hlink ["nvPairs" ]["PEER2_CONF" ],
2943+ ]
2944+ }
2945+ )
28952946
28962947 if (
28972948 (
0 commit comments