[PATCH v2] [Kimchi] test_mock_network.py: fixes due to backend changes
by dhbarboza82@gmail.com
From: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
This patch makes the following improvements in test_vlag_tag_bridge:
- fixed connection type. Recent backend changes do not allow
for connection='macvtap' and 'vlan_id' to be sent together.
- added Network Manager check. The test can fail randomly if
Network Manager is active.
- fixed copyright format.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
---
tests/test_mock_network.py | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/tests/test_mock_network.py b/tests/test_mock_network.py
index 4b0a284..3a9b7b5 100644
--- a/tests/test_mock_network.py
+++ b/tests/test_mock_network.py
@@ -2,7 +2,7 @@
#
# Project Kimchi
#
-# Copyright IBM, Corp. 2015
+# Copyright IBM Corp, 2015-2016
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -26,6 +26,7 @@ from functools import partial
from tests.utils import get_free_port, patch_auth, request, run_server
from wok.plugins.kimchi.mockmodel import MockModel
+from wok.utils import run_command
from test_model_network import _do_network_test
@@ -56,11 +57,21 @@ def tearDownModule():
os.unlink('/tmp/obj-store-test')
+def is_network_manager_running():
+ out, err, rc = run_command(['nmcli', 'dev', 'status'])
+ if rc != 0:
+ return False
+ return True
+
+
class MockNetworkTests(unittest.TestCase):
def setUp(self):
self.request = partial(request, host, ssl_port)
model.reset()
+ @unittest.skipIf(is_network_manager_running(),
+ 'test_vlan_tag_bridge skipped because Network '
+ 'Manager is running.')
def test_vlan_tag_bridge(self):
# Verify the current system has at least one interface to create a
# bridged network
@@ -69,6 +80,6 @@ class MockNetworkTests(unittest.TestCase):
)
if len(interfaces) > 0:
iface = interfaces[0]['name']
- _do_network_test(self, model, {'name': u'macvtap-network',
- 'connection': 'macvtap',
+ _do_network_test(self, model, {'name': u'vlan-tagged-bridge',
+ 'connection': 'bridge',
'interface': iface, 'vlan_id': 987})
--
2.5.0
8 years, 9 months
[PATCH v4] [Kimchi 0/8] Web serial console
by Jose Ricardo Ziviani
v4:
- fix patch encoding to utf-8
v3:
- applied code review
- removed favicon from this patch
v2:
- applied code review
- updated the build system
This is the initial version of a web serial console for kimchi/libvirt
VMs.
When a VM is turned on, a new action is displayed named "Connect
Serial", this will open a new tab with an interface like the existing
novnc.
That interface opens a websocket to kimchi webserver (nginx), then
it is redirected to websockify. Websockify will proxy that connection to
a local unix socket server to finally communicate with the guest
console.
I chose to create one server per guest because that's the way websockify
was designed (it was born inside novnc), so I could reuse the token
security plugin implemented in websockify. In order to avoid wasting
resources I decided to user unix socket, a local/lightweight/reliable
socket if compared with internet sockets, this uses files instead of
ports to accept connections.
When a connection is established no one else can get that console (I'm
not multiplexing it but it's possible in future). The serial console
will be available again if the current user does one of:
- type ctrl+q
- close the tab
- 2 min. timeout
Thanks
Jose Ricardo Ziviani (8):
Rename vnc.py to websocket.py
Implement the web serial console server
Implement the backend to support web serial console
Import term.js to Kimchi project
Implement the web serial console front-end
Implement the Kimchi front-end for the web serial console
Update the build system to make the serial console
Add test case for the socket server
COPYING | 2 +
Makefile.am | 4 +-
config.py.in | 6 +-
configure.ac | 3 +
control/vms.py | 3 +-
i18n.py | 3 +
model/vms.py | 43 +-
root.py | 6 +-
serialconsole.py | 315 +++
tests/test_model.py | 28 +-
ui/Makefile.am | 2 +-
ui/js/src/kimchi.api.js | 27 +
ui/js/src/kimchi.guest_main.js | 14 +-
ui/pages/guest.html.tmpl | 5 +-
ui/serial/Makefile.am | 21 +
ui/serial/html/Makefile.am | 21 +
ui/serial/html/serial.html | 99 +
ui/serial/libs/Makefile.am | 21 +
ui/serial/libs/term.js | 5973 ++++++++++++++++++++++++++++++++++++++++
vnc.py | 92 -
websocket.py | 122 +
21 files changed, 6700 insertions(+), 110 deletions(-)
create mode 100644 serialconsole.py
create mode 100644 ui/serial/Makefile.am
create mode 100644 ui/serial/html/Makefile.am
create mode 100644 ui/serial/html/serial.html
create mode 100644 ui/serial/libs/Makefile.am
create mode 100644 ui/serial/libs/term.js
delete mode 100644 vnc.py
create mode 100644 websocket.py
--
1.9.1
8 years, 9 months
[PATCH v3] [Kimchi 0/8] Web serial console
by Jose Ricardo Ziviani
v3:
- applied code review
- removed favicon from this patch
v2:
- applied code review
- updated the build system
This is the initial version of a web serial console for kimchi/libvirt
VMs.
When a VM is turned on, a new action is displayed named "Connect
Serial", this will open a new tab with an interface like the existing
novnc.
That interface opens a websocket to kimchi webserver (nginx), then
it is redirected to websockify. Websockify will proxy that connection to
a local unix socket server to finally communicate with the guest
console.
I chose to create one server per guest because that's the way websockify
was designed (it was born inside novnc), so I could reuse the token
security plugin implemented in websockify. In order to avoid wasting
resources I decided to user unix socket, a local/lightweight/reliable
socket if compared with internet sockets, this uses files instead of
ports to accept connections.
When a connection is established no one else can get that console (I'm
not multiplexing it but it's possible in future). The serial console
will be available again if the current user does one of:
- type ctrl+q
- close the tab
- 2 min. timeout
Thanks
Jose Ricardo Ziviani (8):
Rename vnc.py to websocket.py
Implement the web serial console server
Implement the backend to support web serial console
Import term.js to Kimchi project
Implement the web serial console front-end
Implement the Kimchi front-end for the web serial console
Update the build system to make the serial console
Add test case for the socket server
COPYING | 2 +
Makefile.am | 4 +-
config.py.in | 6 +-
configure.ac | 3 +
control/vms.py | 3 +-
i18n.py | 3 +
model/vms.py | 43 +-
root.py | 6 +-
serialconsole.py | 315 +++
tests/test_model.py | 28 +-
ui/Makefile.am | 2 +-
ui/js/src/kimchi.api.js | 27 +
ui/js/src/kimchi.guest_main.js | 14 +-
ui/pages/guest.html.tmpl | 5 +-
ui/serial/Makefile.am | 21 +
ui/serial/html/Makefile.am | 21 +
ui/serial/html/serial.html | 99 +
ui/serial/libs/Makefile.am | 21 +
ui/serial/libs/term.js | 5973 ++++++++++++++++++++++++++++++++++++++++
vnc.py | 92 -
websocket.py | 122 +
21 files changed, 6700 insertions(+), 110 deletions(-)
create mode 100644 serialconsole.py
create mode 100644 ui/serial/Makefile.am
create mode 100644 ui/serial/html/Makefile.am
create mode 100644 ui/serial/html/serial.html
create mode 100644 ui/serial/libs/Makefile.am
create mode 100644 ui/serial/libs/term.js
delete mode 100644 vnc.py
create mode 100644 websocket.py
--
1.9.1
8 years, 9 months
[PATCH] [Kimchi] test_mock_network.py: fixes due to backend changes
by dhbarboza82@gmail.com
From: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
This patch makes the following improvements in test_vlag_tag_bridge:
- fixed connection type. Recent backend changes do not allow
for connection='macvtap' and 'vlan_id' to be sent together.
- added Network Manager check. The test can fail randomly if
Network Manager is active.
- fixed copyright format.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
---
tests/test_mock_network.py | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/tests/test_mock_network.py b/tests/test_mock_network.py
index 4b0a284..d9810f3 100644
--- a/tests/test_mock_network.py
+++ b/tests/test_mock_network.py
@@ -2,7 +2,7 @@
#
# Project Kimchi
#
-# Copyright IBM, Corp. 2015
+# Copyright IBM Corp, 2015-2016
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -26,6 +26,7 @@ from functools import partial
from tests.utils import get_free_port, patch_auth, request, run_server
from wok.plugins.kimchi.mockmodel import MockModel
+from wok.utils import run_command
from test_model_network import _do_network_test
@@ -56,11 +57,21 @@ def tearDownModule():
os.unlink('/tmp/obj-store-test')
+def is_network_manager_running():
+ out, err, rc = run_command(['nmcli', 'dev', 'status'])
+ if rc != 0:
+ return False
+ return True
+
+
class MockNetworkTests(unittest.TestCase):
def setUp(self):
self.request = partial(request, host, ssl_port)
model.reset()
+ @unittest.skipIf(is_network_manager_running(),
+ 'test_vlan_tag_bridge skipped because Network '
+ 'Manager is running.')
def test_vlan_tag_bridge(self):
# Verify the current system has at least one interface to create a
# bridged network
@@ -70,5 +81,5 @@ class MockNetworkTests(unittest.TestCase):
if len(interfaces) > 0:
iface = interfaces[0]['name']
_do_network_test(self, model, {'name': u'macvtap-network',
- 'connection': 'macvtap',
+ 'connection': 'bridge',
'interface': iface, 'vlan_id': 987})
--
2.5.0
8 years, 9 months
[PATCH] [Wok] Bug fix: Configure nginx to listen on given IP address
by Aline Manera
The 'host' option was being ignored when launching nginx proxy. That
way, the default value - 0.0.0.0 to listen to all interfaces - was being
used. Fix it.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
src/nginx/wok.conf.in | 4 ++--
src/wok/proxy.py | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/nginx/wok.conf.in b/src/nginx/wok.conf.in
index 85790ff..9ae2530 100644
--- a/src/nginx/wok.conf.in
+++ b/src/nginx/wok.conf.in
@@ -59,7 +59,7 @@ http {
}
server {
- listen ${proxy_ssl_port} ssl;
+ listen ${host}:${proxy_ssl_port} ssl;
ssl_certificate ${cert_pem};
ssl_certificate_key ${cert_key};
@@ -90,7 +90,7 @@ http {
}
server {
- listen ${proxy_port};
+ listen ${host}:${proxy_port};
rewrite ^/(.*)$ https://$host:${proxy_ssl_port}/$1 redirect;
}
}
diff --git a/src/wok/proxy.py b/src/wok/proxy.py
index f13dede..d508b73 100644
--- a/src/wok/proxy.py
+++ b/src/wok/proxy.py
@@ -81,6 +81,7 @@ def _create_proxy_config(options):
data = template.read()
data = Template(data)
data = data.safe_substitute(user=user_proxy,
+ host=options.host,
proxy_port=options.port,
proxy_ssl_port=options.ssl_port,
cherrypy_port=options.cherrypy_port,
--
2.5.0
8 years, 9 months
[PATCH] [Kimchi] New UI for adding network bridges
by peterpnns@gmail.com
From: peterpennings <peterpnns(a)gmail.com>
This patch adds Linux and OVS bridges. netinfo.py had to be updated to show OVS bridges in order to reflect the changes made in the UI.
peterpennings (1):
Issue #791: New UI for adding network bridges
netinfo.py | 3 +-
ui/js/src/kimchi.network.js | 2 +
ui/js/src/kimchi.network_add_main.js | 146 ++++++++++++++++++++++-------------
ui/pages/network-add.html.tmpl | 3 +-
4 files changed, 96 insertions(+), 58 deletions(-)
--
2.5.0
8 years, 9 months
[PATCH] [Kimchi] New UI for adding network bridges V2.
by peterpnns@gmail.com
From: peterpennings <peterpnns(a)gmail.com>
This patch adds Linux and OVS bridges. netinfo.py had to be updated to show OVS bridges in order to reflect the changes made in the UI.
V2:
* Fixed error messages
* Fixed function name
* Form validations
peterpennings (1):
Issue #791: New UI for adding network bridges
netinfo.py | 3 +-
ui/js/src/kimchi.network.js | 2 +
ui/js/src/kimchi.network_add_main.js | 159 +++++++++++++++++++++--------------
ui/pages/network-add.html.tmpl | 5 +-
4 files changed, 103 insertions(+), 66 deletions(-)
--
2.5.0
8 years, 9 months
[PATCH] [Kimchi] Fix handling of VLANs in backend
by Lucio Correia
- Allow VLANs only for bridged virtual networks
- Code simplification
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
i18n.py | 6 ++---
model/networks.py | 71 ++++++++++++++++++++++++++++++-------------------------
2 files changed, 42 insertions(+), 35 deletions(-)
diff --git a/i18n.py b/i18n.py
index 0b9fa39..bd36efa 100644
--- a/i18n.py
+++ b/i18n.py
@@ -248,8 +248,8 @@ messages = {
"KCHNET0001E": _("Network %(name)s already exists"),
"KCHNET0002E": _("Network %(name)s does not exist"),
- "KCHNET0003E": _("Subnet %(subnet)s specified for network %(network)s is not valid."),
- "KCHNET0004E": _("Specify a network interface to create bridged network %(name)s"),
+ "KCHNET0003E": _("Subnet %(subnet)s specified for network %(network)s is not valid."),
+ "KCHNET0004E": _("Specify a network interface to create bridged or macvtap networks."),
"KCHNET0005E": _("Unable to delete active network %(name)s"),
"KCHNET0006E": _("Interface %(iface)s specified for network %(network)s is already in use"),
"KCHNET0007E": _("Interface should be bare NIC, bonding or bridge device."),
@@ -270,8 +270,8 @@ messages = {
"KCHNET0022E": _("Failed to start network %(name)s. Details: %(err)s"),
"KCHNET0024E": _("Unable to redefine interface %(name)s. Details: %(err)s"),
"KCHNET0025E": _("Unable to create bridge %(name)s. Details: %(err)s"),
- "KCHNET0026E": _("Open VSwitch bridges can only host bridged networks."),
"KCHNET0027E": _("Unable to create bridge with NetworkManager enabled. Disable it and try again."),
+ "KCHNET0028E": _("Interface should be bare NIC or bonding."),
"KCHSR0001E": _("Storage server %(server)s was not used by Kimchi"),
diff --git a/model/networks.py b/model/networks.py
index fba181f..9a49634 100644
--- a/model/networks.py
+++ b/model/networks.py
@@ -86,21 +86,20 @@ class NetworksModel(object):
if name in self.get_list():
raise InvalidOperation("KCHNET0001E", {'name': name})
+ # handle connection type
connection = params["connection"]
- # set forward mode, isolated do not need forward
if connection == 'macvtap':
- params['forward'] = {'mode': 'bridge'}
- elif connection != 'isolated':
- params['forward'] = {'mode': connection}
+ self._set_network_macvtap(params)
+ elif connection == 'bridge':
+ self._set_network_bridge(params)
+ elif connection in ['nat', 'isolated']:
+ if connection == 'nat':
+ params['forward'] = {'mode': 'nat'}
- # set subnet, bridge network do not need subnet
- if connection in ["nat", 'isolated']:
+ # set subnet; bridge/macvtap networks do not need subnet
self._set_network_subnet(params)
- # only bridge network need bridge(linux bridge) or interface(macvtap)
- if connection in ['bridge', 'macvtap']:
- self._set_network_bridge(params)
-
+ # create network XML
params['name'] = escape(params['name'])
xml = to_network_xml(**params)
@@ -165,7 +164,7 @@ class NetworksModel(object):
else:
raise OperationFailed("KCHNET0021E", {'iface': iface})
- def _set_network_bridge(self, params):
+ def _check_network_interface(self, params):
try:
# fails if host interface is already in use by a libvirt network
iface = params['interface']
@@ -175,9 +174,24 @@ class NetworksModel(object):
except KeyError:
raise MissingParameter("KCHNET0004E", {'name': params['name']})
- # Linux bridges cannot be the trunk device of a VLAN
- if 'vlan_id' in params and \
- (netinfo.is_bridge(iface) or params['connection'] == "bridge"):
+ def _set_network_macvtap(self, params):
+ self._check_network_interface(params)
+
+ iface = params['interface']
+ if 'vlan_id' in params or not (netinfo.is_bare_nic(iface) or
+ netinfo.is_bonding(iface)):
+ raise InvalidParameter('KCHNET0028E', {'name': iface})
+
+ # set macvtap network
+ params['forward'] = {'mode': 'bridge', 'dev': iface}
+
+ def _set_network_bridge(self, params):
+ self._check_network_interface(params)
+ params['forward'] = {'mode': 'bridge'}
+
+ # Bridges cannot be the trunk device of a VLAN
+ iface = params['interface']
+ if 'vlan_id' in params and netinfo.is_bridge(iface):
raise InvalidParameter('KCHNET0019E', {'name': iface})
# User specified bridge interface, simply use it
@@ -189,29 +203,22 @@ class NetworksModel(object):
if netinfo.is_ovs_bridge(iface):
params['ovs'] = True
- # OVS bridges don't work with macvtap
- if params['connection'] != "bridge":
- raise InvalidParameter('KCHNET0026E')
-
- # User wants Linux bridge network, but didn't specify bridge interface
- elif params['connection'] == "bridge":
-
- # libvirt will fail to create bridge if NetworkManager is enabled
- if self.caps.nm_running:
- raise InvalidParameter('KCHNET0027E')
-
- # create Linux bridge interface first and use it as actual iface
- iface = self._create_linux_bridge(iface)
- params['bridge'] = iface
-
# connection == macvtap and iface is not bridge
elif netinfo.is_bare_nic(iface) or netinfo.is_bonding(iface):
- if params.get('vlan_id') is None:
- params['forward']['dev'] = iface
- else:
+ if 'vlan_id' in params:
params['bridge'] = \
self._create_vlan_tagged_bridge(str(iface),
str(params['vlan_id']))
+ else:
+ # libvirt bridge creation will fail with NetworkManager enabled
+ if self.caps.nm_running:
+ raise InvalidParameter('KCHNET0027E')
+
+ # create Linux bridge interface and use it as actual iface
+ iface = self._create_linux_bridge(iface)
+ params['bridge'] = iface
+
+ # unrecognized interface type: fail
else:
raise InvalidParameter("KCHNET0007E")
--
1.9.1
8 years, 9 months
[PATCH] [Kimchi] New UI for adding network bridges V4
by peterpnns@gmail.com
From: peterpennings <peterpnns(a)gmail.com>
Fixed:
* Enable VLAN is now being showed after loadinterfaces callback function.
peterpennings (1):
Issue #791: New UI for adding network bridges
netinfo.py | 3 +-
ui/js/src/kimchi.network.js | 2 +
ui/js/src/kimchi.network_add_main.js | 146 ++++++++++++++++++++---------------
ui/pages/network-add.html.tmpl | 5 +-
4 files changed, 88 insertions(+), 68 deletions(-)
--
2.5.0
8 years, 9 months