Skip to content

Commit

Permalink
fix: Added EdgeType args to c_in_graph method
Browse files Browse the repository at this point in the history
  • Loading branch information
1101-1 committed Nov 27, 2023
1 parent 7803c56 commit b059209
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 60 deletions.
1 change: 0 additions & 1 deletion plugins/azure/resoto_plugin_azure/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def collect(self) -> None:
# collect all regional resources
for location in locations:
self.collect_resource_list(location.safe_name, builder.with_location(location), regional_resources)

# wait for all work to finish
queue.wait_for_submitted_work()
# connect nodes
Expand Down
39 changes: 23 additions & 16 deletions plugins/azure/resoto_plugin_azure/resource/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
BaseAutoScalingGroup,
InstanceStatus,
ModelReference,
EdgeType,
)


Expand Down Expand Up @@ -89,10 +90,12 @@ class AzureAvailabilitySet(AzureResource):

def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
if placement_group_id := self.proximity_placement_group:
builder.add_edge(self, clazz=AzureProximityPlacementGroup, id=placement_group_id)
builder.add_edge(
self, edge_type=EdgeType.default, clazz=AzureProximityPlacementGroup, id=placement_group_id
)
if virtual_machines := self.virtual_machines_availability:
for vm_id in virtual_machines:
builder.add_edge(self, clazz=AzureVirtualMachine, id=vm_id)
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureVirtualMachine, id=vm_id)


@define(eq=False, slots=False)
Expand Down Expand Up @@ -140,7 +143,7 @@ class AzureCapacityReservationGroup(AzureResource):
def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
if virtual_machines := self.virtual_machines_associated:
for vm_id in virtual_machines:
builder.add_edge(self, clazz=AzureVirtualMachine, id=vm_id)
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureVirtualMachine, id=vm_id)


@define(eq=False, slots=False)
Expand Down Expand Up @@ -717,9 +720,9 @@ class AzureDisk(AzureResource, BaseVolume):

def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
if disk_id := self.id:
builder.add_edge(self, clazz=AzureDiskAccess, id=disk_id)
builder.add_edge(self, edge_type=EdgeType.default, 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, clazz=AzureDiskEncryptionSet, id=disk_en_set_id)
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureDiskEncryptionSet, id=disk_en_set_id)


@define(eq=False, slots=False)
Expand Down Expand Up @@ -1099,7 +1102,7 @@ def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
if vmsss := self.virtual_machine_scale_sets:
for vmss in vmsss:
if vmss_id := vmss.id:
builder.add_edge(self, clazz=AzureVirtualMachineScaleSet, id=vmss_id)
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureVirtualMachineScaleSet, id=vmss_id)


@define(eq=False, slots=False)
Expand Down Expand Up @@ -1752,7 +1755,7 @@ class AzureRestorePointCollection(AzureResource):

def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
if (source_id := self.source) and (vm_id := source_id.id):
builder.add_edge(self, clazz=AzureVirtualMachine, id=vm_id)
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureVirtualMachine, id=vm_id)


@define(eq=False, slots=False)
Expand Down Expand Up @@ -1855,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, clazz=AzureDisk, id=disk_id)
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureDisk, id=disk_id)


@define(eq=False, slots=False)
Expand Down Expand Up @@ -2608,42 +2611,44 @@ 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, clazz=AzureProximityPlacementGroup, id=placement_group_id)
builder.add_edge(
self, edge_type=EdgeType.default, clazz=AzureProximityPlacementGroup, id=placement_group_id
)

if (
(sp := self.virtual_machine_storage_profile)
and (image_ref := sp.image_reference)
and (image_reference_id := image_ref.id)
):
builder.add_edge(self, clazz=AzureImage, id=image_reference_id)
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureImage, id=image_reference_id)

if (
(sp := self.virtual_machine_storage_profile)
and (disk := sp.os_disk)
and (managed := disk.managed_disk)
and (managed_disk_id := managed.id)
):
builder.add_edge(self, clazz=AzureDisk, id=managed_disk_id)
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureDisk, id=managed_disk_id)

if (vm_network_profile := self.virtual_machine_network_profile) and (
ni_cofigurations := vm_network_profile.network_interface_configurations
):
for ni_configuration in ni_cofigurations:
if nsg_id := ni_configuration.network_security_group:
builder.add_edge(self, clazz=AzureNetworkSecurityGroup, id=nsg_id)
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureNetworkSecurityGroup, id=nsg_id)
if ip_configurations := ni_configuration.ip_configurations:
for ip_configuration in ip_configurations:
if subnet_id := ip_configuration.subnet:
builder.add_edge(self, clazz=AzureSubnet, id=subnet_id)
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureSubnet, id=subnet_id)
if lbbap_id := ip_configuration.load_balancer_backend_address_pools:
builder.add_edge(self, clazz=AzureLoadBalancer, id=lbbap_id)
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureLoadBalancer, id=lbbap_id)

if (vm_network_profile := self.virtual_machine_network_profile) and (
network_interfaces := vm_network_profile.network_interfaces
):
for network_interface in network_interfaces:
if ni_id := network_interface.id:
builder.add_edge(self, clazz=AzureNetworkInterface, id=ni_id)
builder.add_edge(self, edge_type=EdgeType.default, clazz=AzureNetworkInterface, id=ni_id)


@define(eq=False, slots=False)
Expand Down Expand Up @@ -3167,7 +3172,9 @@ def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
if baps := ip_config.load_balancer_backend_address_pools:
for bap in baps:
if bap_id := bap:
builder.add_edge(self, clazz=AzureLoadBalancer, id=bap_id)
builder.add_edge(
self, edge_type=EdgeType.default, clazz=AzureLoadBalancer, id=bap_id
)


@define(eq=False, slots=False)
Expand Down
Loading

0 comments on commit b059209

Please sign in to comment.