The test case was failing as below:
======================================================================
ERROR: test_vm_virtviewerfile_vmlifecycle (test_model.ModelTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/mock/mock.py", line 1305, in patched
return func(*args, **keywargs)
File "test_model.py", line 571, in test_vm_virtviewerfile_vmlifecycle
vvmodel.lookup(vm_name.decode('utf-8'))
File "/home/alinefm/wok/src/wok/plugins/kimchi/model/virtviewerfile.py", line
133, in lookup
file_path = create_virt_viewer_file(name, graphics_info)
File "/home/alinefm/wok/src/wok/plugins/kimchi/model/virtviewerfile.py", line
82, in create_virt_viewer_file
{'name': vm_name, 'err': e.message})
OperationFailed: KCHVM0084E: KCHVM0084E
Because the virt-viewer config file generation was relying on Wok
configuration to get the host information but the host information is
not part of Wok anymore. Instead of that, it is being configured on
nginx. Set it to 'localhost' when that information is not part of
request headers.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
model/virtviewerfile.py | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/model/virtviewerfile.py b/model/virtviewerfile.py
index 8e3be8f..533978f 100644
--- a/model/virtviewerfile.py
+++ b/model/virtviewerfile.py
@@ -1,7 +1,7 @@
#
# Project Kimchi
#
-# Copyright IBM Corp, 2016
+# Copyright IBM Corp, 2016-2017
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -22,7 +22,6 @@ import cherrypy
import libvirt
import os
-from wok.config import config as wok_config
from wok.exception import InvalidOperation, OperationFailed
from wok.plugins.kimchi import config as kimchi_config
from wok.plugins.kimchi.model.vms import VMModel
@@ -49,9 +48,7 @@ port=%(graphics_port)s
def _get_request_host():
- host = cherrypy.request.headers.get('Host')
- if not host:
- host = wok_config.get("server", "host")
+ host = cherrypy.request.headers.get('Host', 'localhost')
host = host.split(':')[0]
return host
@@ -107,7 +104,8 @@ class VMVirtViewerFileModel(object):
vm_name = dom.name()
self.firewall_mngr.remove_vm_graphics_port(vm_name)
cb_id = self.vm_event_callbacks.pop(vm_name, None)
- self.conn.get().domainEventDeregisterAny(cb_id)
+ if cb_id is not None:
+ self.conn.get().domainEventDeregisterAny(cb_id)
def handleVMShutdownPowerOff(self, vm_name):
try:
--
2.9.3