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

(POOLER-89) Identify when config issue is present #234

Merged
merged 1 commit into from
Aug 17, 2017
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
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