zygote 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zygote/http.rb +0 -12
- data/lib/zygote/test.rb +1 -1
- data/lib/zygote/util.rb +7 -0
- data/lib/zygote/version.rb +1 -1
- data/views/menu.erb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bd75d436fea9a8f78488c577965a3582cb9a08a
|
4
|
+
data.tar.gz: bd6f75e7c83ed3691f0dc8940209b34e1ad0c227
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69818393b6a753bf0a4e179332242aa81c6c49576ea5ff5a58e65f775170c6ef0b0b54860335d0f01e2a5c1c01c101a06dde0eceb2143337d74c6213acaa1608
|
7
|
+
data.tar.gz: 4523d4cc2876570e98f1adf3dbb2af410c790bedf885ee515fb32829e85ac9f68bbc0a2d43e3d019de665f39531245061bbfc3cfe0ecc28b08a76cbfa275c018
|
data/lib/zygote/http.rb
CHANGED
@@ -73,18 +73,6 @@ class ZygoteWeb < Sinatra::Base
|
|
73
73
|
body { JSON.pretty_generate(CellQueue.show(params['sku'])) }
|
74
74
|
end
|
75
75
|
|
76
|
-
apost %r{/queue/bulk$} do
|
77
|
-
bulk_queue = JSON.parse(request.body.read)
|
78
|
-
bulk_queue.each do |asset, queue|
|
79
|
-
queue = [queue] unless queue.is_a?(Array)
|
80
|
-
queue.each do |action|
|
81
|
-
CellQueue.push(asset, action)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
200
|
86
|
-
end
|
87
|
-
|
88
76
|
# Enable push cells (with optional data) to the cell queue for a SKU
|
89
77
|
apost %r{/queue/(?<sku>\S*)/(?<selected_cell>\S*)$} do
|
90
78
|
# Clean params into a simple hash
|
data/lib/zygote/test.rb
CHANGED
@@ -70,7 +70,7 @@ module Zygote
|
|
70
70
|
|
71
71
|
# Returns EventMachine::HttpClient
|
72
72
|
def post(uri, params = {})
|
73
|
-
EM::Synchrony.sync(EventMachine::HttpRequest.new("http://127.0.0.1:#{TestConfig.port}/#{uri}").apost(body: params))
|
73
|
+
EM::Synchrony.sync(EventMachine::HttpRequest.new("http://127.0.0.1:#{TestConfig.port}/#{uri}").apost(body: JSON.dump(params), head: {'Content-Type' => 'application/json'}))
|
74
74
|
end
|
75
75
|
|
76
76
|
def parameterize(params)
|
data/lib/zygote/util.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'socket'
|
2
|
+
require 'base64'
|
3
|
+
require 'json'
|
2
4
|
|
3
5
|
def compute_sku(vendor, serial, board_serial)
|
4
6
|
# Sanitize params
|
@@ -24,9 +26,14 @@ end
|
|
24
26
|
|
25
27
|
def clean_params(params)
|
26
28
|
params.delete_if { |x, _| x == 'splat' || x == 'captures' }
|
29
|
+
params = params.map { |k,v| [k, v.is_a?(Hash) ? encode64(v) : v] }.to_h
|
27
30
|
params
|
28
31
|
end
|
29
32
|
|
33
|
+
def encode64(content)
|
34
|
+
Base64.encode64(JSON.pretty_generate(content)).gsub(/\n|=/, '')
|
35
|
+
end
|
36
|
+
|
30
37
|
def my_ip
|
31
38
|
Socket.ip_address_list.find { |x| x.ipv4? && !x.ipv4_loopback? }.ip_address
|
32
39
|
end
|
data/lib/zygote/version.rb
CHANGED
data/views/menu.erb
CHANGED
@@ -75,7 +75,7 @@ goto ${selected}
|
|
75
75
|
# Generate chains for each submenu entry
|
76
76
|
<% data['menu']['submenu'].each do |entry, data| %>
|
77
77
|
<% local_params = (data['params'] || {}).merge(params) %>
|
78
|
-
<% parmstr = {entry: entry}.merge(local_params).
|
78
|
+
<% parmstr = {entry: entry}.merge(local_params).to_query %>
|
79
79
|
:<%= cell %>-<%= entry %>
|
80
80
|
chain --replace --autofree http://${dhcp-server}/cell/<%= cell %>/<%= data['action'] || 'boot' %><%= parmstr.empty? ? "" : "?#{parmstr}" %>
|
81
81
|
<% end %>
|