onapsdk.cds package

Submodules

onapsdk.cds.blueprint module

CDS Blueprint module.

class onapsdk.cds.blueprint.Blueprint(cba_file_bytes)

Bases: onapsdk.cds.cds_element.CdsElement

CDS blueprint representation.

TEMPLATES_RE = 'Templates\\/.*json$'
TOSCA_META = 'TOSCA-Metadata/TOSCA.meta'
deploy()

Deploy blueprint.

Return type

None

enrich()

Call CDS API to get enriched blueprint file.

Returns

Enriched blueprint object

Return type

Blueprint

static get_cba_metadata(cba_tosca_meta_bytes)

Parse CBA TOSCA.meta file and get values from it.

Parameters

cba_tosca_meta_bytes (bytes) – TOSCA.meta file bytes.

Raises

ValidationError – TOSCA Meta file has invalid format.

Returns

Dataclass with CBA metadata

Return type

CbaMetadata

get_data_dictionaries()

Get the generated data dictionaries required by blueprint.

If mapping reqires other source than input it should be updated before upload to CDS.

Returns

DataDictionary objects.

Return type

Generator[DataDictionary, None, None]

get_mappings(cba_zip_file)

Read mappings from CBA file.

Search mappings in CBA file and create Mapping object for each of them.

Parameters

cba_zip_file (ZipFile) – CBA file to get mappings from.

Returns

Mappings set object.

Return type

MappingSet

static get_mappings_from_mapping_file(cba_mapping_file_bytes)

Read mapping file and create Mappping object for it.

Parameters

cba_mapping_file_bytes (bytes) – CBA mapping file bytes.

Yields

Generator[Mapping, None, None] – Mapping object.

Return type

Generator[Mapping, None, None]

get_resolved_template(artifact_name, resolution_key=None, resource_type=None, resource_id=None, occurrence=None)

Get resolved template for Blueprint.

Parameters
  • artifact_name (str) – Resolved template’s artifact name

  • resolution_key (Optional[str], optional) – Resolved template’s resolution key. Defaults to None.

  • resource_type (Optional[str], optional) – Resolved template’s resource type. Defaults to None.

  • resource_id (Optional[str], optional) – Resolved template’s resource ID. Defaults to None.

  • occurrence (Optional[str]) – (Optional[str], optional): Resolved template’s occurrence value. Defaults to None.

Returns

Resolved template

Return type

Dict[str, str]

get_workflow_by_name(workflow_name)

Get workflow by name.

If there is no workflow with given name ParameterError is going to be raised.

Parameters

workflow_name (str) – Name of the workflow

Returns

Workflow with given name

Return type

Workflow

get_workflows(cba_entry_definitions_file_bytes)

Get worfklows from entry_definitions file.

Parse entry_definitions file and create Workflow objects for workflows stored in.

Parameters

cba_entry_definitions_file_bytes (bytes) – entry_definition file.

Yields

Generator[Workflow, None, None] – Workflow object.

Return type

Generator[Workflow, None, None]

classmethod load_from_file(cba_file_path)

Load blueprint from file.

Raises

FileError – File to load blueprint from doesn’t exist.

Returns

Blueprint object

Return type

Blueprint

property mappings

Blueprint mappings collection.

Returns

Mappings collection.

Return type

MappingSet

property metadata

Blueprint metadata.

Data from TOSCA.meta file.

Returns

Blueprint metadata object.

Return type

CbaMetadata

publish()

Publish blueprint.

Return type

None

save(dest_file_path)

Save blueprint to file.

Parameters

dest_file_path (str) – Path of file where blueprint is going to be saved

Return type

None

store_resolved_template(artifact_name, data, resolution_key=None, resource_type=None, resource_id=None)

Store resolved template for Blueprint.

Parameters
  • artifact_name (str) – Resolved template’s artifact name

  • data (str) – Resolved template

  • resolution_key (Optional[str], optional) – Resolved template’s resolution key. Defaults to None.

  • resource_type (Optional[str], optional) – Resolved template’s resource type. Defaults to None.

  • resource_id (Optional[str], optional) – Resolved template’s resource ID. Defaults to None.

Return type

None

property url

URL address to use for CDS API call.

Returns

URL to CDS blueprintprocessor.

Return type

str

property workflows

Blueprint’s workflows property.

Returns

Blueprint’s workflow list.

Return type

List[Workflow]

class onapsdk.cds.blueprint.CbaMetadata(tosca_meta_file_version, csar_version, created_by, entry_definitions, template_name, template_version, template_tags)

Bases: object

Class to hold CBA metadata values.

created_by: str
csar_version: str
entry_definitions: str
template_name: str
template_tags: str
template_version: str
tosca_meta_file_version: str
class onapsdk.cds.blueprint.Mapping(name, mapping_type, dictionary_name, dictionary_sources=<factory>)

Bases: object

Blueprint’s template mapping.

Stores mapping data:
  • name,

  • type,

  • name of dictionary from which value should be get,

  • dictionary source of value.

dictionary_name: str
dictionary_sources: List[str]
generate_data_dictionary()

Generate data dictionary for mapping.

Data dictionary with required data sources, type and name for mapping will be created from

Jinja2 template.

Returns

Data dictionary

Return type

dict

mapping_type: str
merge(mapping)

Merge mapping objects.

Merge objects dictionary sources.

Parameters

mapping (Mapping) – Mapping object to merge.

Return type

None

name: str
class onapsdk.cds.blueprint.MappingSet

Bases: object

Set of mapping objects.

Mapping objects will be stored in dictionary where mapping name is a key. No two mappings with the same name can be stored in this collection.

add(mapping)

Add mapping to set.

If there is already mapping object with the same name in collection

they will be merged.

Parameters

mapping (Mapping) – Mapping to add to collection.

Return type

None

extend(iterable)

Extend set with an iterator of mappings.

Parameters

iterable (Iterator[Mapping]) – Mappings iterator.

Return type

None

class onapsdk.cds.blueprint.ResolvedTemplate(blueprint, artifact_name=None, resolution_key=None, resource_id=None, resource_type=None, occurrence=None, response_format='application/json')

Bases: onapsdk.cds.cds_element.CdsElement

Resolved template class.

Store and retrieve rendered template results.

get_resolved_template()

Get resolved template.

Returns

Resolved template

Return type

Dict[str, str]

property resolved_template_url

Url to retrieve resolved template.

Filter None parameters.

Returns

Retrieve resolved template url

Return type

str

store_resolved_template(resolved_template)

Store resolved template.

Parameters

resolved_template (str) – Template to store

Raises
  • ParameterError – To store template it’s needed to pass artifact name and: - resolution key, or - resource type and resource id.

  • If not all needed parameters are given that exception will be raised.

Return type

None

store_resolved_template_with_resolution_key(resolved_template)

Store template using resolution key.

Parameters

resolved_template (str) – Template to store

Return type

None

store_resolved_template_with_resource_type_and_id(resolved_template)

Store template using resource type and resource ID.

Parameters

resolved_template (str) – Template to store

Return type

None

property url

Url property.

Returns

Url

Return type

str

class onapsdk.cds.blueprint.Workflow(cba_workflow_name, cba_workflow_data, blueprint)

Bases: onapsdk.cds.cds_element.CdsElement

Blueprint’s workflow.

Stores workflow steps, inputs, outputs. Executes workflow using CDS HTTP API.

class WorkflowInput(name, required, type, description='')

Bases: object

Workflow input class.

Stores input name, information if it’s required, type, and optional description.

description: str = ''
name: str
required: bool
type: str
class WorkflowOutput(name, type, value)

Bases: object

Workflow output class.

Stores output name, type na value.

name: str
type: str
value: Dict[str, Any]
class WorkflowStep(name, description, target, activities=<factory>)

Bases: object

Workflow step class.

Stores step name, description, target and optional activities.

activities: List[Dict[str, str]]
description: str
name: str
target: str
execute(inputs)

Execute workflow.

Call CDS HTTP API to execute workflow.

Parameters

inputs (dict) – Inputs dictionary.

Returns

Response’s payload.

Return type

dict

property inputs

Workflow’s inputs property.

Returns

List of workflows’s inputs.

Return type

List[Workflow.WorkflowInput]

property outputs

Workflow’s outputs property.

Returns

List of workflows’s outputs.

Return type

List[Workflow.WorkflowOutput]

property steps

Workflow’s steps property.

Returns

List of workflow’s steps.

Return type

List[Workflow.WorkflowStep]

property url

Workflow execution url.

Returns

Url to call warkflow execution.

Return type

str

onapsdk.cds.blueprint_model module

CDS Blueprint Models module.

class onapsdk.cds.blueprint_model.BlueprintModel(blueprint_model_id, artifact_uuid=None, artifact_type=None, artifact_version=None, artifact_description=None, internal_version=None, created_date=None, artifact_name=None, published='N', updated_by=None, tags=None)

Bases: onapsdk.cds.cds_element.CdsElement

Blueprint Model class.

Represents blueprint models in CDS

delete()

Delete blueprint model.

classmethod get_all()

Get all blueprint models.

Yields

BlueprintModel – BlueprintModel object.

Return type

Iterator[BlueprintModel]

get_blueprint()

Get Blueprint object for selected blueprint model.

Returns

Blueprint object

Return type

Blueprint

classmethod get_by_id(blueprint_model_id)

Retrieve blueprint model with provided ID.

Args: blueprint_model_id (str):

Returns

Blueprint model object

Return type

BlueprintModel

Raises

ResourceNotFound – Blueprint model with provided ID doesn’t exist

classmethod get_by_name_and_version(blueprint_name, blueprint_version)

Retrieve blueprint model with provided name and version.

Parameters
  • blueprint_name (str) – Blueprint model name

  • blueprint_version (str) – Blueprint model version

Returns

Blueprint model object

Return type

BlueprintModel

Raises

ResourceNotFound – Blueprint model with provided name and version doesn’t exist

save(dst_file_path)

Save blueprint model to file.

Parameters

dst_file_path (str) – Path of file where blueprint is going to be saved

onapsdk.cds.blueprint_processor module

CDS Blueprintprocessor module.

class onapsdk.cds.blueprint_processor.Blueprintprocessor

Bases: onapsdk.cds.cds_element.CdsElement

Blueprintprocessor class.

classmethod bootstrap(load_model_type=True, load_resource_dictionary=True, load_cba=True)

Bootstrap CDS blueprintprocessor.

That action in needed to work with CDS. Can be done only once.

Parameters
  • load_model_type (bool, optional) – Datermines if model types should be loaded on bootstrap. Defaults to True.

  • load_resource_dictionary (bool, optional) – Determines if resource dictionaries should be loaded on bootstrap. Defaults to True.

  • load_cba (bool, optional) – Determines if cba files should be loaded on bootstrap. Defaults to True.

Return type

None

onapsdk.cds.cds_element module

Base CDS module.

class onapsdk.cds.cds_element.CdsElement

Bases: onapsdk.onap_service.OnapService, abc.ABC

Base CDS class.

Stores url to CDS API (edit if you want to use other) and authentication tuple (username, password).

auth: tuple = ('ccsdkapps', 'ccsdkapps')
classmethod get_guis()

Retrieve the status of the CDS GUIs.

Only one GUI is referenced for CDS: CDS UI

Return the list of GUIs

Return type

GuiItem

onapsdk.cds.data_dictionary module

CDS data dictionary module.

class onapsdk.cds.data_dictionary.DataDictionary(data_dictionary_json, fix_schema=True)

Bases: onapsdk.cds.cds_element.CdsElement

Data dictionary class.

fix_schema()

Fix data dictionary schema.

“Raw” data dictionary can be passed during initialization, but

this kind of data dictionary can’t be uploaded to blueprintprocessor. That method tries to fix it. It can be done only if “raw” data dictionary has a given schema:

{

“name”: “string”, “tags”: “string”, “updated-by”: “string”, “property”: {

“description”: “string”, “type”: “string”

}

}

Raises

ValidationError – Data dictionary doesn’t have all required keys

Return type

None

classmethod get_by_name(name)

Get data dictionary by the provided name.

Returns

Data dicionary object with the given name

Return type

DataDictionary

has_valid_schema()

Check data dictionary json schema.

Check data dictionary JSON and return bool if schema is valid or not.
Valid schema means that data dictionary has given keys:
  • “name”

  • “tags”

  • “data_type”

  • “description”

  • “entry_schema”

  • “updatedBy”

  • “definition”

“definition” key value should contains the “raw” data dictionary.

Returns

True if data dictionary has valid schema, False otherwise

Return type

bool

logger: logging.Logger = <Logger onapsdk.cds.data_dictionary (WARNING)>
property name

Data dictionary name.

Returns

Data dictionary name

Return type

str

upload()

Upload data dictionary using CDS API.

Return type

None

property url

URL to call.

Returns

CDS dictionary API url

Return type

str

class onapsdk.cds.data_dictionary.DataDictionarySet

Bases: object

Data dictionary set.

Stores data dictionary and upload to server.

add(data_dictionary)

Add data dictionary object to set.

Based on name it won’t add duplications.

Parameters

data_dictionary (DataDictionary) – object to add to set.

Return type

None

property length

Get the length of data dicitonary set.

Returns

Number of data dictionaries in set

Return type

int

classmethod load_from_file(dd_file_path, fix_schema=True)

Create data dictionary set from file.

File has to have valid JSON with data dictionaries list.

Parameters
  • dd_file_path (str) – Data dictionaries file path.

  • fix_schema (bool) – Determines if schema should be fixed or not.

Raises

FileError – File to load data dictionaries from doesn’t exist.

Returns

Data dictionary set with data dictionaries from given file.

Return type

DataDictionarySet

logger: logging.Logger = <Logger onapsdk.cds.data_dictionary (WARNING)>
save_to_file(dd_file_path)

Save data dictionaries to file.

Parameters

dd_file_path (str) – Data dictinary file path.

Return type

None

upload()

Upload all data dictionaries using CDS API.

Raises

RuntimeError – Raises if any data dictionary won’t be uploaded to server. Data dictionaries uploaded before the one which raises excepion won’t be deleted from server.

Return type

None

Module contents

ONAP SDK CDS package.