shipyard/shipyard_airflow/plugins/service_endpoint.py
Anthony Lin a90d9fa737 Update Armada Operator
This P.S. will add 'validate site design' workflow to the
Armada Operator. We will make use of the /validatedesign
endpoint in Armada for this purpose.

We will also make use of deckhand reference url instead of
nginx server to retrieve the YAMLs and will remove the existing
'armada_validate' step as that would be done during the initial
stage where the site design is validated.

The reference to the genesis node in the Drydock operator will
be removed as it is no longer needed.

Change-Id: I63e9bcd44d814d12db866032dd56fdfdc28d7b4d
2018-01-08 15:09:54 -05:00

58 lines
1.9 KiB
Python

# Copyright 2017 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import time
from airflow.exceptions import AirflowException
from service_session import ucp_keystone_session
def ucp_service_endpoint(self, svc_type):
# Initialize variables
retry = 0
int_endpoint = None
# Retrieve Keystone Session
sess = ucp_keystone_session(self, svc_type)
# We will allow 1 retry in getting the Keystone Endpoint with a
# backoff interval of 10 seconds in case there is a temporary
# glitch in the network or transient problems with the keystone-api
# pod
while retry <= 1:
# Retrieve Keystone Endpoint
# We will make use of internal endpoint
logging.info("Get Keystone Endpoint")
int_endpoint = sess.get_endpoint(interface='internal',
service_type=svc_type)
# Retry if we fail to get keystone endpoint
if int_endpoint:
logging.info("Successfully Retrieved Keystone Endpoint")
break
else:
logging.info("Unable to get Keystone endpoint on first attempt")
logging.info("Retrying after 10 seconds...")
time.sleep(10)
retry += 1
# Raise Execptions if we fail to get the keystone endpoint
if not int_endpoint:
raise AirflowException("Unable to get Keystone Endpoint!")
else:
return int_endpoint