lib/netdisco/name_map.rb in netdisco-0.0.7 vs lib/netdisco/name_map.rb in netdisco-0.0.8
- old
+ new
@@ -2,9 +2,16 @@
class Netdisco
module NameMap
def name_map(origin_name)
name = origin_name.dup
+ # 早期异常拦截
+ if name.nil?
+ Log.debug "Netdisco name_map origin_name is nil"
+ return nil
+ end
+
+ # 字典替换
CFG.name_map.each do |match, replace|
re = Regexp.new match
name = name.sub re, replace
end
name