Skip to content

Commit f1169e6

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 <guillaume.thouvenin@vates.tech>
1 parent e9082a1 commit f1169e6

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

backend.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def getPrepSequence(ans, interactive):
106106
seq = [
107107
Task(util.getUUID, As(ans), ['installation-uuid']),
108108
Task(util.getUUID, As(ans), ['control-domain-uuid']),
109+
Task(util.mgmtAddrType, As(ans), ['management-address-type']),
109110
Task(util.randomLabelStr, As(ans), ['disk-label-suffix']),
110111
Task(diskutil.create_raid, A(ans, 'raid'), []),
111112
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']),
@@ -190,7 +191,7 @@ def getFinalisationSequence(ans):
190191
Task(writeFstab, A(ans, 'mounts', 'target-boot-mode', 'primary-disk', 'logs-partnum', 'swap-partnum', 'disk-label-suffix'), []),
191192
Task(enableAgent, A(ans, 'mounts', 'network-backend', 'services'), []),
192193
Task(configureCC, A(ans, 'mounts'), []),
193-
Task(writeInventory, A(ans, 'installation-uuid', 'control-domain-uuid', 'mounts', 'primary-disk',
194+
Task(writeInventory, A(ans, 'installation-uuid', 'control-domain-uuid', 'management-address-type', 'mounts', 'primary-disk',
194195
'backup-partnum', 'storage-partnum', 'guest-disks', 'net-admin-bridge',
195196
'branding', 'net-admin-configuration', 'host-config', 'install-type'), []),
196197
Task(writeXencommons, A(ans, 'control-domain-uuid', 'mounts'), []),
@@ -1595,7 +1596,7 @@ def writeXencommons(controlID, mounts):
15951596
with open(os.path.join(mounts['root'], constants.XENCOMMONS_FILE), "w") as f:
15961597
f.write(contents)
15971598

1598-
def writeInventory(installID, controlID, mounts, primary_disk, backup_partnum, storage_partnum, guest_disks, admin_bridge, branding, admin_config, host_config, install_type):
1599+
def writeInventory(installID, controlID, mgmtAddrType, mounts, primary_disk, backup_partnum, storage_partnum, guest_disks, admin_bridge, branding, admin_config, host_config, install_type):
15991600
inv = open(os.path.join(mounts['root'], constants.INVENTORY_FILE), "w")
16001601
if 'product-brand' in branding:
16011602
inv.write("PRODUCT_BRAND='%s'\n" % branding['product-brand'])
@@ -1636,11 +1637,15 @@ def writeInventory(installID, controlID, mounts, primary_disk, backup_partnum, s
16361637
inv.write("DOM0_MEM='%d'\n" % host_config['dom0-mem'])
16371638
inv.write("DOM0_VCPUS='%d'\n" % host_config['dom0-vcpus'])
16381639
inv.write("MANAGEMENT_INTERFACE='%s'\n" % admin_bridge)
1639-
# Default to IPv4 unless we have only got an IPv6 admin interface
1640-
if ((not admin_config.mode) and admin_config.modev6):
1641-
inv.write("MANAGEMENT_ADDRESS_TYPE='IPv6'\n")
1640+
# If we read MANAGEMENT_ADDRESS_TYPE from xensource-inventory use it
1641+
if mgmtAddrType:
1642+
inv.write("MANAGEMENT_ADDRESS_TYPE='%s'\n" % mgmtAddrType)
16421643
else:
1643-
inv.write("MANAGEMENT_ADDRESS_TYPE='IPv4'\n")
1644+
# Default to IPv4 unless we have only got an IPv6 admin interface
1645+
if ((not admin_config.mode) and admin_config.modev6):
1646+
inv.write("MANAGEMENT_ADDRESS_TYPE='IPv6'\n")
1647+
else:
1648+
inv.write("MANAGEMENT_ADDRESS_TYPE='IPv4'\n")
16441649
if constants.CC_PREPARATIONS and install_type == constants.INSTALL_TYPE_FRESH:
16451650
inv.write("CC_PREPARATIONS='true'\n")
16461651
inv.close()

upgrade.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,17 +524,18 @@ def replace_config(config_file, destination):
524524
primary_fs.unmount()
525525

526526
prepUpgradeArgs = []
527-
prepStateChanges = ['installation-uuid', 'control-domain-uuid']
528-
def prepareUpgrade(self, progress_callback):
527+
prepStateChanges = ['installation-uuid', 'control-domain-uuid', 'management-address-type']
528+
def prepareUpgrade(self, progress_callback, installID, controlID, mgmtAddrType):
529529
""" Try to preserve the installation and control-domain UUIDs from
530530
xensource-inventory."""
531531
try:
532532
installID = self.source.getInventoryValue("INSTALLATION_UUID")
533533
controlID = self.source.getInventoryValue("CONTROL_DOMAIN_UUID")
534+
mgmtAddrType = self.source.getInventoryValue("MANAGEMENT_ADDRESS_TYPE")
534535
except KeyError:
535-
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.")
536+
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.")
536537

537-
return installID, controlID
538+
return installID, controlID, mgmtAddrType
538539

539540
def buildRestoreList(self, src_base):
540541
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
@@ -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 mgmtAddrType():
363+
return None
364+
362365
def getLocalTime(timezone=None):
363366
if timezone:
364367
os.environ['TZ'] = timezone

0 commit comments

Comments
 (0)