+ @staticmethod
+ def get_auth_token(vim_uuid, verify_ssl=True):
+ """Authenticate and/or renew the authentication token."""
+ auth_manager = AuthManager()
+ creds = auth_manager.get_credentials(vim_uuid)
+ sess = session.Session(verify=verify_ssl)
+ ks = client.Client(session=sess)
+ token_dict = ks.get_raw_token_from_identity_service(auth_url=creds.url,
+ username=creds.user,
+ password=creds.password,
+ project_name=creds.tenant_name,
+ project_domain_id='default',
+ user_domain_id='default')
+ return token_dict['auth_token']
+
+ @staticmethod
+ def get_endpoint(service_type, vim_uuid, verify_ssl=True):
+ """
+ Gets the public endpoint for an OpenStack service in the configured region (default: RegionOne).
+ :param service_type: Service type name (eg. metric or alarming)
+ :param vim_uuid: VIM UUID generated by OSM
+ :param verify_ssl: If False, disables SSL validation. Useful when using self signed certs.
+ :return: Endpoint url string.
+
+ :raises ValueError If it can't find services, or if it can find services but no endpoint for specified region.
+ """
+ auth_manager = AuthManager()
+ creds = auth_manager.get_credentials(vim_uuid)
+ auth = v3.Password(auth_url=creds.url,
+ username=creds.user,
+ password=creds.password,
+ project_name=creds.tenant_name,
+ project_domain_id='default',
+ user_domain_id='default')
+ sess = session.Session(auth=auth, verify=verify_ssl)
+ ks = client.Client(session=sess, interface='public')
+ services = ks.services.list(type=service_type)
+ if not services:
+ raise ValueError("No services found for {}. Is the corresponding service enabled?".format(service_type))
+ service = services[0]
+ endpoints = ks.endpoints.list(service)
+ endpoint_type = 'publicURL'
+ region_name = 'RegionOne'
+ if creds.config is not None: