Fix static-inventory option for minor update
The generate-inventory is always true in the current code, when we want to provide a static inventory it won't be taken in account. the patch aim to fix this bug Change-Id: If204b3da9b279d7b001d8cfe8c77106f8bf594af
This commit is contained in:
parent
04a5193092
commit
098e9da9af
|
@ -101,8 +101,7 @@ class TestOvercloudUpdate(fakes.TestOvercloudUpdate):
|
|||
verifylist = [
|
||||
('stack', 'overcloud'),
|
||||
('nodes', 'Compute'),
|
||||
('generate_inventory', True),
|
||||
('static_inventory', 'tripleo-hosts-inventory'),
|
||||
('static_inventory', None),
|
||||
('playbook', 'fake-playbook.yaml')
|
||||
]
|
||||
|
||||
|
|
|
@ -72,18 +72,13 @@ class UpdateOvercloud(command.Command):
|
|||
default="update_steps_playbook.yaml",
|
||||
help=_('Playbook to use for update')
|
||||
)
|
||||
parser.add_argument('--generate-inventory',
|
||||
dest='generate_inventory',
|
||||
action='store_true',
|
||||
default=True,
|
||||
help=_("Generate inventory for the ansible "
|
||||
"playbook"),
|
||||
)
|
||||
parser.add_argument('--static-inventory',
|
||||
dest='static_inventory',
|
||||
action="store",
|
||||
default='tripleo-hosts-inventory',
|
||||
help=_('Path to the static inventory to use')
|
||||
default=None,
|
||||
help=_('Path to an existing ansible inventory to '
|
||||
'use. If not specified, one will be '
|
||||
'generated in ~/tripleo-ansible-inventory')
|
||||
)
|
||||
return parser
|
||||
|
||||
|
@ -117,22 +112,21 @@ class UpdateOvercloud(command.Command):
|
|||
# Run ansible:
|
||||
nodes = parsed_args.nodes
|
||||
playbook = parsed_args.playbook
|
||||
inventory_path = '%s/%s' % (os.path.expanduser('~'),
|
||||
parsed_args.static_inventory)
|
||||
if parsed_args.generate_inventory:
|
||||
inventory_file = parsed_args.static_inventory
|
||||
if inventory_file is None:
|
||||
inventory_file = '%s/%s' % (os.path.expanduser('~'),
|
||||
'tripleo-ansible-inventory')
|
||||
try:
|
||||
processutils.execute('/bin/tripleo-ansible-inventory',
|
||||
'--static-inventory', inventory_path)
|
||||
'--static-inventory', inventory_file)
|
||||
except processutils.ProcessExecutionError as e:
|
||||
message = "Failed to generate inventory file: %s" % str(e)
|
||||
message = "Failed to generate inventory: %s" % str(e)
|
||||
raise exceptions.InvalidConfiguration(message)
|
||||
if os.path.exists(inventory_path):
|
||||
inventory = open(inventory_path, 'r').read()
|
||||
if os.path.exists(inventory_file):
|
||||
inventory = open(inventory_file, 'r').read()
|
||||
else:
|
||||
raise exceptions.InvalidConfiguration(
|
||||
"Inventory file missing, provide an inventory file or "
|
||||
"generate an inventory by using the --generate-inventory "
|
||||
"option")
|
||||
"Inventory file %s can not be found." % inventory_file)
|
||||
output = package_update.update_ansible(
|
||||
clients, nodes=nodes,
|
||||
inventory_file=inventory,
|
||||
|
|
Loading…
Reference in New Issue