[CORD-1362] Remove old config module
Change-Id: Ic463174e1235fd732411795e52ff8570863f234d
diff --git a/containers/xos/Dockerfile.synchronizer-base b/containers/xos/Dockerfile.synchronizer-base
index 66cd3da..325f831 100644
--- a/containers/xos/Dockerfile.synchronizer-base
+++ b/containers/xos/Dockerfile.synchronizer-base
@@ -2,7 +2,6 @@
FROM xosproject/xos-client:candidate
COPY xos/synchronizers/new_base /opt/xos/synchronizers/new_base
-COPY xos/xos/config.py /opt/xos/xos/config.py
COPY xos/xos/logger.py /opt/xos/xos/logger.py
COPY xos/xos/xml_util.py /opt/xos/xos/xml_util.py
COPY xos/xos/__init__.py /opt/xos/xos/__init__.py
diff --git a/lib/xos-config/tests/config_test.py b/lib/xos-config/tests/config_test.py
index b98b817..36869b3 100644
--- a/lib/xos-config/tests/config_test.py
+++ b/lib/xos-config/tests/config_test.py
@@ -133,7 +133,15 @@
"file": "/var/log/xos.log",
})
- def _test_get_missing_param(self):
+ def test_get_config_file(self):
+ """
+ [XOS-Config] Should return the config file in use
+ """
+ Config.init(sample_conf)
+ res = Config.get_config_file()
+ self.assertEqual(res, sample_conf)
+
+ def test_get_missing_param(self):
"""
[XOS-Config] Should raise reading a missing param
"""
diff --git a/lib/xos-config/xosconfig/config.py b/lib/xos-config/xosconfig/config.py
index 3e0482d..db3b5c1 100644
--- a/lib/xos-config/xosconfig/config.py
+++ b/lib/xos-config/xosconfig/config.py
@@ -8,6 +8,7 @@
DEFAULT_CONFIG_FILE = "/opt/xos/xos_config.yaml"
DEFAULT_CONFIG_SCHEMA = 'xos-config-schema.yaml'
INITIALIZED = False
+CONFIG_FILE = None
CONFIG = {}
class Config:
@@ -24,6 +25,7 @@
global INITIALIZED
global CONFIG
+ global CONFIG_FILE
# the config module can be initialized only one
if INITIALIZED:
raise Exception('[XOS-Config] Module already initialized')
@@ -44,9 +46,15 @@
if Config.get_cli_param(sys.argv):
config_schema = Config.get_cli_param(sys.argv)
+
+ CONFIG_FILE = config_file
CONFIG = Config.read_config(config_file, config_schema)
@staticmethod
+ def get_config_file():
+ return CONFIG_FILE
+
+ @staticmethod
def clear():
global INITIALIZED
INITIALIZED = False
diff --git a/xos/core/dashboard/views/home.py b/xos/core/dashboard/views/home.py
index f72be81..041ca4a 100644
--- a/xos/core/dashboard/views/home.py
+++ b/xos/core/dashboard/views/home.py
@@ -48,8 +48,10 @@
return self.singleDashboardView(request, name, context)
def readTemplate(self, fn):
- TEMPLATE_DIRS = [XOS_DIR + "/templates/admin/dashboard/",
- XOS_DIR + "/core/xoslib/dashboards/"]
+ dashboards_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../')
+ xoslib_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../xoslib/dashboards/')
+ TEMPLATE_DIRS = [dashboards_dir,
+ xoslib_dir]
for template_dir in TEMPLATE_DIRS:
pathname = os.path.join(template_dir, fn) + ".html"
diff --git a/xos/core/dashboard/views/view_common.py b/xos/core/dashboard/views/view_common.py
index 478f4d3..e1cb18b 100644
--- a/xos/core/dashboard/views/view_common.py
+++ b/xos/core/dashboard/views/view_common.py
@@ -17,7 +17,6 @@
from operator import itemgetter, attrgetter
import traceback
import math
-from xos.config import Config, XOS_DIR
def getDashboardContext(user, context={}, tableFormat = False):
context = {}
diff --git a/xos/core/views/serviceGraph.py b/xos/core/views/serviceGraph.py
deleted file mode 100644
index c6cdf56..0000000
--- a/xos/core/views/serviceGraph.py
+++ /dev/null
@@ -1,50 +0,0 @@
-from django.http import HttpResponse
-from django.views.generic import TemplateView, View
-from django import template
-from core.models import *
-from core.dashboard.views import DashboardDynamicView
-from xos.config import XOS_DIR
-import json
-import os
-import time
-import tempfile
-
-
-class ServiceGridView(TemplateView):
-
- head_template = r"""{% extends "admin/dashboard/dashboard_base.html" %}
- {% load admin_static %}
- {% block content %}
- """
-
- tail_template = r"{% endblock %}"
-
- def readTemplate(self, fn):
- TEMPLATE_DIRS = [XOS_DIR + "/templates/admin/dashboard/",
- XOS_DIR + "/core/xoslib/dashboards/"]
-
- for template_dir in TEMPLATE_DIRS:
- pathname = os.path.join(template_dir, fn) + ".html"
- if os.path.exists(pathname):
- break
- else:
- return "failed to find %s in %s" % (fn, TEMPLATE_DIRS)
-
- template = open(pathname, "r").read()
- return template
-
- def get(self, request, name="root", *args, **kwargs):
-
- dash = DashboardView.objects.get(name="Services Grid")
-
- gridTemplate = self.readTemplate(dash.url[9:])
-
- t = template.Template(self.head_template + gridTemplate + self.tail_template)
-
- response_kwargs = {}
- response_kwargs.setdefault('content_type', self.content_type)
-
- return self.response_class(
- request=request,
- template=t,
- **response_kwargs)
diff --git a/xos/manage.py b/xos/manage.py
index 48695f0..028eb4f 100644
--- a/xos/manage.py
+++ b/xos/manage.py
@@ -12,14 +12,4 @@
os.system("/opt/xos/tools/xos-manage makemigrations")
sys.argv.remove("--makemigrations")
-# if "--nomodelpolicy" in sys.argv:
-# import synchronizers.model_policy as model_policy
-# model_policy.EnableModelPolicy(False)
-# sys.argv.remove("--nomodelpolicy")
-
- if "--noobserver" in sys.argv:
- import synchronizers.base as observer
- observer.EnableObserver(False)
- sys.argv.remove("--noobserver")
-
execute_from_command_line(sys.argv)
diff --git a/xos/synchronizers/new_base/ansible_helper.py b/xos/synchronizers/new_base/ansible_helper.py
index 2eca993..454b882 100644
--- a/xos/synchronizers/new_base/ansible_helper.py
+++ b/xos/synchronizers/new_base/ansible_helper.py
@@ -15,6 +15,7 @@
from xosconfig import Config
from xos.logger import observer_logger as logger
from multiprocessing import Process, Queue
+from xosconfig import Config
step_dir = Config.get("steps_dir")
@@ -54,7 +55,8 @@
args = {"ansible_hosts": ansible_hosts,
"ansible_config": ansible_config,
"fqp": fqp,
- "opts": opts}
+ "opts": opts,
+ "config_file": Config.get_config_file()}
keep_temp_files = Config.get("keep_temp_files")
diff --git a/xos/synchronizers/new_base/ansible_main.py b/xos/synchronizers/new_base/ansible_main.py
index 2df23b9..00def66 100644
--- a/xos/synchronizers/new_base/ansible_main.py
+++ b/xos/synchronizers/new_base/ansible_main.py
@@ -3,6 +3,7 @@
import sys
#import json
import traceback
+from xosconfig import Config
sys.path.append("/opt/xos")
@@ -44,6 +45,9 @@
result_fn = sys.argv[2]
args = pickle.loads(open(input_fn).read())
+
+ Config.init(args['config_file'], 'synchronizer-config-schema.yaml')
+
ansible_hosts = args["ansible_hosts"]
ansible_config = args["ansible_config"]
fqp = args["fqp"]
diff --git a/xos/synchronizers/new_base/xos-policy.py b/xos/synchronizers/new_base/xos-policy.py
index d2630ec..3ed8668 100644
--- a/xos/synchronizers/new_base/xos-policy.py
+++ b/xos/synchronizers/new_base/xos-policy.py
@@ -9,60 +9,20 @@
"""
import os
-import argparse
import sys
sys.path.append('/opt/xos')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings")
-from xos.config import Config, DEFAULT_CONFIG_FN
+from xosconfig import Config
from xos.logger import Logger, logging, logger
import time
from synchronizers.new_base.model_policy_loop import XOSPolicyEngine
from synchronizers.new_base.modelaccessor import *
-config = Config()
-
logger = Logger(level=logging.INFO)
-# after http://www.erlenstar.demon.co.uk/unix/faq_2.html
-def daemon():
- """Daemonize the current process."""
- if os.fork() != 0: os._exit(0)
- os.setsid()
- if os.fork() != 0: os._exit(0)
- os.umask(0)
- devnull = os.open(os.devnull, os.O_RDWR)
- os.dup2(devnull, 0)
- # xxx fixme - this is just to make sure that nothing gets stupidly lost - should use devnull
- logdir=os.path.dirname(config.observer_logfile)
- # when installed in standalone we might not have httpd installed
- if not os.path.isdir(logdir): os.mkdir(logdir)
- crashlog = os.open('%s'%config.observer_logfile, os.O_RDWR | os.O_APPEND | os.O_CREAT, 0644)
- os.dup2(crashlog, 1)
- os.dup2(crashlog, 2)
-
- if hasattr(config, "observer_pidfile"):
- pidfile = config.get("observer_pidfile")
- else:
- pidfile = "/var/run/xosobserver.pid"
- try:
- file(pidfile,"w").write(str(os.getpid()))
- except:
- print "failed to create pidfile %s" % pidfile
-
def main():
- # Generate command line parser
- parser = argparse.ArgumentParser(usage='%(prog)s [options]')
- parser.add_argument('-d', '--daemon', dest='daemon', action='store_true', default=False,
- help='Run as daemon.')
- # smbaker: util/config.py parses sys.argv[] directly to get config file name; include the option here to avoid
- # throwing unrecognized argument exceptions
- parser.add_argument('-C', '--config', dest='config_file', action='store', default=DEFAULT_CONFIG_FN,
- help='Name of config file.')
- args = parser.parse_args()
-
- if args.daemon: daemon()
models_active = False
wait = False
@@ -81,7 +41,7 @@
time.sleep(60) # Safety factor, seeing that we stumbled waiting for the data model to come up.
# start model policies thread
- policies_dir = Config().observer_model_policies_dir
+ policies_dir = Config.get("model_policies_dir")
XOSPolicyEngine(policies_dir=policies_dir).run()
diff --git a/xos/synchronizers/new_base/xos-synchronizer.py b/xos/synchronizers/new_base/xos-synchronizer.py
index 0bb45fa..b48fcdf 100644
--- a/xos/synchronizers/new_base/xos-synchronizer.py
+++ b/xos/synchronizers/new_base/xos-synchronizer.py
@@ -36,5 +36,4 @@
backend.run()
if __name__ == '__main__':
-
main()
diff --git a/xos/tools/apigen/synchronizer.template.txt b/xos/tools/apigen/synchronizer.template.txt
deleted file mode 100644
index 67f3ca1..0000000
--- a/xos/tools/apigen/synchronizer.template.txt
+++ /dev/null
@@ -1,69 +0,0 @@
-{% for app,files in generator.apps.items() %}
-{% for file,models in files.items() %}
-{% for m in models %}
-# This file implements the synchronization of the {{ m.class_name }} model
-# TODO (see below):
-
-import os
-import base64
-import socket
-from django.db.models import F, Q
-from xos.config import Config
-from synchronizers.base.syncstep import SyncStep
-from {{app}}.models.{{ file }} import {{ m.class_name.title }}
-from synchronizers.base.ansible import *
-from synchronizers.base.syncstep import *
-from xos.logger import observer_logger as logger
-
-class Sync{{m.camel.title}}(SyncStep):
- # The model synchronized
- provides=[{{m.class_name.title()}}]
- # How often do you want this to run. 0 means immediately following changes to the model
- requested_interval=0
- # The model in which changes trigger this module
- observes={{m.class_name}}
- # The Ansible recipe that does the bulk of the synchronization (hopefully)
- playbook='sync_{{m.class_name}}.yaml'
-
- # 1. Populate a data structure to pass into your ansible recipe, based on the data model.
- def map_sync_inputs(self, {{ m.class_name }}):
- fields = {
- {% for f in m.fields %}'{{f.name}}': {{f.name}},
- {% endfor %}
- }
- return fields
-
- # 2. Store the result of the operation in the model
- def map_sync_outputs(self, {{ m.class_name }}, res):
- // Store the output of res in the {{m.class_name}} object
- return
-
- # 3. Populate the data structure that identifies objects to delete
- def map_delete_inputs(self, {{ m.class_name }}, res):
- fields = {
- {% for f in m.fields %}'{{f.name}}': {{f.name}},
- {% endfor %}
- 'delete':True
- }
- return fields
-
-
-+++ Sync{{ m.class_name }}.py
----
-- hosts: 127.0.0.1
- connection: local
- tasks:
- - task_1:
- {% for f in m.fields %}
- {{f.name}}: {{ '{{' }}{{f.name}}{{ '}}' }}
- {% endfor %}
- {{ '{%' }} if delete {{ '%}' }}
- state: absent
- {{ '{%' }} else {{ '%}' }}
- state: present
- {{ '{%' }} endif {{ '%}' }}
- {{ '{%' }} endif {{ '%}' }}
-+++ Sync{{ m.class_name }}.yaml
-{% endfor %}
-{% endfor %}
-{% endfor %}
diff --git a/xos/tosca/tests/observertest.py b/xos/tosca/tests/observertest.py
deleted file mode 100644
index 4c8d5df..0000000
--- a/xos/tosca/tests/observertest.py
+++ /dev/null
@@ -1,97 +0,0 @@
-from basetest import *
-
-import logging
-import StringIO
-import subprocess
-import sys
-
-from synchronizers.base.event_loop import XOSObserver
-from synchronizers.model_policy import run_policy_once
-from xos.config import set_override
-from xos.logger import Logger, observer_logger
-
-class BaseObserverToscaTest(BaseToscaTest):
- hide_observer_output = True
-
- def __init__(self):
- super(BaseObserverToscaTest, self).__init__()
-
- def get_usable_deployment(self):
- return "MyDeployment"
-
- def get_usable_controller(self):
- return "CloudLab"
-
- def ensure_observer_not_running(self):
- ps_output = subprocess.Popen("ps -elfy", shell=True, stdout=subprocess.PIPE).stdout.read()
- if "/opt/xos/xos-observer.py" in ps_output:
- print >> sys.stderr, "an observer is still running"
- print >> sys.stderr, "please stop it, for example 'supervisorctl stop observer'"
- sys.exit(-1)
-
- def log_to_memory(self):
- logStream = StringIO.StringIO()
- handler = logging.StreamHandler(stream=logStream)
- handler.setLevel(logging.DEBUG)
- handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
-
- loggername = Logger().loggername
- log = logging.getLogger(loggername)
- for hdlr in log.handlers[:]:
- log.removeHandler(hdlr)
- log.addHandler(handler)
- log.propagate = False
-
- log = observer_logger.logger
- for hdlr in log.handlers[:]:
- log.removeHandler(hdlr)
- log.addHandler(handler)
- log.propagate = False
-
- self.logStream = logStream
-
- def hide_output(self):
- set_override("observer_console_print", False)
- self.log_to_memory()
- sys.stdout = self.logStream
- sys.stderr = self.logStream
-
- def restore_output(self):
- sys.stdout = sys.__stdout__
- sys.stderr = sys.__stderr__
-
- if not self.hide_observer_output:
- print self.logStream.getvalue()
-
- def save_output(self, what, fn):
- file(fn,"w").write(self.logStream.getvalue())
- print >> sys.__stdout__," (%s log saved to %s)" % (what, fn)
-
- def run_model_policy(self, save_output=None):
- self.ensure_observer_not_running()
-
- self.hide_output()
- try:
- print ">>>>> run model_policies"
- run_policy_once()
- print ">>>>> done model_policies"
- if save_output:
- self.save_output("model_policy",save_output)
- finally:
- self.restore_output()
-
- def run_observer(self, save_output=None):
- self.ensure_observer_not_running()
- self.log_to_memory()
-
- self.hide_output()
- try:
- print ">>>>> run observer"
- observer = XOSObserver()
- observer.run_once()
- print ">>>>> done observer"
- if save_output:
- self.save_output("observer",save_output)
- finally:
- self.restore_output()
-
diff --git a/xos/xos/config.py b/xos/xos/config.py
deleted file mode 100644
index 154ba20..0000000
--- a/xos/xos/config.py
+++ /dev/null
@@ -1,280 +0,0 @@
-#!/usr/bin/env python
-import sys
-import os
-import time
-import ConfigParser
-import tempfile
-import codecs
-from StringIO import StringIO
-from xml_util import Xml
-
-default_config = \
-"""
-"""
-
-XOS_DIR = "/opt/xos"
-DEFAULT_CONFIG_FN = os.path.join(XOS_DIR, "xos_configuration/")
-
-# warning for now, remove once we're sure everyone has made the change
-if (os.path.exists("/opt/planetstack/plstackapi_config") and (not os.path.exists(DEFAULT_CONFIG_FN))):
- print >> sys.stderr, "WARNING: did you forget to rename plstackapi_config to xos_config ??"
-
-def isbool(v):
- return v.lower() in ("true", "false")
-
-def str2bool(v):
- return v.lower() in ("true", "1")
-
-# allow the test framework to apply global overrides to the config framework
-override = {}
-def set_override(name, value):
- override[name] = value
-
-class Config:
-
- def __init__(self, config_file=None):
- if (config_file==None):
- config_file = self.get_config_fn()
-
- self._files = []
- self.config_path = os.path.dirname(config_file)
- self.config = ConfigParser.ConfigParser()
- self.filename = config_file
- if not os.path.isfile(self.filename) and not os.path.isdir(self.filename):
- self.create(self.filename)
- self.load(self.filename)
-
- def get_config_fn(self):
- # Look for "-C <something>" to get the
- # name of the config file. Using a real OptionParser here is
- # problematic as it will throw 'no such option' errors for options
- # that it does not understand.
-
- last = None
- for arg in sys.argv:
- if (last=="-C"):
- return arg
- last = arg
-
- return DEFAULT_CONFIG_FN
-
- def _header(self):
- header = """
-DO NOT EDIT. This file was automatically generated at
-%s from:
-
-%s
-""" % (time.asctime(), os.linesep.join(self._files))
-
- # Get rid of the surrounding newlines
- return header.strip().split(os.linesep)
-
- def create(self, filename):
- if not os.path.exists(os.path.dirname(filename)):
- os.makedirs(os.path.dirname(filename))
- configfile = open(filename, 'w')
- configfile.write(default_config)
- configfile.close()
-
-
- def load(self, filename):
- if filename:
- try:
- if os.path.isdir(filename):
- config_list = list(sorted(os.listdir(filename)))
- config_list = [x for x in config_list if not x.endswith(".md")]
- if "xos_common_config" in config_list:
- # move xos_common_config to the front of the list
- config_list.remove("xos_common_config")
- config_list=["xos_common_config"] + config_list
- config_list = [os.path.join(filename, s) for s in config_list]
- self.config.read(config_list)
- else:
- self.config.read(filename)
- except ConfigParser.MissingSectionHeaderError:
- if filename.endswith('.xml'):
- self.load_xml(filename)
- else:
- self.load_shell(filename)
- self._files.append(filename)
- self.set_attributes()
-
- def load_xml(self, filename):
- xml = XML(filename)
- categories = xml.xpath('//configuration/variables/category')
- for category in categories:
- section_name = category.get('id')
- if not self.config.has_section(section_name):
- self.config.add_section(section_name)
- options = category.xpath('./variablelist/variable')
- for option in options:
- option_name = option.get('id')
- value = option.xpath('./value')[0].text
- if not value:
- value = ""
- self.config.set(section_name, option_name, value)
-
- def load_shell(self, filename):
- f = open(filename, 'r')
- for line in f:
- try:
- if line.startswith('#'):
- continue
- parts = line.strip().split("=")
- if len(parts) < 2:
- continue
- option = parts[0]
- value = parts[1].replace('"', '').replace("'","")
- section, var = self.locate_varname(option, strict=False)
- if section and var:
- self.set(section, var, value)
- except:
- pass
- f.close()
-
- def locate_varname(self, varname, strict=True):
- varname = varname.lower()
- sections = self.config.sections()
- section_name = ""
- var_name = ""
- for section in sections:
- if varname.startswith(section.lower()) and len(section) > len(section_name):
- section_name = section.lower()
- var_name = varname.replace(section_name, "")[1:]
- if strict and not self.config.has_option(section_name, var_name):
- raise ConfigParser.NoOptionError(var_name, section_name)
- return (section_name, var_name)
-
- def set_attributes(self):
- sections = self.config.sections()
- for section in sections:
- for item in self.config.items(section):
- name = "%s_%s" % (section, item[0])
- value = item[1]
- if isbool(value):
- value = str2bool(value)
- elif value.isdigit():
- value = int(value)
- setattr(self, name, value)
- setattr(self, name.upper(), value)
-
-
- def verify(self, config1, config2, validate_method):
- return True
-
- def validate_type(self, var_type, value):
- return True
-
- @staticmethod
- def is_xml(config_file):
- try:
- x = Xml(config_file)
- return True
- except:
- return False
-
- @staticmethod
- def is_ini(config_file):
- try:
- c = ConfigParser.ConfigParser()
- c.read(config_file)
- return True
- except ConfigParser.MissingSectionHeaderError:
- return False
-
-
- def dump(self, sections = []):
- sys.stdout.write(output_python())
-
- def output_python(self, encoding = "utf-8"):
- buf = codecs.lookup(encoding)[3](StringIO())
- buf.writelines(["# " + line + os.linesep for line in self._header()])
-
- for section in self.sections():
- buf.write("[%s]%s" % (section, os.linesep))
- for (name,value) in self.items(section):
- buf.write("%s=%s%s" % (name,value,os.linesep))
- buf.write(os.linesep)
- return buf.getvalue()
-
- def output_shell(self, show_comments = True, encoding = "utf-8"):
- """
- Return variables as a shell script.
- """
-
- buf = codecs.lookup(encoding)[3](StringIO())
- buf.writelines(["# " + line + os.linesep for line in self._header()])
-
- for section in self.sections():
- for (name,value) in self.items(section):
- # bash does not have the concept of NULL
- if value:
- option = "%s_%s" % (section.upper(), name.upper())
- if isbool(value):
- value = str(str2bool(value))
- elif not value.isdigit():
- value = '"%s"' % value
- buf.write(option + "=" + value + os.linesep)
- return buf.getvalue()
-
- def output_php(self, encoding = "utf-8"):
- """
- Return variables as a PHP script.
- """
-
- buf = codecs.lookup(encoding)[3](StringIO())
- buf.write("<?php" + os.linesep)
- buf.writelines(["// " + line + os.linesep for line in self._header()])
-
- for section in self.sections():
- for (name,value) in self.items(section):
- option = "%s_%s" % (section, name)
- buf.write(os.linesep)
- buf.write("// " + option + os.linesep)
- if value is None:
- value = 'NULL'
- buf.write("define('%s', %s);" % (option, value) + os.linesep)
-
- buf.write("?>" + os.linesep)
-
- return buf.getvalue()
-
- def output_xml(self, encoding = "utf-8"):
- pass
-
- def output_variables(self, encoding="utf-8"):
- """
- Return list of all variable names.
- """
-
- buf = codecs.lookup(encoding)[3](StringIO())
- for section in self.sections():
- for (name,value) in self.items(section):
- option = "%s_%s" % (section,name)
- buf.write(option + os.linesep)
-
- return buf.getvalue()
- pass
-
- def write(self, filename=None):
- if not filename:
- filename = self.filename
- configfile = open(filename, 'w')
- self.config.write(configfile)
-
- def save(self, filename=None):
- self.write(filename)
-
- def __getattr__(self, attr):
- if attr in override:
- return override[attr]
- return getattr(self.config, attr)
-
-if __name__ == '__main__':
- filename = None
- if len(sys.argv) > 1:
- filename = sys.argv[1]
- config = Config(filename)
- else:
- config = Config()
- config.dump()
diff --git a/xos/xos/logger.py b/xos/xos/logger.py
index 95da9ad..f891d52 100644
--- a/xos/xos/logger.py
+++ b/xos/xos/logger.py
@@ -30,8 +30,7 @@
import logging
import logging.handlers
import logstash
-# from xosconfig import Config
-from xos.config import Config
+from xosconfig import Config
CRITICAL = logging.CRITICAL
ERROR = logging.ERROR
@@ -48,7 +47,7 @@
# Logstash config
try:
- logstash_host, logstash_port = 'cordloghost:5617'.split(':') #Config.get("logging.logstash_hostport").split(':')
+ logstash_host, logstash_port = Config.get("logging.logstash_hostport").split(':')
logstash_handler = logstash.LogstashHandler(
logstash_host, int(logstash_port), version=1)
# always log at DEBUG level to logstash
@@ -59,10 +58,10 @@
# default is to locate loggername from the logfile if avail.
if not logfile:
- logfile = '/var/log/xos.log' #Config.get("logging.file")
+ logfile = Config.get("logging.file")
# allow config-file override of console/logfile level
- level_str = 'info' #Config.get("logging.level")
+ level_str = Config.get("logging.level")
if level_str:
level_str = level_str.lower()
@@ -150,7 +149,7 @@
def extract_context(self, cur):
try:
- observer_name = Config().observer_name #Config.get("name")
+ observer_name = Config.get("name")
cur['synchronizer_name'] = observer_name
except:
pass
diff --git a/xos/xos/urls.py b/xos/xos/urls.py
index 2284c63..6f5b524 100644
--- a/xos/xos/urls.py
+++ b/xos/xos/urls.py
@@ -7,8 +7,6 @@
# This is the generated API
from xosapi import *
-from core.views.serviceGraph import ServiceGridView
-
# from services.vbbu.view import *
from core.views.mcordview import *
# from core.views.analytics import AnalyticsAjaxView
@@ -47,10 +45,6 @@
urlpatterns = patterns(
'',
- url(r'^mcord', MCordView.as_view(), name='mcord'),
-
- url(r'^serviceGrid', ServiceGridView.as_view(), name='serviceGrid'),
-
# url(r'^docs/', include('rest_framework_swagger.urls')),
# Uncomment the admin/doc line below to enable admin documentation: