onapsdk.sdc package¶
Submodules¶
onapsdk.sdc.category_management module¶
SDC category management module.
-
class
onapsdk.sdc.category_management.
BaseCategory
(name)¶ Bases:
onapsdk.sdc.SDC
,abc.ABC
Base SDC category class.
- It’s SDC admin resource, has no common properties with
SDC resourcer or elements, so SDC class can’t be it’s base class.
-
SDC_ADMIN_USER
= 'demo'¶
-
abstract classmethod
category_name
()¶ Class category name.
Used for logs.
- Returns
Category name
- Return type
-
classmethod
create
(name)¶ Create category instance.
- Checks if category with given name exists and if it already
exists just returns category with given name.
- Returns
Created category instance
- Return type
-
classmethod
get
(name)¶ Get category with given name.
- Raises
ResourceNotFound – Category with given name does not exist
- Returns
BaseCategory instance
- Return type
-
classmethod
get_all
(**kwargs)¶ Get the categories list created in SDC.
-
classmethod
headers
()¶ Headers used for category management.
It uses SDC admin user.
-
class
onapsdk.sdc.category_management.
ResourceCategory
(name)¶ Bases:
onapsdk.sdc.category_management.BaseCategory
Resource category class.
-
classmethod
category_name
()¶ Resource category name.
Used for logging.
- Returns
Resource category name
- Return type
-
classmethod
get
(name, subcategory=None)¶ Get resource category with given name.
- It returns resource category with all subcategories by default. You can
get resource category with only one subcategory if you provide it’s name as subcategory parameter.
- Parameters
- Raises
ResourceNotFound – Subcategory with given name does not exist
- Returns
BaseCategory instance
- Return type
-
classmethod
-
class
onapsdk.sdc.category_management.
ServiceCategory
(name)¶ Bases:
onapsdk.sdc.category_management.BaseCategory
Service category class.
onapsdk.sdc.component module¶
SDC Component module.
-
class
onapsdk.sdc.component.
Component
(created_from_csar, actual_component_uid, unique_id, normalized_name, name, origin_type, customization_uuid, component_uid, component_version, tosca_component_name, component_name, group_instances, sdc_resource, parent_sdc_resource)¶ Bases:
object
Component dataclass.
-
classmethod
create_from_api_response
(api_response, sdc_resource, parent_sdc_resource)¶ Create component from api response.
- Parameters
api_response (Dict[str, Any]) – component API response
sdc_resource (SdcResource) – component’s SDC resource
parent_sdc_resource (SdcResource) – component’s parent SDC resource
- Returns
Component created using api_response and SDC resource
- Return type
-
get_property
(property_name)¶ Get component property by it’s name.
- Parameters
property_name (str) – property name
- Raises
ParameterError – Component has no property with given name
- Returns
Component’s property object
- Return type
-
parent_sdc_resource
: SdcResource¶
-
property
properties
¶ Component properties.
- In SDC it’s named as properties, but we uses “inputs” endpoint to fetch them.
Structure is also input’s like, but it’s a property.
- Yields
ComponentProperty – Component property object
- Return type
-
property
properties_url
¶ Url to get component’s properties.
- Returns
Compoent’s properties url
- Return type
-
property
properties_value_url
¶ Url to set component property value.
- Returns
Url to set component property value
- Return type
-
sdc_resource
: SdcResource¶
-
set_property_value
(property_obj, value)¶ Set property value.
Set given value to component property
- Parameters
property_obj (ComponentProperty) – Component property object
value (Any) – Property value to set
- Return type
-
classmethod
onapsdk.sdc.pnf module¶
Pnf module.
-
class
onapsdk.sdc.pnf.
Pnf
(name=None, version=None, vendor=None, sdc_values=None, vsp=None, properties=None, inputs=None, category=None, subcategory=None)¶ Bases:
onapsdk.sdc.sdc_resource.SdcResource
ONAP PNF Object used for SDC operations.
-
vendor
¶ the vendor of the PNF
- Type
optional
-
vsp
¶ the vsp related to the PNF
- Type
optional
-
onapsdk.sdc.properties module¶
Service properties module.
-
class
onapsdk.sdc.properties.
ComponentProperty
(unique_id, property_type, name, component, _value=None)¶ Bases:
object
Component property dataclass.
- Component properties are inputs objects in SDC, but in logic
it’s a property.
-
component
: Component¶
-
property
value
¶ Property value getter.
- Returns
Property value
- Return type
Any
-
class
onapsdk.sdc.properties.
Input
(unique_id, input_type, name, sdc_resource, _default_value=None)¶ Bases:
object
Property input dataclass.
-
property
default_value
¶ Input default value.
- Returns
Input default value
- Return type
Any
-
sdc_resource
: SdcResource¶
-
property
-
class
onapsdk.sdc.properties.
NestedInput
(sdc_resource, input_obj)¶ Bases:
object
Dataclass used for nested input declaration.
-
input_obj
: onapsdk.sdc.properties.Input¶
-
sdc_resource
: SdcResource¶
-
-
class
onapsdk.sdc.properties.
Property
(name, property_type, description=None, unique_id=None, parent_unique_id=None, sdc_resource=None, value=None, get_input_values=None)¶ Bases:
object
Service property class.
-
property
input
¶ Property input.
- Returns property Input object.
Returns None if property has no associated input.
- Raises
ParameterError – Input has no associated SdcResource
ParameterError – Input for given property does not exits. It shouldn’t ever happen, but it’s possible if after you get property object someone delete input.
- Returns
Property input object.
- Return type
-
property
value
¶ Value property.
Get property value.
- Returns
Property value
- Return type
Any
-
property
onapsdk.sdc.sdc_element module¶
SDC Element module.
-
class
onapsdk.sdc.sdc_element.
SdcElement
(name=None)¶ Bases:
onapsdk.sdc.SdcOnboardable
,abc.ABC
Mother Class of all SDC elements.
-
abstract classmethod
import_from_sdc
(values)¶ Import SdcElement from SDC.
- Parameters
values (Dict[str, Any]) – dict to parse returned from SDC.
- Raises
NotImplementedError – this is an abstract method.
- Return type
-
update_informations_from_sdc
(details)¶ Update instance with details from SDC.
-
abstract classmethod
onapsdk.sdc.sdc_resource module¶
SDC Element module.
-
class
onapsdk.sdc.sdc_resource.
SdcResource
(name=None, version=None, sdc_values=None, properties=None, inputs=None, category=None, subcategory=None)¶ Bases:
onapsdk.sdc.SdcOnboardable
,abc.ABC
Mother Class of all SDC resources.
-
RESOURCE_PATH
= 'resources'¶
-
add_deployment_artifact
(artifact_type, artifact_label, artifact_name, artifact)¶ Add deployment artifact to resource.
Add deployment artifact to resource using payload data.
- Parameters
- Raises
StatusError – Resource has not DRAFT status
-
property
add_deployment_artifacts_url
¶ Add deployment artifacts url.
- Returns
Url used to add deployment artifacts
- Return type
-
add_property
(property_to_add)¶ Add property to resource.
Call SDC FE API to add property to resource.
- Parameters
property_to_add (Property) – Property object to add to resource.
- Raises
StatusError – Resource has not DRAFT status
- Return type
-
add_resource
(resource)¶ Add a Resource.
- Parameters
resource (SdcResource) – the resource to add
- Return type
-
property
category
¶ Sdc resource category.
Depends on the resource type returns ResourceCategory or ServiceCategory.
- Returns
resource category
- Return type
Uniton[ResourceCategory, ServiceCategory]
-
property
components
¶ Resource components.
Iterate resource components.
-
create
()¶ Create resource.
Abstract method which should be implemented by subclasses and creates resource in SDC.
- Raises
NotImplementedError – Method not implemented by subclasses.
- Return type
-
declare_input
(input_to_declare)¶ Declare input for given property or nested input object.
Call SDC FE API to declare input for given property.
- Parameters
input_declaration (Union[Property, NestedInput]) – Property to declare input or NestedInput object
- Raises
ParameterError – if the given property is not SDC resource property
- Return type
-
declare_input_for_own_property
(property_obj)¶ Declare input for resource’s property.
For each property input can be declared.
-
declare_nested_input
(nested_input)¶ Declare nested input for SDC resource.
Nested input is an input of one of the components.
- Parameters
nested_input (NestedInput) – Nested input object
- Return type
-
property
deployment_artifacts_url
¶ Deployment artifacts url.
- Returns
SdcResource Deployment artifacts url
- Return type
-
get_category_for_new_resource
()¶ Get category for resource not created in SDC yet.
If no category values are provided default category is going to be used.
- Returns
Category of the new resource
- Return type
-
get_component
(sdc_resource)¶ Get resource’s component.
Get component by SdcResource object.
- Parameters
sdc_resource (SdcResource) – Component’s SdcResource
- Raises
ResourceNotFound – Component with given SdcResource does not exist
- Returns
Component object
- Return type
-
get_component_by_name
(component_name)¶ Get resource’s component by it’s name.
Get component by name.
- Parameters
component_name (str) – Component’s name
- Raises
ResourceNotFound – Component with given name does not exist
- Returns
Component object
- Return type
-
get_component_properties_url
(component)¶ Url to get component’s properties.
- This method is here because component can have different url when
it’s a component of another SDC resource type, eg. for service and for VF components have different urls.
-
get_component_properties_value_set_url
(component)¶ Url to set component property value.
- This method is here because component can have different url when
it’s a component of another SDC resource type, eg. for service and for VF components have different urls.
-
get_input
(input_name)¶ Get input by it’s name.
- Parameters
input_name (str) – Input name
- Raises
ResourceNotFound – Resource doesn’t have input with given name
- Returns
Found input object
- Return type
-
get_property
(property_name)¶ Get resource property by it’s name.
- Parameters
property_name (str) – property name
- Raises
ResourceNotFound – Resource has no property with given name
- Returns
Resource’s property object
- Return type
-
headers
: Dict[str, str] = {'Accept': 'application/json', 'Authorization': 'Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU=', 'Content-Type': 'application/json', 'USER_ID': 'cs0008', 'X-ECOMP-InstanceID': 'onapsdk'}¶
-
classmethod
import_from_sdc
(values)¶ Import SdcResource from SDC.
- Parameters
values (Dict[str, Any]) – dict to parse returned from SDC.
- Returns
the created resource
- Return type
-
property
inputs
¶ SDC resource inputs.
Iterate resource inputs.
-
is_own_property
(property_to_check)¶ Check if given property is one of the resource’s properties.
-
property
origin_type
¶ Resource origin type.
- Value needed for composition. It’s used for adding SDC resource
as an another SDC resource component.
- Returns
SDC resource origin type
- Return type
-
property
properties
¶ SDC resource properties.
Iterate resource properties.
-
property
resource_inputs_url
¶ Resource inputs url.
Method which returns url which point to resource inputs.
- Returns
Resource inputs url
- Return type
-
set_input_default_value
(input_obj, default_value)¶ Set input default value.
Set given value as input default value
-
property
set_input_default_value_url
¶ Url to set input default value.
- Returns
SDC API url used to set input default value
- Return type
-
set_property_value
(property_obj, value)¶ Set property value.
Set given value to resource property
- Parameters
property_obj (Property) – Property object
value (Any) – Property value to set
- Raises
ParameterError – if the given property is not the resource’s property
- Return type
-
update_informations_from_sdc
(details)¶ Update instance with details from SDC.
-
onapsdk.sdc.service module¶
Service module.
-
class
onapsdk.sdc.service.
Network
(name, node_template_type, model_name, model_version_id, model_invariant_id, model_version, model_customization_id, model_instance_name, component)¶ Bases:
onapsdk.sdc.service.NodeTemplate
Network dataclass.
-
component
: Component¶
-
-
class
onapsdk.sdc.service.
NodeTemplate
(name, node_template_type, model_name, model_version_id, model_invariant_id, model_version, model_customization_id, model_instance_name, component)¶ Bases:
object
Node template dataclass.
Base class for Vnf, Pnf and Network classes.
-
component
: Component¶
-
-
class
onapsdk.sdc.service.
Pnf
(name, node_template_type, model_name, model_version_id, model_invariant_id, model_version, model_customization_id, model_instance_name, component)¶ Bases:
onapsdk.sdc.service.NodeTemplate
Pnf dataclass.
-
component
: Component¶
-
-
class
onapsdk.sdc.service.
Service
(name=None, version=None, sdc_values=None, resources=None, properties=None, inputs=None, instantiation_type=None, category=None, role='', function='', service_type='')¶ Bases:
onapsdk.sdc.sdc_resource.SdcResource
ONAP Service Object used for SDC operations.
-
SERVICE_PATH
= 'services'¶
-
add_artifact_to_vf
(vnf_name, artifact_type, artifact_name, artifact=None)¶ Add artifact to vf.
Add artifact to vf using payload data.
- Raises
RequestError – file upload (POST request) for an artifact fails.
- Parameters
-
property
add_deployment_artifacts_url
¶ Add deployment artifacts url.
- Returns
Url used to add deployment artifacts
- Return type
-
create_node_template
(node_template_type, component)¶ Create a node template type object.
The base of the all node template types objects (Vnf, Pnf, Network) is the same. The difference is only for the Vnf which can have vf modules associated with. Vf modules could have “vf_module_label” property with”base_template_dummy_ignore” value. These vf modules should be ignored/
- Parameters
node_template_type (Type[NodeTemplate]) – Node template class type
component (Component) – Component on which base node template object should be created
- Returns
Node template object created from component
- Return type
-
declare_resources_and_properties
()¶ Delcare resources and properties.
It declares also inputs.
- Return type
-
property
deployment_artifacts_url
¶ Deployment artifacts url.
- Returns
SdcResource Deployment artifacts url
- Return type
-
classmethod
get_by_unique_uuid
(unique_uuid)¶ Get the service model using unique uuid.
- Returns
object with provided unique_uuid
- Return type
- Raises
ResourceNotFound – No service with given unique_uuid exists
-
get_category_for_new_resource
()¶ Get category for service not created in SDC yet.
If no category values are provided default category is going to be used.
- Returns
Category of the new service
- Return type
-
get_component_properties_url
(component)¶ Url to get component’s properties.
- This method is here because component can have different url when
it’s a component of another SDC resource type, eg. for service and for VF components have different urls. Also for VL origin type components properties url is different than for the other types.
-
get_component_properties_value_set_url
(component)¶ Url to set component property value.
- This method is here because component can have different url when
it’s a component of another SDC resource type, eg. for service and for VF components have different urls. Also for VL origin type components properties url is different than for the other types.
-
get_nf_unique_id
(nf_name)¶ Get nf (network function) uniqueID.
Get nf uniqueID from service nf in sdc.
- Parameters
nf_name (str) – the nf from which we extract the unique ID
- Return type
- Returns
the nf unique ID
- Raises
ResourceNotFound – Couldn’t find NF by name.
-
property
instantiation_type
¶ Service instantiation type.
One of ServiceInstantiationType enum value.
- Returns
Service instantiation type
- Return type
-
property
networks
¶ Service networks.
Load networks from service’s components generator.
- Returns
Network objects generator
- Return type
Iterator[Network]
-
onboard
()¶ Onboard the Service in SDC.
- Raises
StatusError – service has an invalid status
ParameterError – no resources, no properties for service in DRAFT status
- Return type
-
property
origin_type
¶ Service origin type.
- Value needed for composition. It’s used for adding SDC resource
as an another SDC resource component. For Service that value has to be set to “ServiceProxy”.
- Returns
Service resource origin type
- Return type
-
property
pnfs
¶ Service Pnfs.
Load PNFS from components generator.
- Returns
Pnf objects generator
- Return type
Iterator[Pnf]
-
property
set_input_default_value_url
¶ Url to set input default value.
- Returns
SDC API url used to set input default value
- Return type
-
property
tosca_model
¶ Service’s tosca model file.
Send request to get service TOSCA model,
- Returns
TOSCA model file bytes
- Return type
-
property
tosca_template
¶ Service tosca template file.
Get tosca template from service tosca model bytes.
- Returns
Tosca template file
- Return type
-
-
class
onapsdk.sdc.service.
ServiceInstantiationType
(value)¶ Bases:
enum.Enum
Service instantiation type enum class.
Service can be instantiated using A-la-carte or Macro flow. It has to be determined during design time. That class stores these two values to set during initialization.
-
A_LA_CARTE
= 'A-la-carte'¶
-
MACRO
= 'Macro'¶
-
-
class
onapsdk.sdc.service.
VfModule
(name, group_type, model_name, model_version_id, model_invariant_uuid, model_version, model_customization_id, properties)¶ Bases:
object
VfModule dataclass.
-
properties
: Iterator[onapsdk.sdc.properties.Property]¶
-
-
class
onapsdk.sdc.service.
Vnf
(name, node_template_type, model_name, model_version_id, model_invariant_id, model_version, model_customization_id, model_instance_name, component, vf_modules=<factory>)¶ Bases:
onapsdk.sdc.service.NodeTemplate
Vnf dataclass.
-
vf_modules
: List[onapsdk.sdc.service.VfModule]¶
-
onapsdk.sdc.vendor module¶
Vendor module.
-
class
onapsdk.sdc.vendor.
Vendor
(name=None)¶ Bases:
onapsdk.sdc.sdc_element.SdcElement
ONAP Vendor Object used for SDC operations.
-
VENDOR_PATH
= 'vendor-license-models'¶
-
headers
: Dict[str, str] = {'Accept': 'application/json', 'Authorization': 'Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU=', 'Content-Type': 'application/json', 'USER_ID': 'cs0008', 'X-ECOMP-InstanceID': 'onapsdk'}¶
-
classmethod
import_from_sdc
(values)¶ Import Vendor from SDC.
-
onapsdk.sdc.vf module¶
Vf module.
-
class
onapsdk.sdc.vf.
Vf
(name=None, version=None, sdc_values=None, vsp=None, properties=None, inputs=None, category=None, subcategory=None, vendor=None)¶ Bases:
onapsdk.sdc.sdc_resource.SdcResource
ONAP Vf Object used for SDC operations.
-
create
()¶ Create the Vf in SDC if not already existing.
- Raises
ParameterError – VSP is not provided during VF object initalization
- Return type
-
declare_input
(input_to_declare)¶ Declare input for given property, nested input or component property object.
Call SDC FE API to declare input for given property.
- Parameters
input_declaration (Union[Property, NestedInput]) – Property or ComponentProperty to declare input or NestedInput object
- Raises
ParameterError – if the given property is not SDC resource property
- Return type
-
update_vsp
(vsp)¶ Update Vsp.
Update VSP UUID and version for Vf object.
- Parameters
vsp (Vsp) – Object to be used in Vf
- Raises
ValidationError – Vf object request has invalid structure.
- Return type
-
property
vendor
¶ Vendor related wth Vf.
If Vf is created vendor is get from it’s resource metadata. Otherwise it’s vendor provided by the user or the vendor from vsp. It’s possible that method returns None, but it won’t be possible then
to create that Vf resource.
- Returns
Vendor object related with Vf
- Return type
Optional[Vendor]
-
onapsdk.sdc.vl module¶
Vl module.
-
class
onapsdk.sdc.vl.
Vl
(name, version=None, sdc_values=None)¶ Bases:
onapsdk.sdc.sdc_resource.SdcResource
ONAP Vl Object used for SDC operations.
onapsdk.sdc.vsp module¶
VSP module.
-
class
onapsdk.sdc.vsp.
Vsp
(name=None, package=None, vendor=None)¶ Bases:
onapsdk.sdc.sdc_element.SdcElement
ONAP VSP Object used for SDC operations.
-
VSP_PATH
= 'vendor-software-products'¶
-
create_new_version
()¶ Create new version of VSP.
- Create a new major version of VSP so it would be possible to
update a package or do some changes in VSP.
- Return type
-
headers
: Dict[str, str] = {'Accept': 'application/json', 'Authorization': 'Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU=', 'Content-Type': 'application/json', 'USER_ID': 'cs0008', 'X-ECOMP-InstanceID': 'onapsdk'}¶
-
classmethod
import_from_sdc
(values)¶ Import Vsp from SDC.
-
load_status
()¶ Load Vsp status from SDC.
rules are following:
DRAFT: status == DRAFT and networkPackageName not present
UPLOADED: status == DRAFT and networkPackageName present and validationData not present
VALIDATED: status == DRAFT and networkPackageName present and validationData present and state.dirty = true
COMMITED: status == DRAFT and networkPackageName present and validationData present and state.dirty = false
CERTIFIED: status == CERTIFIED
status is found in sdc items state is found in sdc version from items networkPackageName and validationData is found in SDC vsp show
- Return type
-
property
status
¶ Return and load the status.
-
update_package
(package_to_upload)¶ Upload given zip file into SDC as artifacts for this Vsp.
- Parameters
package_to_upload (file) – the zip file to upload
- Return type
-
upload_package
(package_to_upload)¶ Upload given zip file into SDC as artifacts for this Vsp.
- Parameters
package_to_upload (file) – the zip file to upload
- Return type
-
Module contents¶
SDC Element module.
-
class
onapsdk.sdc.
SDC
(name=None)¶ Bases:
onapsdk.onap_service.OnapService
,abc.ABC
Mother Class of all SDC elements.
-
base_back_url
= 'https://sdc.api.be.simpledemo.onap.org:30204'¶
-
base_front_url
= 'https://sdc.api.fe.simpledemo.onap.org:30207'¶
-
exists
()¶ Check if object already exists in SDC and update infos.
- Return type
- Returns
True if exists, False either
-
classmethod
get_all
(**kwargs)¶ Get the objects list created in SDC.
-
classmethod
get_guis
()¶ Retrieve the status of the SDC GUIs.
Only one GUI is referenced for SDC the SDC Front End
Return the list of GUIs
- Return type
GuiItem
-
abstract classmethod
import_from_sdc
(values)¶ Import Sdc object from SDC.
- Parameters
values (Dict[str, Any]) – dict to parse returned from SDC.
- Raises
NotImplementedError – this is an abstract method.
- Return type
-
-
class
onapsdk.sdc.
SdcOnboardable
(name=None)¶ Bases:
onapsdk.sdc.SDC
,abc.ABC
Base class for onboardable SDC resources (Vendors, Services, …).
-
abstract
load
()¶ Load Object information from SDC.
- Raises
NotImplementedError – this is an abstract method.
- Return type
-
abstract
onboard
()¶ Onboard resource.
- Onboarding is a full stack of actions which needs to be done to
make SDC resource ready to use. It depends on the type of object but most of them needs to be created and submitted.
- Return type
-
abstract
update_informations_from_sdc
(details)¶ Update instance with details from SDC.
-
abstract
update_informations_from_sdc_creation
(details)¶ Update instance with details from SDC after creation.
-
abstract