Skip to content

Commit b51d7af

Browse files
dymurrayjmontleon
authored andcommitted
Add fix for new automation broker namespace (#297)
* Add fix for new automation broker namespace * Fix suffix
1 parent a6fecca commit b51d7af

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

src/apb/engine.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -382,22 +382,18 @@ def get_registry_service_ip(namespace, svc_name):
382382
def get_asb_route():
383383
asb_route = None
384384
route_list = None
385-
try:
386-
openshift_config.load_kube_config()
387-
oapi = openshift_client.OapiApi()
388-
route_list = oapi.list_namespaced_route('ansible-service-broker')
389-
except ApiException as e:
390-
print("Didn't find OpenShift Ansible Broker route in namespace: ansible-service-broker.\
391-
Reason: [%s]. Trying namespace: openshift-ansible-service-broker" % e.reason)
392-
393-
if route_list is None or route_list.items == []:
385+
possible_namespaces = ["ansible-service-broker", "openshift-ansible-service-broker",
386+
"openshift-automation-service-broker"]
387+
for namespace in possible_namespaces:
394388
try:
395389
openshift_config.load_kube_config()
396390
oapi = openshift_client.OapiApi()
397-
route_list = oapi.list_namespaced_route('openshift-ansible-service-broker')
391+
route_list = oapi.list_namespaced_route(namespace)
392+
if route_list.items != []:
393+
break
398394
except ApiException as e:
399-
print("Unable to find OpenShift Ansible Broker route. Reason: [%s]." % e.reason)
400-
return None
395+
print("Didn't find OpenShift Automation Broker route in namespace: %s.\
396+
Reason: [%s]. Trying alternative namespaces." % namespace, e.reason)
401397

402398
if route_list.items == []:
403399
print("No routes found in broker namespaces.")
@@ -407,7 +403,11 @@ def get_asb_route():
407403
if 'asb' in route.metadata.name and 'etcd' not in route.metadata.name:
408404
asb_route = route.spec.host
409405

410-
url = asb_route + "/ansible-service-broker"
406+
if asb_route is None:
407+
print("Error finding a route to the OpenShift Automation Broker.")
408+
return None
409+
410+
url = asb_route + "/openshift-automation-service-broker"
411411
if url.find("http") < 0:
412412
url = "https://" + url
413413

@@ -743,11 +743,6 @@ def broker_request(broker, service_route, method, **kwargs):
743743
raise Exception("Could not find route to ansible-service-broker. "
744744
"Use --broker or log into the cluster using \"oc login\"")
745745

746-
if not broker.endswith('/ansible-service-broker'):
747-
if not broker.endswith('/'):
748-
broker = broker + '/'
749-
broker = broker + 'ansible-service-broker'
750-
751746
if not broker.startswith('http'):
752747
broker = 'https://' + broker
753748

0 commit comments

Comments
 (0)