Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%
- require 'ipaddr'
- # it's a bit confusing where values are coming from, so we are doing lookup to clarify
- ilo_hostname = scope.lookupvar("::hostname")
- ilo_netmask = scope.lookupvar("hpilo::netmask")
- ilo_domain = scope.lookupvar("::domain")
- # caculate ipaddress automatically or use manual settings.
- if mapping == 'automatic'
- ip = IPAddr.new(ipaddress)
- mask = IPAddr.new(netmask)
- ilo = IPAddr.new(ilo_network)
- gwhost = IPAddr.new(ilo_gwhost)
- if ilo_host
- host = (ip.to_i & mask.to_i).to_i + IPAddr.new(ilo_host).to_i
- ilogw = (ip.to_i & mask.to_i).to_i + gwhost.to_i
- else
- host = ilo.to_i + (ip.to_i & (~mask).to_i).to_i
- ilogw = ilo.to_i + gwhost.to_i
- end
- ilo_ipaddress = IPAddr.new(host, Socket::AF_INET).to_s
- ilo_gateway = IPAddr.new(ilogw, Socket::AF_INET).to_s
- else
- ilo_ipaddress = scope.lookupvar("hpilo::ip")
- ilo_gateway = scope.lookupvar("hpilo::gateway")
- end
- -%>
Add Comment
Please, Sign In to add comment