Skip to content

Commit

Permalink
per dst subscriber capacity limit (#1668)
Browse files Browse the repository at this point in the history
* per dst subscriber capacity limit
  • Loading branch information
dmitry-sinina authored Dec 31, 2024
1 parent 3d28884 commit 8373801
Show file tree
Hide file tree
Showing 14 changed files with 1,760 additions and 13 deletions.
4 changes: 3 additions & 1 deletion app/admin/equipment/gateways.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
[:contractor_name, proc { |row| row.contractor.try(:name) }],
:is_shared,
:allow_origination, :allow_termination, :sst_enabled,
:origination_capacity, :termination_capacity,
:origination_capacity, :termination_capacity, :termination_subscriber_capacity,
:preserve_anonymous_from_domain,
[:termination_src_numberlist_name, proc { |row| row.termination_src_numberlist.try(:name) }],
[:termination_dst_numberlist_name, proc { |row| row.termination_dst_numberlist.try(:name) }],
Expand Down Expand Up @@ -357,6 +357,7 @@ def resource_params

f.input :origination_capacity
f.input :termination_capacity
f.input :termination_subscriber_capacity
f.input :acd_limit
f.input :asr_limit
f.input :short_calls_limit
Expand Down Expand Up @@ -551,6 +552,7 @@ def resource_params
row :allow_termination
row :origination_capacity
row :termination_capacity
row :termination_subscriber_capacity
row :acd_limit
row :asr_limit
row :short_calls_limit
Expand Down
7 changes: 6 additions & 1 deletion app/models/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
# term_outbound_proxy :string
# term_use_outbound_proxy :boolean default(FALSE), not null
# termination_capacity :integer(2)
# termination_subscriber_capacity :integer(2)
# to_rewrite_result :string
# to_rewrite_rule :string
# transit_headers_from_origination :string
Expand Down Expand Up @@ -310,7 +311,11 @@ def normalize_host(value)

validates :max_30x_redirects, :max_transfers, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: PG_MAX_SMALLINT, allow_nil: true, only_integer: true }

validates :origination_capacity, :termination_capacity, numericality: { greater_than: 0, less_than_or_equal_to: PG_MAX_SMALLINT, allow_nil: true, only_integer: true }
validates :origination_capacity,
:termination_capacity,
:termination_subscriber_capacity,
numericality: { greater_than: 0, less_than_or_equal_to: PG_MAX_SMALLINT, allow_nil: true, only_integer: true }

validates :port, numericality: { greater_than_or_equal_to: ApplicationRecord::L4_PORT_MIN, less_than_or_equal_to: ApplicationRecord::L4_PORT_MAX, allow_nil: true, only_integer: true }

validates :fake_180_timer, numericality: { greater_than: 0, less_than_or_equal_to: PG_MAX_SMALLINT, allow_nil: true, only_integer: true }
Expand Down
64 changes: 64 additions & 0 deletions db/custom_seeds/yeti_ro_role.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# frozen_string_literal: true

routing_role = 'yeti_ro'
routing_schemas = %w[
billing
class4
data_import
gui
lnp
logs
notifications
ratemanagement
runtime_stats
sys
]
routing_schemas_with_partitioning = ['logs']

cdr_role = 'cdr_ro'
cdr_schemas = %w[
auth_log
billing
cdr
event
external_data
reports
rtp_statistics
stats
]

cdr_schemas_with_partitioning = %w[
auth_log
cdr
rtp_statistics
]

SqlCaller::Yeti.transaction do
SqlCaller::Yeti.execute "DROP OWNED BY #{routing_role}"
SqlCaller::Yeti.execute "DROP ROLE IF EXISTS #{routing_role}"
SqlCaller::Yeti.execute "CREATE ROLE #{routing_role} NOLOGIN"

routing_schemas.each do |s|
SqlCaller::Yeti.execute "GRANT USAGE ON SCHEMA #{s} TO #{routing_role}"
SqlCaller::Yeti.execute "GRANT SELECT ON ALL TABLES IN SCHEMA #{s} TO #{routing_role}"
end

routing_schemas_with_partitioning.each do |s|
SqlCaller::Yeti.execute "ALTER DEFAULT PRIVILEGES IN SCHEMA #{s} GRANT SELECT ON TABLES TO #{routing_role}"
end
end

Cdr::Cdr.transaction do
SqlCaller::Cdr.execute "DROP OWNED BY #{cdr_role}"
SqlCaller::Cdr.execute "DROP ROLE IF EXISTS #{cdr_role}"
SqlCaller::Cdr.execute "CREATE ROLE #{cdr_role} NOLOGIN"

cdr_schemas.each do |s|
SqlCaller::Cdr.execute "GRANT USAGE ON SCHEMA #{s} TO #{cdr_role}"
SqlCaller::Cdr.execute "GRANT SELECT ON ALL TABLES IN SCHEMA #{s} TO #{cdr_role}"
end

cdr_schemas_with_partitioning.each do |s|
SqlCaller::Cdr.execute "ALTER DEFAULT PRIVILEGES IN SCHEMA #{s} GRANT SELECT ON TABLES TO #{cdr_role}"
end
end
Loading

0 comments on commit 8373801

Please sign in to comment.