Top Level Namespace
Defined Under Namespace
Modules: CellQueue, Memory, Zygote
Classes: CellQueueEntry, ZygoteServer, ZygoteWeb
Instance Method Summary
collapse
Instance Method Details
#clean_params(params) ⇒ Object
27
28
29
30
31
|
# File 'lib/zygote/util.rb', line 27
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
|
#compute_sku(vendor, serial, board_serial) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/zygote/util.rb', line 5
def compute_sku(vendor, serial, board_serial)
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' end
sku = "#{sku}-#{serial}"
sku
end
|
#discover_domain ⇒ Object
41
42
43
|
# File 'lib/zygote/util.rb', line 41
def discover_domain
Socket.gethostname.split('.')[1..-1].join('.')
end
|
#encode64(content) ⇒ Object
33
34
35
|
# File 'lib/zygote/util.rb', line 33
def encode64(content)
Base64.encode64(JSON.pretty_generate(content)).gsub(/\n|=/, '')
end
|
#init_sighandlers ⇒ Object
41
42
43
44
45
|
# File 'lib/zygote/server.rb', line 41
def init_sighandlers
trap(:INT) { 'Got interrupt'; EM.stop; exit }
trap(:TERM) { 'Got term'; EM.stop; exit }
trap(:KILL) { 'Got kill'; EM.stop; exit }
end
|
#kernel_params(hash) ⇒ Object
45
46
47
|
# File 'lib/zygote/util.rb', line 45
def kernel_params(hash)
hash.map { |k, v| v == true ? k : "#{k}=#{v}" }.join(' ')
end
|
#my_ip ⇒ Object
37
38
39
|
# File 'lib/zygote/util.rb', line 37
def my_ip
Socket.ip_address_list.find { |x| x.ipv4? && !x.ipv4_loopback? }.ip_address
end
|