t.add :last_ping_at
t.add :slot_number
t.add :status
+ t.add :crunch_worker_state
end
api_accessible :superuser, :extend => :user do |t|
t.add :first_ping_at
super || @@domain
end
+ def crunch_worker_state
+ case self.info.andand[:slurm_state]
+ when 'alloc', 'comp'
+ 'busy'
+ when 'idle'
+ 'idle'
+ else
+ 'down'
+ end
+ end
+
def status
if !self.last_ping_at
if Time.now - self.created_at > 5.minutes
-running:
+busy:
uuid: zzzzz-7ekkf-53y36l1lu5ijveb
owner_uuid: zzzzz-tpzed-d9tiejq69daie8f
hostname: compute0
ip_address: 172.17.2.172
last_ping_at: <%= 1.minute.ago.to_s(:db) %>
first_ping_at: <%= 23.hour.ago.to_s(:db) %>
- info: {ping_secret: "48dpm3b8ijyj3jkr2yczxw0844dqd2752bhll7klodvgz9bg80"}
+ info:
+ :ping_secret: "48dpm3b8ijyj3jkr2yczxw0844dqd2752bhll7klodvgz9bg80"
+ :slurm_state: "alloc"
down:
uuid: zzzzz-7ekkf-2vbompg3ecc6e2s
ip_address: 172.17.2.173
last_ping_at: <%= 1.hour.ago.to_s(:db) %>
first_ping_at: <%= 23.hour.ago.to_s(:db) %>
- info: {ping_secret: "2k3i71depad36ugwmlgzilbi4e8n0illb2r8l4efg9mzkb3a1k"}
+ info:
+ :ping_secret: "2k3i71depad36ugwmlgzilbi4e8n0illb2r8l4efg9mzkb3a1k"
+
+idle:
+ uuid: zzzzz-7ekkf-2z3mc76g2q73aio
+ owner_uuid: zzzzz-tpzed-d9tiejq69daie8f
+ hostname: compute2
+ domain: ""
+ ip_address: 172.17.2.174
+ last_ping_at: <%= 2.minute.ago.to_s(:db) %>
+ first_ping_at: <%= 23.hour.ago.to_s(:db) %>
+ info:
+ :ping_secret: "69udawxvn3zzj45hs8bumvndricrha4lcpi23pd69e44soanc0"
+ :slurm_state: "idle"
assert_response :success
node_items = JSON.parse(@response.body)['items']
assert_not_equal 0, node_items.size
+ found_busy_node = false
node_items.each do |node|
assert_nil node['info'].andand['ping_secret']
+ assert_not_nil node['crunch_worker_state']
+ if node['uuid'] == nodes(:busy).uuid
+ found_busy_node = true
+ assert_equal 'busy', node['crunch_worker_state']
+ end
end
+ assert_equal true, found_busy_node
end
end