3 Star 2 Fork 0

Gitee 极速下载 / kimchi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/kimchi-project/kimchi
克隆/下载
config.py.in 6.51 KB
一键复制 编辑 原始数据 按行查看 历史
#
# 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 libvirt
import os
import platform
import threading
from wok.config import PluginConfig, PluginPaths
from wok.utils import load_plugin_conf
from wok.xmlutils.utils import xpath_get_text
kimchiLock = threading.Lock()
__with_spice__ = "@withspice@"
__with_spice_web_client__ = "@withspicewebclient@"
__version__ = "@kimchiversion@"
__release__ = "@kimchirelease@"
# Storage pool constant for read-only pool types
READONLY_POOL_TYPE = ['iscsi', 'scsi', 'mpath']
def get_libvirt_path():
run_state_dir = "@runstatedir@" if "@runstatedir@" else "@localstatedir@/run"
return os.path.join(run_state_dir, 'libvirt')
def get_kimchi_version():
return "-".join([__version__, __release__])
def with_spice_web_client():
return __with_spice_web_client__ == 'yes'
def get_distros_store():
return os.path.join(kimchiPaths.sysconf_dir, 'distros.d')
def get_debugreports_path():
return os.path.join(PluginPaths('kimchi').state_dir, 'debugreports')
def get_object_store():
return os.path.join(PluginPaths('kimchi').state_dir, 'objectstore')
def get_screenshot_path():
return os.path.join(PluginPaths('kimchi').state_dir, 'screenshots')
def get_virtviewerfiles_path():
return os.path.join(PluginPaths('kimchi').state_dir, 'virtviewerfiles')
def get_config():
return load_plugin_conf('kimchi')
config = get_config()
def find_qemu_binary(find_emulator=False):
try:
connect = libvirt.open(None)
except Exception as e:
raise Exception("Unable to get qemu binary location: %s" % e)
try:
xml = connect.getCapabilities()
# On Little Endian system, the qemu binary is
# qemu-system-ppc64, not qemu-system-ppc64le as expected
arch = platform.machine()
if arch == "ppc64le":
arch = "ppc64"
if find_emulator:
expr = "/capabilities/guest/arch[@name='%s']\
/emulator" % arch
else:
expr = "/capabilities/guest/arch[@name='%s']\
/domain[@type='kvm']/emulator" % arch
res = xpath_get_text(xml, expr)
location = res[0]
except Exception as e:
raise Exception("Unable to get qemu binary location: %s" % e)
finally:
connect.close()
return location
class KimchiPaths(PluginPaths):
def __init__(self):
super(KimchiPaths, self).__init__('kimchi')
if __with_spice_web_client__ == 'yes':
self.spice_file = os.path.join(self.ui_dir,
'spice-web-client/index.html')
self.spice_dir = os.path.join(self.ui_dir, 'spice-web-client')
else:
self.spice_file = os.path.join(self.ui_dir,
'spice-html5/pages/spice_auto.html')
if __with_spice__ == 'yes':
self.spice_dir = os.path.join(self.ui_dir, 'spice-html5')
elif os.path.exists('@datadir@/spice-html5'):
self.spice_dir = '@datadir@/spice-html5'
else:
self.spice_dir = '/usr/share/spice-html5'
if os.path.exists('@datadir@/novnc'):
self.novnc_dir = '@datadir@/novnc'
else:
self.novnc_dir = '/usr/share/novnc'
if self.installed:
self.spice_css_file = os.path.join(self.spice_dir, 'spice.css')
# Expose system configuration directory
self.sysconf_dir = os.path.join('@sysconfdir@', 'kimchi')
else:
self.spice_css_file = os.path.join(self.spice_dir, 'css/spice.css')
self.sysconf_dir = self.add_prefix(self.plugin_dir)
self.serial_dir = os.path.join(self.ui_dir, 'serial')
kimchiPaths = KimchiPaths()
class KimchiConfig(PluginConfig):
def __init__(self):
super(KimchiConfig, self).__init__('kimchi')
static_config = {
'/novnc': {'type': 'dir',
'path': kimchiPaths.novnc_dir},
'/spice-html5': {'type': 'dir',
'path': kimchiPaths.spice_dir},
'/spice_auto.html': {'type': 'file',
'path': kimchiPaths.spice_file},
'/spice-html5/spice.css': {'type': 'file',
'path': kimchiPaths.spice_css_file},
'/spice-web-client': {'type': 'dir',
'path': kimchiPaths.spice_dir},
'/serial': {'type': 'dir',
'path': kimchiPaths.serial_dir}}
custom_config = {
'/help': {'tools.nocache.on': True,
'tools.staticdir.dir':
os.path.join(kimchiPaths.ui_dir, 'pages/help'),
'tools.staticdir.on': True},
'/data/screenshots': {'tools.nocache.on': False,
'tools.staticdir.dir':
get_screenshot_path(),
'tools.staticdir.on': True},
'/data/virtviewerfiles': {'tools.nocache.on': False,
'tools.staticdir.dir':
get_virtviewerfiles_path(),
'tools.staticdir.on': True}}
for uri, data in static_config.items():
custom_config[uri] = {'tools.nocache.on': True,
'tools.wokauth.on': True}
path = data['path']
if data['type'] == 'dir':
custom_config[uri].update({'tools.staticdir.on': True,
'tools.staticdir.dir': path})
elif data['type'] == 'file':
custom_config[uri].update({'tools.staticfile.on': True,
'tools.staticfile.filename': path})
self.update(custom_config)
Python
1
https://gitee.com/mirrors/kimchi.git
git@gitee.com:mirrors/kimchi.git
mirrors
kimchi
kimchi
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891