From: Benjamin Diaz Date: Sat, 21 Apr 2018 12:38:52 +0000 (-0300) Subject: Fixes loading of vim config in OpenStack plugin X-Git-Tag: v4.0.0~9 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F16%2F6016%2F1;p=osm%2FMON.git Fixes loading of vim config in OpenStack plugin Changes default value for region to RegionOne Signed-off-by: Benjamin Diaz --- diff --git a/osm_mon/plugins/OpenStack/common.py b/osm_mon/plugins/OpenStack/common.py index 7525395..e5a70f9 100644 --- a/osm_mon/plugins/OpenStack/common.py +++ b/osm_mon/plugins/OpenStack/common.py @@ -20,10 +20,11 @@ # contact: helena.mcgough@intel.com or adrian.hoban@intel.com ## """Common methods for the OpenStack plugins.""" - +import json import logging import requests +import yaml from keystoneclient.v3 import client from osm_mon.core.auth import AuthManager @@ -61,12 +62,17 @@ class Common(object): password=creds.password, tenant_name=creds.tenant_name) endpoint_type = 'publicURL' - region_name = 'regionOne' + region_name = 'RegionOne' if creds.config is not None: - if 'endpoint_type' in creds.config: - endpoint_type = creds.config['endpoint_type'] - if 'region_name' in creds.config: - region_name = creds.config['region_name'] + try: + config = json.loads(creds.config) + except ValueError: + config = yaml.safe_load(creds.config) + if 'endpoint_type' in config: + endpoint_type = config['endpoint_type'] + if 'region_name' in config: + region_name = config['region_name'] + return ks.service_catalog.url_for( service_type=service_type, endpoint_type=endpoint_type,