summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
58834ab)
Currently if MON can't find Gnocchi or Aodh services it fails obscurely.
Same thing happens if it can't find endpoints for those services in the
specified region. This patch adds throwing an exception in those cases
to ease troubleshooting.
Signed-off-by: Benjamin Diaz <bdiaz@whitestack.com>
@staticmethod
def get_endpoint(service_type, vim_uuid, verify_ssl=True):
@staticmethod
def get_endpoint(service_type, vim_uuid, verify_ssl=True):
- """Get the endpoint for Gnocchi/Aodh."""
+ """
+ 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,
auth_manager = AuthManager()
creds = auth_manager.get_credentials(vim_uuid)
auth = v3.Password(auth_url=creds.url,
user_domain_id='default')
sess = session.Session(auth=auth, verify=verify_ssl)
ks = client.Client(session=sess, interface='public')
user_domain_id='default')
sess = session.Session(auth=auth, verify=verify_ssl)
ks = client.Client(session=sess, interface='public')
- service = ks.services.list(type=service_type)[0]
+ 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'
endpoints = ks.endpoints.list(service)
endpoint_type = 'publicURL'
region_name = 'RegionOne'
for endpoint in endpoints:
if endpoint.interface in endpoint_type and endpoint.region == region_name:
return endpoint.url
for endpoint in endpoints:
if endpoint.interface in endpoint_type and endpoint.region == region_name:
return endpoint.url
+ raise ValueError("No endpoints found for service {} in region {}".format(service_type, region_name))
@staticmethod
def perform_request(url, auth_token,
@staticmethod
def perform_request(url, auth_token,