diff --git a/controllerconfig/controllerconfig/upgrade-scripts/69-update-nfs-ip-address-alias.py b/controllerconfig/controllerconfig/upgrade-scripts/69-update-nfs-ip-address-alias.py index 125deb387a..bd6d1cd3f3 100644 --- a/controllerconfig/controllerconfig/upgrade-scripts/69-update-nfs-ip-address-alias.py +++ b/controllerconfig/controllerconfig/upgrade-scripts/69-update-nfs-ip-address-alias.py @@ -74,13 +74,6 @@ def _add_nfs_alias_to_hosts_file(connection, to_release): 'in {}'.format(ctrl_mgmt_ip['address'], host_file)) -def _remove_nfs_ip_allocation(connection): - with connection.cursor(cursor_factory=DictCursor) as cur: - LOG.info("Del controller-platform-nfs-mgmt from 'addresses' table") - cur.execute("DELETE FROM addresses WHERE " - "name = 'controller-platform-nfs-mgmt';") - - def main(): action = None from_release = None @@ -110,7 +103,6 @@ def main(): conn = psycopg2.connect("dbname=sysinv user=postgres") try: _add_nfs_alias_to_hosts_file(conn, to_release) - _remove_nfs_ip_allocation(conn) except psycopg2.Error as ex: LOG.exception(ex) @@ -121,10 +113,9 @@ def main(): LOG.warning("Exception") res = 1 else: - LOG.info("committing changes into database") - conn.commit() + LOG.info("controller-platform-nfs alias updated") finally: - LOG.info("Closing connection") + LOG.info("Closing DB connection") conn.close() return res diff --git a/sysinv/sysinv/sysinv/sysinv/conductor/manager.py b/sysinv/sysinv/sysinv/sysinv/conductor/manager.py index 01f21debe9..8aa30343fd 100644 --- a/sysinv/sysinv/sysinv/sysinv/conductor/manager.py +++ b/sysinv/sysinv/sysinv/sysinv/conductor/manager.py @@ -7491,6 +7491,37 @@ class ConductorManager(service.PeriodicService): } self._config_apply_runtime_manifest(context, config_uuid, config_dict) + # TODO: update_platform_nfs_ip_references is just necessary to allow an upgrade + # from StarlingX releases 6 or 7 to new releases. + # remove it when StarlingX rel. 6 or 7 are not being used anymore + def update_platform_nfs_ip_references(self, context): + """Update platform nfs ip references during upgrade""" + + address_name = cutils.format_address_name('controller-platform-nfs', + constants.NETWORK_TYPE_MGMT) + + if not cutils.is_aio_simplex_system(self.dbapi): + personalities = [constants.CONTROLLER] + + config_uuid = self._config_update_hosts(context, personalities) + config_dict = { + "personalities": personalities, + "classes": ['platform::network::update_platform_nfs_ip_references'], + } + self._config_apply_runtime_manifest(context, config_uuid, config_dict) + + try: + # remove IP address from DB + address_uuid = self.dbapi.address_get_by_name(address_name).uuid + self.dbapi.address_destroy(address_uuid) + except exception.AddressNotFoundByName: + LOG.info("exception: AddressNotFoundByName: {}".format(address_name)) + except exception.AddressNotFound: + LOG.info("exception: AddressNotFound: {}".format(address_name)) + except Exception as e: + LOG.exception(e) + LOG.error("exception: address: {} could not be deleted".format(address_name)) + def update_clock_synchronization_config(self, context, host): """Update clock_synchronization configuration of a host""" personalities = [host.get('personality')] @@ -12419,6 +12450,22 @@ class ConductorManager(service.PeriodicService): upgrade.uuid, {'state': constants.UPGRADE_ACTIVATION_FAILED}) + # Remove platform-nfs-ip references if it exists + # TODO: platform-nfs-ip is just necessary to allow an upgrade from StarlingX + # releases 6 or 7 to new releases. + # remove the plat_nfs_address_name and update_platform_nfs_ip_references when + # StarlingX rel. 6 or 7 are not being used anymore + plat_nfs_address_name = cutils.format_address_name("controller-platform-nfs", + constants.NETWORK_TYPE_MGMT) + try: + self.dbapi.address_get_by_name(plat_nfs_address_name) + + LOG.info("platform-nfs-ip exists in the DB, updating all references") + self.update_platform_nfs_ip_references(context) + + except exception.AddressNotFoundByName: + LOG.debug("activate_upgrade: {} does not exist".format(plat_nfs_address_name)) + manifests_applied = False if manifests_applied: diff --git a/sysinv/sysinv/sysinv/sysinv/puppet/networking.py b/sysinv/sysinv/sysinv/sysinv/puppet/networking.py index 519c31f105..7ebeb43e14 100644 --- a/sysinv/sysinv/sysinv/sysinv/puppet/networking.py +++ b/sysinv/sysinv/sysinv/sysinv/puppet/networking.py @@ -60,6 +60,23 @@ class NetworkingPuppet(base.BasePuppet): gateway_address, }) + # TODO: platform-nfs-iaddress is just necessary to allow an upgrade + # from StarlingX releases 6 or 7 to new releases. + # remove it when StarlingX rel. 6 or 7 are not being used anymore + # During the upgrade If platform-nfs-ip is still available in the DB, + # add it to the config to allow downgrade if something goes wrong + try: + platform_nfs_address = self._get_address_by_name( + 'controller-platform-nfs', networktype).address + except exception.AddressNotFoundByName: + platform_nfs_address = None + + if platform_nfs_address is not None: + config.update({ + 'platform::network::%s::params::platform_nfs_address' % networktype: + platform_nfs_address, + }) + return config def _get_cluster_network_config(self):