1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/mirrors-kimchi

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
config.py.in 6.5 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
Aline Manera Отправлено 15.09.2020 03:25 c6fd04d
#
# 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)

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/mirrors-kimchi.git
git@api.gitlife.ru:oschina-mirror/mirrors-kimchi.git
oschina-mirror
mirrors-kimchi
mirrors-kimchi
master