openstack-ansible/inventory/dynamic_inventory.py
Dmitriy Rabotyagov 7319bc994d Move argument parsing for dynamic_inventory to generate
At the moment osa_toolkit is installable as a package. With recent
changes to PBR for python3.12 console_scripts are no longer
installed "as is", but only a simple import is created. This change
results in broken `openstack-ansible-inventory` binary, as `inventory`
can not be imported.

To avoid the issue and follow our existing logic for rest of tooling,
we move argument parsing logic to generate.py itself, allowing it to
be self-sufficient and be leaving a dynamic_inventory.py as a simple
pointer which needs to stay in inventory folder for gropup_vars to
load properly.

Change-Id: Ie6d68f9c7b91d88736c5fc67c997cffd812afc61
2025-04-01 10:23:56 +02:00

36 lines
1.0 KiB
Python
Executable File

#!/opt/ansible-runtime/bin/python
# Copyright 2014, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# (c) 2014, Kevin Carter <kevin.carter@rackspace.com>
import os
import sys
try:
from osa_toolkit import generate
except ImportError:
current_path = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
lib_path = os.path.join(current_path, '..')
sys.path.append(lib_path)
from osa_toolkit import generate
def main():
generate.main()
if __name__ == '__main__':
main()