From ebcbb6206b9af8e08b690c3dbf43e44fd254a35d Mon Sep 17 00:00:00 2001 From: Pavel Gurenko Date: Sat, 1 Jun 2019 17:30:38 -0700 Subject: [PATCH] added with_spice_web_client to config --- autogen.sh | 3 ++- config.py.in | 6 ++++++ docs/API.md | 1 + model/config.py | 4 +++- tests/test_rest.py | 2 +- ui/js/src/kimchi.api.js | 27 +++++++++++++-------------- 6 files changed, 26 insertions(+), 17 deletions(-) diff --git a/autogen.sh b/autogen.sh index 0c1a6713b..bd243d12f 100755 --- a/autogen.sh +++ b/autogen.sh @@ -29,7 +29,8 @@ if [ ! -f "configure" ]; then fi if [ "x$1" == "x--system" ]; then - ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var + shift + ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var $@ else if [ $# -gt 0 ]; then ./configure $@ diff --git a/config.py.in b/config.py.in index 97bc18395..f22aafc76 100644 --- a/config.py.in +++ b/config.py.in @@ -42,6 +42,10 @@ 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') @@ -109,6 +113,8 @@ class KimchiPaths(PluginPaths): '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'): diff --git a/docs/API.md b/docs/API.md index 0fcb74890..24e3d1b52 100644 --- a/docs/API.md +++ b/docs/API.md @@ -824,6 +824,7 @@ Contains information about Kimchi configuration. * **GET**: Retrieve configuration information * version: The version of the kimchi service + * with_spice_web_client: True is buit with spice web client support * **POST**: *See Configuration Actions* **Actions (POST):** diff --git a/model/config.py b/model/config.py index f0c2c1203..bfc93b8cb 100644 --- a/model/config.py +++ b/model/config.py @@ -23,6 +23,7 @@ from wok.exception import NotFoundError from wok.plugins.kimchi.config import find_qemu_binary from wok.plugins.kimchi.config import get_kimchi_version +from wok.plugins.kimchi.config import with_spice_web_client from wok.plugins.kimchi.distroloader import DistroLoader from wok.plugins.kimchi.model.featuretests import FEATURETEST_POOL_NAME from wok.plugins.kimchi.model.featuretests import FEATURETEST_VM_NAME @@ -39,7 +40,8 @@ def __init__(self, **kargs): pass def lookup(self, name): - return {'version': get_kimchi_version()} + return {'version': get_kimchi_version(), + 'with_spice_web_client': with_spice_web_client()} class CapabilitiesModel(object, metaclass=Singleton): diff --git a/tests/test_rest.py b/tests/test_rest.py index 2948f093c..cfccae853 100644 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -1683,7 +1683,7 @@ def test_tasks(self): def test_config(self): resp = self.request('/plugins/kimchi/config').read() conf = json.loads(resp) - keys = ['version'] + keys = ["version", "with_spice_web_client"] self.assertEqual(keys, sorted(conf.keys())) def test_capabilities(self): diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js index eb6147c7a..81720efc7 100644 --- a/ui/js/src/kimchi.api.js +++ b/ui/js/src/kimchi.api.js @@ -372,10 +372,20 @@ var kimchi = { }).done(function(data, textStatus, xhr) { url = 'https://' + location.hostname + ':' + proxy_port; url += server_root; - - let spice_html5 = true; - if(spice_html5) + if(kimchi.config['with_spice_web_client']) + { + /* + * Slightly different api for spice-web-client + */ + url += "/plugins/kimchi/spice-web-client/index.html"; + url += "?port=" + proxy_port + server_root; + url += "&host=" + location.hostname; + url += "&vmInfoToken=" + wok.urlSafeB64Encode(vm).replace(/=*$/g, ""); + url += '&protocol=wss'; + } + else { + // Using spice-html5 by default url += "/plugins/kimchi/spice_auto.html"; /* * When using server_root we need pass the value with port @@ -393,17 +403,6 @@ var kimchi = { url += "&token=" + wok.urlSafeB64Encode(vm).replace(/=*$/g, ""); url += '&encrypt=1'; } - else - { - /* - * Slightly different api for spice-web-client - */ - url += "/plugins/kimchi/spice-web-client/index.html"; - url += "?port=" + proxy_port + server_root; - url += "&host=" + location.hostname; - url += "&vmInfoToken=" + wok.urlSafeB64Encode(vm).replace(/=*$/g, ""); - url += '&protocol=wss'; - } window.open(url); }); },