Skip to content

Commit

Permalink
Merge pull request #234 from mattkirby/config_issues
Browse files Browse the repository at this point in the history
(POOLER-89) Identify when config issue is present
  • Loading branch information
mattkirby authored Aug 17, 2017
2 parents 03e8933 + 2f5e432 commit 0ea1e50
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/vmpooler/providers/vsphere.rb
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ def get_host_utilization(host, model = nil, limit = 90)
end
return nil if host.runtime.inMaintenanceMode
return nil unless host.overallStatus == 'green'
return nil unless host.configIssue.empty?

cpu_utilization = cpu_utilization_for host
memory_utilization = memory_utilization_for host
Expand Down
6 changes: 5 additions & 1 deletion spec/rbvmomi_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def find(name, type=Object)
# From HostSystem
:capability, :config, :configManager, :datastore, :datastoreBrowser, :hardware, :network, :runtime, :summary, :systemResources, :vm,
# From ManagedEntity
:overallStatus, :name, :parent
:overallStatus, :name, :parent,
# From ManagedObject
:configIssue
)

MockPropertyCollector = Struct.new(
Expand Down Expand Up @@ -507,6 +509,7 @@ def mock_RbVmomi_VIM_HostSystem(options = {})
options[:overall_cpu_usage] = 1 if options[:overall_cpu_usage].nil?
options[:overall_memory_usage] = 1 if options[:overall_memory_usage].nil?
options[:name] = 'HOST' + rand(65536).to_s if options[:name].nil?
options[:config_issue] = [] if options[:config_issue].nil?

mock = MockHostSystem.new()
mock.name = options[:name]
Expand All @@ -527,6 +530,7 @@ def mock_RbVmomi_VIM_HostSystem(options = {})

mock.runtime.inMaintenanceMode = options[:maintenance_mode]
mock.overallStatus = options[:overall_status]
mock.configIssue = options[:config_issue]

mock.summary.hardware.memorySize = options[:memory_size]
mock.hardware.memorySize = options[:memory_size]
Expand Down
10 changes: 10 additions & 0 deletions spec/unit/providers/vsphere_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1903,6 +1903,16 @@
end
end

context "host with configuration issue" do
let(:host) { mock_RbVmomi_VIM_HostSystem({
:config_issue => 'No quickstats',
})
}
it 'should return nil' do
expect(subject.get_host_utilization(host,model,limit)).to be_nil
end
end

# CPU utilization
context "host which exceeds limit in CPU utilization" do
let(:host) { mock_RbVmomi_VIM_HostSystem({
Expand Down

0 comments on commit 0ea1e50

Please sign in to comment.