son_editor.util package¶
son_editor.util.constants module¶
Created on 22.07.2016
@author: Jonas
-
son_editor.util.constants.
CATALOGUES
= 'catalogues'¶ The network service url constant
-
son_editor.util.constants.
GIT
= 'git'¶ The project path relative to the workspace
-
class
son_editor.util.constants.
Github
¶ Bases:
object
Holds GitHub API relevant strings.
-
API_CREATE_REPO_REL
= '/user/repos'¶ - Argument is owner of the repos to delete
- Argument is the name of the remote repository
-
API_DELETE_REPO
= '/repos/{}/{}'¶ - Argument is Username
-
API_LIST_REPOS
= '/users/{}/repos'¶
-
API_URL
= 'https://api.github.com'¶
-
DOMAINS
= ['github.com', 'www.github.com']¶
-
-
son_editor.util.constants.
NSFS
= 'nsfs'¶ The git api url constant
-
son_editor.util.constants.
PLATFORMS
= 'platforms'¶ the platform url constant
-
son_editor.util.constants.
PROJECTS
= 'projects'¶ The platform url constant
-
son_editor.util.constants.
SERVICES
= 'services'¶ The virtual network function url constant
-
son_editor.util.constants.
VNFS
= 'functions'¶ The network services and funtions url constant
-
son_editor.util.constants.
WORKSPACES
= 'workspaces'¶ The project url constant
son_editor.util.context module¶
-
son_editor.util.context.
init_test_context
()¶ - Initializes a test-case context and cleans up workspace location beforehand
Returns: The test client
son_editor.util.descriptorutil module¶
-
son_editor.util.descriptorutil.
get_file_name
(model) → str¶ Get the standard file name for a descriptor
Parameters: model – The database model of the descriptor Returns: The standard descriptor file name, computed from the models vendor name and version
-
son_editor.util.descriptorutil.
get_file_path
(folder: str, model) → str¶ Returns the filepath to the descriptor computed from the models vendor name and version
Parameters: - folder – the folder to write to, either “vnf” or “nsd” to specify if a vnf or network service needs to be saved
- model – The database model of the descriptor
Returns: None
-
son_editor.util.descriptorutil.
get_schema
(schema_index, schema_id: str) → dict¶ Get the requested schema :param schema_index: The schema index referring to the “schema”-index in the configuration file :param schema_id: either “vnf” or “ns” :return: The requested schema
-
son_editor.util.descriptorutil.
get_schemas
()¶ Get the schemas
Will load the schemas if still empty
-
son_editor.util.descriptorutil.
load_ns_vnf_from_disk
(file: str, model)¶ Loads a vnf or network service descriptor from disk and initializes the given model
Parameters: - file – the file path of the descriptor
- model – The database model of the descriptor
Returns: the given updated model
-
son_editor.util.descriptorutil.
load_project_descriptor
(project) → dict¶ Loads the project descriptor from disk
-
son_editor.util.descriptorutil.
load_schemas
()¶ Loads the schemas congigured under “schemas” from the schema remotes
-
son_editor.util.descriptorutil.
load_workspace_descriptor
(workspace) → None¶ Loads the workspace descriptor from disk and updates the database model
Parameters: workspace – The workspace database model
-
son_editor.util.descriptorutil.
sync_project_descriptor
(project) → None¶ Updates the project model with data from the project descriptor and vice versa
Parameters: project – The projects database model
-
son_editor.util.descriptorutil.
update_workspace_descriptor
(workspace) → None¶ Updates the workspace descriptor with data from the workspace model
Parameters: workspace – The workspace model
-
son_editor.util.descriptorutil.
write_ns_vnf_to_disk
(folder: str, model) → None¶ Saves the given model to disk as a yml file
Parameters: - folder – the folder to write to, either “vnf” or “nsd” to specify if a vnf or network service needs to be saved
- model – The database model of the descriptor
Returns: None
-
son_editor.util.descriptorutil.
write_private_descriptor
(workspace_path: str, is_vnf: bool, descriptor: dict)¶ Write the private descriptor into the private cataloge folder on disk
Parameters: - workspace_path – The workspace path
- is_vnf – If the descriptor is a vnf
- descriptor – the descriptor data
Returns:
-
son_editor.util.descriptorutil.
write_project_descriptor
(project, project_descriptor)¶ Writes the project database model to disk
son_editor.util.publishutil module¶
-
son_editor.util.publishutil.
pack_project
(project: son_editor.models.project.Project) → str¶ Calls the son-package cli tool to pack the project and prepare it for deployment
Parameters: project – The project to pack Returns: The file name of the package file
-
son_editor.util.publishutil.
push_to_platform
(package_path: str, ws: son_editor.models.workspace.Workspace) → str¶ Pushes the package located at the package_path to the specified Platform
Parameters: - package_path – the location of package to be pushed on disk
- platform – The platform to upload to
Returns: The uuid returned by the platform
son_editor.util.requestutil module¶
Created on 28.07.2016
@author: Jonas
-
son_editor.util.requestutil.
get_config
()¶ Returns the current configuration
-
son_editor.util.requestutil.
get_json
(request: flask.wrappers.Request) → dict¶ Helper function to get a json dict out of a request
Parameters: request – Request to get the json data from Returns: json data as dict
-
son_editor.util.requestutil.
prepare_error
(data=None, code=500) → tuple¶ Prepares the error response and returns it as a tuple to accommodate for flask_restplus’s way to deal with errors
Parameters: - data – The error message
- code – the http error code, 500 by default
Returns: A tuple of the data, the status code and the headers
-
son_editor.util.requestutil.
prepare_response
(data=None, code=200) → flask.wrappers.Response¶ Sets the necessary headers and status code on the response
Parameters: - data – The data to be returned to the client
- code – the status code. 200 by default
Returns: The Response object with the headers set according to the input data
-
son_editor.util.requestutil.
rreplace
(s, old, new, occurrence)¶ Replaces ‘occurences’ occurences of string ‘old’ in the given string ‘s’ from right by ‘new’
Parameters: - s – String that contains the replacing string
- old – String that gets replaced
- new – New string that replaces the old string
- occurrence – How many occurences get replaced
Returns: String that has replaced strings
-
son_editor.util.requestutil.
update_config
(config)¶ Update the configuratiion file
Parameters: config – The new configuration Returns: Message if successful