Support private address override in inventory
ansible inventory supports a command line switch --private which overrides the clouds.yaml setting. Support passing it in. Change-Id: I74bf98be26b605a5e9ac74ab478f421c39616d74
This commit is contained in:
parent
0d22456cba
commit
0a1c7c84a3
@ -38,6 +38,8 @@ def parse_args():
|
||||
group.add_argument('--list', action='store_true',
|
||||
help='List active servers')
|
||||
group.add_argument('--host', help='List details about the specific host')
|
||||
parser.add_argument('--private', action='store_true', default=False,
|
||||
help='Use private IPs for interface_ip')
|
||||
parser.add_argument('--yaml', action='store_true', default=False,
|
||||
help='Output data in nicely readable yaml')
|
||||
parser.add_argument('--debug', action='store_true', default=False,
|
||||
@ -50,7 +52,7 @@ def main():
|
||||
try:
|
||||
shade.simple_logging(debug=args.debug)
|
||||
inventory = shade.inventory.OpenStackInventory(
|
||||
refresh=args.refresh)
|
||||
refresh=args.refresh, private=args.private)
|
||||
if args.list:
|
||||
output = inventory.list_hosts()
|
||||
elif args.host:
|
||||
|
@ -21,7 +21,7 @@ from shade import _utils
|
||||
class OpenStackInventory(object):
|
||||
|
||||
def __init__(
|
||||
self, config_files=[], refresh=False):
|
||||
self, config_files=[], refresh=False, private=False):
|
||||
config = os_client_config.config.OpenStackConfig(
|
||||
config_files=os_client_config.config.CONFIG_FILES + config_files)
|
||||
|
||||
@ -34,6 +34,9 @@ class OpenStackInventory(object):
|
||||
**f.config)
|
||||
for f in config.get_all_clouds()
|
||||
]
|
||||
if private:
|
||||
for cloud in self.clouds:
|
||||
cloud.private = True
|
||||
|
||||
# Handle manual invalidation of entire persistent cache
|
||||
if refresh:
|
||||
|
Loading…
Reference in New Issue
Block a user