Example #1
0
 def get_routes(datapusher_name, deis_instance_id, backend_url_target_id, one, external_domain, edit):
     if datapusher_name:
         assert not deis_instance_id
         routes = routers_manager.get_datapusher_routes(datapusher_name, edit=edit)
     elif deis_instance_id:
         routes = routers_manager.get_deis_instance_routes(deis_instance_id, edit=edit)
     elif backend_url_target_id:
         routes = routers_manager.get_backend_url_routes(backend_url_target_id, edit=edit)
     else:
         raise Exception(f'invalid arguments')
     if routes:
         if one: assert len(routes) == 1, 'too many routes!'
         for route in routes:
             if external_domain:
                 data = routers_manager.get_route_frontend_hostname(route)
                 if one:
                     print(data)
                 else:
                     print(yaml.dump([data], default_flow_style=False))
             else:
                 data = {
                     'name': route['metadata']['name'],
                     'backend-url': routes_manager.get_backend_url(route),
                     'frontend-hostname': routes_manager.get_frontend_hostname(route),
                 }
                 if one:
                     print(yaml.dump(data, default_flow_style=False))
                 else:
                     print(yaml.dump([data], default_flow_style=False))
def _get_frontend_hostname(storage_suffix=None):
    backend_url_target_id = _get_backend_url_target_id(
        storage_suffix=storage_suffix)
    routes = routers_manager.get_backend_url_routes(backend_url_target_id)
    assert storage_suffix or len(routes) == 1
    if len(routes) < 1:
        return 'localhost:9000'
    else:
        return routers_manager.get_route_frontend_hostname(routes[0])
Example #3
0
 def get_routes(datapusher_name, deis_instance_id, ckan_instance_id,
                backend_url_target_id, one, external_domain, edit):
     if datapusher_name:
         assert not deis_instance_id and not ckan_instance_id and not backend_url_target_id
         routes = routers_manager.get_datapusher_routes(datapusher_name,
                                                        edit=edit)
     elif deis_instance_id:
         assert not datapusher_name and not ckan_instance_id and not backend_url_target_id
         routes = routers_manager.get_deis_instance_routes(deis_instance_id,
                                                           edit=edit)
     elif ckan_instance_id:
         assert not datapusher_name and not deis_instance_id and not backend_url_target_id
         routes = routers_manager.get_ckan_instance_routes(ckan_instance_id,
                                                           edit=edit)
     elif backend_url_target_id:
         assert not datapusher_name and not deis_instance_id and not ckan_instance_id
         routes = routers_manager.get_backend_url_routes(
             backend_url_target_id, edit=edit)
     else:
         routes = routers_manager.get_all_routes()
     if routes:
         if one: assert len(routes) == 1, 'too many routes!'
         for route in routes:
             if external_domain:
                 data = routers_manager.get_route_frontend_hostname(route)
                 if one:
                     print(data)
                 else:
                     print(yaml.dump([data], default_flow_style=False))
             else:
                 try:
                     data = {
                         'name':
                         route['metadata']['name'],
                         'backend-url':
                         routes_manager.get_backend_url(route),
                         'frontend-hostname':
                         routes_manager.get_frontend_hostname(route),
                         'router-name':
                         route['spec']['router_name']
                     }
                 except Exception as e:
                     print('Warning: %s' % repr(e))
                     continue
                 if one:
                     print(yaml.dump(data, default_flow_style=False))
                 else:
                     print(yaml.dump([data], default_flow_style=False))