Skip to content

Commit 9c6d48a

Browse files
Archana Singhalinefm
Archana Singh
authored andcommitted
s390x specific changes to support storage path and storage pool as disk.
1) As on s390x, default is storage path, but if pool explicitly specified in template.conf it takes preference. So added code to ensure that if storage pool explicitly specified in file conf then check for default storage pool is performed. 2) Code changes in tmpl default creation which ensure that on s390x, default disk is path but if conf file has explicitly pool specified then defult disk is the sepecified pool. And also ensures that disk is either pool or path and not both. 3) Code changes in vmtemplate, to ensure that on s390x either a path disk or a pool disk can be added to template. And if disk to add does not have both path and pool then tmpl default storage is used. 4) Added 'path' specific to s390x only as commented in template.conf. Signed-off-by: Archana Singh <[email protected]>
1 parent 9764bdb commit 9c6d48a

File tree

4 files changed

+70
-18
lines changed

4 files changed

+70
-18
lines changed

model/storagepools.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ def __init__(self, **kargs):
7373
def _check_default_pools(self):
7474
pools = {}
7575

76-
if is_s390x():
76+
# Don't create default pool if it's not
77+
# explicitly specified in template.conf
78+
if is_s390x() and 'pool' not in tmpl_defaults['disks'][0]:
7779
return
7880

7981
default_pool = tmpl_defaults['disks'][0]['pool']['name']
@@ -91,7 +93,7 @@ def _check_default_pools(self):
9193
error_msg = ("Storage pool %s does not exist or is not "
9294
"active. Please, check the configuration in "
9395
"%s/template.conf to ensure it lists only valid "
94-
"networks." % (pool_name, kimchiPaths.sysconf_dir))
96+
"storage." % (pool_name, kimchiPaths.sysconf_dir))
9597
try:
9698
pool = conn.storagePoolLookupByName(pool_name)
9799
except libvirt.libvirtError, e:

osinfo.py

+37-7
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727
from distutils.version import LooseVersion
2828

2929
from wok.config import PluginPaths
30+
from wok.utils import wok_log
31+
from wok.exception import InvalidParameter
3032
from wok.plugins.kimchi.config import kimchiPaths
3133

32-
3334
SUPPORTED_ARCHS = {'x86': ('i386', 'i686', 'x86_64'),
3435
'power': ('ppc', 'ppc64'),
3536
'ppc64le': ('ppc64le'),
@@ -176,14 +177,43 @@ def _get_tmpl_defaults():
176177
default_config = ConfigObj(tmpl_defaults)
177178

178179
# Load template configuration file
179-
if is_on_s390x:
180-
config_file = os.path.join(
181-
kimchiPaths.sysconf_dir,
182-
'template_s390x.conf')
183-
else:
184-
config_file = os.path.join(kimchiPaths.sysconf_dir, 'template.conf')
180+
config_file = os.path.join(kimchiPaths.sysconf_dir, 'template.conf')
185181
config = ConfigObj(config_file)
186182

183+
# File configuration takes preference.
184+
# In s390x, file configuration can have storage pool or path.
185+
# Default configuration for s390x is storage path.
186+
# In case file conf has storage pool then storage pool takes preference.
187+
# When conf file has explicitly storage pool: "defaults" should
188+
# have storage pool and default configured path should be removed,
189+
# as either storage can be path or pool, cannot be both.
190+
# When conf file does not explicity storage pool or have explicitly
191+
# storage path: "default" should have storage path only and cannot
192+
# have default pool.
193+
#
194+
# Check file conf has storage configured.
195+
if is_on_s390x and config.get('storage').get('disk.0'):
196+
# remove storage from default_config as file configuration takes
197+
# preference.
198+
default_config.pop('storage')
199+
200+
# Get storage configuration present in conf file
201+
config_pool = config.get('storage').get('disk.0').get('pool')
202+
config_path = config.get('storage').get('disk.0').get('path')
203+
204+
# If storage configured in conf file then it should have either
205+
# pool or path.
206+
if not config_pool and not config_path:
207+
raise InvalidParameter('KCHTMPL0040E')
208+
209+
# On s390x if config file has both path and pool uncommented
210+
# then path should take preference.
211+
if config_pool and config_path:
212+
wok_log.warning("Both default pool and path are specified in" +
213+
" template.conf. Hence default pool is being" +
214+
" ignored and only default path will be used")
215+
config.get('storage').get('disk.0').pop('pool')
216+
187217
# Merge default configuration with file configuration
188218
default_config.merge(config)
189219

template.conf

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
# Storage pool used to handle the guest disk
2929
#pool = default
3030

31+
# Only Applicable for s390x. Storage path used to handle the guest disk.
32+
# In Each disk, pool and path are mutually exclusive parameters and
33+
# pool will be ignored in case of both specified.
34+
#path = /var/lib/libvirt/images
35+
3136
[graphics]
3237
# Graphics type
3338
# Valid options: vnc | spice

vmtemplate.py

+24-9
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,25 @@ def __init__(self, args, scan=False, netboot=False):
106106

107107
for index, disk in enumerate(disks):
108108
disk_info = dict(default_disk)
109-
# on s390x/s390 either pool or path should be present in
110-
# default disk.
111-
if is_s390x() and 'pool' not in default_disk and \
112-
'path' not in default_disk:
113-
raise InvalidParameter('KCHTMPL0040E')
114109

115-
# On s390x/s390 pool is optional attribute for disk.
116-
pool = disk.get('pool', default_disk.get('pool'))
110+
if is_s390x():
111+
# Default disk should have either pool or path.
112+
if 'pool' not in default_disk and 'path' not in default_disk:
113+
raise InvalidParameter('KCHTMPL0040E')
114+
115+
# Each disk should have either pool or path.
116+
# if not then use "default_disk" configuration.
117+
pool = disk.get('pool')
118+
path = disk.get('path')
119+
if not path and not pool:
120+
# If default disk is path then set disk with default path
121+
if default_disk.get('path'):
122+
path = default_disk.get('path')
123+
# If default disk is pool then set disk with default pool
124+
elif default_disk.get('pool'):
125+
pool = default_disk.get('pool')
126+
else:
127+
pool = disk.get('pool', default_disk.get('pool'))
117128

118129
if pool:
119130
pool_type = self._get_storage_type(pool['name'])
@@ -148,8 +159,12 @@ def __init__(self, args, scan=False, netboot=False):
148159
disk_info['index'] = disk_info.get('index', index)
149160
self.info['disks'][index] = disk_info
150161
elif is_s390x():
151-
# For now support 'path' only on s390x
152-
path = disk.get('path', default_disk.get('path'))
162+
# This check is required where 'path' disk
163+
# has to be added and hence default pool
164+
# has to be removed during template update.
165+
if 'pool' in disk_info:
166+
del disk_info['pool']
167+
153168
disk_info.update(disk)
154169
keys = sorted(disk_info.keys())
155170
if ((keys != sorted(basic_path_disk)) and

0 commit comments

Comments
 (0)