def post_import(_file)
@vguests.each do |system_id, guest_ids|
handle_missing_and_supress "setting guests for #{system_id}" do
uuid = get_translated_id(:systems, system_id)
vguest_uuids = guest_ids.collect do |id|
get_translated_id(:systems, id)
end if guest_ids
debug "Setting virtual guests for #{uuid}: #{vguest_uuids.inspect}"
update_entity(
:systems,
uuid,
{:guest_ids => vguest_uuids}
) if uuid && vguest_uuids
end
end
return if @map.empty?
create_rpmbuild_structure
version = '0.0.1'
now = Time.now
rpm_name = "system-profile-transition-#{Socket.gethostname}-#{now.to_i}"
tar_name = "#{rpm_name}-#{version}"
dir_name = File.join(option_export_directory, tar_name)
FileUtils.rm_rf(dir_name) if File.directory?(dir_name)
Dir.mkdir dir_name
CSVHelper.csv_write_hashes(
File.join(dir_name, "system-id_to_uuid-#{now.to_i}.map"),
[:system_id, :uuid, :org_id],
@map.sort_by { |x| [x[:org_id], x[:system_id], x[:uuid]] })
sources_dir = File.join(option_export_directory, 'SOURCES')
system("tar -C #{option_export_directory} -czf #{sources_dir}/#{tar_name}.tar.gz #{tar_name}")
FileUtils.rm_rf(dir_name)
File.open(
File.join(option_export_directory, 'SPECS', "#{tar_name}.spec"), 'w') do |file|
file.write(rpm_spec(rpm_name, version, now))
end
progress ''
progress 'To build the system-profile-transition rpm, run:'
progress ''
progress "\tcd #{option_export_directory}/SPECS && "
progress "\t rpmbuild -ba --define \"_topdir #{option_export_directory}\" #{tar_name}.spec"
progress ''
progress "Then find your #{rpm_name} package"
progress "\tin #{File.join(option_export_directory, 'RPMS/noarch/')} directory."
end