X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fplugins%2FOpenStack%2Fcommon.py;h=e5a70f981ce2f04844e5a1a4e32f86b0b6396fbe;hb=e69fe6fd4fca96b7e3f771cfbe7664bc0e8d727d;hp=2540a3f0d7db6f43e24317920bd11a660ade2e23;hpb=6c10123aa1538801c01d20f659197918967a9b7f;p=osm%2FMON.git diff --git a/osm_mon/plugins/OpenStack/common.py b/osm_mon/plugins/OpenStack/common.py index 2540a3f..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 @@ -60,10 +61,22 @@ class Common(object): username=creds.user, password=creds.password, tenant_name=creds.tenant_name) + endpoint_type = 'publicURL' + region_name = 'RegionOne' + if creds.config is not None: + 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=creds.endpoint_type, - region_name=creds.region_name) + endpoint_type=endpoint_type, + region_name=region_name) @staticmethod def perform_request(url, auth_token,