Exemple #1
0
def get(router_name_or_values, required=False, only_dns=False, failfast=False):
    if type(router_name_or_values) == str:
        router_name = router_name_or_values
        router_values = kubectl.get(f'CkanCloudRouter {router_name}', required=required)
    else:
        router_name = router_name_or_values['metadata']['name']
        router_values = router_name_or_values
    router, spec, router_type, annotations, labels, router_type_config = _init_router(router_name, router_values, required=required)
    if router:
        dns_data = router_type_config['manager'].get(router_name, 'dns', router, failfast=True)
        if not only_dns:
            deployment_data = router_type_config['manager'].get(router_name, 'deployment')
            routes = routes_manager.list(_get_labels(router_name, router_type))
        else:
            deployment_data = None
            routes = None
        if only_dns:
            return {'name': router_name,
                    'dns': dns_data}
        else:
            return {'name': router_name,
                    'annotations': router_values['metadata']['annotations'],
                    'routes': [route.get('spec') for route in routes] if routes else [],
                    'type': router_type,
                    'deployment': deployment_data,
                    'ready': deployment_data.get('ready', False),
                    'dns': dns_data,
                    'spec': {'ready': True, **router_values['spec']}}
    else:
        return None
Exemple #2
0
def update(router_name, wait_ready=False):
    router, spec, router_type, annotations, labels, router_type_config = _init_router(
        router_name)
    print(f'Updating CkanCloudRouter {router_name} (type={router_type})')
    routes = routes_manager.list(labels)
    router_type_config['manager'].update(router_name, wait_ready, spec,
                                         annotations, routes)