def get(self, ws_id, catalogue_id):
        """List all functions

        Lists all available functions in the given project or catalogue."""

        functions = catalogue_servicesimpl.get_all_in_catalogue(ws_id, catalogue_id, True)
        return prepare_response(functions)
Beispiel #2
0
    def get(self, ws_id, catalogue_id):
        """List all functions

        Lists all available functions in the given project or catalogue."""

        functions = catalogue_servicesimpl.get_all_in_catalogue(
            ws_id, catalogue_id, True)
        return prepare_response(functions)
 def get(self, ws_id, parent_id):
     """Get a list of all Services
     Returns a list of all services available in this resource"""
     if get_parent(request) is Category.project:
         service = servicesimpl.get_services(ws_id, parent_id)
         return prepare_response(service)
     if get_parent(request) is Category.catalogue:
         service = catalogue_servicesimpl.get_all_in_catalogue(ws_id, parent_id, False)
         return prepare_response(service)
     return prepare_response("not yet implemented")
    def get(self, ws_id, parent_id):
        """List all functions

        Lists all available functions in the given project or catalogue."""
        if get_parent(request) is Category.project:
            functions = functionsimpl.get_functions(ws_id, parent_id)
            return prepare_response(functions)
        if get_parent(request) is Category.catalogue:
            functions = catalogue_servicesimpl.get_all_in_catalogue(ws_id, parent_id, True)
            return prepare_response(functions)
        return prepare_response("not yet implemented")
 def get(self, ws_id, parent_id):
     """Get a list of all Services
     Returns a list of all services available in this resource"""
     if get_parent(request) is Category.project:
         service = servicesimpl.get_services(ws_id, parent_id)
         return prepare_response(service)
     if get_parent(request) is Category.catalogue:
         service = catalogue_servicesimpl.get_all_in_catalogue(
             ws_id, parent_id, False)
         return prepare_response(service)
     return prepare_response("not yet implemented")
Beispiel #6
0
    def get(self, ws_id, parent_id):
        """List all functions

        Lists all available functions in the given project or catalogue."""
        if get_parent(request) is Category.project:
            functions = functionsimpl.get_functions(ws_id, parent_id)
            return prepare_response(functions)
        if get_parent(request) is Category.catalogue:
            functions = catalogue_servicesimpl.get_all_in_catalogue(
                ws_id, parent_id, True)
            return prepare_response(functions)
        return prepare_response("not yet implemented")
Beispiel #7
0
def find_by_priority(user_data, ws_id, project_id, vendor, name, version,
                     is_vnf):
    """
    Tries to find vnf / network services by descending priority
     1. project
     2. private catalogue
     3. public catalogues.

    :param user_data: Information about the current user
    :param ws_id: The Workspace ID
    :param project_id: The project ID
    :param vendor: The descriptors vendor
    :param name: The descriptors name
    :param version: The descriptors versions
    :param is_vnf: if the descriptor is a VNF
    :return: The descriptor if found
    """
    # 1. Try to find in project
    project = get_project(project_id)
    if project is None:
        raise NotFound("No project with id {} found.".format(project_id))

    function = get_function(project.functions, vendor, name,
                            version) if is_vnf else get_function(
                                project.services, vendor, name, version)

    if function is not None:
        return function.as_dict()

    # 2. Try to find in private catalogue
    # private catalogue funcs/nss are cached in db
    function = query_private_nsfs(ws_id, vendor, name, version, is_vnf)
    if function is not None:
        return function.as_dict()

    # 3. Try to find in public catalogue
    catalogues = get_catalogues(ws_id)
    for catalogue in catalogues:
        try:
            function_list = get_all_in_catalogue(user_data, ws_id,
                                                 catalogue['id'], is_vnf)
        except:
            continue
        for func in function_list:
            if func['vendor'] == vendor and func['name'] == name and func[
                    'version'] == version:
                function = func
                return function.as_dict()

    # If none found, raise exception
    raise NotFound("VNF" if is_vnf else "NS" +
                   " {}:{}:{} not found".format(vendor, name, version))
def find_by_priority(user_data, ws_id, project_id, vendor, name, version, is_vnf):
    """
    Tries to find vnf / network services by descending priority
     1. project
     2. private catalogue
     3. public catalogues.

    :param user_data: Information about the current user
    :param ws_id: The Workspace ID
    :param project_id: The project ID
    :param vendor: The descriptors vendor
    :param name: The descriptors name
    :param version: The descriptors versions
    :param is_vnf: if the descriptor is a VNF
    :return: The descriptor if found
    """
    # 1. Try to find in project
    project = get_project(project_id)
    if project is None:
        raise NotFound("No project with id {} found.".format(project_id))

    function = get_function(project.functions, vendor, name, version) if is_vnf else get_function(project.services,
                                                                                                  vendor, name, version)

    if function is not None:
        return function.as_dict()

    # 2. Try to find in private catalogue
    # private catalogue funcs/nss are cached in db
    function = query_private_nsfs(ws_id, vendor, name, version, is_vnf)
    if function is not None:
        return function.as_dict()

    # 3. Try to find in public catalogue
    catalogues = get_catalogues(ws_id)
    for catalogue in catalogues:
        try:
            function_list = get_all_in_catalogue(user_data, ws_id, catalogue['id'], is_vnf)
        except:
            continue
        for func in function_list:
            if func['vendor'] == vendor and func['name'] == name and func['version'] == version:
                function = func
                return function.as_dict()

    # If none found, raise exception
    raise NotFound("VNF" if is_vnf else "NS" + " {}:{}:{} not found".format(vendor, name, version))
def find_by_priority(user_data, ws_id, project_id, vendor, name, version, is_vnf):
    """
    Tries to find vnf / network services by descending priority project / private catalogue / public catalogue.
    :param user_data:
    :param ws_id:
    :param project_id:
    :param vendor:
    :param name:
    :param version:
    :param is_vnf:
    :return:
    """
    # 1. Try to find in project
    project = get_project(project_id)
    if project is None:
        raise NotFound("No project with id {} found.".format(project_id))

    function = (
        get_function(project.functions, vendor, name, version)
        if is_vnf
        else get_function(project.services, vendor, name, version)
    )

    if function is not None:
        return function.as_dict()

    # 2. Try to find in private catalogue
    # private catalogue funcs/nss are cached in db
    function = query_private_nsfs(ws_id, vendor, name, version, is_vnf)
    if function is not None:
        return function.as_dict()

    # 3. Try to find in public catalogue
    catalogues = get_catalogues(ws_id)
    for catalogue in catalogues:
        try:
            function_list = get_all_in_catalogue(user_data, ws_id, catalogue["id"], is_vnf)
        except:
            continue
        for func in function_list:
            if func["vendor"] == vendor and func["name"] == name and func["version"] == version:
                function = func
                return function.as_dict()

    # If none found, raise exception
    raise NotFound("VNF" if is_vnf else "NS" + " {}:{}:{} not found".format(vendor, name, version))
Beispiel #10
0
    def get(self, ws_id, catalogue_id):
        """Get a list of all Services
        Returns a list of all services available in this resource"""

        service = catalogue_servicesimpl.get_all_in_catalogue(ws_id, catalogue_id, False)
        return prepare_response(service)