Skip to content

Commit

Permalink
Show relation "security group belongs to router and subnet"
Browse files Browse the repository at this point in the history
Two foreign keys have been added to the SecurityGroup model recently:

```
security_group.network_router
security_group.cloud_subnet
```

With this commit we show them both on UI in both directions.

Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
  • Loading branch information
miha-plesko committed Aug 27, 2018
1 parent e8a7289 commit a5f280b
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/controllers/cloud_subnet_controller.rb
Expand Up @@ -11,7 +11,7 @@ class CloudSubnetController < ApplicationController
include Mixins::GenericFormMixin

def self.display_methods
%w(instances cloud_subnets network_ports)
%w(instances cloud_subnets network_ports security_groups)
end

def button
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/network_router_controller.rb
Expand Up @@ -11,7 +11,7 @@ class NetworkRouterController < ApplicationController
include Mixins::GenericFormMixin

def self.display_methods
%w(instances cloud_subnets floating_ips)
%w(instances cloud_subnets floating_ips security_groups)
end

def button
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/security_group_controller.rb
Expand Up @@ -10,7 +10,7 @@ class SecurityGroupController < ApplicationController
include Mixins::GenericShowMixin

def self.display_methods
%w(instances network_ports)
%w(instances network_ports network_routers cloud_subnets)
end

menu_section :net
Expand Down
6 changes: 5 additions & 1 deletion app/helpers/cloud_subnet_helper/textual_summary.rb
Expand Up @@ -18,7 +18,7 @@ def textual_group_relationships
_("Relationships"),
%i(
parent_ems_cloud ems_network cloud_tenant availability_zone instances cloud_network
network_router parent_subnet managed_subnets network_ports
network_router parent_subnet managed_subnets network_ports security_groups
)
)
end
Expand Down Expand Up @@ -110,4 +110,8 @@ def textual_availability_zone
def textual_network_ports
textual_link(@record.network_ports, :label => _('Network Ports'))
end

def textual_security_groups
textual_link(@record.security_groups, :label => _('Security Groups'))
end
end
9 changes: 8 additions & 1 deletion app/helpers/network_router_helper/textual_summary.rb
Expand Up @@ -13,7 +13,10 @@ def textual_group_properties
def textual_group_relationships
TextualGroup.new(
_("Relationships"),
%i(parent_ems_cloud ems_network cloud_tenant instances cloud_subnets external_gateway floating_ips)
%i(
parent_ems_cloud ems_network cloud_tenant instances cloud_subnets external_gateway floating_ips
security_groups
)
)
end

Expand Down Expand Up @@ -90,4 +93,8 @@ def textual_external_gateway
def textual_floating_ips
textual_link(@record.floating_ips, :label => _('Floating IPs'))
end

def textual_security_groups
textual_link(@record.security_groups, :label => _('Security Groups'))
end
end
13 changes: 12 additions & 1 deletion app/helpers/security_group_helper/textual_summary.rb
Expand Up @@ -13,7 +13,10 @@ def textual_group_properties
def textual_group_relationships
TextualGroup.new(
_("Relationships"),
%i(parent_ems_cloud ems_network cloud_tenant instances orchestration_stack network_ports)
%i(
parent_ems_cloud ems_network cloud_tenant instances orchestration_stack network_ports network_router
cloud_subnet
)
)
end

Expand Down Expand Up @@ -70,6 +73,14 @@ def textual_network_ports
@record.network_ports
end

def textual_network_router
@record.network_router
end

def textual_cloud_subnet
@record.cloud_subnet
end

def port_range_helper(rule)
if rule.host_protocol.to_s.upcase.include?("ICMP")
_("N/A")
Expand Down
2 changes: 1 addition & 1 deletion app/views/cloud_subnet/show.html.haml
@@ -1,5 +1,5 @@
#main_div
- if ["instances", "cloud_subnets", "network_ports"].include?(@display) && @showtype != "compare"
- if ["instances", "cloud_subnets", "network_ports", "security_groups"].include?(@display) && @showtype != "compare"
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"}
- elsif @showtype == 'main'
= render :partial => "layouts/textual_groups_generic"
2 changes: 1 addition & 1 deletion app/views/network_router/show.html.haml
@@ -1,5 +1,5 @@
#main_div
- if %w(instances cloud_subnets floating_ips).include?(@display) && @showtype != "compare"
- if %w(instances cloud_subnets floating_ips security_groups).include?(@display) && @showtype != "compare"
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"}
- elsif @showtype == 'main'
= render :partial => "layouts/textual_groups_generic"
1 change: 1 addition & 0 deletions spec/helpers/cloud_subnet_helper/textual_summary_spec.rb
Expand Up @@ -21,5 +21,6 @@
parent_subnet
managed_subnets
network_ports
security_groups
)
end
1 change: 1 addition & 0 deletions spec/helpers/network_router_helper/textual_summary_spec.rb
Expand Up @@ -9,5 +9,6 @@
cloud_subnets
external_gateway
floating_ips
security_groups
)
end
2 changes: 2 additions & 0 deletions spec/helpers/security_group_helper/textual_summary_spec.rb
Expand Up @@ -24,5 +24,7 @@
instances
orchestration_stack
network_ports
network_router
cloud_subnet
)
end

0 comments on commit a5f280b

Please sign in to comment.