def __init__(self, wok_options): make_dirs = [ os.path.dirname(os.path.abspath(config.get_object_store())), os.path.abspath(config.get_distros_store()), os.path.abspath(config.get_screenshot_path()), os.path.abspath(config.get_virtviewerfiles_path()) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) # When running on test mode, specify the objectstore location to # remove the file on server shutting down. That way, the system will # not suffer any change while running on test mode if wok_options.test and (wok_options.test is True or wok_options.test.lower() == 'true'): self.objectstore_loc = tempfile.mktemp() self.model = mockmodel.MockModel(self.objectstore_loc) def remove_objectstore(): if os.path.exists(self.objectstore_loc): os.unlink(self.objectstore_loc) cherrypy.engine.subscribe('exit', remove_objectstore) else: self.model = kimchiModel.Model() dev_env = wok_options.environment != 'production' super(Kimchi, self).__init__(self.model, dev_env) 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.paths = config.kimchiPaths self.domain = 'kimchi' self.messages = messages self.extends = { "/plugins/gingerbase": { "host-dashboard.html": "/plugins/kimchi/js/kimchi.peers.js" } } self.depends = ['gingerbase'] # Some paths or URI's present in the objectstore have changed after # Kimchi 2.0.0 release. Check here if an upgrade in the schema and data # are necessary. if upgrade_objectstore_schema(config.get_object_store(), 'version'): upgrade_objectstore_data('icon', 'images', 'plugins/kimchi/') upgrade_objectstore_data('storagepool', '/storagepools', '/plugins/kimchi') upgrade_objectstore_template_disks(self.model.conn) # Upgrade memory data, if necessary upgrade_objectstore_memory()
def __init__(self, wok_options): if hasattr(wok_options, "model"): self.model = wok_options.model elif wok_options.test: self.model = mockmodel.MockModel() else: self.model = kimchiModel.Model() dev_env = wok_options.environment != 'production' super(KimchiRoot, self).__init__(self.model, dev_env) for ident, node in sub_nodes.items(): setattr(self, ident, node(self.model)) if isinstance(self.model, kimchiModel.Model): vnc_ws_proxy = vnc.new_ws_proxy() cherrypy.engine.subscribe('exit', vnc_ws_proxy.terminate) self.api_schema = json.load( open( os.path.join(os.path.dirname(os.path.abspath(__file__)), 'API.json'))) self.paths = config.kimchiPaths self.domain = 'kimchi' self.messages = messages make_dirs = [ os.path.dirname(os.path.abspath(config.get_object_store())), os.path.abspath(config.get_distros_store()), os.path.abspath(config.get_debugreports_path()), os.path.abspath(config.get_screenshot_path()) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory)
def setUpModule(): global model, test_server, fake_iso cherrypy.request.headers = {'Accept': 'application/json'} model = mockmodel.MockModel('/tmp/obj-store-test') patch_auth() test_server = run_server(test_mode=True, model=model) fake_iso = '/tmp/fake.iso' iso_gen.construct_fake_iso(fake_iso, True, '12.04', 'ubuntu')
def setUpModule(): global test_server, model, host, port, ssl_port patch_auth(sudo=False) model = mockmodel.MockModel('/tmp/obj-store-test') 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 setUpModule(): global test_server, model patch_auth(sudo=False) model = mockmodel.MockModel('/tmp/obj-store-test') test_server = run_server(test_mode=True, model=model) # Create fake ISO to do the tests construct_fake_iso(fake_iso, True, '12.04', 'ubuntu')
def setUpModule(): global host, port, ssl_port, model, test_server, fake_iso cherrypy.request.headers = {'Accept': 'application/json'} model = mockmodel.MockModel('/tmp/obj-store-test') patch_auth() port = get_free_port('http') ssl_port = get_free_port('https') host = '127.0.0.1' test_server = run_server(host, port, ssl_port, test_mode=True, model=model) fake_iso = '/tmp/fake.iso' open(fake_iso, 'w').close()
def setUpModule(): global test_server, model, host, port, ssl_port patch_auth(sudo=False) model = mockmodel.MockModel('/tmp/obj-store-test') 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) # Create fake ISO to do the tests construct_fake_iso(fake_iso, True, '12.04', 'ubuntu')
def __init__(self, wok_options): make_dirs = [ os.path.dirname(os.path.abspath(config.get_object_store())), os.path.abspath(config.get_distros_store()), os.path.abspath(config.get_screenshot_path()), os.path.abspath(config.get_virtviewerfiles_path()) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) if hasattr(wok_options, "model"): self.model = wok_options.model elif wok_options.test: self.model = mockmodel.MockModel() else: self.model = kimchiModel.Model() dev_env = wok_options.environment != 'production' super(Kimchi, self).__init__(self.model, dev_env) for ident, node in sub_nodes.items(): setattr(self, ident, node(self.model)) if isinstance(self.model, kimchiModel.Model): ws_proxy = websocket.new_ws_proxy() cherrypy.engine.subscribe('exit', ws_proxy.terminate) self.api_schema = json.load( open( os.path.join(os.path.dirname(os.path.abspath(__file__)), 'API.json'))) self.paths = config.kimchiPaths self.domain = 'kimchi' self.messages = messages self.extends = { "/plugins/gingerbase": { "host-dashboard.html": "/plugins/kimchi/js/kimchi.peers.js" } } # Some paths or URI's present in the objectstore have changed after # Kimchi 2.0.0 release. Check here if an upgrade in the schema and data # are necessary. if upgrade_objectstore_schema(config.get_object_store(), 'version'): upgrade_objectstore_data('icon', 'images', 'plugins/kimchi/') upgrade_objectstore_data('storagepool', '/storagepools', '/plugins/kimchi') upgrade_objectstore_template_disks(self.model.conn) # Upgrade memory data, if necessary upgrade_objectstore_memory()