|
27 | 27 | from distutils.version import LooseVersion
|
28 | 28 |
|
29 | 29 | from wok.config import PluginPaths
|
| 30 | +from wok.utils import wok_log |
| 31 | +from wok.exception import InvalidParameter |
30 | 32 | from wok.plugins.kimchi.config import kimchiPaths
|
31 | 33 |
|
32 |
| - |
33 | 34 | SUPPORTED_ARCHS = {'x86': ('i386', 'i686', 'x86_64'),
|
34 | 35 | 'power': ('ppc', 'ppc64'),
|
35 | 36 | 'ppc64le': ('ppc64le'),
|
@@ -176,14 +177,43 @@ def _get_tmpl_defaults():
|
176 | 177 | default_config = ConfigObj(tmpl_defaults)
|
177 | 178 |
|
178 | 179 | # 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') |
185 | 181 | config = ConfigObj(config_file)
|
186 | 182 |
|
| 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 | + |
187 | 217 | # Merge default configuration with file configuration
|
188 | 218 | default_config.merge(config)
|
189 | 219 |
|
|
0 commit comments