Deprecate openstack_hostnames_ips

We never used that faile anywhere in the inventory generation process,
except saving mapping of hostnames to container_address.
At the same time we never stored extra IPs there and as of today we
can simplify workflow by simply dropping that file.

Change-Id: Id8c4f6512bc913b2480106dedfa2e457c4776ae7
This commit is contained in:
Dmitriy Rabotyagov 2022-07-28 11:48:27 +02:00
parent 25d9d01d17
commit 7ebd4a7914
6 changed files with 13 additions and 57 deletions

View File

@ -26,13 +26,10 @@ To understand how the dynamic inventory works, see
.. warning::
Never edit or delete the files
``/etc/openstack_deploy/openstack_inventory.json`` or
``/etc/openstack_deploy/openstack_hostnames_ips.yml``. This can
lead to file corruptions, and problems with the inventory: hosts
and container could disappear and new ones would appear,
breaking your existing deployment.
Never edit or delete the file
``/etc/openstack_deploy/openstack_inventory.json``. This can lead to
problems with the inventory: existng hosts and containers will be unmanaged
and new ones will be generated instead, breaking your existing deployment.
Configuration constraints
~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -3,12 +3,10 @@ Inspecting and manipulating the inventory
.. warning::
Never edit or delete the files
``/etc/openstack_deploy/openstack_inventory.json`` or
``/etc/openstack_deploy/openstack_hostnames_ips.yml``. This can
lead to file corruptions, and problems with the inventory: hosts
and container could disappear and new ones would appear,
breaking your existing deployment.
Never edit or delete the file
``/etc/openstack_deploy/openstack_inventory.json``. This can lead to
problems with the inventory: existng hosts and containers will be unmanaged
and new ones will be generated instead, breaking your existing deployment.
The file ``scripts/inventory-manage.py`` is used to produce human readable
output based on the ``/etc/openstack_deploy/openstack_inventory.json`` file.

View File

@ -187,32 +187,6 @@ def _get_backup_name(basename):
return '{}-{}.json'.format(basename, utctime)
def write_hostnames(save_path, hostnames_ips):
"""Write a list of all hosts and their given IP addresses
NOTE: the file is saved in json format to a file with the name
``openstack_hostnames_ips.yml``
:param save_path: path to save the file to, will use default location if
None or an invalid path is provided
:param hostnames_ips: the list of all hosts and their IP addresses
"""
file_path = dir_find(save_path)
hostnames_ip_file = os.path.join(file_path, 'openstack_hostnames_ips.yml')
with open(hostnames_ip_file, 'wb') as f:
f.write(
('# This file is managed by openstack-ansible. No manual edits.\n'
+ json.dumps(
hostnames_ips,
indent=4,
separators=(',', ': '),
sort_keys=True
)).encode('ascii')
)
def _load_from_json(filename, preferred_path=None, raise_if_missing=True):
"""Return a dictionary found in json format in a given file

View File

@ -1081,19 +1081,6 @@ def _check_all_conf_groups_present(config, environment):
return retval
def _collect_hostnames(inventory):
# Generate a list of all hosts and their used IP addresses
hostnames_ips = {}
for _host, _vars in inventory['_meta']['hostvars'].items():
host_hash = hostnames_ips[_host] = {}
for _key, _value in _vars.items():
if _key.endswith('address') or _key == 'ansible_host':
host_hash[_key] = _value
return hostnames_ips
def _prepare_debug_logger():
log_fmt = "%(lineno)d - %(funcName)s: %(message)s"
logging.basicConfig(format=log_fmt, filename='inventory.log')
@ -1212,10 +1199,6 @@ def main(config=None, check=False, debug=False, environment=None, **kwargs):
if _check_all_conf_groups_present(user_defined_config, environment):
return 'Configuration ok!'
# Save a list of all hosts and their given IP addresses
hostnames_ips = _collect_hostnames(inventory)
filesys.write_hostnames(config, hostnames_ips)
if logger.isEnabledFor(logging.DEBUG):
num_hosts = len(inventory['_meta']['hostvars'])
logger.debug("%d hosts found.", num_hosts)

View File

@ -0,0 +1,5 @@
---
other:
- |
File ``/etc/openstack_deploy/openstack_hostnames_ips.yml`` is not used
anymore and can be safely removed from your deployment configuration.

View File

@ -46,7 +46,6 @@ USER_CONFIG_FILE = path.join(TARGET_DIR, 'openstack_user_config.yml')
# They should be cleaned up between each test.
CLEANUP = [
'openstack_inventory.json',
'openstack_hostnames_ips.yml',
'backup_openstack_inventory.tar'
]