Skip to content

Commit 53353b3

Browse files
gthvn1ydirson
authored andcommitted
Use the management address type from old install
During an upgrade we need to use the management address from the installation read from /etc/xensource-inventory. This does not change the behaviour of installation. Signed-off-by: Guillaume <[email protected]> Signed-off-by: Yann Dirson <[email protected]>
1 parent d4a492b commit 53353b3

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

backend.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def getPrepSequence(ans, interactive):
105105
seq = [
106106
Task(util.getUUID, As(ans), ['installation-uuid']),
107107
Task(util.getUUID, As(ans), ['control-domain-uuid']),
108+
Task(util.getMgmtAddrType, As(ans), ['management-address-type']),
108109
Task(util.randomLabelStr, As(ans), ['disk-label-suffix']),
109110
Task(partitionTargetDisk, A(ans, 'primary-disk', 'installation-to-overwrite', 'preserve-first-partition','sr-on-primary', 'target-platform'),
110111
['target-boot-mode', 'primary-partnum', 'backup-partnum', 'storage-partnum', 'boot-partnum', 'logs-partnum', 'swap-partnum']),
@@ -188,7 +189,7 @@ def getFinalisationSequence(ans):
188189
Task(writeFstab, A(ans, 'mounts', 'target-boot-mode', 'primary-disk', 'logs-partnum', 'swap-partnum', 'disk-label-suffix'), []),
189190
Task(enableAgent, A(ans, 'mounts', 'network-backend', 'services'), []),
190191
Task(configureCC, A(ans, 'mounts'), []),
191-
Task(writeInventory, A(ans, 'installation-uuid', 'control-domain-uuid', 'mounts', 'primary-disk',
192+
Task(writeInventory, A(ans, 'installation-uuid', 'control-domain-uuid', 'management-address-type', 'mounts', 'primary-disk',
192193
'backup-partnum', 'logs-partnum', 'boot-partnum', 'swap-partnum', 'storage-partnum',
193194
'guest-disks', 'net-admin-bridge',
194195
'branding', 'net-admin-configuration', 'host-config', 'install-type'), []),
@@ -1590,7 +1591,7 @@ def writeXencommons(controlID, mounts):
15901591
with open(os.path.join(mounts['root'], constants.XENCOMMONS_FILE), "w") as f:
15911592
f.write(contents)
15921593

1593-
def writeInventory(installID, controlID, mounts, primary_disk, backup_partnum, logs_partnum, boot_partnum, swap_partnum,
1594+
def writeInventory(installID, controlID, mgmtAddrType, mounts, primary_disk, backup_partnum, logs_partnum, boot_partnum, swap_partnum,
15941595
storage_partnum, guest_disks, admin_bridge, branding, admin_config, host_config, install_type):
15951596
inv = open(os.path.join(mounts['root'], constants.INVENTORY_FILE), "w")
15961597
if 'product-brand' in branding:
@@ -1640,11 +1641,16 @@ def writeInventory(installID, controlID, mounts, primary_disk, backup_partnum, l
16401641
inv.write("DOM0_MEM='%d'\n" % host_config['dom0-mem'])
16411642
inv.write("DOM0_VCPUS='%d'\n" % host_config['dom0-vcpus'])
16421643
inv.write("MANAGEMENT_INTERFACE='%s'\n" % admin_bridge)
1643-
# Default to IPv4 unless we have only got an IPv6 admin interface
1644-
if ((not admin_config.mode) and admin_config.modev6):
1645-
inv.write("MANAGEMENT_ADDRESS_TYPE='IPv6'\n")
1644+
# If we read MANAGEMENT_ADDRESS_TYPE from xensource-inventory use it
1645+
if mgmtAddrType:
1646+
# On upgrade, persist value read from install
1647+
inv.write("MANAGEMENT_ADDRESS_TYPE='%s'\n" % mgmtAddrType)
16461648
else:
1647-
inv.write("MANAGEMENT_ADDRESS_TYPE='IPv4'\n")
1649+
# On install, default to IPv4 unless we have only got an IPv6 admin interface
1650+
if ((not admin_config.mode) and admin_config.modev6):
1651+
inv.write("MANAGEMENT_ADDRESS_TYPE='IPv6'\n")
1652+
else:
1653+
inv.write("MANAGEMENT_ADDRESS_TYPE='IPv4'\n")
16481654
if constants.CC_PREPARATIONS and install_type == constants.INSTALL_TYPE_FRESH:
16491655
inv.write("CC_PREPARATIONS='true'\n")
16501656
inv.close()

upgrade.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,17 +593,18 @@ def replace_config(config_file, destination):
593593
primary_fs.unmount()
594594

595595
prepUpgradeArgs = []
596-
prepStateChanges = ['installation-uuid', 'control-domain-uuid']
596+
prepStateChanges = ['installation-uuid', 'control-domain-uuid', 'management-address-type']
597597
def prepareUpgrade(self, progress_callback):
598598
""" Try to preserve the installation and control-domain UUIDs from
599599
xensource-inventory."""
600600
try:
601601
installID = self.source.getInventoryValue("INSTALLATION_UUID")
602602
controlID = self.source.getInventoryValue("CONTROL_DOMAIN_UUID")
603+
mgmtAddrType = self.source.getInventoryValue("MANAGEMENT_ADDRESS_TYPE")
603604
except KeyError:
604-
raise RuntimeError("Required information (INSTALLATION_UUID, CONTROL_DOMAIN_UUID) was missing from your xensource-inventory file. Aborting installation; please replace these keys and try again.")
605+
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.")
605606

606-
return installID, controlID
607+
return installID, controlID, mgmtAddrType
607608

608609
def buildRestoreList(self, src_base):
609610
restore_list = []

util.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ def udevinfoCmd():
359359
def randomLabelStr():
360360
return "".join([random.choice(string.ascii_lowercase) for x in range(6)])
361361

362+
def getMgmtAddrType():
363+
return None
364+
362365
def getLocalTime(timezone=None):
363366
if timezone:
364367
os.environ['TZ'] = timezone

0 commit comments

Comments
 (0)