diff --git a/app/models/manageiq/providers/amazon/cloud_manager/refresh_parser.rb b/app/models/manageiq/providers/amazon/cloud_manager/refresh_parser.rb index 66716d510..dcaf1e95d 100644 --- a/app/models/manageiq/providers/amazon/cloud_manager/refresh_parser.rb +++ b/app/models/manageiq/providers/amazon/cloud_manager/refresh_parser.rb @@ -185,6 +185,7 @@ def parse_image(image, is_public) :vendor => "amazon", :raw_power_state => "never", :template => true, + :labels => parse_labels(image.tags), # the is_public flag here avoids having to make an additional API call # per image, since we already know whether it's a public image :publicly_available => is_public, @@ -231,7 +232,7 @@ def parse_instance(instance) :vendor => "amazon", :raw_power_state => status, :boot_time => instance.launch_time, - + :labels => parse_labels(instance.tags), :hardware => { :bitness => architecture_to_bitness(instance.architecture), :virtualization_type => instance.virtualization_type, @@ -387,4 +388,20 @@ def parse_stack_resource(resource) } return uid, new_result end + + def parse_labels(tags) + result = [] + return result if tags.empty? + tags.each do |tag| + custom_attr = { + :section => 'labels', + :name => tag[:key].to_s, + :value => tag[:value], + :source => 'amazon' + } + result << custom_attr + end + + result + end end diff --git a/spec/models/manageiq/providers/amazon/aws_refresher_spec_common.rb b/spec/models/manageiq/providers/amazon/aws_refresher_spec_common.rb index ce149f188..6a30ac2c6 100644 --- a/spec/models/manageiq/providers/amazon/aws_refresher_spec_common.rb +++ b/spec/models/manageiq/providers/amazon/aws_refresher_spec_common.rb @@ -336,7 +336,7 @@ def assert_specific_vm_powered_on :cpu_reserve_expand => nil, :cpu_limit => nil, :cpu_shares => nil, - :cpu_shares_level => nil + :cpu_shares_level => nil, ) expect(v.ext_management_system).to eq(@ems) @@ -403,6 +403,7 @@ def assert_specific_vm_powered_on v.with_relationship_type("genealogy") do expect(v.parent).to eq(@template) end + expect(v.custom_attributes.find_by(:name => "Name")).to eq("EmsRefreshSpec-PoweredOn-Basic3") end def assert_specific_vm_powered_off