Skip to content

Commit 265ed12

Browse files
committed
Use the management address type from old install
During an upgrade if no modes are selected we need to use the management address from the previous installation read from /etc/xensource-inventory. By default it is set to IPv4. If a mode is selected then we are using it. It both modes are selected (IPv4 abd IPv6) then we are using IPv4. Signed-off-by: Guillaume <[email protected]>
1 parent 13f5787 commit 265ed12

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

backend.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def getPrepSequence(ans, interactive):
104104
seq = [
105105
Task(util.getUUID, As(ans), ['installation-uuid']),
106106
Task(util.getUUID, As(ans), ['control-domain-uuid']),
107+
Task(util.mgmtAddrType, As(ans), ['management-address-type']),
107108
Task(util.randomLabelStr, As(ans), ['disk-label-suffix']),
108109
Task(diskutil.create_raid, A(ans, 'raid'), []),
109110
Task(partitionTargetDisk, A(ans, 'primary-disk', 'installation-to-overwrite', 'preserve-first-partition','sr-on-primary'), ['target-boot-mode', 'boot-partnum', 'primary-partnum', 'backup-partnum', 'logs-partnum', 'swap-partnum', 'storage-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', 'storage-partnum', 'guest-disks', 'net-admin-bridge',
193194
'branding', 'net-admin-configuration', 'host-config', 'install-type'), []),
194195
Task(writeXencommons, A(ans, 'control-domain-uuid', 'mounts'), []),
@@ -1617,7 +1618,7 @@ def writeXencommons(controlID, mounts):
16171618
with open(os.path.join(mounts['root'], constants.XENCOMMONS_FILE), "w") as f:
16181619
f.write(contents)
16191620

1620-
def writeInventory(installID, controlID, mounts, primary_disk, backup_partnum, storage_partnum, guest_disks, admin_bridge, branding, admin_config, host_config, install_type):
1621+
def writeInventory(installID, controlID, mgmtAddrType, mounts, primary_disk, backup_partnum, storage_partnum, guest_disks, admin_bridge, branding, admin_config, host_config, install_type):
16211622
inv = open(os.path.join(mounts['root'], constants.INVENTORY_FILE), "w")
16221623
if 'product-brand' in branding:
16231624
inv.write("PRODUCT_BRAND='%s'\n" % branding['product-brand'])
@@ -1658,11 +1659,15 @@ def writeInventory(installID, controlID, mounts, primary_disk, backup_partnum, s
16581659
inv.write("DOM0_MEM='%d'\n" % host_config['dom0-mem'])
16591660
inv.write("DOM0_VCPUS='%d'\n" % host_config['dom0-vcpus'])
16601661
inv.write("MANAGEMENT_INTERFACE='%s'\n" % admin_bridge)
1661-
# Default to IPv4 unless we have only got an IPv6 admin interface
1662-
if ((not admin_config.mode) and admin_config.modev6):
1663-
inv.write("MANAGEMENT_ADDRESS_TYPE='IPv6'\n")
1664-
else:
1662+
# Default to IPv4 is set
1663+
if admin_config.mode:
16651664
inv.write("MANAGEMENT_ADDRESS_TYPE='IPv4'\n")
1665+
else:
1666+
if admin_config.modev6:
1667+
inv.write("MANAGEMENT_ADDRESS_TYPE='IPv6'\n")
1668+
else:
1669+
# if no modes are configured then use mgmtAddrType
1670+
inv.write("MANAGEMENT_ADDRESS_TYPE='%s'\n" % mgmtAddrType)
16661671
if constants.CC_PREPARATIONS and install_type == constants.INSTALL_TYPE_FRESH:
16671672
inv.write("CC_PREPARATIONS='true'\n")
16681673
inv.close()

upgrade.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,18 +503,19 @@ def replace_config(config_file, destination):
503503
finally:
504504
primary_fs.unmount()
505505

506-
prepUpgradeArgs = ['installation-uuid', 'control-domain-uuid']
507-
prepStateChanges = ['installation-uuid', 'control-domain-uuid']
508-
def prepareUpgrade(self, progress_callback, installID, controlID):
506+
prepUpgradeArgs = ['installation-uuid', 'control-domain-uuid', 'management-address-type']
507+
prepStateChanges = ['installation-uuid', 'control-domain-uuid', 'management-address-type']
508+
def prepareUpgrade(self, progress_callback, installID, controlID, mgmtAddrType):
509509
""" Try to preserve the installation and control-domain UUIDs from
510510
xensource-inventory."""
511511
try:
512512
installID = self.source.getInventoryValue("INSTALLATION_UUID")
513513
controlID = self.source.getInventoryValue("CONTROL_DOMAIN_UUID")
514+
mgmtAddrType = self.source.getInventoryValue("MANAGEMENT_ADDRESS_TYPE")
514515
except KeyError:
515-
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.")
516+
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.")
516517

517-
return installID, controlID
518+
return installID, controlID, mgmtAddrType
518519

519520
def buildRestoreList(self, src_base):
520521
self.restore_list += ['etc/xensource/ptoken', 'etc/xensource/pool.conf',

util.py

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

360+
def mgmtAddrType():
361+
return "IPv4"
362+
360363
def getLocalTime(timezone=None):
361364
if timezone:
362365
os.environ['TZ'] = timezone

0 commit comments

Comments
 (0)