|
7 | 7 | from infrahub_sdk.protocols import CoreIPAddressPool |
8 | 8 | from netutils.interface import sort_interface_list |
9 | 9 |
|
10 | | -from .schema_protocols import DcimConsoleInterface, InterfacePhysical |
| 10 | +from .schema_protocols import DcimCable, DcimConsoleInterface, InterfacePhysical |
11 | 11 |
|
12 | 12 | # Range expansion pattern from infrahub_sdk |
13 | 13 | RANGE_PATTERN = re.compile(r"(\[[\w,-]*[-,][\w,-]*\])") |
@@ -944,19 +944,28 @@ async def create_oob_connections( |
944 | 944 | source_endpoint.description.value = ( |
945 | 945 | f"Connection to {' -> '.join(target_endpoint.hfid or [])}" |
946 | 946 | ) |
947 | | - # Infrahub handles bidirectional connector relationships automatically |
948 | | - source_endpoint.connector = target_endpoint.id # type: ignore[assignment] |
949 | 947 | target_endpoint.status.value = "active" |
950 | 948 | target_endpoint.description.value = ( |
951 | 949 | f"Connection to {' -> '.join(source_endpoint.hfid or [])}" |
952 | 950 | ) |
953 | | - # Note: Don't set target_endpoint.connector - Infrahub creates bidirectional relationship automatically |
| 951 | + |
| 952 | + # Create cable to connect the endpoints |
| 953 | + cable = await self.client.create(kind=DcimCable) |
| 954 | + cable.status.value = "connected" |
| 955 | + # Use cat6 for management/console connections |
| 956 | + cable.cable_type.value = "cat6" |
| 957 | + cable.connected_endpoints.add(source_endpoint.id) |
| 958 | + cable.connected_endpoints.add(target_endpoint.id) |
| 959 | + |
954 | 960 | batch.add( |
955 | 961 | task=source_endpoint.save, allow_upsert=True, node=source_endpoint |
956 | 962 | ) |
957 | 963 | batch.add( |
958 | 964 | task=target_endpoint.save, allow_upsert=True, node=target_endpoint |
959 | 965 | ) |
| 966 | + batch.add( |
| 967 | + task=cable.save, allow_upsert=True, node=cable |
| 968 | + ) |
960 | 969 | try: |
961 | 970 | async for node, _ in batch.execute(): |
962 | 971 | self.log.info( |
|
0 commit comments