Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #47 from slemrmartin/specs-and-relations-fix
Browse files Browse the repository at this point in the history
Fixed specs with mandatory nil values + parser fixes
  • Loading branch information
agrare authored Jan 20, 2020
2 parents 2984f95 + 7830c31 commit fe4cd6d
Show file tree
Hide file tree
Showing 4 changed files with 438 additions and 342 deletions.
3 changes: 2 additions & 1 deletion lib/topological_inventory/amazon/parser/network_adapter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module TopologicalInventory::Amazon
class Parser
module NetworkAdapter
# Network adapters also added by *parse_vms*
def parse_network_adapters(interface, scope)
stack_id = get_from_tags(interface.tag_set, "aws:cloudformation:stack-id")
stack = lazy_find(:orchestration_stacks, :source_ref => stack_id) if stack_id
Expand All @@ -23,7 +24,7 @@ def parse_network_adapters(interface, scope)
:status => interface.status,
:requester_id => interface.requester_id,
:requester_managed => interface.requester_managed,
:source_dest_check => interface.source_dest_check,
:source_dest_check => interface.source_dest_check
},
:source_region => lazy_find(:source_regions, :source_ref => scope[:region]),
:subscription => lazy_find_subscription(scope),
Expand Down
28 changes: 15 additions & 13 deletions lib/topological_inventory/amazon/parser/vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ def parse_vms(instance, scope)
stack = lazy_find(:orchestration_stacks, :source_ref => stack_id) if stack_id

vm = TopologicalInventoryIngressApiClient::Vm.new(
:source_ref => uid,
:uid_ems => uid,
:name => name,
:power_state => parse_vm_power_state(instance.state),
:flavor => flavor,
:mac_addresses => parse_network(instance)[:mac_addresses],
:source_region => lazy_find(:source_regions, :source_ref => scope[:region]),
:subscription => lazy_find_subscription(scope),
:orchestration_stacks => stack,
:source_ref => uid,
:uid_ems => uid,
:name => name,
:power_state => parse_vm_power_state(instance.state),
:flavor => flavor,
:mac_addresses => parse_network(instance)[:mac_addresses],
:source_region => lazy_find(:source_regions, :source_ref => scope[:region]),
:subscription => lazy_find_subscription(scope),
:orchestration_stack => stack,
)

collections[:vms].data << vm
Expand Down Expand Up @@ -62,10 +62,12 @@ def ec2_classic_network_adapters_and_ips(instance, scope)
return if instance.vpc_id

collections[:network_adapters].data << TopologicalInventoryIngressApiClient::NetworkAdapter.new(
:source_ref => instance.instance_id,
:mac_address => nil,
:source_region => lazy_find(:source_regions, :source_ref => scope[:region]),
:device => lazy_find(:vms, :source_ref => instance.instance_id),
:source_ref => instance.instance_id,
:device => lazy_find(:vms, :source_ref => instance.instance_id),
:mac_address => nil,
:orchestration_stack => nil,
:source_region => lazy_find(:source_regions, :source_ref => scope[:region]),
:subscription => nil
)

collections[:ipaddresses].data << TopologicalInventoryIngressApiClient::Ipaddress.new(
Expand Down
18 changes: 9 additions & 9 deletions lib/topological_inventory/amazon/parser/volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ def parse_volumes(data, scope)
stack = lazy_find(:orchestration_stacks, :source_ref => stack_id) if stack_id

volume = TopologicalInventoryIngressApiClient::Volume.new(
:source_ref => data.volume_id,
:name => get_from_tags(data.tags, :name) || data.volume_id,
:state => parse_volume_state(data.state),
:source_created_at => data.create_time,
:size => (data.size || 0) * 1024 ** 3,
:volume_type => lazy_find(:volume_types, :source_ref => data.volume_type),
:source_region => lazy_find(:source_regions, :source_ref => scope[:region]),
:subscription => lazy_find_subscription(scope),
:orchestration_stacks => stack,
:source_ref => data.volume_id,
:name => get_from_tags(data.tags, :name) || data.volume_id,
:state => parse_volume_state(data.state),
:source_created_at => data.create_time,
:size => (data.size || 0) * 1024 ** 3,
:volume_type => lazy_find(:volume_types, :source_ref => data.volume_type),
:source_region => lazy_find(:source_regions, :source_ref => scope[:region]),
:subscription => lazy_find_subscription(scope),
:orchestration_stack => stack,
)

collections[:volumes].data << volume
Expand Down
Loading

0 comments on commit fe4cd6d

Please sign in to comment.