-
Notifications
You must be signed in to change notification settings - Fork 1
/
web.rb
48 lines (38 loc) · 1.08 KB
/
web.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'sinatra'
require 'haml'
require 'redis'
require 'nokogiri'
require 'sinatra/static_assets'
require 'rack'
class Web < Sinatra::Base
get '/' do
redis = Redis.new
@waiting = Hash.new
redis.smembers('waiting').each do | uuid |
spec = Nokogiri::XML( $redis.hget(uuid, 'spec') )
name = spec.xpath( '/domain/name' ).first.text
@waiting[ uuid ] = name
end
@copying = Hash.new
redis.smembers('copying').each do | uuid |
spec = Nokogiri::XML( redis.hget(uuid, 'spec') )
name = spec.xpath( '/domain/name' ).first.text
@copying[ uuid ] = name
end
@running = Hash.new
redis.smembers('running').each do | uuid |
spec = Nokogiri::XML( redis.hget(uuid, 'spec') )
name = spec.xpath( '/domain/name' ).first.text
state = 'running'
@running[ uuid ] = name
end
haml :index
end
get '/instances/:uuid' do
redis = Redis.new
@uuid = params[:uuid]
@spec = Nokogiri::XML( redis.hget(@uuid, 'spec') )
@name = @spec.xpath('/domain/name').first
haml :instance
end
end