-
Notifications
You must be signed in to change notification settings - Fork 356
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
Topology for Container Projects #120
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class ContainerProjectTopologyController < TopologyController | ||
@layout = "container_topology" | ||
@service_class = ContainerProjectTopologyService | ||
|
||
menu_section :cnt | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class ApplicationHelper::Toolbar::ContainerProjectView < ApplicationHelper::Toolbar::Basic | ||
button_group('container_project', [ | ||
twostate( | ||
:view_summary, | ||
'fa fa-th-list', | ||
N_('Summary View'), | ||
nil, | ||
:url => "/show", | ||
:url_parms => "" | ||
), | ||
twostate( | ||
:view_topology, | ||
'fa pficon-topology', | ||
N_('Topology View'), | ||
nil, | ||
:url => "/show", | ||
:url_parms => "?display=topology", | ||
:klass => ApplicationHelper::Button::TopologyFeatureButton | ||
) | ||
]) | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,8 @@ def view_toolbar_filename | |
'drift_view_tb' | ||
elsif %w(ems_container ems_infra).include?(@layout) && %w(main dashboard topology).include?(@display) | ||
'dashboard_summary_toggle_view_tb' | ||
elsif %w(container_project).include?(@layout) | ||
"#{@layout}_view_tb" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I thought that if an entity (like ems) has a dashboard view available (maybe through There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, I don't get it :-( |
||
elsif !%w(all_tasks all_ui_tasks timeline diagnostics my_tasks my_ui_tasks miq_server usage).include?(@layout) && | ||
(!@layout.starts_with?("miq_request")) && !@treesize_buttons && | ||
@display == "main" && @showtype == "main" && !@in_a_form | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class ContainerProjectTopologyService < TopologyService | ||
include UiServiceMixin | ||
include ContainerTopologyServiceMixin | ||
|
||
@provider_class = ContainerProject | ||
|
||
def build_topology | ||
topo_items = {} | ||
links = [] | ||
|
||
entity_relationships = { :ContainerProject => { :ContainerGroups => { | ||
:Containers => nil, | ||
:ContainerReplicator => nil, | ||
:ContainerServices => { :ContainerRoutes => nil }, | ||
:ContainerNode => { :lives_on => {:Host => nil}} | ||
} | ||
} | ||
} | ||
|
||
preloaded = @providers.includes(:container_groups => [:containers, | ||
:container_replicator, | ||
:container_node => [:lives_on => [:host]], | ||
:container_services => [:container_routes]]) | ||
|
||
preloaded.each do |entity| | ||
topo_items, links = build_recursive_topology(entity, entity_relationships[:ContainerProject], topo_items, links) | ||
end | ||
|
||
populate_topology(topo_items, links, build_kinds, icons) | ||
end | ||
|
||
|
||
def build_kinds | ||
kinds = [:ContainerReplicator, :ContainerGroup, :Container, :ContainerNode, | ||
:ContainerService, :Host, :Vm, :ContainerRoute, :ContainerManager, :ContainerProject] | ||
build_legend_kinds(kinds) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
module ContainerTopologyServiceMixin | ||
def entity_display_type(entity) | ||
if entity.kind_of?(ManageIQ::Providers::ContainerManager) | ||
entity.class.short_token | ||
elsif entity.kind_of?(ContainerGroup) | ||
"Pod" | ||
else | ||
name = entity.class.name.demodulize | ||
if name.start_with? "Container" | ||
if name.length > "Container".length # container related entities such as ContainerService | ||
name["Container".length..-1] | ||
else | ||
"Container" # the container entity itself | ||
end | ||
else | ||
if entity.kind_of?(Vm) | ||
name.upcase # turn Vm to VM because it's an abbreviation | ||
else | ||
name # non container entities such as Host | ||
end | ||
end | ||
end | ||
end | ||
|
||
def build_entity_data(entity) | ||
data = build_base_entity_data(entity) | ||
data.merge!(:status => entity_status(entity), | ||
:display_kind => entity_display_type(entity)) | ||
|
||
if (entity.kind_of?(Host) || entity.kind_of?(Vm)) && entity.ext_management_system.present? | ||
data.merge!(:provider => entity.ext_management_system.name) | ||
end | ||
|
||
data | ||
end | ||
|
||
def entity_status(entity) | ||
if entity.kind_of?(Host) || entity.kind_of?(Vm) | ||
status = entity.power_state.capitalize | ||
elsif entity.kind_of?(ContainerNode) | ||
node_ready_status = entity.container_conditions.find_by_name('Ready').try(:status) | ||
status = case node_ready_status | ||
when 'True' | ||
'Ready' | ||
when 'False' | ||
'NotReady' | ||
else | ||
'Unknown' | ||
end | ||
elsif entity.kind_of?(ContainerGroup) | ||
status = entity.phase | ||
elsif entity.kind_of?(Container) | ||
status = entity.state.capitalize | ||
elsif entity.kind_of?(ContainerReplicator) | ||
status = (entity.current_replicas == entity.replicas) ? 'OK' : 'Warning' | ||
elsif entity.kind_of?(ManageIQ::Providers::ContainerManager) | ||
status = entity.authentications.empty? ? 'Unknown' : entity.default_authentication.status.capitalize | ||
else | ||
status = 'Unknown' | ||
end | ||
status | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@himdel @simon3z I tried to make it a little more clear