@ -57,6 +57,7 @@ import os
import sys
import sys
import time
import time
from distutils . version import StrictVersion
from distutils . version import StrictVersion
from io import StringIO
try :
try :
import json
import json
@ -81,7 +82,8 @@ def get_groups_from_server(server_vars, namegroup=True):
groups . append ( cloud )
groups . append ( cloud )
# Create a group on region
# Create a group on region
groups . append ( region )
if region :
groups . append ( region )
# And one by cloud_region
# And one by cloud_region
groups . append ( " %s _ %s " % ( cloud , region ) )
groups . append ( " %s _ %s " % ( cloud , region ) )
@ -235,6 +237,8 @@ def parse_args():
def main ( ) :
def main ( ) :
args = parse_args ( )
args = parse_args ( )
try :
try :
# openstacksdk library may write to stdout, so redirect this
sys . stdout = StringIO ( )
config_files = cloud_config . CONFIG_FILES + CONFIG_FILES
config_files = cloud_config . CONFIG_FILES + CONFIG_FILES
sdk . enable_logging ( debug = args . debug )
sdk . enable_logging ( debug = args . debug )
inventory_args = dict (
inventory_args = dict (
@ -255,6 +259,7 @@ def main():
inventory = sdk_inventory . OpenStackInventory ( * * inventory_args )
inventory = sdk_inventory . OpenStackInventory ( * * inventory_args )
sys . stdout = sys . __stdout__
if args . list :
if args . list :
output = get_host_groups ( inventory , refresh = args . refresh , cloud = args . cloud )
output = get_host_groups ( inventory , refresh = args . refresh , cloud = args . cloud )
elif args . host :
elif args . host :