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() network = NetworkModel() 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() sub_models = [ backup, archives, archive, firmware, interfaces, interface, network, powerprofiles, powerprofile, users, user, san_adapters, san_adapter, sensors, ibm_sep] 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() network = NetworkModel() 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() features = [ firmware, backup, network, powerprofiles, san_adapters, sensors, ibm_sep, users ] capabilities = CapabilitiesModel(features) sub_models = [ backup, archives, archive, firmware, interfaces, interface, network, powerprofiles, powerprofile, users, user, san_adapters, san_adapter, sensors, ibm_sep, capabilities ] super(GingerModel, self).__init__(sub_models)
def setUpModule(): global test_server, model, host, port, ssl_port, objstore_loc patch_auth() objstore_loc = config.get_object_store() model = kimchi.mockmodel.MockModel(objstore_loc) host = '127.0.0.1' port = get_free_port('http') ssl_port = get_free_port('https') test_server = run_server(host, port, ssl_port, test_mode=True, model=model)
def __init__(self): objstore_loc = config.get_object_store() self.objstore = ObjectStore(objstore_loc) sub_models = [] collectionsample = CollectionSampleModel() collectionresourcesample = \ CollectionResourceSampleModel(collectionsample) resourcesample = ResourceSampleModel() progresssample = ProgressSampleModel(objstore=self.objstore) sub_models = [ collectionresourcesample, collectionsample, progresssample, resourcesample ] return super(DummyModel, self).__init__(sub_models)
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())), os.path.abspath(config.get_screenshot_path()), os.path.abspath(config.get_debugreports_path()), os.path.abspath(config.get_distros_store()) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) self.configObj = KimchiConfig() cherrypy.tools.nocache = cherrypy.Tool('on_end_resource', set_no_cache) cherrypy.tools.kimchiauth = cherrypy.Tool('before_handler', auth.kimchiauth) # Setting host to 127.0.0.1. This makes kimchi runs # 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 cherrypy.config.nginx_port = options.port cherrypy.log.screen = True 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' # 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 elif options.test: model_instance = mockmodel.get_mock_environment() else: model_instance = model.Model() if isinstance(model_instance, model.Model): vnc_ws_proxy = vnc.new_ws_proxy() cherrypy.engine.subscribe('exit', vnc_ws_proxy.kill) for ident, node in sub_nodes.items(): if node.url_auth: cfg = self.configObj ident = "/%s" % ident cfg[ident] = {'tools.kimchiauth.on': True} if node.admin_methods: cfg[ident][ 'tools.kimchiauth.admin_methods'] = node.admin_methods self.app = cherrypy.tree.mount(KimchiRoot(model_instance, dev_env), config=self.configObj) self._load_plugins() # 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 __init__(self, 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())), os.path.abspath(config.get_screenshot_path()), os.path.abspath(config.get_session_path()), os.path.abspath(config.get_debugreports_path()), os.path.abspath(config.get_distros_store()) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) cherrypy.tools.nocache = cherrypy.Tool('on_end_resource', set_no_cache) cherrypy.tools.kimchiauth = cherrypy.Tool('before_handler', auth.kimchiauth) cherrypy.server.socket_host = options.host cherrypy.server.socket_port = options.port # SSL Server try: if options.ssl_port and options.ssl_port > 0: self._init_ssl(options) except AttributeError: pass cherrypy.log.screen = True 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' # 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 elif options.test: model_instance = mockmodel.get_mock_environment() else: model_instance = model.Model() if isinstance(model_instance, model.Model): vnc_ws_proxy = vnc.new_ws_proxy() cherrypy.engine.subscribe('exit', vnc_ws_proxy.kill) for ident, node in sub_nodes.items(): if node.url_auth: self.configObj["/%s" % ident] = {'tools.kimchiauth.on': True} self.app = cherrypy.tree.mount(KimchiRoot(model_instance, dev_env), config=self.configObj) self._load_plugins() cherrypy.lib.sessions.init()