def __init__(self, wok_options=None): objstore_dir = os.path.dirname(os.path.abspath(config.get_object_store())) if not os.path.isdir(objstore_dir): os.makedirs(objstore_dir) self.model = GingerModel() super(Ginger, self).__init__(self.model) self.backup = Backup(self.model) self.capabilities = Capabilities(self.model) self.dasddevs = DASDdevs(self.model) self.dasdpartitions = DASDPartitions(self.model) self.filesystems = FileSystems(self.model) self.firmware = Firmware(self.model) self.lvs = LogicalVolumes(self.model) self.partitions = Partitions(self.model) self.powerprofiles = PowerProfiles(self.model) self.pvs = PhysicalVolumes(self.model) self.sensors = Sensors(self.model) self.stgdevs = StorageDevs(self.model) self.users = Users(self.model) self.swaps = Swaps(self.model) self.network = Network(self.model) self.api_schema = json.load(open(os.path.join(os.path.dirname( os.path.abspath(__file__)), 'API.json'))) self.paths = PluginPaths('ginger') self.domain = "ginger" self.messages = messages self.san_adapters = SanAdapters(self.model) self.ibm_sep = Sep(self.model) self.vgs = VolumeGroups(self.model) self.tasks = Tasks(self.model)
def __init__(self): objstore_loc = config.get_object_store() + '_ginger' self._objstore = ObjectStore(objstore_loc) sub_models = [] firmware = FirmwareModel() powerprofiles = PowerProfilesModel() powerprofile = PowerProfileModel() users = UsersModel() user = UserModel() interfaces = InterfacesModel() interface = InterfaceModel() cfginterface = CfginterfaceModel() cfginterfaces = CfginterfacesModel() dasddevs = DASDdevsModel() dasddev = DASDdevModel(objstore=self._objstore) dasdpartitions = DASDPartitionsModel() dasdpartition = DASDPartitionModel() network = NetworkModel() filesystems = FileSystemsModel() filesystem = FileSystemModel() archives = ArchivesModel(objstore=self._objstore) archive = ArchiveModel(objstore=self._objstore) backup = BackupModel(objstore=self._objstore, archives_model=archives, archive_model=archive) san_adapters = SanAdaptersModel() san_adapter = SanAdapterModel() sensors = SensorsModel() ibm_sep = SepModel() subscription = SubscriptionModel() subscriber = SubscribersModel() features = [firmware, backup, dasddevs, dasdpartitions, network, powerprofiles, san_adapters, sensors, ibm_sep, users, filesystems] capabilities = CapabilitiesModel(features) sub_models = [ backup, archives, archive, firmware, interfaces, interface, cfginterface, cfginterfaces, dasddevs, dasddev, dasdpartitions, dasdpartition, network, filesystems, filesystem, powerprofiles, powerprofile, users, user, san_adapters, san_adapter, sensors, ibm_sep, subscription, subscriber, capabilities] super(GingerModel, self).__init__(sub_models)
def __init__(self): objstore_loc = config.get_object_store() + '_ginger' self._objstore = ObjectStore(objstore_loc) sub_models = [] firmware = FirmwareModel() powerprofiles = PowerProfilesModel() powerprofile = PowerProfileModel() users = UsersModel() user = UserModel() interfaces = InterfacesModel() interface = InterfaceModel() cfginterface = CfginterfaceModel() cfginterfaces = CfginterfacesModel() dasddevs = DASDdevsModel() dasddev = DASDdevModel(objstore=self._objstore) dasdpartitions = DASDPartitionsModel() dasdpartition = DASDPartitionModel() network = NetworkModel() filesystems = FileSystemsModel() filesystem = FileSystemModel() archives = ArchivesModel(objstore=self._objstore) archive = ArchiveModel(objstore=self._objstore) backup = BackupModel(objstore=self._objstore, archives_model=archives, archive_model=archive) san_adapters = SanAdaptersModel() san_adapter = SanAdapterModel() sensors = SensorsModel() ibm_sep = SepModel() subscription = SubscriptionModel() subscriber = SubscribersModel() features = [ firmware, backup, dasddevs, dasdpartitions, network, powerprofiles, san_adapters, sensors, ibm_sep, users, filesystems ] capabilities = CapabilitiesModel(features) sub_models = [ backup, archives, archive, firmware, interfaces, interface, cfginterface, cfginterfaces, dasddevs, dasddev, dasdpartitions, dasdpartition, network, filesystems, filesystem, powerprofiles, powerprofile, users, user, san_adapters, san_adapter, sensors, ibm_sep, subscription, subscriber, capabilities ] super(GingerModel, self).__init__(sub_models)
def __init__(self): objstore_loc = wok_config.get_object_store() + '_ginger' self._objstore = ObjectStore(objstore_loc) # Some paths or URI's present in the objectstore have changed after # Wok 2.0.0 release. Check here if a schema upgrade is necessary. upgrade_objectstore_schema(objstore_loc, 'version') kargs = {'objstore': self._objstore} models = get_all_model_instances(__name__, __file__, kargs) # Import task model from Wok instances = get_model_instances('wok.model.tasks') for instance in instances: models.append(instance(**kargs)) super(GingerModel, self).__init__(models)
def __init__(self, wok_options=None): object_store = config.get_object_store() objstore_dir = os.path.dirname(os.path.abspath(object_store)) if not os.path.isdir(objstore_dir): os.makedirs(objstore_dir) self.model = GingerModel() super(Ginger, self).__init__(self.model) for ident, node in sub_nodes.items(): setattr(self, ident, node(self.model)) self.api_schema = json.load(open(os.path.join(os.path.dirname( os.path.abspath(__file__)), 'API.json'))) self.domain = "ginger" self.messages = messages self.paths = PluginPaths('ginger')
def __init__(self, wok_options=None): object_store = config.get_object_store() objstore_dir = os.path.dirname(os.path.abspath(object_store)) if not os.path.isdir(objstore_dir): os.makedirs(objstore_dir) self.model = GingerModel() super(Ginger, self).__init__(self.model) for ident, node in sub_nodes.items(): setattr(self, ident, node(self.model)) self.api_schema = json.load( open( os.path.join(os.path.dirname(os.path.abspath(__file__)), 'API.json'))) self.domain = "ginger" self.messages = messages self.paths = PluginPaths('ginger')
def __init__(self, options): # Launch reverse proxy start_proxy(options) make_dirs = [ os.path.dirname(os.path.abspath(options.access_log)), os.path.dirname(os.path.abspath(options.error_log)), os.path.dirname(os.path.abspath(config.get_object_store())) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) self.configObj = WokConfig() # We'll use the session timeout (= 10 minutes) and the # nginx timeout (= 10 minutes). This monitor isn't involved # in anything other than monitor the timeout of the connection, # thus it is safe to unsubscribe. cherrypy.engine.timeout_monitor.unsubscribe() cherrypy.tools.nocache = cherrypy.Tool('on_end_resource', set_no_cache) cherrypy.tools.wokauth = cherrypy.Tool('before_handler', auth.wokauth) # Setting host to 127.0.0.1. This makes wok run # as a localhost app, inaccessible to the outside # directly. You must go through the proxy. cherrypy.server.socket_host = '127.0.0.1' cherrypy.server.socket_port = options.cherrypy_port max_body_size_in_bytes = eval(options.max_body_size) * 1024 cherrypy.server.max_request_body_size = max_body_size_in_bytes cherrypy.log.access_file = options.access_log cherrypy.log.error_file = options.error_log logLevel = LOGGING_LEVEL.get(options.log_level, logging.DEBUG) dev_env = options.environment != 'production' # Enable cherrypy screen logging if running environment # is not 'production' if dev_env: cherrypy.log.screen = True # Create handler to rotate access log file h = logging.handlers.RotatingFileHandler(options.access_log, 'a', 10000000, 1000) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt) # Add access log file to cherrypy configuration cherrypy.log.access_log.addHandler(h) # Create handler to rotate error log file h = logging.handlers.RotatingFileHandler(options.error_log, 'a', 10000000, 1000) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt) # Add rotating log file to cherrypy configuration cherrypy.log.error_log.addHandler(h) # Handling running mode if not dev_env: cherrypy.config.update({'environment': 'production'}) if hasattr(options, 'model'): model_instance = options.model else: model_instance = model.Model() for ident, node in sub_nodes.items(): if node.url_auth: cfg = self.configObj ident = "/%s" % ident cfg[ident] = {'tools.wokauth.on': True} self.app = cherrypy.tree.mount(WokRoot(model_instance, dev_env), config=self.configObj) self._load_plugins(options) # Terminate proxy when cherrypy server is terminated cherrypy.engine.subscribe('exit', terminate_proxy) cherrypy.lib.sessions.init()
def __init__(self, location=None): self._lock = threading.Semaphore() self._connections = OrderedDict() self.location = location or config.get_object_store() with self._lock: self._init_db()
def setUp(self): objstore_loc = config.get_object_store() + '_ginger' self._objstore = ObjectStore(objstore_loc) self.task_model = TaskModel(objstore=self._objstore)
def __init__(self): def get_instances(module_name): instances = [] module = import_module(module_name) members = inspect.getmembers(module, inspect.isclass) for cls_name, instance in members: if inspect.getmodule(instance) == module and \ cls_name.endswith('Model'): instances.append(instance) return instances objstore_loc = wok_config.get_object_store() + '_ginger' self._objstore = ObjectStore(objstore_loc) # Some paths or URI's present in the objectstore have changed after # Wok 2.0.0 release. Check here if a schema upgrade is necessary. upgrade_objectstore_schema(objstore_loc, 'version') sub_models = [] firmware = FirmwareModel(objstore=self._objstore) firmwareprogress = FirmwareProgressModel(objstore=self._objstore) powerprofiles = PowerProfilesModel() powerprofile = PowerProfileModel() users = UsersModel() user = UserModel() interfaces = InterfacesModel() interface = InterfaceModel() cfginterface = CfginterfaceModel() cfginterfaces = CfginterfacesModel() dasddevs = DASDdevsModel() dasddev = DASDdevModel(objstore=self._objstore) dasdpartitions = DASDPartitionsModel() dasdpartition = DASDPartitionModel() network = NetworkModel() filesystems = FileSystemsModel() filesystem = FileSystemModel() log_volumes = LogicalVolumesModel(objstore=self._objstore) log_volume = LogicalVolumeModel(objstore=self._objstore) partitions = PartitionsModel() partition = PartitionModel(objstore=self._objstore) archives = ArchivesModel(objstore=self._objstore) archive = ArchiveModel(objstore=self._objstore) backup = BackupModel(objstore=self._objstore, archives_model=archives, archive_model=archive) san_adapters = SanAdaptersModel() san_adapter = SanAdapterModel() swaps = SwapsModel(objstore=self._objstore) swap = SwapModel() sysmodules = SysModulesModel() sysmodule = SysModuleModel() sensors = SensorsModel() stgdevs = StorageDevsModel() ibm_sep = SepModel() subscription = SubscriptionModel() subscriber = SubscribersModel() physical_vols = PhysicalVolumesModel(objstore=self._objstore) physical_vol = PhysicalVolumeModel(objstore=self._objstore) vol_groups = VolumeGroupsModel(objstore=self._objstore) vol_group = VolumeGroupModel(objstore=self._objstore) features = [firmware, swaps, backup, network, powerprofiles, san_adapters, sensors, ibm_sep, users, filesystems, dasddevs, dasdpartitions, partitions, physical_vols, vol_groups, log_volumes, stgdevs, firmwareprogress, sysmodules, cfginterfaces] capabilities = CapabilitiesModel(features) config = ConfigModel() sub_models = [ backup, archives, archive, firmware, firmwareprogress, interfaces, interface, cfginterface, cfginterfaces, dasddevs, dasddev, dasdpartitions, dasdpartition, network, filesystems, filesystem, log_volumes, log_volume, partitions, partition, physical_vols, physical_vol, powerprofiles, powerprofile, users, user, san_adapters, san_adapter, sensors, stgdevs, swaps, swap, sysmodules, sysmodule, vol_groups, vol_group, ibm_sep, subscription, subscriber, capabilities, config] # Import task model from Wok kargs = {'objstore': self._objstore} task_model_instances = [] instances = get_instances('wok.model.tasks') for instance in instances: task_model_instances.append(instance(**kargs)) sub_models += task_model_instances super(GingerModel, self).__init__(sub_models)
def __init__(self, options): # Check proxy configuration check_proxy_config() make_dirs = [ os.path.abspath(config.get_log_download_path()), os.path.abspath(configParser.get("logging", "log_dir")), os.path.dirname(os.path.abspath(options.access_log)), os.path.dirname(os.path.abspath(options.error_log)), os.path.dirname(os.path.abspath(config.get_object_store())) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) self.configObj = WokConfig() # We'll use the session timeout (= 10 minutes) and the # nginx timeout (= 10 minutes). This monitor isn't involved # in anything other than monitor the timeout of the connection, # thus it is safe to unsubscribe. cherrypy.engine.timeout_monitor.unsubscribe() cherrypy.tools.nocache = cherrypy.Tool('on_end_resource', set_no_cache) cherrypy.tools.wokauth = cherrypy.Tool('before_handler', auth.wokauth) # Setting host to 127.0.0.1. This makes wok run # as a localhost app, inaccessible to the outside # directly. You must go through the proxy. cherrypy.server.socket_host = '127.0.0.1' cherrypy.server.socket_port = options.cherrypy_port max_body_size_in_bytes = eval(options.max_body_size) * 1024 cherrypy.server.max_request_body_size = max_body_size_in_bytes cherrypy.log.access_file = options.access_log cherrypy.log.error_file = options.error_log logLevel = LOGGING_LEVEL.get(options.log_level, logging.DEBUG) dev_env = options.environment != 'production' # Enable cherrypy screen logging if running environment # is not 'production' if dev_env: cherrypy.log.screen = True # close standard file handlers because we are going to use a # watchedfiled handler, otherwise we will have two file handlers # pointing to the same file, duplicating log enries for handler in cherrypy.log.access_log.handlers[:]: if isinstance(handler, logging.FileHandler): cherrypy.log.access_log.removeHandler(handler) for handler in cherrypy.log.error_log.handlers[:]: if isinstance(handler, logging.FileHandler): cherrypy.log.error_log.removeHandler(handler) # Create handler to access log file h = logging.handlers.WatchedFileHandler(options.access_log, 'a', delay=1) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt) # Add access log file to cherrypy configuration cherrypy.log.access_log.addHandler(h) # Create handler to error log file h = SafeWatchedFileHandler(options.error_log, 'a', delay=1) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt) # Add error log file to cherrypy configuration cherrypy.log.error_log.addHandler(h) # start request logger self.reqLogger = RequestLogger() # Handling running mode if not dev_env: cherrypy.config.update({'environment': 'production'}) if hasattr(options, 'model'): model_instance = options.model else: model_instance = model.Model() for ident, node in sub_nodes.items(): if node.url_auth: cfg = self.configObj ident = "/%s" % ident cfg[ident] = {'tools.wokauth.on': True} self.app = cherrypy.tree.mount(WokRoot(model_instance, dev_env), options.server_root, self.configObj) self._load_plugins(options) cherrypy.lib.sessions.init()
def setUp(self): objstore_loc = config.get_object_store() + '_ginger' self._objstore = ObjectStore(objstore_loc) self.task = TaskModel(objstore=self._objstore)
def setUp(self): objstore_loc = config.get_object_store() + '_ginger' self._objstore = ObjectStore(objstore_loc)
def __init__(self, options): # Launch reverse proxy start_proxy(options) make_dirs = [ os.path.abspath(config.get_log_download_path()), os.path.abspath(configParser.get("logging", "log_dir")), os.path.dirname(os.path.abspath(options.access_log)), os.path.dirname(os.path.abspath(options.error_log)), os.path.dirname(os.path.abspath(config.get_object_store())), ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) self.configObj = WokConfig() # We'll use the session timeout (= 10 minutes) and the # nginx timeout (= 10 minutes). This monitor isn't involved # in anything other than monitor the timeout of the connection, # thus it is safe to unsubscribe. cherrypy.engine.timeout_monitor.unsubscribe() cherrypy.tools.nocache = cherrypy.Tool("on_end_resource", set_no_cache) cherrypy.tools.wokauth = cherrypy.Tool("before_handler", auth.wokauth) # Setting host to 127.0.0.1. This makes wok run # as a localhost app, inaccessible to the outside # directly. You must go through the proxy. cherrypy.server.socket_host = "127.0.0.1" cherrypy.server.socket_port = options.cherrypy_port max_body_size_in_bytes = eval(options.max_body_size) * 1024 cherrypy.server.max_request_body_size = max_body_size_in_bytes cherrypy.log.access_file = options.access_log cherrypy.log.error_file = options.error_log logLevel = LOGGING_LEVEL.get(options.log_level, logging.DEBUG) dev_env = options.environment != "production" # Enable cherrypy screen logging if running environment # is not 'production' if dev_env: cherrypy.log.screen = True # close standard file handlers because we are going to use a # watchedfiled handler, otherwise we will have two file handlers # pointing to the same file, duplicating log enries for handler in cherrypy.log.access_log.handlers[:]: if isinstance(handler, logging.FileHandler): cherrypy.log.access_log.removeHandler(handler) for handler in cherrypy.log.error_log.handlers[:]: if isinstance(handler, logging.FileHandler): cherrypy.log.error_log.removeHandler(handler) # Create handler to access log file h = logging.handlers.WatchedFileHandler(options.access_log, "a", delay=1) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt) # Add access log file to cherrypy configuration cherrypy.log.access_log.addHandler(h) # Create handler to error log file h = SafeWatchedFileHandler(options.error_log, "a", delay=1) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt) # Add error log file to cherrypy configuration cherrypy.log.error_log.addHandler(h) # start request logger self.reqLogger = RequestLogger() # only add logrotate if wok is installed if paths.installed: # redefine logrotate configuration according to wok.conf logrotate_file = os.path.join(paths.logrotate_dir, "wokd.in") with open(logrotate_file) as template: data = template.read() data = Template(data) data = data.safe_substitute(log_dir=configParser.get("logging", "log_dir")) # Write file to be used for nginx. config_file = open(os.path.join(paths.logrotate_dir, "wokd"), "w") config_file.write(data) config_file.close() # Handling running mode if not dev_env: cherrypy.config.update({"environment": "production"}) if hasattr(options, "model"): model_instance = options.model else: model_instance = model.Model() for ident, node in sub_nodes.items(): if node.url_auth: cfg = self.configObj ident = "/%s" % ident cfg[ident] = {"tools.wokauth.on": True} self.app = cherrypy.tree.mount(WokRoot(model_instance, dev_env), config=self.configObj) self._load_plugins(options) # Terminate proxy when cherrypy server is terminated cherrypy.engine.subscribe("exit", terminate_proxy) cherrypy.lib.sessions.init()
def __init__(self, options): # Update config.config with the command line values # So the whole application will have access to accurate values for sec in config.config.sections(): for item in config.config.options(sec): if hasattr(options, item): config.config.set(sec, item, str(getattr(options, item))) # Check proxy configuration if not hasattr(options, 'no_proxy') or not options.no_proxy: check_proxy_config() make_dirs = [ os.path.abspath(config.get_log_download_path()), os.path.abspath(configParser.get("logging", "log_dir")), os.path.dirname(os.path.abspath(options.access_log)), os.path.dirname(os.path.abspath(options.error_log)), os.path.dirname(os.path.abspath(config.get_object_store())), os.path.abspath(config.get_wstokens_dir()) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) self.configObj = WokConfig() # We'll use the session timeout (= 10 minutes) and the # nginx timeout (= 10 minutes). This monitor isn't involved # in anything other than monitor the timeout of the connection, # thus it is safe to unsubscribe. cherrypy.engine.timeout_monitor.unsubscribe() cherrypy.tools.nocache = cherrypy.Tool('on_end_resource', set_no_cache) cherrypy.tools.wokauth = cherrypy.Tool('before_handler', auth.wokauth) # Setting host to 127.0.0.1. This makes wok run # as a localhost app, inaccessible to the outside # directly. You must go through the proxy. cherrypy.server.socket_host = '127.0.0.1' cherrypy.server.socket_port = options.cherrypy_port max_body_size_in_bytes = eval(options.max_body_size) * 1024 cherrypy.server.max_request_body_size = max_body_size_in_bytes cherrypy.log.access_file = options.access_log cherrypy.log.error_file = options.error_log logLevel = LOGGING_LEVEL.get(options.log_level, logging.INFO) dev_env = options.environment != 'production' # Enable cherrypy screen logging if running environment # is not 'production' if dev_env: cherrypy.log.screen = True # close standard file handlers because we are going to use a # watchedfiled handler, otherwise we will have two file handlers # pointing to the same file, duplicating log enries for handler in cherrypy.log.access_log.handlers[:]: if isinstance(handler, logging.FileHandler): cherrypy.log.access_log.removeHandler(handler) for handler in cherrypy.log.error_log.handlers[:]: if isinstance(handler, logging.FileHandler): cherrypy.log.error_log.removeHandler(handler) # set logLevel cherrypy.log.access_log.setLevel(logLevel) cherrypy.log.error_log.setLevel(logLevel) # Create handler to access log file h = logging.handlers.WatchedFileHandler(options.access_log, 'a', delay=1) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt) # Add access log file to cherrypy configuration cherrypy.log.access_log.addHandler(h) # Create handler to error log file h = SafeWatchedFileHandler(options.error_log, 'a', delay=1) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt) # Add error log file to cherrypy configuration cherrypy.log.error_log.addHandler(h) # start request logger self.reqLogger = RequestLogger() # Handling running mode if not dev_env: cherrypy.config.update({'environment': 'production'}) for ident, node in sub_nodes.items(): if node.url_auth: cfg = self.configObj ident = "/%s" % ident cfg[ident] = {'tools.wokauth.on': True} cherrypy.tree.mount(WokRoot(model.Model(), dev_env), options.server_root, self.configObj) self._start_websocket_server() self._load_plugins() cherrypy.lib.sessions.init()
def __init__(self, options): # Launch reverse proxy start_proxy(options) make_dirs = [ os.path.abspath(config.get_log_download_path()), os.path.abspath(configParser.get("logging", "log_dir")), os.path.dirname(os.path.abspath(options.access_log)), os.path.dirname(os.path.abspath(options.error_log)), os.path.dirname(os.path.abspath(config.get_object_store())) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) self.configObj = WokConfig() # We'll use the session timeout (= 10 minutes) and the # nginx timeout (= 10 minutes). This monitor isn't involved # in anything other than monitor the timeout of the connection, # thus it is safe to unsubscribe. cherrypy.engine.timeout_monitor.unsubscribe() cherrypy.tools.nocache = cherrypy.Tool('on_end_resource', set_no_cache) cherrypy.tools.wokauth = cherrypy.Tool('before_handler', auth.wokauth) # Setting host to 127.0.0.1. This makes wok run # as a localhost app, inaccessible to the outside # directly. You must go through the proxy. cherrypy.server.socket_host = '127.0.0.1' cherrypy.server.socket_port = options.cherrypy_port max_body_size_in_bytes = eval(options.max_body_size) * 1024 cherrypy.server.max_request_body_size = max_body_size_in_bytes cherrypy.log.access_file = options.access_log cherrypy.log.error_file = options.error_log logLevel = LOGGING_LEVEL.get(options.log_level, logging.DEBUG) dev_env = options.environment != 'production' # Enable cherrypy screen logging if running environment # is not 'production' if dev_env: cherrypy.log.screen = True # close standard file handlers because we are going to use a # watchedfiled handler, otherwise we will have two file handlers # pointing to the same file, duplicating log enries for handler in cherrypy.log.access_log.handlers[:]: if isinstance(handler, logging.FileHandler): cherrypy.log.access_log.removeHandler(handler) for handler in cherrypy.log.error_log.handlers[:]: if isinstance(handler, logging.FileHandler): cherrypy.log.error_log.removeHandler(handler) # Create handler to access log file h = logging.handlers.WatchedFileHandler(options.access_log, 'a', delay=1) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt) # Add access log file to cherrypy configuration cherrypy.log.access_log.addHandler(h) # Create handler to error log file h = SafeWatchedFileHandler(options.error_log, 'a', delay=1) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt) # Add error log file to cherrypy configuration cherrypy.log.error_log.addHandler(h) # start request logger self.reqLogger = RequestLogger() # only add logrotate if wok is installed if paths.installed: # redefine logrotate configuration according to wok.conf data = Template(LOGROTATE_TEMPLATE) data = data.safe_substitute( log_dir=configParser.get("logging", "log_dir"), log_size=configParser.get("logging", "log_size") ) # Write file to be used for nginx. config_file = open(os.path.join(paths.logrotate_dir, "wokd"), "w") config_file.write(data) config_file.close() # Handling running mode if not dev_env: cherrypy.config.update({'environment': 'production'}) if hasattr(options, 'model'): model_instance = options.model else: model_instance = model.Model() for ident, node in sub_nodes.items(): if node.url_auth: cfg = self.configObj ident = "/%s" % ident cfg[ident] = {'tools.wokauth.on': True} self.app = cherrypy.tree.mount(WokRoot(model_instance, dev_env), config=self.configObj) self._load_plugins(options) # Terminate proxy when cherrypy server is terminated cherrypy.engine.subscribe('exit', terminate_proxy) cherrypy.lib.sessions.init()