[PATCH V1] [Kimchi] Only on s390x add default networks to template if template.conf has default network configuration uncommented.
by archus@linux.vnet.ibm.com
From: Archana Singh <archus(a)linux.vnet.ibm.com>
Below are the changes done for s390x architecture to only add default networks
to template if template.conf has network configuration uncommented
otherwise do not add any network by default.
1) Only on s390x, osinfo._get_tmpl_defaults() does not add
default network in case template.conf has commented out network configuration.
2) Only on s390x, NetworksModel._check_default_networks() does
not throw key error if networks not found in tmpl_defaults.
3) Only on s390x, VMTemplate.validate_integrity() does not throw
key error if networks not found in the template.
4) Only on s390x, LibvirtVMTemplate._network_validate() does not
throw key error on s390x if networks not found in tmpl_default, as on s390x networks is optional.
5) Only on s390x, VMTemplate._get_network_xml() does
return empty string and does not throw key error if networks not found in template object.
6) Only on s390x, control/templates.py gets networks as [] if not found
self.info.
7) Added method is_running_on_s390x in kimchi's utils.
Signed-off-by: Archana Singh <archus(a)linux.vnet.ibm.com>
---
control/templates.py | 2 +-
model/networks.py | 7 ++++++-
model/templates.py | 6 +++++-
osinfo.py | 14 +++++++++++++-
utils.py | 11 +++++++++++
vmtemplate.py | 17 ++++++++++++++---
6 files changed, 50 insertions(+), 7 deletions(-)
diff --git a/control/templates.py b/control/templates.py
index bb2e068..2dd8601 100644
--- a/control/templates.py
+++ b/control/templates.py
@@ -67,7 +67,7 @@ class Template(Resource):
'memory': self.info['memory'],
'cdrom': self.info.get('cdrom', None),
'disks': self.info['disks'],
- 'networks': self.info['networks'],
+ 'networks': self.info.get('networks', []),
'folder': self.info.get('folder', []),
'graphics': self.info['graphics'],
'cpu_info': self.info.get('cpu_info')
diff --git a/model/networks.py b/model/networks.py
index 35431d4..603a31c 100644
--- a/model/networks.py
+++ b/model/networks.py
@@ -35,6 +35,7 @@ from wok.plugins.kimchi import network as knetwork
from wok.plugins.kimchi.config import kimchiPaths
from wok.plugins.kimchi.model.config import CapabilitiesModel
from wok.plugins.kimchi.osinfo import defaults as tmpl_defaults
+from wok.plugins.kimchi.utils import is_running_on_s390x
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
@@ -55,7 +56,11 @@ class NetworksModel(object):
self.caps = CapabilitiesModel(**kargs)
def _check_default_networks(self):
- networks = list(set(tmpl_defaults['networks']))
+ if is_running_on_s390x():
+ networks = list(set(tmpl_defaults.get('networks', [])))
+ else:
+ networks = list(set(tmpl_defaults['networks']))
+
conn = self.conn.get()
for net_name in networks:
diff --git a/model/templates.py b/model/templates.py
index a299c85..387e4f1 100644
--- a/model/templates.py
+++ b/model/templates.py
@@ -35,6 +35,7 @@ from wok.plugins.kimchi.config import get_kimchi_version
from wok.plugins.kimchi.kvmusertests import UserTests
from wok.plugins.kimchi.model.cpuinfo import CPUInfoModel
from wok.plugins.kimchi.utils import is_libvirtd_up, pool_name_from_uri
+from wok.plugins.kimchi.utils import is_running_on_s390x
from wok.plugins.kimchi.vmtemplate import VMTemplate
ISO_TYPE = "ISO 9660 CD-ROM"
@@ -358,7 +359,10 @@ class LibvirtVMTemplate(VMTemplate):
return sorted(map(lambda x: x.decode('utf-8'), names))
def _network_validate(self):
- names = self.info['networks']
+ if is_running_on_s390x():
+ names = self.info.get('networks', [])
+ else:
+ names = self.info['networks']
for name in names:
try:
conn = self.conn.get()
diff --git a/osinfo.py b/osinfo.py
index 2c59312..af37c72 100644
--- a/osinfo.py
+++ b/osinfo.py
@@ -138,10 +138,22 @@ def _get_tmpl_defaults():
'pool': '/plugins/kimchi/storagepools/default'}},
'processor': {'vcpus': '1', 'maxvcpus': 1},
'graphics': {'type': 'spice', 'listen': '127.0.0.1'}}
+
+ The default values on s390x architecture:
+
+ {'memory': {'current': 1024, 'maxmemory': 1024},
+ 'storage': { 'disk.0': {'format': 'qcow2', 'size': '10',
+ 'pool': '/plugins/kimchi/storagepools/default'}},
+ 'processor': {'vcpus': '1', 'maxvcpus': 1},
+ 'graphics': {'type': 'spice', 'listen': '127.0.0.1'}}
"""
# Create dict with default values
tmpl_defaults = defaultdict(dict)
- tmpl_defaults['main']['networks'] = ['default']
+
+ host_arch = _get_arch()
+ if host_arch not in ['s390x']:
+ tmpl_defaults['main']['networks'] = ['default']
+
tmpl_defaults['memory'] = {'current': _get_default_template_mem(),
'maxmemory': _get_default_template_mem()}
tmpl_defaults['storage']['disk.0'] = {'size': 10, 'format': 'qcow2',
diff --git a/utils.py b/utils.py
index 26d3cf6..b88740a 100644
--- a/utils.py
+++ b/utils.py
@@ -20,6 +20,7 @@
import contextlib
import json
+import os
import platform
import re
import sqlite3
@@ -272,3 +273,13 @@ def is_libvirtd_up():
output, error, rc = run_command(cmd, silent=True)
return True if output == 'active\n' else False
+
+
+def is_running_on_s390x():
+ """
+ Checks if running on s390x.
+ """
+ if os.uname()[4] == 's390x':
+ return True
+ else:
+ return False
diff --git a/vmtemplate.py b/vmtemplate.py
index 7ac0541..f5405fa 100644
--- a/vmtemplate.py
+++ b/vmtemplate.py
@@ -288,7 +288,13 @@ class VMTemplate(object):
networks = ""
params = {'type': 'network',
'model': self.info['nic_model']}
- for nw in self.info['networks']:
+
+ if self.info.get('arch') == 's390x':
+ info_networks = self.info.get('networks', [])
+ else:
+ info_networks = self.info['networks']
+
+ for nw in info_networks:
params['network'] = nw
networks += get_iface_xml(params, self.info['arch'],
self.info['os_distro'],
@@ -353,7 +359,7 @@ class VMTemplate(object):
graphics.update(kwargs.get('graphics', {}))
# Graphics is not supported on s390x, this check will
# not add graphics tag in domain xml.
- if params['arch'] not in ['s390x']:
+ if params.get('arch') != 's390x':
params['graphics'] = get_graphics_xml(graphics)
libvirt_stream_protocols = kwargs.get('libvirt_stream_protocols', [])
@@ -487,7 +493,12 @@ class VMTemplate(object):
def validate_integrity(self):
invalid = {}
# validate networks integrity
- invalid_networks = list(set(self.info['networks']) -
+ if self.info.get('arch') == 's390x':
+ networks = self.info.get('networks', [])
+ else:
+ networks = self.info['networks']
+
+ invalid_networks = list(set(networks) -
set(self._get_all_networks_name()))
if invalid_networks:
invalid['networks'] = invalid_networks
--
2.7.4
8 years, 4 months
[PATCH][Kimchi] Fix when calling error message in storagepool
by Ramon Medeiros
Error message was waiting a string with index "pool", instead of "name"
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
model/storagevolumes.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/model/storagevolumes.py b/model/storagevolumes.py
index 91e1c6b..c55217c 100644
--- a/model/storagevolumes.py
+++ b/model/storagevolumes.py
@@ -284,7 +284,7 @@ class StorageVolumeModel(object):
def get_storagevolume(poolname, name, conn):
pool = StoragePoolModel.get_storagepool(poolname, conn)
if not pool.isActive():
- raise InvalidOperation("KCHVOL0006E", {'name': pool})
+ raise InvalidOperation("KCHVOL0006E", {'pool': pool.name()})
try:
return pool.storageVolLookupByName(name.encode("utf-8"))
except libvirt.libvirtError as e:
--
2.5.5
8 years, 4 months
[PATCH][Kimchi] Issue #933: Invalid image path not marking template as "invalid" (back-end)
by Ramon Medeiros
Template was not checking if image-based templates are still valid. Now,
if image is missing, an warning will be displayed at UI
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
vmtemplate.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/vmtemplate.py b/vmtemplate.py
index 79730cf..7ac0541 100644
--- a/vmtemplate.py
+++ b/vmtemplate.py
@@ -492,13 +492,19 @@ class VMTemplate(object):
if invalid_networks:
invalid['networks'] = invalid_networks
- # validate storagepools integrity
+ # validate storagepools and image-based templates integrity
for disk in self.info['disks']:
pool_uri = disk['pool']['name']
pool_name = pool_name_from_uri(pool_uri)
if pool_name not in self._get_active_storagepools_name():
invalid['storagepools'] = [pool_name]
+ if disk.get("base") is None:
+ continue
+
+ if os.path.exists(disk.get("base")) is False:
+ invalid['vm-image'] = disk["base"]
+
# validate iso integrity
# FIXME when we support multiples cdrom devices
iso = self.info.get('cdrom')
--
2.5.5
8 years, 4 months
[PATCH][Kimchi] Fix test_model pep8 non-compliant syntax
by Ramon Medeiros
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
tests/test_model.py | 29 ++++++++++-------------------
1 file changed, 10 insertions(+), 19 deletions(-)
diff --git a/tests/test_model.py b/tests/test_model.py
index 27225f8..09821b1 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -466,12 +466,9 @@ class ModelTests(unittest.TestCase):
self.assertEqual(fw_manager.opened_ports, {})
mock_run_cmd.assert_has_calls(
- [
- call(['firewall-cmd', '--state', '-q']),
- call(['firewall-cmd', '--add-port=5905/tcp']),
- call(['firewall-cmd', '--remove-port=5905/tcp'])
- ]
- )
+ [call(['firewall-cmd', '--state', '-q']),
+ call(['firewall-cmd', '--add-port=5905/tcp']),
+ call(['firewall-cmd', '--remove-port=5905/tcp'])])
@mock.patch('wok.plugins.kimchi.model.virtviewerfile.run_command')
def test_firewall_provider_ufw(self, mock_run_cmd):
@@ -487,13 +484,10 @@ class ModelTests(unittest.TestCase):
self.assertEqual(fw_manager.opened_ports, {})
mock_run_cmd.assert_has_calls(
- [
- call(['firewall-cmd', '--state', '-q']),
- call(['ufw', 'status']),
- call(['ufw', 'allow', '5905/tcp']),
- call(['ufw', 'deny', '5905/tcp'])
- ]
- )
+ [call(['firewall-cmd', '--state', '-q']),
+ call(['ufw', 'status']),
+ call(['ufw', 'allow', '5905/tcp']),
+ call(['ufw', 'deny', '5905/tcp'])])
@mock.patch('wok.plugins.kimchi.model.virtviewerfile.run_command')
def test_firewall_provider_iptables(self, mock_run_cmd):
@@ -515,12 +509,9 @@ class ModelTests(unittest.TestCase):
5905, '-j', 'ACCEPT']
mock_run_cmd.assert_has_calls(
- [
- call(['firewall-cmd', '--state', '-q']),
- call(['ufw', 'status']),
- call(iptables_add), call(iptables_del)
- ]
- )
+ [call(['firewall-cmd', '--state', '-q']),
+ call(['ufw', 'status']),
+ call(iptables_add), call(iptables_del)])
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
@mock.patch('wok.plugins.kimchi.model.virtviewerfile.'
--
2.5.5
8 years, 4 months
[RFC] Invalid image path not marking template as "invalid" (kimchi-project/kimchi: Issue #933)
by Ramon Medeiros
vmtemplate.py has a function that checks template integrity
(validate_integrity), that check template and if found some parameters
invalid, warn the user.
Today, the function is not verifying disks. I'll do it. Just want to
make sure i'm checking all kind:
Here is the function:
def validate_integrity(self):
invalid = {}
# validate networks integrity
invalid_networks = list(set(self.info['networks']) -
set(self._get_all_networks_name()))
if invalid_networks:
invalid['networks'] = invalid_networks
# validate storagepools and integrity
for disk in self.info['disks']:
pool_uri = disk['pool']['name']
pool_name = pool_name_from_uri(pool_uri)
if pool_name not in self._get_active_storagepools_name():
invalid['storagepools'] = [pool_name]
if os.path.exists(disk["base"])
# validate iso integrity
# FIXME when we support multiples cdrom devices
iso = self.info.get('cdrom')
if iso:
if os.path.exists(iso):
st_mode = os.stat(iso).st_mode
if not (stat.S_ISREG(st_mode) or stat.S_ISBLK(st_mode)):
invalid['cdrom'] = [iso]
elif not check_url_path(iso):
invalid['cdrom'] = [iso]
self.info['invalid'] = invalid
return self.info
I just need to get the loop "# validate storagepools and integrity" and
add a checking:
# validate storagepools and integrity
for disk in self.info['disks']:
pool_uri = disk['pool']['name']
pool_name = pool_name_from_uri(pool_uri)
if pool_name not in self._get_active_storagepools_name():
invalid['storagepools'] = [pool_name]
+
+ if not os.path.exists(disk.get("base")):
+ invalid["disks"] = disk
+
I guess this way i can validate disks on dir storagepools, and nfs. But,
what about netboot and other kind?
--
Ramon Nunes Medeiros
Kimchi Developer
Linux Technology Center Brazil
IBM Systems & Technology Group
Phone : +55 19 2132 7878
ramonn(a)br.ibm.com
8 years, 4 months
[PATCH] [Wok] Status Label on user log #145
by peterpnns@gmail.com
From: peterpennings <peterpnns(a)gmail.com>
This patch adds a label message to show the HTTP status code on user log.
peterpennings:
Status label on user log #145
ui/js/wok.user-log.js | 37 ++++-
ui/pages/i18n.json.tmpl | 1 +
2 files changed, 320 insertions(+), 24 deletions(-)
--
2.5.0
8 years, 4 months
[PATCH v3][Kimchi 0/3] Issue #857: Support VM description
by Ramon Medeiros
Changes:
v3:
Fix pep8 issues
v2:
Create xml tag when updating a xml that does not have the tag
Update messages to use Virtual machine instead of VM
Ramon Medeiros (3):
Issue #857: Support VM description
Update tests
Update docs
API.json | 20 ++++++++++++++++++++
docs/API.md | 6 ++++++
i18n.py | 2 ++
model/vms.py | 34 +++++++++++++++++++++++++++++++---
tests/test_mockmodel.py | 3 ++-
tests/test_model.py | 3 ++-
vmtemplate.py | 5 ++++-
7 files changed, 67 insertions(+), 6 deletions(-)
--
2.5.5
8 years, 4 months
[PATCH v2][Kimchi 0/3] Issue #857: Support VM description
by Ramon Medeiros
Changes:
Create xml tag when updating a xml that does not have the tag
Update messages to use Virtual machine instead of VM
Ramon Medeiros (3):
Issue #857: Support VM description
Update tests
Update docs
API.json | 20 ++++++++++++++++++++
docs/API.md | 6 ++++++
i18n.py | 2 ++
model/vms.py | 35 ++++++++++++++++++++++++++++++++---
tests/test_mockmodel.py | 3 ++-
tests/test_model.py | 3 ++-
vmtemplate.py | 5 ++++-
7 files changed, 68 insertions(+), 6 deletions(-)
--
2.5.5
8 years, 4 months