@@ -60,34 +60,26 @@ def deduplicate_command_list(data):
6060 return unique_list
6161
6262
63- def _get_commands_to_run (yaml_parsed_info , sync_vlans , sync_vrfs , sync_cables , sync_software_version ):
63+ def _get_commands_to_run (yaml_parsed_info , skip_list = None ):
6464 """Return a deduplicated list of commands to run based on YAML info and sync flags."""
6565 all_commands = []
6666
67- # Define which keys to skip based on sync flags
68- skip_conditions = {
69- "interfaces__tagged_vlans" : not sync_vlans ,
70- "interfaces__untagged_vlan" : not sync_vlans ,
71- "interfaces__vrf" : not sync_vrfs ,
72- "cables" : not sync_cables ,
73- "software_version" : not sync_software_version ,
74- }
75-
7667 for key , value in yaml_parsed_info .items ():
7768 # Handle pre_processor section separately
7869 if key == "pre_processor" :
79- for pre_processor , v in value .items ():
80- if not sync_vlans and pre_processor == "vlan_map" :
70+ for pre_processor_name , pre_processor_value in value .items ():
71+ # Skip if this key shouldn't be synced
72+ if skip_list and (pre_processor_name in skip_list ):
8173 continue
82- commands = v .get ("commands" , [])
74+ commands = pre_processor_value .get ("commands" , [])
8375 if isinstance (commands , dict ):
8476 all_commands .append (commands )
8577 elif isinstance (commands , list ):
8678 all_commands .extend (commands )
8779 continue # move to next key
8880
8981 # Skip if this key shouldn't be synced
90- if skip_conditions . get (key , False ):
82+ if skip_list and (key in skip_list ):
9183 continue
9284
9385 commands = value .get ("commands" , [])
@@ -99,7 +91,12 @@ def _get_commands_to_run(yaml_parsed_info, sync_vlans, sync_vrfs, sync_cables, s
9991 return deduplicate_command_list (all_commands )
10092
10193
102- def netmiko_send_commands (task : Task , command_getter_yaml_data : Dict , command_getter_job : str , logger , nautobot_job ):
94+ def netmiko_send_commands (task : Task ,
95+ command_getter_yaml_data : Dict ,
96+ command_getter_job : str ,
97+ logger ,
98+ nautobot_job
99+ ):
103100 """Run commands specified in PLATFORM_COMMAND_MAP."""
104101 if not task .host .platform :
105102 return Result (host = task .host , result = f"{ task .host .name } has no platform set." , failed = True )
@@ -115,13 +112,24 @@ def netmiko_send_commands(task: Task, command_getter_yaml_data: Dict, command_ge
115112 host = task .host , result = f"{ task .host .name } failed connectivity check via tcp_ping." , failed = True
116113 )
117114 task .host .data ["platform_parsing_info" ] = command_getter_yaml_data [task .host .platform ]
115+
116+ skip_conditions = {
117+ "interfaces__tagged_vlans" : not sync_vlans ,
118+ "vlan_map" : not sync_vlans ,
119+ "interfaces__untagged_vlan" : not sync_vlans ,
120+ "interfaces__vrf" : not sync_vrfs ,
121+ "cables" : not sync_cables ,
122+ "software_version" : not sync_software_version ,
123+ }
124+
118125 commands = _get_commands_to_run (
119126 command_getter_yaml_data [task .host .platform ][command_getter_job ],
120- getattr (nautobot_job , "sync_vlans" , False ),
121- getattr (nautobot_job , "sync_vrfs" , False ),
122- getattr (nautobot_job , "sync_cables" , False ),
123- getattr (nautobot_job , "sync_software_version" , False ),
127+ # getattr(nautobot_job, "sync_vlans", False),
128+ # getattr(nautobot_job, "sync_vrfs", False),
129+ # getattr(nautobot_job, "sync_cables", False),
130+ # getattr(nautobot_job, "sync_software_version", False),
124131 )
132+
125133 if (
126134 getattr (nautobot_job , "sync_cables" , False )
127135 and "cables" not in command_getter_yaml_data [task .host .platform ][command_getter_job ].keys ()
0 commit comments