def import_module(module_file, mib_dir=DEFAULT_MIB_PATH)
raise "smidump tool must be installed" unless import_supported?
FileUtils.makedirs mib_dir
mib_hash = `smidump -f python #{module_file}`
mib = eval_mib_data(mib_hash)
if mib
module_name = mib["moduleName"]
raise "#{module_file}: invalid file format; no module name" unless module_name
if mib["nodes"]
oid_hash = {}
mib["nodes"].each { |key, value| oid_hash[key] = value["oid"] }
if mib["notifications"]
mib["notifications"].each { |key, value| oid_hash[key] = value["oid"] }
end
File.open(module_file_name(module_name, mib_dir), 'w') do |file|
YAML.dump(oid_hash, file)
file.puts
end
module_name
else
warn "*** No nodes defined in: #{module_file} ***"
nil
end
else
warn "*** Import failed for: #{module_file} ***"
nil
end
end