summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorArtem Goncharov <Artem.goncharov@gmail.com>2018-05-26 03:40:39 +0200
committerMonty Taylor <mordred@redhat.com>2018-05-25 18:40:39 -0700
commit89ce826a9fb53c304238923a73667ab820711338 (patch)
treeb053a142ad2e90aa7e87c4dc3bc8767c6778ecc8 /contrib
parente16490c9c0686acc3535176d11e7122937f6d182 (diff)
downloadansible-89ce826a9fb53c304238923a73667ab820711338.tar.gz
retire shade in favor of openstacksdk for openstack modules (#40532)
* Establish connection through openstacksdk * Switch from shade to openstacksdk * fix typo in link to openstacksdk * remove nova_client usage * further remove of min_version from openstack modules
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/inventory/openstack_inventory.py (renamed from contrib/inventory/openstack.py)22
1 files changed, 11 insertions, 11 deletions
diff --git a/contrib/inventory/openstack.py b/contrib/inventory/openstack_inventory.py
index 30007e408c..cb581ad85d 100755
--- a/contrib/inventory/openstack.py
+++ b/contrib/inventory/openstack_inventory.py
@@ -63,9 +63,9 @@ try:
except:
import simplejson as json
-import os_client_config
-import shade
-import shade.inventory
+import openstack as sdk
+from openstack.cloud import inventory as sdk_inventory
+from openstack.config import loader as cloud_config
CONFIG_FILES = ['/etc/ansible/openstack.yaml', '/etc/ansible/openstack.yml']
@@ -148,7 +148,7 @@ def get_host_groups_from_cloud(inventory):
if hasattr(inventory, 'extra_config'):
use_hostnames = inventory.extra_config['use_hostnames']
list_args['expand'] = inventory.extra_config['expand_hostvars']
- if StrictVersion(shade.__version__) >= StrictVersion("1.6.0"):
+ if StrictVersion(sdk.version.__version__) >= StrictVersion("0.13.0"):
list_args['fail_on_cloud_config'] = \
inventory.extra_config['fail_on_errors']
else:
@@ -191,8 +191,8 @@ def is_cache_stale(cache_file, cache_expiration_time, refresh=False):
def get_cache_settings(cloud=None):
- config = os_client_config.config.OpenStackConfig(
- config_files=os_client_config.config.CONFIG_FILES + CONFIG_FILES)
+ config = cloud_config.OpenStackConfig(
+ config_files=cloud_config.CONFIG_FILES + CONFIG_FILES).get_one()
# For inventory-wide caching
cache_expiration_time = config.get_cache_expiration_time()
cache_path = config.get_cache_path()
@@ -230,15 +230,15 @@ def parse_args():
def main():
args = parse_args()
try:
- config_files = os_client_config.config.CONFIG_FILES + CONFIG_FILES
- shade.simple_logging(debug=args.debug)
+ config_files = cloud_config.CONFIG_FILES + CONFIG_FILES
+ sdk.enable_logging(debug=args.debug)
inventory_args = dict(
refresh=args.refresh,
config_files=config_files,
private=args.private,
cloud=args.cloud,
)
- if hasattr(shade.inventory.OpenStackInventory, 'extra_config'):
+ if hasattr(sdk_inventory.OpenStackInventory, 'extra_config'):
inventory_args.update(dict(
config_key='ansible',
config_defaults={
@@ -248,14 +248,14 @@ def main():
}
))
- inventory = shade.inventory.OpenStackInventory(**inventory_args)
+ inventory = sdk_inventory.OpenStackInventory(**inventory_args)
if args.list:
output = get_host_groups(inventory, refresh=args.refresh, cloud=args.cloud)
elif args.host:
output = to_json(inventory.get_host(args.host))
print(output)
- except shade.OpenStackCloudException as e:
+ except sdk.exceptions.OpenStackCloudException as e:
sys.stderr.write('%s\n' % e.message)
sys.exit(1)
sys.exit(0)