Skip to content

Commit

Permalink
Merge remote-tracking branch master into petrosian
Browse files Browse the repository at this point in the history
  • Loading branch information
Fryguy committed May 30, 2023
2 parents 22b0790 + e045cb1 commit 9230773
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 47 deletions.
136 changes: 111 additions & 25 deletions app/models/manageiq/providers/vmware/infra_manager/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class ManageIQ::Providers::Vmware::InfraManager::Host < ::Host
include ManageIQ::Providers::Vmware::InfraManager::EmsRefObjMixin

supports :capture
supports :update

# overrides base start to support "standby" powerstate
supports :start do
Expand Down Expand Up @@ -70,34 +71,119 @@ def reserve_next_available_vnc_port
end
end

def detect_discovered_hypervisor(_ost, ipaddr)
find_method = :find_by_ipaddress

self.name = "VMware ESX Server (#{ipaddr})"
self.ipaddress = ipaddr
self.vmm_vendor = "vmware"
self.vmm_product = "Esx"
if has_credentials?(:ws)
begin
with_provider_connection(:ip => ipaddr) do |vim|
_log.info("VIM Information for ESX Host with IP Address: [#{ipaddr}], Information: #{vim.about.inspect}")
self.vmm_product = vim.about['name'].dup.split(' ').last
self.vmm_version = vim.about['version']
self.vmm_buildnumber = vim.about['build']
self.name = "#{vim.about['name']} (#{ipaddr})"
end
rescue => err
_log.warn("Cannot connect to ESX Host with IP Address: [#{ipaddr}], Username: [#{authentication_userid(:ws)}] because #{err.message}")
end
end
self.type = %w(esx esxi).include?(vmm_product.to_s.downcase) ? "ManageIQ::Providers::Vmware::InfraManager::HostEsx" : "ManageIQ::Providers::Vmware::InfraManager::Host"

find_method
end

supports :quick_stats

def self.display_name(number = 1)
n_('Host (Vmware)', 'Hosts (Vmware)', number)
end

def params_for_update
{
:fields => [
{
:component => 'sub-form',
:id => 'endpoints-subform',
:name => 'endpoints-subform',
:title => _("Endpoints"),
:fields => [
:component => 'tabs',
:name => 'tabs',
:fields => [
{
:component => 'tab-item',
:id => 'ws-tab',
:name => 'ws-tab',
:title => _('Web Service'),
:fields => [
{
:component => 'validate-host-credentials',
:id => 'endpoints.ws.valid',
:name => 'endpoints.ws.valid',
:skipSubmit => true,
:isRequired => true,
:fields => [
{
:component => "text-field",
:id => "authentications.ws.userid",
:name => "authentications.ws.userid",
:label => _("Username"),
:isRequired => true,
:validate => [{:type => "required"}],
},
{
:component => "password-field",
:id => "authentications.ws.password",
:name => "authentications.ws.password",
:label => _("Password"),
:type => "password",
:isRequired => true,
:validate => [{:type => "required"}],
:helperText => _('Used for access to Web Services.')
},
],
},
],
},
{
:component => 'tab-item',
:id => 'remote-tab',
:name => 'remote-tab',
:title => _('Remote'),
:fields => [
{
:component => 'protocol-selector',
:id => 'remoteEnabled',
:name => 'remoteEnabled',
:skipSubmit => true,
:initialValue => 'disabled',
:label => _('Enabled'),
:options => [
{
:label => _('Disabled'),
:value => 'disabled'
},
{
:label => _('Enabled'),
:value => 'enabled',
},
],
},
{
:component => 'validate-host-credentials',
:id => 'endpoints.remote.valid',
:name => 'endpoints.remote.valid',
:skipSubmit => true,
:condition => {
:when => 'remoteEnabled',
:is => 'enabled',
},
:fields => [
{
:component => "text-field",
:id => "authentications.remote.userid",
:name => "authentications.remote.userid",
:label => _("Username"),
:isRequired => true,
:validate => [{:type => "required"}],
},
{
:component => "password-field",
:id => "authentications.remote.password",
:name => "authentications.remote.password",
:label => _("Password"),
:type => "password",
:isRequired => true,
:validate => [{:type => "required"}],
:helperText => _('Used for SSH login.')
},
],
},
],
},
]
]
},
]
}
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ def verify_credentials_with_ws(auth_type = nil)
end
end

def verify_credentials_default(auth_type, _options)
verify_credentials_with_ws(auth_type)
end

def refresh_logs
if self.missing_credentials?
_log.warn "No credentials defined for Host [#{name}]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def parse_host_system_network(host_hash, props)
hostname = dns_config[:hostName]
domain_name = dns_config[:domainName]

hostname = "#{hostname}.#{domain_name}" if domain_name
hostname = "#{hostname}.#{domain_name}" if domain_name.present?

host_hash[:name] = hostname
host_hash[:hostname] = hostname
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def perf_collect_metrics(interval_name, start_time = nil, end_time = nil)
counter_info, = Benchmark.realtime_block(:counter_info) { self.class.counter_info_by_counter_id(ems, @perf_vim_hist) }
interval_by_mor, = Benchmark.realtime_block(:capture_intervals) { perf_capture_intervals(targets_by_mor.keys, interval_name) }
query_params, = Benchmark.realtime_block(:build_query_params) { perf_build_query_params(interval_by_mor, counter_info, start_time, end_time) }
counters_by_mor, counter_values_by_mor_and_ts = perf_query(query_params, counter_info, interval_name)
counters_by_mor, counter_values_by_mor_and_ts = perf_query(query_params, counter_info)

return counters_by_mor, counter_values_by_mor_and_ts
rescue HTTPClient::ReceiveTimeoutError => err
Expand Down Expand Up @@ -363,28 +363,20 @@ def perf_build_query_params(interval_by_mor, counter_info, start_time, end_time)
params
end

def perf_query(params, counter_info, interval_name)
def perf_query(params, counter_info)
counters_by_mor = {}
counter_values_by_mor_and_ts = {}
return counter_values_by_mor_and_ts if params.blank?

Benchmark.current_realtime[:num_vim_queries] = params.length
_log.debug { "Total item(s) to be requested: [#{params.length}], #{params.inspect}" }

query_size = Metric::Capture.concurrent_requests(interval_name)
vim_trips = 0
params.each_slice(query_size) do |query|
vim_trips += 1
_log.debug { "Starting request for [#{params.length}] item(s), #{params.inspect}" }
data, = Benchmark.realtime_block(:vim_execute_time) { @perf_vim_hist.queryPerfMulti(params) }
_log.debug { "Finished request for [#{params.length}] item(s)" }

_log.debug { "Starting request for [#{query.length}] item(s), #{query.inspect}" }
data, = Benchmark.realtime_block(:vim_execute_time) { @perf_vim_hist.queryPerfMulti(query) }
_log.debug { "Finished request for [#{query.length}] item(s)" }

Benchmark.realtime_block(:perf_processing) do
self.class.preprocess_data(data, counter_info, counters_by_mor, counter_values_by_mor_and_ts)
end
Benchmark.realtime_block(:perf_processing) do
self.class.preprocess_data(data, counter_info, counters_by_mor, counter_values_by_mor_and_ts)
end
Benchmark.current_realtime[:num_vim_trips] = vim_trips

return counters_by_mor, counter_values_by_mor_and_ts
end
Expand Down
5 changes: 4 additions & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
:critical:
:power:
:critical:
:capture_batch_size: 250
:concurrent_requests:
:historical: 100
:hourly: 250
:realtime: 100
:ems_refresh:
:vmware_tanzu:
:refresh_interval: 24.hours
Expand Down
4 changes: 0 additions & 4 deletions lib/manageiq-providers-vmware.rb

This file was deleted.

3 changes: 3 additions & 0 deletions lib/manageiq/providers/vmware.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
require "manageiq/providers/vmware/engine"
require "manageiq/providers/vmware/version"

module ManageIQ
module Providers
module Vmware
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Dir[Rails.root.join("spec/shared/**/*.rb")].each { |f| require f }
Dir[File.join(__dir__, "support/**/*.rb")].each { |f| require f }

require "manageiq-providers-vmware"
require "manageiq/providers/vmware"

VCR.configure do |config|
config.ignore_hosts 'codeclimate.com' if ENV['CI']
Expand Down

0 comments on commit 9230773

Please sign in to comment.