def _create_entity(entity_type, entity_hash, original_id)
type = to_singular(entity_type)
if @pm[entity_type][original_id]
info type.capitalize + ' [' + original_id.to_s + '->' + @pm[entity_type][original_id].to_s + '] already imported.'
report_summary :found, entity_type
return get_cache(entity_type)[@pm[entity_type][original_id]]
else
info 'Creating new ' + type + ': ' + entity_hash.values_at(:name, :label, :login).compact[0]
entity_hash = {@wrap_out[entity_type] => entity_hash} if @wrap_out[entity_type]
debug "entity_hash: #{entity_hash.inspect}"
entity = mapped_api_call(entity_type, :create, entity_hash)
debug "created entity: #{entity.inspect}"
entity = entity[@wrap_in[entity_type]] if @wrap_in[entity_type]
entity['id'] = entity['uuid'] if entity_type == :systems
@pm[entity_type][original_id] = entity['id']
get_cache(entity_type)[entity['id']] = entity
debug "@pm[#{entity_type}]: #{@pm[entity_type].inspect}"
report_summary :created, entity_type
return entity
end
end