Skip to content

Commit

Permalink
fix: Fixed predecessors by reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
1101-1 committed Nov 27, 2023
1 parent b059209 commit e442a2f
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 62 deletions.
28 changes: 20 additions & 8 deletions plugins/azure/resoto_plugin_azure/resource/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ class AzureDisk(AzureResource, BaseVolume):

def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
if disk_id := self.id:
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureDiskAccess, id=disk_id)
builder.add_edge(self, edge_type=EdgeType.default, reverse=True, clazz=AzureDiskAccess, id=disk_id)
if (disk_encryption := self.disk_encryption) and (disk_en_set_id := disk_encryption.disk_encryption_set_id):
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureDiskEncryptionSet, id=disk_en_set_id)

Expand Down Expand Up @@ -1858,7 +1858,7 @@ class AzureSnapshot(AzureResource, BaseSnapshot):

def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
if (disk_data := self.creation_data) and (disk_id := disk_data.source_resource_id):
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureDisk, id=disk_id)
builder.add_edge(self, edge_type=EdgeType.default, reverse=True, clazz=AzureDisk, id=disk_id)


@define(eq=False, slots=False)
Expand Down Expand Up @@ -2520,17 +2520,21 @@ class AzureVirtualMachine(AzureResource, BaseInstance):
expect_array=True,
)
reference_kinds: ClassVar[ModelReference] = {
"successors": {
"predecessors": {
"default": [
"azure_proximity_placement_group",
"azure_image",
"azure_disk",
"azure_network_security_group",
"azure_subnet",
"azure_network_interface",
"azure_load_balancer",
]
},
"successors": {
"default": [
"azure_image",
"azure_disk",
"azure_network_interface",
]
},
}
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("id"),
Expand Down Expand Up @@ -2612,7 +2616,11 @@ class AzureVirtualMachine(AzureResource, BaseInstance):
def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
if placement_group_id := self.proximity_placement_group:
builder.add_edge(
self, edge_type=EdgeType.default, clazz=AzureProximityPlacementGroup, id=placement_group_id
self,
edge_type=EdgeType.default,
reverse=True,
clazz=AzureProximityPlacementGroup,
id=placement_group_id,
)

if (
Expand Down Expand Up @@ -3173,7 +3181,11 @@ def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
for bap in baps:
if bap_id := bap:
builder.add_edge(
self, edge_type=EdgeType.default, clazz=AzureLoadBalancer, id=bap_id
self,
edge_type=EdgeType.default,
reverse=True,
clazz=AzureLoadBalancer,
id=bap_id,
)


Expand Down
Loading

0 comments on commit e442a2f

Please sign in to comment.