File tree Expand file tree Collapse file tree 2 files changed +28
-8
lines changed
Expand file tree Collapse file tree 2 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -1142,11 +1142,21 @@ async def create_oob_connections(
11421142 target_endpoint .description .value = f"Connection to { ' -> ' .join (source_endpoint .hfid or [])} "
11431143
11441144 # Check if either endpoint already has a cable attached
1145+ # Note: Accessing .peer can raise ValueError if the related node exists
1146+ # but doesn't have an ID/HFID (e.g., hasn't been saved yet). We catch
1147+ # this and treat it as "no existing cable".
11451148 existing_cable_id = None
1146- if source_endpoint .connector .peer :
1147- existing_cable_id = source_endpoint .connector .peer .id
1148- elif target_endpoint .connector .peer :
1149- existing_cable_id = target_endpoint .connector .peer .id
1149+ try :
1150+ if source_endpoint .connector .peer :
1151+ existing_cable_id = source_endpoint .connector .peer .id
1152+ except ValueError :
1153+ pass # No existing cable or peer doesn't have an ID
1154+ if not existing_cable_id :
1155+ try :
1156+ if target_endpoint .connector .peer :
1157+ existing_cable_id = target_endpoint .connector .peer .id
1158+ except ValueError :
1159+ pass # No existing cable or peer doesn't have an ID
11501160
11511161 # Create or update cable to connect the endpoints
11521162 cable_data : dict [str , Any ] = {
Original file line number Diff line number Diff line change @@ -166,11 +166,21 @@ async def create_fabric_peering(self) -> None:
166166 target_endpoint .role .value = interface_role
167167
168168 # Check if either endpoint already has a cable attached
169+ # Note: Accessing .peer can raise ValueError if the related node exists
170+ # but doesn't have an ID/HFID (e.g., hasn't been saved yet). We catch
171+ # this and treat it as "no existing cable".
169172 existing_cable_id = None
170- if source_endpoint .connector .peer :
171- existing_cable_id = source_endpoint .connector .peer .id
172- elif target_endpoint .connector .peer :
173- existing_cable_id = target_endpoint .connector .peer .id
173+ try :
174+ if source_endpoint .connector .peer :
175+ existing_cable_id = source_endpoint .connector .peer .id
176+ except ValueError :
177+ pass # No existing cable or peer doesn't have an ID
178+ if not existing_cable_id :
179+ try :
180+ if target_endpoint .connector .peer :
181+ existing_cable_id = target_endpoint .connector .peer .id
182+ except ValueError :
183+ pass # No existing cable or peer doesn't have an ID
174184
175185 # Create or update cable object connecting both endpoints
176186 # Uses DAC (Direct Attach Copper) passive cables for fabric links
You can’t perform that action at this time.
0 commit comments