Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed MiqExpression evaluation on tagged Services #18020

Merged
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
9 changes: 8 additions & 1 deletion app/models/condition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def self.options2hash(opts, rec)
attr, val = o.split("=")
ohash[attr.strip.downcase.to_sym] = val.strip.downcase
end
if ohash[:ref] != rec.class.to_s.downcase
if ohash[:ref] != rec.class.to_s.downcase && !exclude_from_object_ref_substitution(ohash[:ref], rec)
ref = rec.send(val) if val && rec.respond_to?(val)
end

Expand All @@ -232,6 +232,13 @@ def self.options2hash(opts, rec)
return ohash, ref, object
end

def self.exclude_from_object_ref_substitution(reference, rec)
case reference
when "service"
rec.kind_of?(Service)
end
end

def self.registry_data(ref, name, ohash)
# <registry>HKLM\Software\Microsoft\Windows\CurrentVersion\explorer\Shell Folders\Common AppData</registry> == 'C:\Documents and Settings\All Users\Application Data'
# <registry>HKLM\Software\Microsoft\Windows\CurrentVersion\explorer\Shell Folders : Common AppData</registry> == 'C:\Documents and Settings\All Users\Application Data'
Expand Down
8 changes: 8 additions & 0 deletions spec/models/condition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,12 @@
expect(condition.expression.exp).to eq("not" => {">" => {"field" => "Vm-cpu_num", "value" => 2}})
end
end

describe ".options2hash" do
it 'returns the same record if it is descendant from Service class and passed reference is "service" ' do
record = ServiceContainerTemplate.new
_, result_record, _ = described_class.options2hash("ref=service", record)
expect(result_record).to be(record)
end
end
end