Module: Netdisco::NameMap

Included in:
XDP
Defined in:
lib/netdisco/name_map.rb

Instance Method Summary collapse

Instance Method Details

#name_map(origin_name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/netdisco/name_map.rb', line 5

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
end