Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import re
import tempfile

import rpm
import repository
import generalui
import xelogging
Expand Down Expand Up @@ -161,7 +162,7 @@ def getPrepSequence(ans, interactive):

def getMainRepoSequence(ans, repos):
seq = []
seq.append(Task(repository.installFromRepos, lambda a: [repos] + [a.get('mounts'), a.get('kernel-alt'), a.get('linstor-version')], [],
seq.append(Task(repository.installFromRepos, lambda a: [repos] + [a.get('mounts'), a.get('kernel-alt'), a.get('linstor-version'), a.get('xapi-version')], [],
Comment thread
stormi marked this conversation as resolved.
progress_scale=100,
pass_progress_callback=True,
progress_text="Installing %s..." % (", ".join([repo.name() for repo in repos]))))
Expand Down Expand Up @@ -440,6 +441,19 @@ def performInstallation(answers, ui_package, interactive):
"latest dedicated ISO." %
(answers['linstor-version'], ', '.join(available_linstor_versions)))

# if upgrading a host with xapi, check we can upgrade it first
if answers['install-type'] == INSTALL_TYPE_REINSTALL and answers['xapi-version']:
available_xapi_versions = repository.listPackagesFromRepos(
main_repositories, 'xapi-core', '%{evr}', latest_only=True)
if not available_xapi_versions:
raise RuntimeError("No XAPI package found in package source")
assert len(available_xapi_versions) == 1
if rpm.labelCompare(('pkg', 'arch', available_xapi_versions[0]), ('pkg', 'arch', answers['xapi-version'])) < 0:
raise RuntimeError("Cannot upgrade the host: the XAPI version on the host (%s) "
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't we just say that it may be better to make it a warning screen rather than a fatal error?

"is newer than the XAPI version to install (%s). "
"Please refer to the XCP-ng upgrade documentation." %
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not forget to add said doc. We can discuss what we should tell users. I know it's already covered at least for migration from XS, but I'm thinking about users who'd go check the docs after they saw the error. Something that explicitly gives them the error message their search for and explains their options.

(answers['xapi-version'], available_xapi_versions[0]))

# perform installation:
prep_seq = getPrepSequence(answers, interactive)
executeSequence(prep_seq, "Preparing for installation...", answers, ui_package, False)
Expand Down
11 changes: 11 additions & 0 deletions product.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ def getLinstorVersion(rootfs_mount):
return None
return out

def getXapiVersion(rootfs_mount):
""" Returns the package version of the xapi packages"""
command = ['rpm', '--root', rootfs_mount, '-q', '--qf', '%{evr}', 'xapi-core']
rc, out = util.runCmd2(command, with_stdout=True)
if rc != 0:
return None
return out

class ExistingInstallation:
def __init__(self, primary_disk, boot_device, state_device):
self.primary_disk = primary_disk
Expand Down Expand Up @@ -388,6 +396,9 @@ def fetchIfaceInfoFromNetworkdbAsDict(bridge, iface=None):
results['linstor-version'] = getLinstorVersion(self.state_fs.mount_point) or None
logger.info("LINSTOR version detected: %s" % (results['linstor-version'],))

results['xapi-version'] = getXapiVersion(self.state_fs.mount_point) or None
logger.info("xapi version detected: %s" % (results['xapi-version'],))

finally:
self.unmount_state()

Expand Down
4 changes: 2 additions & 2 deletions repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ def hideNullEpoch(package):
return package
return "".join(m.groups())

def listPackagesFromRepos(repos, rpm_pattern, query_format='%{nevr}'):
def listPackagesFromRepos(repos, rpm_pattern, query_format='%{nevr}', latest_only=False):
cachedir = "var/cache/yum/installer"
yum_conf_path = '/root/yum-repoquery.conf'

Expand All @@ -944,7 +944,7 @@ def listPackagesFromRepos(repos, rpm_pattern, query_format='%{nevr}'):

rv, out = util.runCmd2(['repoquery', '-c', yum_conf_path,
'--qf', query_format,
rpm_pattern], with_stdout=True)
rpm_pattern] + ([] if latest_only else ['--show-duplicates']), with_stdout=True)
finally:
for repo in repos:
repo._accessor.finish()
Expand Down
4 changes: 2 additions & 2 deletions upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def replace_config(config_file, destination):
primary_fs.unmount()

prepUpgradeArgs = []
prepStateChanges = ['installation-uuid', 'control-domain-uuid', 'management-address-type', 'linstor-version']
prepStateChanges = ['installation-uuid', 'control-domain-uuid', 'management-address-type', 'linstor-version', 'xapi-version']
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather add xapi-version (which could be interesting upstream) before linstor-version (which I'm less sure we'll manage to upstream easily)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, but as we need both on the same line, and for now this PR is based on the version with all the branches merged. I'll take care of that later when I'll make this PR based on upstream only :-)

def prepareUpgrade(self, progress_callback):
""" Try to preserve the installation and control-domain UUIDs from
xensource-inventory."""
Expand All @@ -619,7 +619,7 @@ def prepareUpgrade(self, progress_callback):
except KeyError:
raise RuntimeError("Required information (INSTALLATION_UUID, CONTROL_DOMAIN_UUID, MANAGEMENT_ADDRESS_TYPE) was missing from your xensource-inventory file. Aborting installation; please replace these keys and try again.")

return installID, controlID, mgmtAddrType, self.source.settings['linstor-version']
return installID, controlID, mgmtAddrType, self.source.settings['linstor-version'], self.source.settings['xapi-version']

def buildRestoreList(self, src_base):
restore_list = []
Expand Down