[PATCH 0/3] Host tab functionality split into Dashboard and Updates
by chandra@linux.vnet.ibm.com
From: Chandra Shekhar Reddy Potula <chandra(a)linux.vnet.ibm.com>
Host tab functionality split into Dashboard and Updates
Splitting host tab functionality into two tabs
1. Dashboard
a. restart, shutdown buttons
b. statistics
c. debug reports
2. Updates
a. Repositories
b. Software updates
Ginger Base screen shot change to reflect new ui
New UI screen shot shows
1. New UI page
2. Feature tab split
Issue 728 : processor info displays blank for system z
UI changes to accommodate the basic system info
1. memory shows online, offline memory info
2. cpu shows online, offline cpu info
On s390x deidcated, shared cpu info shown
3. On s390x hypervisor, LPAR details shown
Note : Stage 1, debug reports is not moved to Administration tab.
Have to experiment on having single tab hosting multiple plugin features.
Till that time individual tab host single plugin features.
Chandra Shekhar Reddy Potula (3):
Host tab functionality split into Dashboard and Updates
Ginger Base screen shot change to reflect new ui
Issue 728 : processor info displays blank for system z
.../gingerbase/docs/gingerbase-host-tab.png | Bin 79669 -> 105906 bytes
src/wok/plugins/gingerbase/ui/config/tab-ext.xml | 10 +-
.../gingerbase/ui/css/src/modules/_host.scss | 9 +-
.../ui/js/src/gingerbase.host-dashboard.js | 614 ++++++++++++++
.../gingerbase/ui/js/src/gingerbase.host-update.js | 405 +++++++++
.../gingerbase/ui/js/src/gingerbase.host.js | 928 ---------------------
.../gingerbase/ui/pages/host-dashboard.html.tmpl | 143 ++++
.../gingerbase/ui/pages/host-update.html.tmpl | 90 ++
src/wok/plugins/gingerbase/ui/pages/host.html.tmpl | 156 ----
9 files changed, 1265 insertions(+), 1090 deletions(-)
create mode 100644 src/wok/plugins/gingerbase/ui/js/src/gingerbase.host-dashboard.js
create mode 100644 src/wok/plugins/gingerbase/ui/js/src/gingerbase.host-update.js
delete mode 100644 src/wok/plugins/gingerbase/ui/js/src/gingerbase.host.js
create mode 100644 src/wok/plugins/gingerbase/ui/pages/host-dashboard.html.tmpl
create mode 100644 src/wok/plugins/gingerbase/ui/pages/host-update.html.tmpl
delete mode 100644 src/wok/plugins/gingerbase/ui/pages/host.html.tmpl
--
2.4.0
9 years, 1 month
[PATCH] Issue 769 : kimchi dependancy update to gingerbase instead wok
by chandra@linux.vnet.ibm.com
From: Chandra Shekhar Reddy Potula <chandra(a)linux.vnet.ibm.com>
Kimchi should be pointing to gingerbase than wok, as plugin kimchi
have dependeny on gingerbase common files (like disks.py)
All the spec file changes to reflect the dependancy as gingerbase
Update the README.md to relect the dependancy as gingerbase
Taken care of README.md to shows png files correctly when browse it
Chandra Shekhar Reddy Potula (1):
Issue 769 : kimchi dependancy update to gingerbase instead wok
src/wok/plugins/kimchi/contrib/DEBIAN/control.in | 2 +-
src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in | 2 +-
src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in | 2 +-
src/wok/plugins/kimchi/docs/README.md | 12 ++++++------
4 files changed, 9 insertions(+), 9 deletions(-)
--
2.4.3
9 years, 1 month
[PATCH] [new-ui] Added SCSS assets
by sguimaraes943@gmail.com
From: samhenri <samuel.guimaraes(a)eldorado.org.br>
This patch updates the UI build process to use python-libsass to compile SCSS files.
It also includes the latest changes in the new-ui CSS (these changes will only take effect only when the patches for each panel is sent to the ML and ginger.css and host-admin.css were deleted from local branch)
samhenri (1):
[new-ui] Added SCSS assets
.gitignore | 1 +
ui/css/Makefile.am | 12 +-
ui/css/ginger.css | 1 -
ui/css/host-admin.css | 586 -------------------------------
ui/css/src/ginger.scss | 1 +
ui/css/src/host-admin.scss | 595 ++++++++++++++++++++++++++++++++
ui/css/src/modules/_administration.scss | 372 ++++++++++++++++++++
7 files changed, 976 insertions(+), 592 deletions(-)
delete mode 100644 ui/css/ginger.css
delete mode 100644 ui/css/host-admin.css
create mode 100644 ui/css/src/ginger.scss
create mode 100644 ui/css/src/host-admin.scss
create mode 100644 ui/css/src/modules/_administration.scss
--
1.9.3
9 years, 1 month
[PATCH] Fix issue 766 - Define network interface in libvirt
by Lucio Correia
When a network interface was only visible to the system and
not to libvirt, libvirt throws an error when user asks a
bridged network to be created using that interface, since
it is not visible to libvirt.
This patch adds network interface redefinition code to make
it visible to libvirt, allowing the bridged network to be
created.
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
src/wok/plugins/kimchi/model/networks.py | 40 +++++++++++++++-------------
src/wok/plugins/kimchi/network.py | 5 ++++
src/wok/plugins/kimchi/xmlutils/interface.py | 20 +++++++++++---
3 files changed, 42 insertions(+), 23 deletions(-)
diff --git a/src/wok/plugins/kimchi/model/networks.py b/src/wok/plugins/kimchi/model/networks.py
index 7f50003..25640a4 100644
--- a/src/wok/plugins/kimchi/model/networks.py
+++ b/src/wok/plugins/kimchi/model/networks.py
@@ -33,6 +33,7 @@ from wok.xmlutils.utils import xpath_get_text
from wok.plugins.kimchi import netinfo
from wok.plugins.kimchi import network as knetwork
from wok.plugins.kimchi.osinfo import defaults as tmpl_defaults
+from wok.plugins.kimchi.xmlutils.interface import get_iface_xml
from wok.plugins.kimchi.xmlutils.network import create_linux_bridge_xml
from wok.plugins.kimchi.xmlutils.network import create_vlan_tagged_bridge_xml
from wok.plugins.kimchi.xmlutils.network import get_no_network_config_xml
@@ -237,8 +238,23 @@ class NetworksModel(object):
'err': e.get_error_message()})
def _create_linux_bridge(self, interface):
- # get xml definition of interface
- iface_xml = self._get_interface_desc_xml(interface)
+ iface_defined = False
+ try:
+ # get xml definition of configured interface
+ conn = self.conn.get()
+ iface = conn.interfaceLookupByName(interface)
+ iface_xml = iface.XMLDesc(flags=VIR_INTERFACE_XML_INACTIVE)
+ except libvirt.libvirtError, e:
+ try:
+ # try to define that interface in libvirt
+ mac = knetwork.get_dev_macaddr(str(interface))
+ iface_xml = get_iface_xml({'name': interface, 'mac': mac,
+ 'startmode': "onboot"})
+ conn.interfaceDefineXML(iface_xml.encode("utf-8"))
+ iface_defined = True
+ except libvirt.libvirtError, e:
+ raise OperationFailed("KCHNET0023E", {'name': interface,
+ 'err': e.get_error_message()})
# Truncate the interface name if it exceeds 13 characters to make sure
# the length of bridge name is less than 15 (its maximum value).
@@ -246,7 +262,7 @@ class NetworksModel(object):
br_xml = create_linux_bridge_xml(br_name, interface, iface_xml)
# drop network config from interface
- self._redefine_iface_no_network(interface)
+ iface_defined or self._redefine_iface_no_network(interface, iface_xml)
# create and start bridge
self._create_bridge(br_name, br_xml)
@@ -263,27 +279,13 @@ class NetworksModel(object):
return br_name
- def _get_interface_desc_xml(self, name):
- conn = self.conn.get()
-
- try:
- iface = conn.interfaceLookupByName(name)
- xml = iface.XMLDesc(flags=VIR_INTERFACE_XML_INACTIVE)
- except libvirt.libvirtError, e:
- raise OperationFailed("KCHNET0023E",
- {'name': name, 'err': e.get_error_message()})
-
- return xml
-
- def _redefine_iface_no_network(self, name):
- conn = self.conn.get()
-
+ def _redefine_iface_no_network(self, name, iface_xml):
# drop network config from definition of interface
- iface_xml = self._get_interface_desc_xml(name)
xml = get_no_network_config_xml(iface_xml.encode("utf-8"))
try:
# redefine interface
+ conn = self.conn.get()
conn.interfaceDefineXML(xml.encode("utf-8"))
except libvirt.libvirtError as e:
raise OperationFailed("KCHNET0024E", {'name': name,
diff --git a/src/wok/plugins/kimchi/network.py b/src/wok/plugins/kimchi/network.py
index 1433b8a..eee0e8c 100644
--- a/src/wok/plugins/kimchi/network.py
+++ b/src/wok/plugins/kimchi/network.py
@@ -31,6 +31,11 @@ DefaultNetsPool = [ipaddr.IPNetwork('192.168.122.0/23'),
ipaddr.IPNetwork('192.168.128.0/17')]
+def get_dev_macaddr(dev):
+ info = ethtool.get_interfaces_info(dev)[0]
+ return info.mac_address
+
+
def get_dev_netaddr(dev):
info = ethtool.get_interfaces_info(dev)[0]
return (info.ipv4_address and
diff --git a/src/wok/plugins/kimchi/xmlutils/interface.py b/src/wok/plugins/kimchi/xmlutils/interface.py
index 64df8cd..7730407 100644
--- a/src/wok/plugins/kimchi/xmlutils/interface.py
+++ b/src/wok/plugins/kimchi/xmlutils/interface.py
@@ -26,15 +26,27 @@ from wok.plugins.kimchi import osinfo
def get_iface_xml(params, arch=None, os_distro=None, os_version=None):
"""
- <interface type='network'>
+ <interface type='network' name='ethX'>
+ <start mode='onboot'/>
<source network='default'/>
<model type='virtio'/>
</interface>
"""
- interface = E.interface(type=params['type'])
- interface.append(E.source(network=params['network']))
+ name = params.get('name', None)
+ if name:
+ interface = E.interface(type=params.get('type', 'ethernet'), name=name)
+ else:
+ interface = E.interface(type=params.get('type', 'ethernet'))
- model = params.get('model')
+ stmode = params.get('startmode', None)
+ if stmode:
+ interface.append(E.start(mode=stmode))
+
+ nw = params.get('network', None)
+ if nw:
+ interface.append(E.source(network=nw))
+
+ model = params.get('model', None)
# no model specified; let's try querying osinfo
if model is None:
--
1.9.1
9 years, 1 month
[PATCH] Live Migration UI Support
by Socorro Stoppler
TODO:
- Error-handling
- Text not in i18n
- Getting data from user input in UI to be passed in to backend
There are places in kimchi.guest_main.js that I've tagged with //TODO
I've tested migrateGuest (in kimchi.api.js) by using hard-coded values to be passed in
to the backend so I know that API works. Hopefully just minimal modifications are needed
for the actual panel itself. The main piece missing is the user input from UI to be
passed into the backend.
Socorro Stoppler (1):
Initial checkin for live migration UI support
src/wok/plugins/ginger | 2 +-
src/wok/plugins/kimchi/ui/js/src/kimchi.api.js | 3 +-
.../plugins/kimchi/ui/js/src/kimchi.guest_main.js | 46 ++++++++++++++-
.../kimchi/ui/pages/guest-migration.html.tmpl | 65 ++++++++++++++++++++++
src/wok/plugins/kimchi/ui/pages/guest.html.tmpl | 1 +
5 files changed, 113 insertions(+), 4 deletions(-)
create mode 100644 src/wok/plugins/kimchi/ui/pages/guest-migration.html.tmpl
--
1.9.1
9 years, 1 month
[PATCH v2] Add checking for UI codes when running make check-local
by Ramon Medeiros
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
Changes:
v2:
Add Copyright text
Use diff to expose ui codes not used
---
Makefile.am | 1 +
check_ui_code_errors.sh | 31 ++++++++++++++++++++++++++
src/wok/plugins/kimchi/Makefile.am | 2 +-
src/wok/plugins/kimchi/check_ui_code_errors.sh | 31 ++++++++++++++++++++++++++
src/wok/plugins/kimchi/model/vms.py | 6 ++---
5 files changed, 67 insertions(+), 4 deletions(-)
create mode 100755 check_ui_code_errors.sh
create mode 100755 src/wok/plugins/kimchi/check_ui_code_errors.sh
diff --git a/Makefile.am b/Makefile.am
index 027344f..106a577 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -56,6 +56,7 @@ check-local:
$(PEP8) --version
$(PEP8) --filename '*.py,*.py.in' --exclude="$(PEP8_BLACKLIST)" .
+ /bin/bash check_ui_code_errors.sh
# Link built mo files in the source tree to enable use of translations from
# within the source tree
diff --git a/check_ui_code_errors.sh b/check_ui_code_errors.sh
new file mode 100755
index 0000000..58e5990
--- /dev/null
+++ b/check_ui_code_errors.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2015
+#
+# 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
+
+errors="$(cat ui/pages/i18n.json.tmpl | grep -o 'WOK[0-9A-Z]*'| sort)"
+uiErrors="$(grep -Ro 'WOK[0-9A-Z]*' ui/js/ | cut -d: -f2 | sort| uniq)"
+
+# all errors on i18n are present in js/html files: success
+if [ "$errors" == "$uiErrors" ]; then
+ echo "UI errors codes are correct"
+else
+ echo "Error while checking UI errors codes."
+ diff <(echo "$errors" ) <(echo "$uiErrors")
+fi
diff --git a/src/wok/plugins/kimchi/Makefile.am b/src/wok/plugins/kimchi/Makefile.am
index 8a55b23..250dc83 100644
--- a/src/wok/plugins/kimchi/Makefile.am
+++ b/src/wok/plugins/kimchi/Makefile.am
@@ -65,7 +65,7 @@ check-local:
$(PEP8) --version
$(PEP8) --filename '*.py,*.py.in' --exclude="$(PEP8_BLACKLIST)" .
-
+ ./check_ui_code_errors.sh
# Link built mo files in the source tree to enable use of translations from
# within the source tree
diff --git a/src/wok/plugins/kimchi/check_ui_code_errors.sh b/src/wok/plugins/kimchi/check_ui_code_errors.sh
new file mode 100755
index 0000000..e44c688
--- /dev/null
+++ b/src/wok/plugins/kimchi/check_ui_code_errors.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2015
+#
+# 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
+
+errors="$(cat ui/pages/i18n.json.tmpl | grep -o 'KCH[0-9A-Z]*'| sort)"
+uiErrors="$(grep -Ro 'KCH[0-9A-Z]*' ui/js/ | cut -d: -f2 | sort| uniq)"
+
+# all errors on i18n are present in js/html files: success
+if [ "$errors" == "$uiErrors" ]; then
+ echo "UI errors codes are correct"
+else
+ echo "Error while checking UI errors codes."
+ diff <(echo "$errors" ) <(echo "$uiErrors")
+fi
diff --git a/src/wok/plugins/kimchi/model/vms.py b/src/wok/plugins/kimchi/model/vms.py
index 7e12b91..366f1b4 100644
--- a/src/wok/plugins/kimchi/model/vms.py
+++ b/src/wok/plugins/kimchi/model/vms.py
@@ -1520,9 +1520,9 @@ class VMModel(object):
def migration_pre_check(self, remote_host, user, password):
self._check_if_host_not_localhost(remote_host)
self._check_if_password_less_login_enabled(
- remote_host,
- user,
- password
+ remote_host,
+ user,
+ password
)
self._check_if_migrating_same_arch_hypervisor(remote_host, user)
--
2.1.0
9 years, 1 month
[PATCH] Add OVS bridges recognition support
by Lucio Correia
In some distributions, i.e. Fedora, the directories "bridge"
and "brif" are not created for OVS bridges, and they are the
method Kimchi uses to detect bridges.
This patch fixes that by recognizing OVS bridges through OVS
commands, allowing networks to be created using OVS bridges
in those distributions.
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
src/wok/plugins/kimchi/model/networks.py | 2 +-
src/wok/plugins/kimchi/netinfo.py | 55 ++++++++++++++++++++++++++++----
2 files changed, 50 insertions(+), 7 deletions(-)
diff --git a/src/wok/plugins/kimchi/model/networks.py b/src/wok/plugins/kimchi/model/networks.py
index 71ea595..d78b88e 100644
--- a/src/wok/plugins/kimchi/model/networks.py
+++ b/src/wok/plugins/kimchi/model/networks.py
@@ -167,7 +167,7 @@ class NetworksModel(object):
raise MissingParameter("KCHNET0004E", {'name': params['name']})
self._ensure_iface_up(iface)
- if netinfo.is_bridge(iface):
+ if netinfo.is_bridge(iface) or netinfo.is_ovs_bridge(iface):
if 'vlan_id' in params:
raise InvalidParameter('KCHNET0019E', {'name': iface})
params['bridge'] = iface
diff --git a/src/wok/plugins/kimchi/netinfo.py b/src/wok/plugins/kimchi/netinfo.py
index c5746d7..f210da8 100644
--- a/src/wok/plugins/kimchi/netinfo.py
+++ b/src/wok/plugins/kimchi/netinfo.py
@@ -21,6 +21,8 @@ import ethtool
import glob
import os
+from distutils.spawn import find_executable
+from wok.utils import run_command
NET_PATH = '/sys/class/net'
NIC_PATH = '/sys/class/net/*/device'
@@ -79,6 +81,39 @@ def bridges():
def is_bridge(iface):
return iface in bridges()
+# OVS bridges need special handling because in some distributions, like Fedora,
+# the files bridge and brif are not created under /sys/class/net/<ovsbridge>.
+def ovs_bridges():
+ ovs_cmd = find_executable("ovs-vsctl")
+
+ # OVS not installed: there is no OVS bridge configured
+ if ovs_cmd is None:
+ return []
+
+ out, error, rc = run_command([ovs_cmd, '--oneline', 'list-br'])
+ if rc != 0 or len(out) == 0:
+ return []
+
+ return list(set(out.split('\n')) - set(['']))
+
+
+def is_ovs_bridge(iface):
+ return iface in ovs_bridges()
+
+
+def ovs_bridge_ports(ovsbr):
+ ovs_cmd = find_executable("ovs-vsctl")
+
+ # OVS not installed: there is no OVS bridge configured
+ if ovs_cmd is None:
+ return []
+
+ out, error, rc = run_command([ovs_cmd, '--oneline', 'list-ports', ovsbr])
+ if rc != 0 or len(out) == 0:
+ return []
+
+ return list(set(out.split('\n')) - set(['']))
+
def all_interfaces():
return [d.rsplit("/", 1)[-1] for d in glob.glob(NET_PATH + '/*')]
@@ -91,7 +126,12 @@ def slaves(bonding):
def ports(bridge):
- return os.listdir(BRIDGE_PORTS % bridge)
+ if bridge in bridges():
+ return os.listdir(BRIDGE_PORTS % bridge)
+ elif bridge in ovs_bridges():
+ return ovs_bridge_ports(bridge)
+
+ raise ValueError('unknown bridge %s' % bridge)
def is_brport(nic):
@@ -136,9 +176,11 @@ def get_vlan_device(vlan):
def get_bridge_port_device(bridge):
"""Return the nics list that belongs to bridge."""
- # br --- v --- bond --- nic1
- if bridge not in bridges():
+
+ if bridge not in bridges() and bridge not in ovs_bridges():
raise ValueError('unknown bridge %s' % bridge)
+
+ # br --- v --- bond --- nic1
nics = []
for port in ports(bridge):
if port in vlans():
@@ -155,9 +197,10 @@ def get_bridge_port_device(bridge):
def aggregated_bridges():
- return [bridge for bridge in bridges() if
- (set(get_bridge_port_device(bridge)) & set(nics()))]
+ all_bridges = list(set(bridges() + ovs_bridges()))
+ return [bridge for bridge in all_bridges if
+ (set(get_bridge_port_device(bridge)) & set(nics()))]
def bare_nics():
"The nic is not a port of a bridge or a slave of bond."
@@ -184,7 +227,7 @@ def get_interface_type(iface):
return "nic"
if is_bonding(iface):
return "bonding"
- if is_bridge(iface):
+ if is_bridge(iface) or is_ovs_bridge(iface):
return "bridge"
if is_vlan(iface):
return "vlan"
--
1.9.1
9 years, 1 month
[PATCH V3] Support Linux Bridge creation
by Lucio Correia
From: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
This commit adds a new option to bridged network creation
API: "macvtap". When it is chosen, the usual behavior for
option "bridge" will be applied.
This commit also changes the behavior for the already
existing "bridge" option. Now, when that option is chosen,
a Linux bridge will be created, not a macvtap one.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
V3:
- applied code review (including API change)
Test case results in ubuntu (no additional error added):
MASTER:
Ran 108 tests in 340.323s
FAILED (failures=2, errors=2, skipped=7)
This branch:
Ran 110 tests in 344.527s
FAILED (failures=2, errors=2, skipped=7)
IMPORTANT: This patch only changes backend. UI needs to
be adapted in a further patch.
---
src/wok/plugins/kimchi/API.json | 2 +-
src/wok/plugins/kimchi/docs/API.md | 11 +-
src/wok/plugins/kimchi/i18n.py | 5 +-
src/wok/plugins/kimchi/model/networks.py | 114 +++++++++++++++------
src/wok/plugins/kimchi/tests/test_mock_network.py | 16 ++-
src/wok/plugins/kimchi/tests/test_model_network.py | 2 +
src/wok/plugins/kimchi/tests/test_networkxml.py | 24 +++++
src/wok/plugins/kimchi/xmlutils/network.py | 25 +++++
8 files changed, 161 insertions(+), 38 deletions(-)
diff --git a/src/wok/plugins/kimchi/API.json b/src/wok/plugins/kimchi/API.json
index 961f35f..5b86ee1 100644
--- a/src/wok/plugins/kimchi/API.json
+++ b/src/wok/plugins/kimchi/API.json
@@ -342,7 +342,7 @@
"connection": {
"description": "Specifies how this network should be connected to the other networks",
"type": "string",
- "pattern": "^isolated|nat|bridge$",
+ "pattern": "^isolated|nat|bridge|macvtap$",
"required": true,
"error": "KCHNET0012E"
},
diff --git a/src/wok/plugins/kimchi/docs/API.md b/src/wok/plugins/kimchi/docs/API.md
index 52368b7..6cbe913 100644
--- a/src/wok/plugins/kimchi/docs/API.md
+++ b/src/wok/plugins/kimchi/docs/API.md
@@ -623,13 +623,16 @@ A interface represents available interface on host.
networks visible to this host.
* isolated: Create a private, isolated virtual network.
* nat: Outgoing traffic will be routed through the host.
- * bridge: All traffic on this network will be bridged through the indicated
- interface.
+ * macvtap: All traffic on this network will be bridged through the
+ specified interface.
+ * bridge: All traffic on this network will be bridged through a Linux
+ bridged, which is created upon specified interface in case
+ it is not already a Linux bridge.
* subnet *(optional)*: Network segment in slash-separated format with ip address and
prefix or netmask used to create nat network.
* interface *(optional)*: The name of a network interface on the host.
- For bridge network, the interface can be a bridge or nic/bonding
- device.
+ For "macvtap" and "bridge" connections, the
+ interface can be a nic, bridge or bonding device.
* vlan_id *(optional)*: VLAN tagging ID for the bridge network.
### Resource: Network
diff --git a/src/wok/plugins/kimchi/i18n.py b/src/wok/plugins/kimchi/i18n.py
index 59b61de..8de3a19 100644
--- a/src/wok/plugins/kimchi/i18n.py
+++ b/src/wok/plugins/kimchi/i18n.py
@@ -242,7 +242,7 @@ messages = {
"KCHNET0009E": _("Unable to find a free IP address for network '%(name)s'"),
"KCHNET0010E": _("The interface %(iface)s already exists."),
"KCHNET0011E": _("Network name must be a string without slashes (/) or quotes (\")"),
- "KCHNET0012E": _("Supported network types are isolated, NAT and bridge"),
+ "KCHNET0012E": _("Supported network types are isolated, NAT, macvtap and bridge"),
"KCHNET0013E": _("Network subnet must be a string with IP address and prefix or netmask"),
"KCHNET0014E": _("Network interface must be a string"),
"KCHNET0015E": _("Network VLAN ID must be an integer between 1 and 4094"),
@@ -253,6 +253,9 @@ messages = {
"KCHNET0020E": _("Failed to activate interface %(iface)s: %(err)s."),
"KCHNET0021E": _("Failed to activate interface %(iface)s. Please check the physical link status."),
"KCHNET0022E": _("Failed to start network %(name)s. Details: %(err)s"),
+ "KCHNET0023E": _("Unable to get XML definition for interface %(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"),
"KCHSR0001E": _("Storage server %(server)s was not used by Kimchi"),
diff --git a/src/wok/plugins/kimchi/model/networks.py b/src/wok/plugins/kimchi/model/networks.py
index 71ea595..54cb0ea 100644
--- a/src/wok/plugins/kimchi/model/networks.py
+++ b/src/wok/plugins/kimchi/model/networks.py
@@ -21,19 +21,21 @@ import ipaddr
import libvirt
import sys
import time
+from libvirt import VIR_INTERFACE_XML_INACTIVE
from xml.sax.saxutils import escape
from wok.config import PluginPaths
from wok.exception import InvalidOperation, InvalidParameter
from wok.exception import MissingParameter, NotFoundError, OperationFailed
-from wok.rollbackcontext import RollbackContext
from wok.utils import run_command, wok_log
from wok.xmlutils.utils import xpath_get_text
from wok.plugins.kimchi import netinfo
from wok.plugins.kimchi import network as knetwork
from wok.plugins.kimchi.osinfo import defaults as tmpl_defaults
+from wok.plugins.kimchi.xmlutils.network import create_linux_bridge_xml
from wok.plugins.kimchi.xmlutils.network import create_vlan_tagged_bridge_xml
+from wok.plugins.kimchi.xmlutils.network import get_no_network_config_xml
from wok.plugins.kimchi.xmlutils.network import to_network_xml
@@ -90,7 +92,7 @@ class NetworksModel(object):
self._set_network_subnet(params)
# only bridge network need bridge(linux bridge) or interface(macvtap)
- if connection == 'bridge':
+ if connection in ['bridge', 'macvtap']:
self._set_network_bridge(params)
params['name'] = escape(params['name'])
@@ -159,6 +161,7 @@ class NetworksModel(object):
def _set_network_bridge(self, params):
try:
+ # fails if host interface is already in use by a libvirt network
iface = params['interface']
if iface in self.get_all_networks_interfaces():
msg_args = {'iface': iface, 'network': params['name']}
@@ -166,11 +169,23 @@ 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"):
+ raise InvalidParameter('KCHNET0019E', {'name': iface})
+
+ # User specified bridge interface, simply use it
self._ensure_iface_up(iface)
if netinfo.is_bridge(iface):
- if 'vlan_id' in params:
- raise InvalidParameter('KCHNET0019E', {'name': iface})
params['bridge'] = iface
+
+ # User wants Linux bridge network, but didn't specify bridge interface
+ elif params['connection'] == "bridge":
+ # 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
@@ -190,42 +205,79 @@ class NetworksModel(object):
xml = network.XMLDesc(0)
net_dict = NetworkModel.get_network_from_xml(xml)
forward = net_dict['forward']
- (forward['mode'] == 'bridge' and forward['interface'] and
+ (forward['mode'] == 'macvtap' and forward['interface'] and
interfaces.append(forward['interface'][0]) is None or
interfaces.extend(forward['interface'] + forward['pf']))
net_dict['bridge'] and interfaces.append(net_dict['bridge'])
return interfaces
+ def _create_bridge(self, name, xml):
+ conn = self.conn.get()
+
+ # check if name exists
+ if name in netinfo.all_interfaces():
+ raise InvalidOperation("KCHNET0010E", {'iface': name})
+
+ # create bridge through libvirt
+ try:
+ bridge = conn.interfaceDefineXML(xml)
+ bridge.create()
+ except libvirt.libvirtError as e:
+ raise OperationFailed("KCHNET0025E", {'name': name,
+ 'err': e.get_error_message()})
+
+ def _create_linux_bridge(self, interface):
+ # get xml definition of interface
+ iface_xml = self._get_interface_desc_xml(interface)
+
+ # Truncate the interface name if it exceeds 13 characters to make sure
+ # the length of bridge name is less than 15 (its maximum value).
+ br_name = KIMCHI_BRIDGE_PREFIX + interface[-13:]
+ br_xml = create_linux_bridge_xml(br_name, interface, iface_xml)
+
+ # drop network config from interface
+ self._redefine_iface_no_network(interface)
+
+ # create and start bridge
+ self._create_bridge(br_name, br_xml)
+
+ return br_name
+
def _create_vlan_tagged_bridge(self, interface, vlan_id):
# Truncate the interface name if it exceeds 8 characters to make sure
# the length of bridge name is less than 15 (its maximum value).
br_name = KIMCHI_BRIDGE_PREFIX + interface[-8:] + '-' + vlan_id
br_xml = create_vlan_tagged_bridge_xml(br_name, interface, vlan_id)
+
+ self._create_bridge(br_name, br_xml)
+
+ return br_name
+
+ def _get_interface_desc_xml(self, name):
conn = self.conn.get()
- bridges = []
- for net in conn.listAllNetworks():
- # Bridged networks do not have a bridge name
- # So in those cases, libvirt raises an error when trying to get
- # the bridge name
- try:
- bridges.append(net.bridgeName())
- except libvirt.libvirtError, e:
- wok_log.error(e.message)
+ try:
+ iface = conn.interfaceLookupByName(name)
+ xml = iface.XMLDesc(flags=VIR_INTERFACE_XML_INACTIVE)
+ except libvirt.libvirtError, e:
+ raise OperationFailed("KCHNET0023E",
+ {'name': name, 'err': e.get_error_message()})
- if br_name in bridges:
- raise InvalidOperation("KCHNET0010E", {'iface': br_name})
+ return xml
- with RollbackContext() as rollback:
- try:
- vlan_tagged_br = conn.interfaceDefineXML(br_xml, 0)
- rollback.prependDefer(vlan_tagged_br.destroy)
- vlan_tagged_br.create(0)
- except libvirt.libvirtError as e:
- raise OperationFailed(e.message)
- else:
- return br_name
+ def _redefine_iface_no_network(self, name):
+ conn = self.conn.get()
+ # drop network config from definition of interface
+ iface_xml = self._get_interface_desc_xml(name)
+ xml = get_no_network_config_xml(iface_xml.encode("utf-8"))
+
+ try:
+ # redefine interface
+ iface = conn.interfaceDefineXML(xml.encode("utf-8"))
+ except libvirt.libvirtError as e:
+ raise OperationFailed("KCHNET0024E", {'name': name,
+ 'err': e.get_error_message()})
class NetworkModel(object):
def __init__(self, **kargs):
@@ -243,10 +295,12 @@ class NetworkModel(object):
connection = forward['mode'] or "isolated"
# FIXME, if we want to support other forward mode well.
- if connection == 'bridge':
- # macvtap bridge
+ # macvtap
+ if connection == 'macvtap':
interface = interface or forward['interface'][0]
- # exposing the network on linux bridge or macvtap interface
+
+ # exposing the network on Linux bridge or macvtap interface
+ if connection in ['bridge', 'macvtap']:
interface_subnet = knetwork.get_dev_netaddr(interface)
subnet = subnet if subnet else interface_subnet
@@ -333,7 +387,7 @@ class NetworkModel(object):
if network.isActive():
raise InvalidOperation("KCHNET0005E", {'name': name})
- self._remove_vlan_tagged_bridge(network)
+ self._remove_bridge(network)
network.undefine()
@staticmethod
@@ -369,7 +423,7 @@ class NetworkModel(object):
'interface': forward_if,
'pf': forward_pf}}
- def _remove_vlan_tagged_bridge(self, network):
+ def _remove_bridge(self, network):
try:
bridge = network.bridgeName()
except libvirt.libvirtError:
diff --git a/src/wok/plugins/kimchi/tests/test_mock_network.py b/src/wok/plugins/kimchi/tests/test_mock_network.py
index 4e2a939..e47f8ec 100644
--- a/src/wok/plugins/kimchi/tests/test_mock_network.py
+++ b/src/wok/plugins/kimchi/tests/test_mock_network.py
@@ -68,6 +68,18 @@ class MockNetworkTests(unittest.TestCase):
)
if len(interfaces) > 0:
iface = interfaces[0]['name']
- _do_network_test(self, model, {'name': u'bridge-network',
- 'connection': 'bridge',
+ _do_network_test(self, model, {'name': u'macvtap-network',
+ 'connection': 'macvtap',
'interface': iface, 'vlan_id': 987})
+
+ def test_linux_bridge(self):
+ # Verify the current system has at least one interface to create a
+ # bridged network
+ interfaces = json.loads(
+ self.request('/plugins/kimchi/interfaces?type=nic').read()
+ )
+ if len(interfaces) > 0:
+ iface = interfaces[0]['name']
+ _do_network_test(self, model, {'name': u'bridged-network',
+ 'connection': 'bridge',
+ 'interface': iface})
diff --git a/src/wok/plugins/kimchi/tests/test_model_network.py b/src/wok/plugins/kimchi/tests/test_model_network.py
index e4cf5ef..aad8a95 100644
--- a/src/wok/plugins/kimchi/tests/test_model_network.py
+++ b/src/wok/plugins/kimchi/tests/test_model_network.py
@@ -142,6 +142,8 @@ class NetworkTests(unittest.TestCase):
)
if len(interfaces) > 0:
iface = interfaces[0]['name']
+ networks.append({'name': u'macvtap-network',
+ 'connection': 'macvtap', 'interface': iface})
networks.append({'name': u'bridge-network', 'connection': 'bridge',
'interface': iface})
diff --git a/src/wok/plugins/kimchi/tests/test_networkxml.py b/src/wok/plugins/kimchi/tests/test_networkxml.py
index a64b6c2..e9485a8 100644
--- a/src/wok/plugins/kimchi/tests/test_networkxml.py
+++ b/src/wok/plugins/kimchi/tests/test_networkxml.py
@@ -170,3 +170,27 @@ class InterfaceXmlTests(unittest.TestCase):
"""
actual_xml = nxml.create_vlan_tagged_bridge_xml('br10', 'em1', '10')
self.assertEquals(actual_xml, utils.normalize_xml(expected_xml))
+
+ def test_linux_bridge_no_ip(self):
+ em1_xml = """
+ <interface type='ethernet' name='em1'>
+ <start mode='onboot'/>
+ <protocol family='ipv4'>
+ <dhcp/>
+ </protocol>
+ </interface>
+ """
+ expected_xml = """
+ <interface type='bridge' name='br10'>
+ <start mode='onboot'/>
+ <bridge>
+ <interface type='ethernet' name='em1' />
+ </bridge>
+ <protocol family='ipv4'>
+ <dhcp/>
+ </protocol>
+ </interface>
+ """
+ actual_xml = nxml.create_linux_bridge_xml('br10', 'em1',
+ utils.normalize_xml(em1_xml))
+ self.assertEquals(actual_xml, utils.normalize_xml(expected_xml))
diff --git a/src/wok/plugins/kimchi/xmlutils/network.py b/src/wok/plugins/kimchi/xmlutils/network.py
index c73aad9..14c7e13 100644
--- a/src/wok/plugins/kimchi/xmlutils/network.py
+++ b/src/wok/plugins/kimchi/xmlutils/network.py
@@ -120,3 +120,28 @@ def create_vlan_tagged_bridge_xml(bridge, interface, vlan_id):
type='bridge',
name=bridge)
return ET.tostring(m)
+
+def create_linux_bridge_xml(bridge, interface, iface_xml):
+ m = E.interface(
+ E.start(mode='onboot'),
+ E.bridge(
+ E.interface(
+ type='ethernet',
+ name=interface)),
+ type='bridge',
+ name=bridge)
+
+ # use same network configuration of lower interface
+ iface = ET.fromstring(iface_xml)
+ for element in iface.iter("protocol"):
+ m.append(element)
+
+ return ET.tostring(m)
+
+def get_no_network_config_xml(iface_xml):
+ # remove all protocol elements from interface xml
+ xml = ET.fromstring(iface_xml)
+ for element in xml.iter("protocol"):
+ element.getparent().remove(element)
+
+ return ET.tostring(xml)
--
1.9.1
9 years, 1 month
[PATCH V3] [Ginger-Base 0/1] Issue 728 - Processor Info in s390 architecture
by sureshab@linux.vnet.ibm.com
From: Suresh Babu Angadi <sureshab(a)in.ibm.com>
V2 -V3:
Changed test_host.py to check memory(Aline)
added description for get_total_cpus() of lscpu(Rodrigo)
V1 to V2 changes:
Changed cpus and memory object to be same across all platforms(aline)
Changed API.md and lookup as per review comments(aline & abhiram)
As per RFC mail thread -
[Kimchi-devel] RFC - #728 - Processor Info in s390 architecture
this patch set adds functionality in back-end to add
architecture, and host name(for all architecture),
split CPUs to online and offline(x86, s390x),
additional virtualization details(for s390x)
Note: Subsequent patch set from Chandra will include
UI changes to accommodate these changes
Test Cases Executed:
====================
1) On x86 machine(ppc o/p will be similar to x86):
curl -k -u suresh -H "Content-Type: application/json" -H "Accept: application/json" -X GET 'https://127.0.0.1:8001/plugins/gingerbase/host'
{
"os_distro":"Fedora",
"cpus":{
"offline":0,
"online":4
},
"cpu_model":"Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz",
"os_version":"21",
"host":"localhost.localdomain",
"os_codename":"Twenty One",
"architecture":"x86_64",
"memory":{
"offline":0,
"online":7933902848
}
}
2) On s390x machine:
curl -k -u root -H "Content-Type: application/json" -H "Accept: application/json" -X GET 'https://127.0.0.1:8001/plugins/gingerbase/host'
{
"os_distro":"KVM for IBM z Systems",
"cpus":{
"shared":2,
"offline":2,
"dedicated":0,
"online":2
},
"cpu_model":"IBM/2827/743 H43",
"os_version":"1.1.1",
"host":"zfwcec103",
"os_codename":"Z",
"architecture":"s390x",
"memory":{
"offline":2147483648,
"online":2147483648
},
"virtualization":{
"lpar_name":"CSTLIN1",
"hypervisor":"PR/SM",
"lpar_number":55,
"hypervisor_vendor":"IBM"
}
}
Suresh Babu Angadi (1):
Fix for issue 728: processor info displays blank for system z
this patch set also adds additional capability:
retrieving architecture and host name (for all architecture)
split CPUs to show online and offline cpus also
includes shared and dedicated cpus for s390x
split memory to show online and offline
additional virtualization details(for s390x):
virtualization will have hypervisor details and lpar details
src/wok/plugins/gingerbase/docs/API.md | 18 +-
src/wok/plugins/gingerbase/i18n.py | 1 +
src/wok/plugins/gingerbase/lscpu.py | 60 ++++++
src/wok/plugins/gingerbase/model/host.py | 259 ++++++++++++++++++++++----
src/wok/plugins/gingerbase/tests/test_host.py | 12 +-
5 files changed, 307 insertions(+), 43 deletions(-)
--
2.1.0
9 years, 1 month
[PATCH V2] [Ginger-Base 0/1] Issue 728 - Processor Info in s390 architecture
by sureshab@linux.vnet.ibm.com
From: Suresh Babu Angadi <sureshab(a)in.ibm.com>
V1 to V2 changes:
Changed cpus and memory object to be same across all platforms(aline)
Changed API.md and lookup as per review comments(aline & abhiram)
As per RFC mail thread -
[Kimchi-devel] RFC - #728 - Processor Info in s390 architecture
this patch set adds functionality in back-end to add
architecture, and host name(for all architecture),
split CPUs to online and offline(x86, s390x),
additional virtualization details(for s390x)
Note: Subsequent patch set for UI changes will follow
to accommodate these changes
Test Cases Executed:
====================
1) On x86 machine(ppc o/p will be similar to x86):
curl -k -u suresh -H "Content-Type: application/json" -H "Accept: application/json" -X GET 'https://127.0.0.1:8001/plugins/gingerbase/host'
{
"os_distro":"Fedora",
"cpus":{
"offline":0,
"online":4
},
"cpu_model":"Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz",
"os_version":"21",
"host":"localhost.localdomain",
"os_codename":"Twenty One",
"architecture":"x86_64",
"memory":{
"offline":0,
"online":7933902848
}
}
2) On s390x machine:
curl -k -u root -H "Content-Type: application/json" -H "Accept: application/json" -X GET 'https://127.0.0.1:8001/plugins/gingerbase/host'
{
"os_distro":"KVM for IBM z Systems",
"cpus":{
"shared":2,
"offline":2,
"dedicated":0,
"online":2
},
"cpu_model":"IBM/2827/743 H43",
"os_version":"1.1.1",
"host":"zfwcec103",
"os_codename":"Z",
"architecture":"s390x",
"memory":{
"offline":2147483648,
"online":2147483648
},
"virtualization":{
"lpar_name":"CSTLIN1",
"hypervisor":"PR/SM",
"lpar_number":55,
"hypervisor_vendor":"IBM"
}
}
Suresh Babu Angadi (1):
Fix for issue 728: processor info displays blank for system z
this patch set also adds additional capability:
retrieving architecture and host name (for all architecture)
split CPUs to show online and offline cpus also
includes shared and dedicated cpus for s390x
split memory to show online and offline
additional virtualization details(for s390x):
virtualization will have hypervisor details and lpar details
src/wok/plugins/gingerbase/docs/API.md | 18 +-
src/wok/plugins/gingerbase/i18n.py | 1 +
src/wok/plugins/gingerbase/lscpu.py | 60 ++++++
src/wok/plugins/gingerbase/model/host.py | 259 ++++++++++++++++++++++----
src/wok/plugins/gingerbase/tests/test_host.py | 12 +-
5 files changed, 307 insertions(+), 43 deletions(-)
--
2.1.0
9 years, 1 month