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

Enhance NetworkRouter model for Amazon #16030

Merged
Merged
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
10 changes: 6 additions & 4 deletions app/models/network_router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ class NetworkRouter < ApplicationRecord
belongs_to :cloud_network

has_many :cloud_subnets
has_many :network_ports, :through => :cloud_subnets
has_many :vms, :through => :cloud_subnets
has_many :network_ports, -> { distinct }, :through => :cloud_subnets
has_many :vms, -> { distinct }, :through => :cloud_subnets

has_many :floating_ips, :through => :cloud_network
has_many :cloud_networks, :through => :cloud_subnets
has_many :cloud_networks, -> { distinct }, :through => :cloud_subnets

alias private_networks cloud_networks
alias public_network cloud_network
Expand All @@ -26,10 +26,12 @@ class NetworkRouter < ApplicationRecord
virtual_column :external_gateway_info, :type => :string # :hash
virtual_column :distributed , :type => :boolean
virtual_column :routes , :type => :string # :array
virtual_column :propagating_vgws , :type => :string # :array
virtual_column :main_route_table , :type => :boolean # :array
virtual_column :high_availability , :type => :boolean

# Define all getters and setters for extra_attributes related virtual columns
%i(external_gateway_info distributed routes high_availability).each do |action|
%i(external_gateway_info distributed routes propagating_vgws main_route_table high_availability).each do |action|
define_method("#{action}=") do |value|
extra_attributes_save(action, value)
end
Expand Down