Skip to content

Commit

Permalink
Add realm in requests and qthreads
Browse files Browse the repository at this point in the history
Ref #245
  • Loading branch information
algorys committed Feb 28, 2018
1 parent 0d9e944 commit 358b6c3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
30 changes: 30 additions & 0 deletions alignak_app/backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from alignak_app.items.livesynthesis import LiveSynthesis
from alignak_app.items.service import Service
from alignak_app.items.user import User
from alignak_app.items.realm import Realm

from alignak_app.utils.config import settings

Expand Down Expand Up @@ -286,6 +287,35 @@ def get_period_name(self, endpoint_id):

return 'n/a'

def query_realms_data(self):
"""
Launch a request on ``realm`` endpoint
"""

request_data = Realm.get_request_model()

request = self.get(
request_data['endpoint'],
request_data['params'],
request_data['projection']
)

if request:
realms_list = []
for item in request['_items']:
realm = Realm()

realm.create(
item['_id'],
item,
item['name'],
)
realms_list.append(realm)

if realms_list:
data_manager.update_database('realm', realms_list)

def query_user_data(self):
"""
Launch request for "user" endpoint
Expand Down
2 changes: 2 additions & 0 deletions alignak_app/qthreads/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def run(self): # pragma: no cover
app_backend.query_daemons_data()
elif 'livesynthesis' in self.thread_name:
app_backend.query_livesynthesis_data()
elif 'realm' in self.thread_name:
app_backend.query_realms_data()
elif self.thread_name == 'history':
if self.data:
app_backend.query_history_data(self.data['hostname'], self.data['host_id'])
Expand Down
2 changes: 1 addition & 1 deletion alignak_app/qthreads/threadmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_threads_to_launch(self):
threads_to_launch = []

# Add BackendQThread only if they are not already running
for cur_thread in ['livesynthesis', 'host', 'service', 'user',
for cur_thread in ['livesynthesis', 'host', 'service', 'user', 'realm',
'alignakdaemon', 'notifications', 'history']:
if self.current_thread:
if cur_thread != self.current_thread.thread_name:
Expand Down

0 comments on commit 358b6c3

Please sign in to comment.