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

Add monitoring manager #15354

Merged
merged 2 commits into from
Jul 6, 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 .rubocop_local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ GlobalVars:
- $rhevm_log
- $kube_log
- $mw_log
- $cn_monitoring_log
- $scvmm_log
- $vim_log
- $websocket_log
Expand Down
1 change: 1 addition & 0 deletions app/models/manageiq/providers/container_manager.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module ManageIQ::Providers
class ContainerManager < BaseManager
include AvailabilityMixin
include HasMonitoringManagerMixin
include SupportsFeatureMixin

has_many :container_nodes, :foreign_key => :ems_id, :dependent => :destroy
Expand Down
11 changes: 11 additions & 0 deletions app/models/manageiq/providers/monitoring_manager.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module ManageIQ::Providers
class MonitoringManager < BaseManager
def self.ems_type
"monitoring".freeze
end

def self.description
"Monitoring Manager".freeze
end
end
end
4 changes: 4 additions & 0 deletions app/models/miq_region.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ def ems_datawarehouses
ext_management_systems.select { |e| e.kind_of? ManageIQ::Providers::DatawarehouseManager }
end

def ems_monitors
ext_management_systems.select { |e| e.kind_of? ManageIQ::Providers::MonitoringManager }
end

def ems_configproviders
ext_management_systems.select { |e| e.kind_of? ManageIQ::Providers::ConfigurationManager }
end
Expand Down
21 changes: 21 additions & 0 deletions app/models/mixins/has_monitoring_manager_mixin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module HasMonitoringManagerMixin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prepare for troubles with this approach.

Also what happens if you include HasMonitoringManagerMixin and HasNetworkingManagerMixin ?
It wont chain ensure_managers. I was experimenting with HasParentManager, which would be included into the parent manager, but it also adds some confusion...
So, in the end, I think this linking of managers via parent_manager is flawed, or at least how we set it up.

Unfortunately there is no better way to do this for now 😢

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the heads up @durandom. I experience some weird stuff (that was solved passing parent_manager to build). We should be good with the first issue and the second one (we use on_create, and Monitoring manager always has a parent_manager).

I should probably change ensure_manager to ensure_X_manager.

I would appreciate it if you can take a look on the manageiq-providers-kubernetes PR adding the concrete manager.

extend ActiveSupport::Concern

private

def ensure_monitoring_manager
# monitoring_manager should be defined by child classes.
if try(:monitoring_manager_needed?)
build_monitoring_manager(:parent_manager => self)
monitoring_manager.name = "#{name} Monitoring Manager"
end
ensure_monitoring_manager_properties
end

def ensure_monitoring_manager_properties
if monitoring_manager
monitoring_manager.zone_id = zone_id
monitoring_manager.provider_region = provider_region
end
end
end
4 changes: 4 additions & 0 deletions app/models/zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ def ems_datawarehouses
ext_management_systems.select { |e| e.kind_of? ManageIQ::Providers::DatawarehouseManager }
end

def ems_monitors
ext_management_systems.select { |e| e.kind_of? ManageIQ::Providers::MonitoringManager }
end

def ems_configproviders
ext_management_systems.select { |e| e.kind_of? ManageIQ::Providers::ConfigurationManager }
end
Expand Down
1 change: 1 addition & 0 deletions config/permissions.tmpl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- ems-type:gce_network
- ems-type:hawkular
- ems-type:hawkular_datawarehouse
- ems-type:monitoring # removed in https://github.com/ManageIQ/manageiq/pull/15506
- ems-type:kubernetes
- ems-type:lenovo_ph_infra
- ems-type:nuage_network
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@
:level_rails: info
:level_lenovo: info
:level_mw: info
:level_cn_monitoring: info
:level_kube: info
:level_api: info
:level_fog: info
Expand Down
2 changes: 2 additions & 0 deletions lib/vmdb/loggers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def self.apply_config(config)
apply_config_value(config, $kube_log, :level_kube)
apply_config_value(config, $mw_log, :level_mw)
apply_config_value(config, $datawarehouse_log, :level_datawarehouse)
apply_config_value(config, $cn_monitoring_log, :level_cn_monitoring)
apply_config_value(config, $scvmm_log, :level_scvmm)
apply_config_value(config, $api_log, :level_api)
apply_config_value(config, $fog_log, :level_fog)
Expand All @@ -52,6 +53,7 @@ def self.create_loggers
$kube_log = create_multicast_logger(path_dir.join("kubernetes.log"))
$mw_log = create_multicast_logger(path_dir.join("middleware.log"))
$datawarehouse_log = create_multicast_logger(path_dir.join("datawarehouse.log"))
$cn_monitoring_log = create_multicast_logger(path_dir.join("container_monitoring.log"))
$scvmm_log = create_multicast_logger(path_dir.join("scvmm.log"))
$azure_log = create_multicast_logger(path_dir.join("azure.log"))
$api_log = create_multicast_logger(path_dir.join("api.log"))
Expand Down
1 change: 1 addition & 0 deletions spec/models/ext_management_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"hawkular_datawarehouse" => "Hawkular Datawarehouse",
"kubernetes" => "Kubernetes",
"openshift" => "OpenShift",
"monitoring" => "Monitoring Manager", # removed in https://github.com/ManageIQ/manageiq/pull/15506
"openstack" => "OpenStack",
"openstack_infra" => "OpenStack Platform Director",
"openstack_network" => "OpenStack Network",
Expand Down