3 Star 2 Fork 0

Gitee 极速下载 / kimchi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/kimchi-project/kimchi
克隆/下载
root.py 3.60 KB
一键复制 编辑 原始数据 按行查看 历史
Aline Manera 提交于 2019-05-01 17:17 . Switch to Python 3
#
# Project Kimchi
#
# Copyright IBM Corp, 2015-2017
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import json
import os
import tempfile
import cherrypy
from wok.plugins.kimchi import config
from wok.plugins.kimchi import mockmodel
from wok.plugins.kimchi.control import sub_nodes
from wok.plugins.kimchi.i18n import messages
from wok.plugins.kimchi.model import model as kimchiModel
from wok.plugins.kimchi.utils import upgrade_objectstore_data
from wok.plugins.kimchi.utils import upgrade_objectstore_memory
from wok.plugins.kimchi.utils import upgrade_objectstore_template_disks
from wok.root import WokRoot
from wok.utils import upgrade_objectstore_schema
class Kimchi(WokRoot):
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))
with open(
os.path.join(os.path.dirname(
os.path.abspath(__file__)), 'API.json')
) as fd:
self.api_schema = json.load(fd)
self.paths = config.kimchiPaths
self.domain = 'kimchi'
self.messages = messages
# 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 get_custom_conf(self):
return config.KimchiConfig()
Python
1
https://gitee.com/mirrors/kimchi.git
git@gitee.com:mirrors/kimchi.git
mirrors
kimchi
kimchi
master

搜索帮助