Skip to content

Commit 7f412b6

Browse files
committed
Move default server roles out of Settings
1 parent f25fb94 commit 7f412b6

File tree

4 files changed

+28
-25
lines changed

4 files changed

+28
-25
lines changed

app/models/miq_server/role_management.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ def set_active_role_flags
4848
end
4949

5050
def sync_assigned_roles
51-
self.role = ::Settings.server.role
51+
self.role = ::Settings.server.role if ::Settings.server.role
5252
end
5353

5454
def ensure_default_roles
55-
MiqServer.my_server.add_settings_for_resource(:server => {:role => ENV["MIQ_SERVER_DEFAULT_ROLES"]}) if role.blank? && ENV["MIQ_SERVER_DEFAULT_ROLES"].present?
56-
sync_assigned_roles
55+
return if role.present?
56+
57+
self.server_role_names = ServerRole.default_roles.pluck(:name)
58+
add_settings_for_resource(:server => {:role => server_role_names.join(",")})
5759
end
5860

5961
def deactivate_all_roles

app/models/server_role.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class ServerRole < ApplicationRecord
44

55
validates :name, :presence => true, :uniqueness_when_changed => true
66

7+
scope :default_roles, -> { where(:default => true).order(:name) }
78
scope :database_roles, -> { where(:role_scope => 'database').order(:name) }
89
scope :region_roles, -> { where(:role_scope => 'region').order(:name) }
910
scope :zone_roles, -> { where(:role_scope => 'zone').order(:name) }

config/settings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@
947947
:ui_login:
948948
:limit: 5
949949
:period: 20.seconds
950-
:role: database_operations,event,reporting,scheduler,smartstate,ems_operations,ems_inventory,ems_metrics_collector,ems_metrics_coordinator,ems_metrics_processor,notifier,user_interface,remote_console,web_services,automate
950+
:role:
951951
:server_dequeue_frequency: 5.seconds
952952
:server_log_frequency: 5.minutes
953953
:server_log_timings_threshold: 1.second

db/fixtures/server_roles.csv

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
name,description,max_concurrent,external_failover,role_scope
2-
automate,Automation Engine,0,false,region
3-
database_operations,Database Operations,0,false,region
4-
database_owner,Database Owner,1,false,database
5-
embedded_ansible,Embedded Ansible,0,false,region
6-
ems_inventory,Provider Inventory,1,false,zone
7-
ems_metrics_collector,Capacity & Utilization Data Collector,0,false,zone
8-
ems_metrics_coordinator,Capacity & Utilization Coordinator,1,false,zone
9-
ems_metrics_processor,Capacity & Utilization Data Processor,0,false,zone
10-
ems_operations,Provider Operations,0,false,zone
11-
event,Event Monitor,1,false,zone
12-
git_owner,Git Repositories Owner,1,false,zone
13-
internet_connectivity,Internet Connectivity,0,false,region
14-
notifier,Notifier,1,false,region
15-
reporting,Reporting,0,false,region
16-
scheduler,Scheduler,1,false,region
17-
smartproxy,SmartProxy,0,false,zone
18-
smartstate,SmartState Analysis,0,false,zone
19-
user_interface,User Interface,0,false,region
20-
remote_console,Remote Consoles,0,false,region
21-
web_services,Web Services,0,false,region
1+
name,description,max_concurrent,external_failover,role_scope,default
2+
automate,Automation Engine,0,false,region,true
3+
database_operations,Database Operations,0,false,region,true
4+
database_owner,Database Owner,1,false,database,false
5+
embedded_ansible,Embedded Ansible,0,false,region,false
6+
ems_inventory,Provider Inventory,1,false,zone,true
7+
ems_metrics_collector,Capacity & Utilization Data Collector,0,false,zone,true
8+
ems_metrics_coordinator,Capacity & Utilization Coordinator,1,false,zone,true
9+
ems_metrics_processor,Capacity & Utilization Data Processor,0,false,zone,true
10+
ems_operations,Provider Operations,0,false,zone,true
11+
event,Event Monitor,1,false,zone,event
12+
git_owner,Git Repositories Owner,1,false,zone,false
13+
internet_connectivity,Internet Connectivity,0,false,region,false
14+
notifier,Notifier,1,false,region,true
15+
reporting,Reporting,0,false,region,true
16+
scheduler,Scheduler,1,false,region,true
17+
smartproxy,SmartProxy,0,false,zone,false
18+
smartstate,SmartState Analysis,0,false,zone,true
19+
user_interface,User Interface,0,false,region,true
20+
remote_console,Remote Consoles,0,false,region,true
21+
web_services,Web Services,0,false,region,true

0 commit comments

Comments
 (0)