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'¶
-
enrich
()¶ Call CDS API to get enriched blueprint file.
- Returns
Enriched blueprint object
- Return type
-
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
-
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
-
static
get_mappings_from_mapping_file
(cba_mapping_file_bytes)¶ Read mapping file and create Mappping object for it.
-
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
-
get_workflow_by_name
(workflow_name)¶ Get workflow by name.
If there is no workflow with given name ParameterError is going to be raised.
-
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.
-
classmethod
load_from_file
(cba_file_path)¶ Load blueprint from file.
-
property
mappings
¶ Blueprint mappings collection.
- Returns
Mappings collection.
- Return type
-
property
metadata
¶ Blueprint metadata.
Data from TOSCA.meta file.
- Returns
Blueprint metadata object.
- Return type
-
save
(dest_file_path)¶ Save blueprint to file.
-
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
-
property
url
¶ URL address to use for CDS API call.
- Returns
URL to CDS blueprintprocessor.
- Return type
-
-
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.
-
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.
-
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
-
merge
(mapping)¶ Merge mapping objects.
Merge objects dictionary sources.
-
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.
-
-
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.
-
property
resolved_template_url
¶ Url to retrieve resolved template.
Filter None parameters.
- Returns
Retrieve resolved template url
- Return type
-
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
-
store_resolved_template_with_resolution_key
(resolved_template)¶ Store template using resolution key.
-
store_resolved_template_with_resource_type_and_id
(resolved_template)¶ Store template using resource type and resource ID.
-
-
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.
-
class
WorkflowOutput
(name, type, value)¶ Bases:
object
Workflow output class.
Stores output name, type na value.
-
class
WorkflowStep
(name, description, target, activities=<factory>)¶ Bases:
object
Workflow step class.
Stores step name, description, target and optional activities.
-
execute
(inputs)¶ Execute workflow.
Call CDS HTTP API to execute workflow.
-
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]
-
class
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
-
get_blueprint
()¶ Get Blueprint object for selected blueprint model.
- Returns
Blueprint object
- Return type
-
classmethod
get_by_id
(blueprint_model_id)¶ Retrieve blueprint model with provided ID.
Args: blueprint_model_id (str):
- Returns
Blueprint model object
- Return type
- 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
- Returns
Blueprint model object
- Return type
- Raises
ResourceNotFound – Blueprint model with provided name and version doesn’t exist
-
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
-
classmethod
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).
-
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
-
classmethod
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
-
classmethod
get_by_name
(name)¶ Get data dictionary by the provided name.
- Returns
Data dicionary object with the given name
- Return type
-
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
-
logger
: logging.Logger = <Logger onapsdk.cds.data_dictionary (WARNING)>¶
-
-
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
-
property
length
¶ Get the length of data dicitonary set.
- Returns
Number of data dictionaries in set
- Return type
-
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
- Raises
FileError – File to load data dictionaries from doesn’t exist.
- Returns
Data dictionary set with data dictionaries from given file.
- Return type
-
logger
: logging.Logger = <Logger onapsdk.cds.data_dictionary (WARNING)>¶
-
save_to_file
(dd_file_path)¶ Save data dictionaries to file.
-
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
-
Module contents¶
ONAP SDK CDS package.