Skip to content

Commit

Permalink
added with_spice_web_client to config
Browse files Browse the repository at this point in the history
  • Loading branch information
pgurenko committed Jun 2, 2019
1 parent 90b452e commit ebcbb62
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
3 changes: 2 additions & 1 deletion autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
Expand Down
6 changes: 6 additions & 0 deletions config.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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'):
Expand Down
1 change: 1 addition & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):**
Expand Down
4 changes: 3 additions & 1 deletion model/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
27 changes: 13 additions & 14 deletions ui/js/src/kimchi.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
});
},
Expand Down

0 comments on commit ebcbb62

Please sign in to comment.