Sha256: 11c38bbd9a44c7c6124ed04b1e596cab3506407a3f2e7b9856d50b1b3d5d5b3c
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
require 'socket' require 'base64' require 'json' def compute_sku(vendor, serial, board_serial) # Sanitize params strip_pattern = /[^-^:\p{Alnum}]/ serial = (serial || '').gsub(strip_pattern, '') vendor = (vendor || '').gsub(strip_pattern, '') board_serial = (board_serial || '').gsub(strip_pattern, '') serial = board_serial unless board_serial.empty? sku = case vendor when 'DellInc' 'DEL' when 'Supermicro' 'SPM' else 'UKN' # unknown manufacturer end sku = "#{sku}-#{serial}" sku end def clean_params(params) params.delete_if { |x, _| x == 'splat' || x == 'captures' } params = params.map { |k,v| [k, v.is_a?(Hash) ? encode64(v) : v] }.to_h params end def encode64(content) Base64.encode64(JSON.pretty_generate(content)).gsub(/\n|=/, '') end def my_ip Socket.ip_address_list.find { |x| x.ipv4? && !x.ipv4_loopback? }.ip_address end def discover_domain Socket.gethostname.split('.')[1..-1].join('.') end def kernel_params(hash) hash.map { |k, v| v == true ? k : "#{k}=#{v}" }.join(' ') end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
zygote-0.2.7 | lib/zygote/util.rb |
zygote-0.2.6 | lib/zygote/util.rb |
zygote-0.2.5 | lib/zygote/util.rb |