son_editor.impl package

son_editor.impl.catalogue_servicesimpl module

son_editor.impl.catalogue_servicesimpl.build_URL(is_vnf, name, vendor, version)

builds the url from the given name vendor and version

Parameters:
  • is_vnf
  • name
  • vendor
  • version
Returns:

son_editor.impl.catalogue_servicesimpl.create_id(e: dict)

Expects a dict type with name, vendor, version :param e: dict with name, vendor, version :return: the id of the descriptor

son_editor.impl.catalogue_servicesimpl.create_in_catalogue(catalogue_id, function_id, is_vnf)

Creates a function on the catalogue

Parameters:
  • catalogue_id
  • function_id
  • is_vnf
Returns:

son_editor.impl.catalogue_servicesimpl.decode_id(id) → tuple

Returns the parts of a given id :param id: :return: tuple of vendor, name, version

son_editor.impl.catalogue_servicesimpl.delete_service_catalogue(ws_id, catalogue_id, descriptor_uid, is_vnf)

Delete the descriptor in the catalogue

Parameters:
  • ws_id – The workspace ID
  • catalogue_id – The catalogue ID
  • descriptor_uid – The descriptors uid (vendor:name:version)
  • is_vnf – If the descriptor is a VNF or NS
Returns:

son_editor.impl.catalogue_servicesimpl.getType(is_vnf: bool) → str

Returns the vnf / ns prefix

Parameters:is_vnf
Returns:the prefix for the type
son_editor.impl.catalogue_servicesimpl.get_all_in_catalogue(ws_id, catalogue_id, is_vnf)

Retrieves a list of catalogue functions

Parameters:
  • ws_id
  • catalogue_id
  • is_vnf
Returns:

son_editor.impl.catalogue_servicesimpl.get_catalogue(catalogue_id)

Retrieves a catalogue by given id

Parameters:catalogue_id – int
Returns:
son_editor.impl.catalogue_servicesimpl.get_function(function_id)

Returns a function with the given function id

son_editor.impl.catalogue_servicesimpl.get_in_catalogue(ws_id, catalogue_id, function_id, is_vnf)

Gets a specific function

Parameters:
  • ws_id
  • catalogue_id
  • function_id
  • is_vnf
Returns:

son_editor.impl.catalogue_servicesimpl.get_service(service_id)

Returns a service with the given service id

son_editor.impl.catalogue_servicesimpl.update_service_catalogue(ws_id, catalogue_id, descriptor_uid, descriptor_data, is_vnf)

Update the descriptor in the catalogue

Parameters:
  • ws_id – The workspace ID
  • catalogue_id – The catalogue id
  • descriptor_uid – the descriptors uid (vendor:name:version)
  • descriptor_data – The descriptor data as a dict containing a “descriptor” property
  • is_vnf – if the descriptor is a VNF or NS

son_editor.impl.cataloguesimpl module

son_editor.impl.cataloguesimpl.create_catalogue(workspace_id: int, catalogue_data)

Creates a catalgoue in the given workspace. A catalogue is defined by its name and url. These are given as json data

Parameters:workspace_id – Workspace ID of the target workspace, where the catalogue should get created.
Returns:Catalogue descriptor
son_editor.impl.cataloguesimpl.delete(workspace_id, catalogue_id)

Deletes a catalogue by its id

Parameters:
  • workspace_id – The workspace ID
  • catalogue_id – The Catalogue ID
Returns:

The deleted catalogue descriptor

son_editor.impl.cataloguesimpl.get_catalogue(catalogue_id)

Retrieves a catalogue by its id

Parameters:catalogue_id – The catalogues ID
Returns:
son_editor.impl.cataloguesimpl.get_catalogues(workspace_id)

Retrieves all catalogues of a specific workspace

Parameters:workspace_id – the workspace id
Returns:list of catalogue descriptors of this workspace
son_editor.impl.cataloguesimpl.update_catalogue(workspace_id, catalogue_id, catalogue_data)

Updates a specific catalogue by its id. The catalogue applies the given name and url, that are in the json parameter. :param workspace_id: The Workspace ID :param catalogue_id: The Catalogue ID :return: The updated Catalogue descriptor

son_editor.impl.functionsimpl module

son_editor.impl.functionsimpl.create_function(ws_id: int, project_id: int, function_data: dict) → dict

Creates a new vnf in the project

Parameters:
  • ws_id – The workspace ID
  • project_id – The Project ID
  • function_data – The function data to create
Returns:

The created function as a dict

son_editor.impl.functionsimpl.delete_function(ws_id: int, project_id: int, function_id: int) → dict

Deletes the function

Parameters:
  • ws_id – The workspace ID
  • project_id – The project ID
  • function_id – The function ID
Returns:

the deleted function

son_editor.impl.functionsimpl.delete_image_file(ws_id, project_id, vnf_id, filename)

Deletes the image file with the given name

Parameters:
  • ws_id – The workspace ID
  • project_id – The project ID
  • vnf_id – The VNF ID
  • filename – The name of the file to delete
Returns:

A success message

Raises:

NotFound – if the image file could not be located

son_editor.impl.functionsimpl.get_function_project(ws_id: int, project_id: int, vnf_id: int) → dict

Get a single function from the specified project

Parameters:
  • ws_id – The Workspace ID
  • project_id – The project ID
  • vnf_id – The VNF ID
Returns:

The requested function descriptor

son_editor.impl.functionsimpl.get_functions(ws_id: int, project_id: int) → list

Get a list of all functions

Parameters:
  • ws_id – The workspace ID
  • project_id – The project id
Returns:

son_editor.impl.functionsimpl.get_image_files(ws_id, project_id, function_id)

Returns a list of image file names located in the vnf folder

Parameters:
  • ws_id – The Workspace ID
  • project_id – The project ID
  • function_id – The function ID
Returns:

A List of image file names for this VNF

son_editor.impl.functionsimpl.get_references(function, session)

Search for references to the function in the database

Parameters:
  • function – The referenced function
  • session – The database session
Returns:

A list of services referencing the given function.

son_editor.impl.functionsimpl.get_uid(vendor, name, version)
son_editor.impl.functionsimpl.replace_function_refs(refs, vendor, name, version, new_vendor, new_name, new_version)

Replaces every reference in refs to the function with (name:vendor:version) with the new_(name:vendor:version)

Parameters:
  • refs – The services referencing the function descriptors
  • vendor – The old vendor
  • name – The old name
  • version – The old version
  • new_vendor – The new vendor
  • new_name – The new name
  • new_version – The new version
son_editor.impl.functionsimpl.save_image_file(ws_id, project_id, function_id, file)

Saves the vnf image file into the vnfs folder

Parameters:
  • ws_id – The workspace ID
  • project_id – The project ID
  • function_id – The function ID
  • file – The image file
Returns:

A success message

son_editor.impl.functionsimpl.update_function(ws_id: int, prj_id: int, func_id: int, func_data: dict) → dict

Update the function descriptor

Parameters:
  • ws_id – The Workspace ID
  • prj_id – The Project ID
  • func_id – The function ID
  • func_data – The funtion Data for updating
Returns:

The updated function descriptor

son_editor.impl.functionsimpl.validate_vnf(schema_index: int, descriptor: dict) → None

Validates the VNF against the VNF schema

Parameters:
  • schema_index – The index of the schema repository
  • descriptor – The descriptor to validate
Returns:

Nothing if descriptor id valid

Raises:

InvalidArgument – if the schema is not Valid

son_editor.impl.gitimpl module

son_editor.impl.gitimpl.build_github_delete(owner: str, repo_name: str) → str

Builds relative github api url to delete a repository

Parameters:
  • owner – Owner of the github repository
  • repo_name – Repository name
Returns:

the relative GitHub api url

son_editor.impl.gitimpl.check_son_validity(project_path: str)

Checks if the given project path is a valid son project, otherwise it raises an exception. Valid means, it has a consistent son file structure, so no semantics will be tested.

Parameters:project_path – the path of the cloned project
son_editor.impl.gitimpl.clone(ws_id: int, url: str, name: str = None)

Clones a repository by url into given workspace

Parameters:
  • name – Optional name of the local repository name, otherwise the remote name is taken
  • user_data – Session data to get access token for GitHub
  • ws_id – Destination workspace to clone
  • url – URL of the source repository
Returns:

True if successful, otherwise NameConflict is thrown

son_editor.impl.gitimpl.commit_and_push(ws_id: int, project_id: int, commit_message: str)

Commits and then pushes changes.

Parameters:
  • ws_id – The workspace ID
  • project_id – The project ID
  • commit_message – The commit message
Returns:

a dictionary containing the result of the operation

son_editor.impl.gitimpl.create_commit_and_push(ws_id: int, project_id: int, remote_repo_name: str)

Creates a remote GitHub repository named remote_repo_name and pushes given git project into it.

Parameters:
  • ws_id – Workspace ID
  • project_id – Project ID to create and push it
  • remote_repo_name – Remote repository name
Returns:

a dictionary containing the result of the operation

son_editor.impl.gitimpl.create_info_dict(out: str = None, err: str = None, exitcode: int = 0) → dict

Creates a dict that holds process information

Parameters:
  • out – Out bytes
  • err – Err bytes
  • exitcode – exitcode
Returns:

Dict with packed information.

son_editor.impl.gitimpl.create_oauth_header() → dict

Creates oauth header by providing the access token in the header.

Returns:Header as dict
son_editor.impl.gitimpl.delete(ws_id: int, project_id: int, remote_repo_name: str, organization_name: str = None)

Deletes given project on remote repository

Parameters:
  • project_id
  • ws_id – Workspace of the project
  • remote_repo_name – Remote repository name
  • organization_name – Optional parameter to specify the organization / login
Returns:

a dictionary containing the result of the operation

son_editor.impl.gitimpl.diff(ws_id: int, pj_id: int)

Shows the local changes of the given project.

Parameters:
  • ws_id – Workspace of the project.
  • pj_id – Given project to show from.
Returns:

a dictionary containing the result of the operation

son_editor.impl.gitimpl.get_project(ws_id, pj_id: int, session=<sqlalchemy.orm.session.Session object at 0x000002BDC27C7748>) → son_editor.models.project.Project

Returns a project and raises 404, when project not found.

Parameters:
  • ws_id – Workspace id
  • pj_id – Project id
  • session – db session
Returns:

Project model

son_editor.impl.gitimpl.get_workspace(ws_id: int) → son_editor.models.workspace.Workspace

Returns the workspace model of the given workspace

Parameters:ws_id – The workspace ID
Returns:The corresponding workspace model
son_editor.impl.gitimpl.git_command(git_args: list, cwd: str = None)

Calls the git command with given args and returns out, err and exitcode

Parameters:
  • git_args – Arguments for git
  • cwd – Optional current working directory
Returns:

out, error, exitcode

son_editor.impl.gitimpl.init(ws_id: int, project_id: int)

Initializes a git repository in the given project

Parameters:
  • ws_id – The workpace ID
  • project_id – The project ID to initialize
Returns:

a dictionary containing the result of the operation

son_editor.impl.gitimpl.is_github(netloc)

Checks if the given url is on github

Parameters:netloc – http url
Returns:True if on github, False else
son_editor.impl.gitimpl.list()

Lists the available remote repositories.

Parameters:ws_id – The workspace ID
Returns:https://developer.github.com/v3/repos/#response
son_editor.impl.gitimpl.pull(ws_id: int, project_id: int)

Pulls data from the given project_id. :param ws_id: Workspace of the project :param project_id: Project to pull. :return: a dictionary containing the result of the operation

son_editor.impl.gitimpl.setup_git_user_email(project_full_path: str)

Setting up the git user in the local git config to be able to make commits and push

Parameters:project_full_path – The absolute project path
son_editor.impl.gitimpl.status(ws_id: int, pj_id: int)

Shows the git status of the repository

Parameters:
  • ws_id – The workspace ID
  • pj_id – The project ID
Returns:

a dictionary containing the result of the operation

son_editor.impl.nsfslookupimpl module

son_editor.impl.nsfslookupimpl.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.
Parameters:
  • user_data – Information about the current user
  • ws_id – The Workspace ID
  • project_id – The project ID
  • vendor – The descriptors vendor
  • name – The descriptors name
  • version – The descriptors versions
  • is_vnf – if the descriptor is a VNF
Returns:

The descriptor if found

son_editor.impl.nsfslookupimpl.find_network_service(user_data, ws_id, project_id, vendor, name, version)
Tries to find a network service by descending priority 1. project 2. private catalogue 3. public catalogues.
Parameters:
  • user_data – Information about the current user
  • ws_id – The Workspace ID
  • project_id – The project ID
  • vendor – Vendor name of the network service
  • name – Name of the network service
  • version – The version of the network service
Returns:

If found, it returns the network service

son_editor.impl.nsfslookupimpl.find_vnf(user_data, ws_id, project_id, vendor, name, version)
Tries to find a vnf by descending priority 1. project 2. private catalogue 3. public catalogues.
Parameters:
  • user_data – Information about the current user
  • ws_id – The Workspace ID
  • project_id – The project ID
  • vendor – Vendor name of the function
  • name – Name of the function
  • version – The version of the function
Returns:

If found, it returns the function

son_editor.impl.nsfslookupimpl.get_function(functions, vendor, name, version)

Finds a function in the given set of functions which matches vendor,name,version

Parameters:
  • functions – Set of functions to look for the specific one
  • vendor – Vendor name of the function
  • name – Name of the function
  • version – The version of the function
Returns:

If found, it returns the function. Otherwise it returns None

son_editor.impl.nsfslookupimpl.get_project(project_id)

Retrieves the project which matches the given project id. Otherwise it raises NotFound Exception

Parameters:project_id – The project ID
Returns:The project model

son_editor.impl.platform_connector module

son_editor.impl.platform_connector.create_service_on_platform(ws_id, platform_id, service_data)

Deploys the service on the referenced Platform

Parameters:
  • ws_id – The workspace ID
  • platform_id – The platform ID
  • service_data – The service descriptor data
Returns:

A message if the function was deployed successfully

son_editor.impl.platform_connector.publish_referenced_functions(ws_id, proj_id, descriptor)

Publishes the referenced functions to the private cataloge after packaging

Parameters:
  • ws_id – The workspace ID
  • proj_id – The project ID
  • descriptor – The service descriptor

son_editor.impl.platformsimpl module

son_editor.impl.platformsimpl.create_platform(workspace_id: int, platform_data) → dict

Create a new platform entry

Parameters:
  • workspace_id – The workspace ID
  • platform_data – The platform info
Returns:

The newly created platform descriptor

son_editor.impl.platformsimpl.delete(workspace_id: int, platform_id: int) → dict

Deletes the platform from the workspace

Parameters:
  • workspace_id – The workspace ID
  • platform_id – The platform ID
Returns:

the deleted platform description

son_editor.impl.platformsimpl.get_platform(platform_id: int) → dict

Get the platform definition

Parameters:platform_id – The platform ID
Returns:The platform information
son_editor.impl.platformsimpl.get_platforms(workspace_id: int) → list

Get a list of platforms for this workspace

Parameters:workspace_id – The workspace ID
Returns:A list of all platforms defined for this workspace
son_editor.impl.platformsimpl.update_platform(workspace_id: int, platform_id: int, platform_data) → dict

Update the platform entry

Parameters:
  • workspace_id – The workspace ID
  • platform_id – The platform ID
Returns:

The updated platform definition

son_editor.impl.private_catalogue_impl module

son_editor.impl.private_catalogue_impl.get_private_nsfs_list(ws_id, is_vnf)

Get a list of all private services or functions

Parameters:
  • ws_id – the Workspace ID
  • is_vnf – if vnf or services should be queried
Returns:

List of all private services or functions

son_editor.impl.private_catalogue_impl.publish_private_nsfs(ws_id: int, descriptor: dict, is_vnf: bool)

Publishes a function or service to the private catalogue repository

Parameters:
  • ws_id – The Workspace ID
  • descriptor – The descriptor to publish
son_editor.impl.private_catalogue_impl.query_private_nsfs(ws_id, vendor, name, version, is_vnf)

Finds a function in the private catalogue

Parameters:
  • ws_id – The workspace ID
  • is_vnf – if descriptor is a VNF
  • vendor – the descriptors vendor
  • name – the descriptors name
  • version – the descriptors version
Returns:

The requested descriptor if found, None if nothing found

son_editor.impl.projectsimpl module

Created on 05.08.2016

@author: Jonas

son_editor.impl.projectsimpl.create_project(ws_id: int, project_data: dict) → dict

Create a new Project in this workspace

Parameters:
  • ws_id – The workpace ID
  • project_data – The project data to create
Returns:

The new project descriptor as a dict

son_editor.impl.projectsimpl.delete_project(project_id: int) → dict

Deletes the project from the database and from the Disk

Parameters:project_id – The id of the project to be deleted
Returns:The deleted project descriptor
son_editor.impl.projectsimpl.get_project(ws_id, pj_id)

Get a specific project :param ws_id: The workspace ID :param pj_id: The project ID :return: The project descriptor

son_editor.impl.projectsimpl.get_project_path(workspace_path: str, rel_path: str) → str

Helper method to resolve the project path on disk for the given project

Parameters:
  • workspace_path – the path to the workspace
  • rel_path – the relative path of the project
Returns:

The absolute project path

son_editor.impl.projectsimpl.get_projects(ws_id: int) → list

Get a list of projects in this workspace

Parameters:ws_id – The workspace ID
Returns:List of all projects
son_editor.impl.projectsimpl.on_rm_error(func, path, exc_info)

Gets called if rm_tree gets an error, happens especially if trying to remove .git files on windows

son_editor.impl.projectsimpl.set_data(project: son_editor.models.project.Project, project_data: dict) → None

Extracts the data from the dictionary and sets it on the database model

Parameters:
  • project – The project database model
  • project_data – The project data dictionary from the frontend
son_editor.impl.projectsimpl.update_project(project_data, project_id)

Update the Project

Parameters:
  • project_data – The project Data
  • project_id – The project ID to update
Returns:

The updated project descriptor

son_editor.impl.servicesimpl module

son_editor.impl.servicesimpl.create_service(ws_id: int, project_id: int, service_data: dict) → dict

Creates a service in the given project

Parameters:
  • ws_id – The Workspace of the project
  • project_id – The Project of the Service
  • service_data – the service descriptor
Returns:

The created service descriptor

son_editor.impl.servicesimpl.delete_service(project_id: int, service_id: int) → dict

Deletes the service from the Database and from the disk

Parameters:
  • project_id – The Projects ID
  • service_id – The Services ID
Returns:

The descriptor of the deleted service

son_editor.impl.servicesimpl.get_references(service, session)

Searches for references to the service.

Parameters:
  • service – The service
  • session – the db_session
Returns:

a list of services referencing the given service

son_editor.impl.servicesimpl.get_service(ws_id, parent_id, service_id)

Get the service by ID

Parameters:
  • ws_id – The workspace ID of the Project
  • parent_id – The project ID
  • service_id – the Service ID
Returns:

The requested service data

son_editor.impl.servicesimpl.get_services(ws_id: int, project_id: int) → list

Get a list of all services in this Project

Parameters:
  • ws_id – The workspace ID
  • project_id – The project ID
Returns:

A list of service descriptors as dicts

son_editor.impl.servicesimpl.get_uid(vendor, name, version)
son_editor.impl.servicesimpl.replace_service_refs(refs, vendor, name, version, new_vendor, new_name, new_version)
son_editor.impl.servicesimpl.update_service(ws_id, project_id, service_id, service_data)

Update the service using the service data from the request

Will also check for references by other services and create a copy if so

Parameters:
  • ws_id – The Workspace ID
  • project_id – The project ID
  • service_id – The service ID
  • service_data – The service data containing the “descriptor” and optionally some “meta” data
Returns:

The updated service data

son_editor.impl.servicesimpl.validate_service_descriptor(schema_index: int, descriptor: dict) → None

Validates the given descriptor with the schema loaded from the configuration

Parameters:
  • schema_index – the workspace
  • descriptor – the service descriptor
Raises:

InvalidArgument: if the validation fails

son_editor.impl.usermanagement module

Created on 05.08.2016

@author: Jonas

son_editor.impl.usermanagement.get_user(login: str)

Gets the user from the Database if it exists or creates a new user in the Database using the login data from the session. If the database does not yet have the full user Data it is queried from Github using the access Token

Returns:The database user model

son_editor.impl.userserviceimpl module

son_editor.impl.userserviceimpl.get_user_info() → dict

Returns current user information

son_editor.impl.userserviceimpl.login()

Login the User with a referral code from the github oauth process

son_editor.impl.userserviceimpl.logout()

Logs out the current user and removes all session related stuff

Returns:Redirect
son_editor.impl.userserviceimpl.origin_from_referrer(referrer)

son_editor.impl.workspaceimpl module

Created on 25.07.2016

@author: Jonas

son_editor.impl.workspaceimpl.create_token_file(ws_path, token)
son_editor.impl.workspaceimpl.create_workspace(login: str, workspace_data: dict) → dict

Creates a workspace (on disk and in the database) from the given workspace data

Parameters:workspace_data – The workspace configuration data
Returns:The created workspace
son_editor.impl.workspaceimpl.delete_workspace(wsid)

Deletes the workspace from the database and from disk

Parameters:wsid – The workspace ID
Returns:The deleted workspace
son_editor.impl.workspaceimpl.get_workspace(ws_id: int) → dict

Get a workspace by ID

Parameters:ws_id – The workspace ID
Returns:A dictionary wich contains the Workspace configuration
son_editor.impl.workspaceimpl.get_workspaces(login: str) → list

Get all workspaces for the current user

Returns:A list wof workspace dictionaries
son_editor.impl.workspaceimpl.on_rm_error(func, path, exc_info)

Gets called if rm_tree gets an error, happens especially if trying to remove .git files on windows

son_editor.impl.workspaceimpl.test_url(name, url)

Tests the url for reachability :param name: the server name :param url: the server url :raises ExtNotReachable: if the external server could not be contacted

son_editor.impl.workspaceimpl.update_workspace(workspace_data, wsid)

Updates the workspace with the given workspace data

Parameters:
  • workspace_data – The new workspace configuration
  • wsid – the workspace ID
Returns:

The updated workspace