Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions hawk/app/models/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,32 @@ def unique_id!(other)
end

def rsc_constraints
outp = Util.safe_x('/usr/sbin/crm_resource', '--resource', "#{id}", '-A', '2>/dev/null')
outp, err, status = Util.capture3('crm', 'resource', 'constraints', id)
info = {}
section = nil
outp.each_line do |l|
l.strip!
next if l.blank? || l.start_with?('* ')
m = l.match(/\s*: Node (\S+)\s+\(score=([^,]+), id=([^)]+)\)/)
if m && !info.key?(m[3])
info[m[3]] = { id: m[3], type: :location, score: m[2], other: m[1] }
else
m = l.match(/\s*(\S+)\s+\(score=([^,]+), id=([^)]+)\)/)
next if l.strip.blank?

if l.strip == "Locations:"
section = :location
next
elsif l.strip =~ /^Resources .+ is colocated with:$/
section = :colocation
next
elsif l !~ /^ / # new Top-Level-Section
section = nil
next
end

case section
when :location
m = l.match(/^ \* Node\s+(\S+)\s+\(score=([^,]+), id=([^,\)]+)/)
if m && !info.key?(m[3])
info[m[3]] = { id: m[3], type: :location, score: m[2], other: m[1] }
end

when :colocation
m = l.match(/^ \* (\S+)\s+\(score=([^,]+), id=([^,\)]+)/)
if m && !info.key?(m[3])
info[m[3]] = { id: m[3], type: :colocation, score: m[2], other: m[1] }
end
Expand Down
2 changes: 1 addition & 1 deletion hawk/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Rails.application.routes.draw do
root to: "pages#index"

regex_safe_id = /[^\^\/\[\]"<>#%{}|\\~`;?:@=&]+/
regex_safe_id = /[^\^\/\[\]"<>#%{}|\\~`;?:@=&]+?/

resources :cib, only: [] do
get "/", via: [:get, :post, :options], to: "cib#show", as: ""
Expand Down
Loading