-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ari Zellner
committed
Feb 23, 2017
1 parent
a718cf7
commit 27279da
Showing
12 changed files
with
160 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/helpers/application_helper/toolbar/container_project_view.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters