|
10 | 10 | import re |
11 | 11 | import tempfile |
12 | 12 |
|
| 13 | +import rpm |
13 | 14 | import repository |
14 | 15 | import generalui |
15 | 16 | import xelogging |
@@ -161,7 +162,7 @@ def getPrepSequence(ans, interactive): |
161 | 162 |
|
162 | 163 | def getMainRepoSequence(ans, repos): |
163 | 164 | seq = [] |
164 | | - seq.append(Task(repository.installFromRepos, lambda a: [repos] + [a.get('mounts'), a.get('kernel-alt'), a.get('linstor-version')], [], |
| 165 | + seq.append(Task(repository.installFromRepos, lambda a: [repos] + [a.get('mounts'), a.get('kernel-alt'), a.get('linstor-version'), a.get('xapi-version')], [], |
165 | 166 | progress_scale=100, |
166 | 167 | pass_progress_callback=True, |
167 | 168 | progress_text="Installing %s..." % (", ".join([repo.name() for repo in repos])))) |
@@ -440,6 +441,19 @@ def performInstallation(answers, ui_package, interactive): |
440 | 441 | "latest dedicated ISO." % |
441 | 442 | (answers['linstor-version'], ', '.join(available_linstor_versions))) |
442 | 443 |
|
| 444 | + # if upgrading a host with xapi, check we can upgrade it first |
| 445 | + if answers['install-type'] == INSTALL_TYPE_REINSTALL and answers['xapi-version']: |
| 446 | + available_xapi_versions = repository.listPackagesFromRepos( |
| 447 | + main_repositories, 'xapi-core', '%{evr}', latest_only=True) |
| 448 | + if not available_xapi_versions: |
| 449 | + raise RuntimeError("No XAPI package found in package source") |
| 450 | + assert len(available_xapi_versions) == 1 |
| 451 | + if rpm.labelCompare(('pkg', 'arch', available_xapi_versions[0]), ('pkg', 'arch', answers['xapi-version'])) < 0: |
| 452 | + raise RuntimeError("Cannot upgrade the host: the XAPI version on the host (%s) " |
| 453 | + "is newer than the XAPI version to install (%s). " |
| 454 | + "Please refer to the XCP-ng upgrade documentation." % |
| 455 | + (answers['xapi-version'], available_xapi_versions[0])) |
| 456 | + |
443 | 457 | # perform installation: |
444 | 458 | prep_seq = getPrepSequence(answers, interactive) |
445 | 459 | executeSequence(prep_seq, "Preparing for installation...", answers, ui_package, False) |
|
0 commit comments