From b754fc3136a54eabdcff112d8862215ed2da697d Mon Sep 17 00:00:00 2001 From: Suman Chakravartula Date: Mon, 1 Feb 2016 15:33:42 -0800 Subject: [PATCH] pass the optional config dictionary while checking service status. #1024 --- src/rockstor/smart_manager/data_collector.py | 19 +++++++++++++------ .../smart_manager/views/active_directory.py | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/rockstor/smart_manager/data_collector.py b/src/rockstor/smart_manager/data_collector.py index e5f406a66..5fefda993 100644 --- a/src/rockstor/smart_manager/data_collector.py +++ b/src/rockstor/smart_manager/data_collector.py @@ -3,6 +3,7 @@ import psutil import re +import json import gevent from socketio.server import SocketIOServer from socketio import socketio_manage @@ -241,14 +242,20 @@ def recv_disconnect(self): self.disconnect() def send_service_statuses(self): - # Iterate through the collection and assign the values accordingly - services = [s.name for s in Service.objects.all()] while True: data = {} - for service in services: - data[service] = {} - output, error, return_code = service_status(service) - data[service]['running'] = return_code + for service in Service.objects.all(): + config = None + if (service.config is not None): + try: + config = json.loads(service.config) + except Exception, e: + logger.error('Exception while loading config of ' + 'Service(%s): %s' % + (service.name, e.__str__())) + data[service.name] = {} + output, error, return_code = service_status(service.name, config=config) + data[service.name]['running'] = return_code self.emit('services:get_services', { 'data': data, 'key': 'services:get_services' diff --git a/src/rockstor/smart_manager/views/active_directory.py b/src/rockstor/smart_manager/views/active_directory.py index 9aab0357c..154e32ccb 100644 --- a/src/rockstor/smart_manager/views/active_directory.py +++ b/src/rockstor/smart_manager/views/active_directory.py @@ -16,6 +16,7 @@ along with this program. If not, see . """ +import socket from rest_framework.response import Response from storageadmin.util import handle_exception from system.services import (toggle_auth_service, systemctl) @@ -40,7 +41,6 @@ def _ntp_check(self, request): @staticmethod def _resolve_check(domain, request): - import socket try: res = socket.gethostbyname(domain) except Exception, e: