onapsdk.so package

Submodules

onapsdk.so.deletion module

Deletion module.

class onapsdk.so.deletion.DeletionRequest(request_id)

Bases: onapsdk.so.so_element.OrchestrationRequest, abc.ABC

Deletion request base class.

classmethod send_request(instance, a_la_carte=True)

Abstract method to send instance deletion request.

Raises

NotImplementedError – Needs to be implemented in inheriting classes

Return type

Deletion

class onapsdk.so.deletion.NetworkDeletionRequest(request_id)

Bases: onapsdk.so.deletion.DeletionRequest

Network deletion request class.

classmethod send_request(instance, a_la_carte=True)

Send request to SO to delete Network instance.

Parameters
  • instance (NetworkInstance) – Network instance to delete

  • a_la_carte (boolean) – deletion mode

Returns

Deletion request object

Return type

NetworkDeletionRequest

class onapsdk.so.deletion.ServiceDeletionRequest(request_id)

Bases: onapsdk.so.deletion.DeletionRequest

Service deletion request class.

classmethod send_request(instance, a_la_carte=True)

Send request to SO to delete service instance.

Parameters
  • instance (ServiceInstance) – service instance to delete

  • a_la_carte (boolean) – deletion mode

Returns

Deletion request object

Return type

ServiceDeletionRequest

class onapsdk.so.deletion.VfModuleDeletionRequest(request_id)

Bases: onapsdk.so.deletion.DeletionRequest

VF module deletion class.

classmethod send_request(instance, a_la_carte=True)

Send request to SO to delete VNF instance.

Parameters
  • instance (VfModuleInstance) – Vf Module instance to delete

  • a_la_carte (boolean) – deletion mode

Returns

Deletion request object

Return type

VnfDeletionRequest

class onapsdk.so.deletion.VnfDeletionRequest(request_id)

Bases: onapsdk.so.deletion.DeletionRequest

VNF deletion class.

classmethod send_request(instance, a_la_carte=True)

Send request to SO to delete VNF instance.

Parameters
  • instance (VnfInstance) – VNF instance to delete

  • a_la_carte (boolean) – deletion mode

Returns

Deletion request object

Return type

VnfDeletionRequest

onapsdk.so.instantiation module

Instantion module.

class onapsdk.so.instantiation.Instantiation(name, request_id, instance_id)

Bases: onapsdk.so.so_element.OrchestrationRequest, abc.ABC

Abstract class used for instantiation.

class onapsdk.so.instantiation.InstantiationParameter(name, value)

Bases: object

Class to store instantiation parameters used for preload or macro instantiation.

Contains two values: name of parameter and it’s value

name: str
value: str
class onapsdk.so.instantiation.NetworkInstantiation(name, request_id, instance_id, line_of_business, platform, network)

Bases: onapsdk.so.instantiation.NodeTemplateInstantiation

Network instantiation class.

classmethod instantiate_ala_carte(aai_service_instance, network_object, line_of_business, platform, cloud_region, tenant, network_instance_name=None, subnets=None)

Instantiate Network using a’la carte method.

Parameters
  • network_object (Network) – Network to instantiate

  • line_of_business (str) – LineOfBusiness name to use in instantiation request

  • platform (str) – Platform name to use in instantiation request

  • cloud_region (CloudRegion) – Cloud region to use in instantiation request.

  • tenant (Tenant) – Tenant to use in instnatiation request.

  • network_instance_name (str, optional) – Network instance name. Defaults to None.

Returns

NetworkInstantiation object

Return type

NetworkInstantiation

class onapsdk.so.instantiation.NodeTemplateInstantiation(name, request_id, instance_id, line_of_business, platform)

Bases: onapsdk.so.instantiation.Instantiation, abc.ABC

Base class for service’s node_template object instantiation.

class onapsdk.so.instantiation.Operation(request_method, request_suffix)

Bases: object

Operation class with data about method and suffix for VnfOperation.

request_method: str
request_suffix: str
class onapsdk.so.instantiation.ServiceInstantiation(name, request_id, instance_id, sdc_service, cloud_region, tenant, customer, owning_entity, project)

Bases: onapsdk.so.instantiation.Instantiation

Service instantiation class.

property aai_service_instance

Service instance associated with service instantiation request.

Raises
  • StatusError – if a service is not instantiated - not in COMPLETE status.

  • APIError – A&AI resource is not created

Returns

ServiceInstance

Return type

ServiceInstance

classmethod instantiate_ala_carte(sdc_service, cloud_region, tenant, customer, owning_entity, project, service_subscription, service_instance_name=None, enable_multicloud=False)

Instantiate service using SO a’la carte request.

Parameters
  • sdc_service (SdcService) – Service to instantiate

  • cloud_region (CloudRegion) – Cloud region to use in instantiation request

  • tenant (Tenant) – Tenant to use in instantiation request

  • customer (Customer) – Customer to use in instantiation request

  • owning_entity (OwningEntity) – Owning entity to use in instantiation request

  • project (str) – Project name to use in instantiation request

  • service_subscription (ServiceSubscription) – Customer’s service subsription.

  • service_instance_name (str, optional) – Service instance name. Defaults to None.

  • enable_multicloud (bool, optional) – Determines if Multicloud should be enabled for instantiation request. Defaults to False.

Raises

StatusError – if a service is not distributed.

Returns

instantiation request object

Return type

ServiceInstantiation

classmethod instantiate_macro(sdc_service, customer, owning_entity, project, line_of_business, platform, aai_service=None, cloud_region=None, tenant=None, service_instance_name=None, vnf_parameters=None, enable_multicloud=False, so_service=None, service_subscription=None)

Instantiate service using SO macro request.

Parameters
  • sdc_service (SdcService) – Service to instantiate

  • customer (Customer) – Customer to use in instantiation request

  • owning_entity (OwningEntity) – Owning entity to use in instantiation request

  • project (Project) – Project name to use in instantiation request

  • line_of_business_object (LineOfBusiness) – LineOfBusiness name to use in instantiation request

  • platform_object (Platform) – Platform name to use in instantiation request

  • aai_service (AaiService) – Service object from aai sdc

  • cloud_region (CloudRegion) – Cloud region to use in instantiation request

  • tenant (Tenant) – Tenant to use in instantiation request

  • service_instance_name (str, optional) – Service instance name. Defaults to None.

  • vnf_parameters (Iterable[ForwardRef]) – (Iterable[VnfParameters]): Parameters which are going to be used for vnfs instantiation. Defaults to None.

  • enable_multicloud (bool, optional) – Determines if Multicloud should be enabled for instantiation request. Defaults to False.

  • so_service (SoService, optional) – SO values to use in instantiation request

  • service_subscription (ServiceSubscription, optional) – Customer service subscription for the instantiated service. Required if so_service is not provided.

Raises

StatusError – if a service is not distributed.

Returns

instantiation request object

Return type

ServiceInstantiation

class onapsdk.so.instantiation.SoService(subscription_service_type, vnfs=<factory>, pnfs=<factory>, instance_name=None)

Bases: object

Class to store SO Service parameters used for macro instantiation.

Contains value list: List of vnfs to instantiate Contains value: subscription service type

instance_name: Optional[str] = None
classmethod load(data)

Create a service instance description object from the dict.

Useful if you keep your instance data in file.

Returns

SoService object created from the dictionary

Return type

SoService

pnfs: List[onapsdk.so.instantiation.SoServicePnf]
subscription_service_type: str
vnfs: List[onapsdk.so.instantiation.SoServiceVnf]
class onapsdk.so.instantiation.SoServicePnf(model_name, instance_name, parameters=<factory>, processing_priority=None)

Bases: onapsdk.so.instantiation.SoServiceXnf

Class to store a Pnf instance parameters.

instance_name: str
model_name: str
parameters: Dict[str, Any]
class onapsdk.so.instantiation.SoServiceVfModule(model_name, instance_name, parameters=<factory>, processing_priority=None)

Bases: object

Class to store a VfModule instance parameters.

instance_name: str
model_name: str
parameters: Dict[str, Any]
processing_priority: Optional[int] = None
class onapsdk.so.instantiation.SoServiceVnf(model_name, instance_name, parameters=<factory>, processing_priority=None, vf_modules=<factory>)

Bases: onapsdk.so.instantiation.SoServiceXnf

Class to store a Vnf instance parameters.

vf_modules: List[onapsdk.so.instantiation.SoServiceVfModule]
class onapsdk.so.instantiation.SoServiceXnf(model_name, instance_name, parameters=<factory>, processing_priority=None)

Bases: object

Class to store a Xnf instance parameters.

instance_name: str
classmethod load(data)

Create a vnf instance description object from the dict.

Useful if you keep your instance data in file.

Returns

SoServiceVnf object created from the dictionary

Return type

SoServiceVnf

model_name: str
parameters: Dict[str, Any]
processing_priority: Optional[int] = None
class onapsdk.so.instantiation.Subnet(name, start_address, gateway_address, role=None, cidr_mask='24', ip_version='4', dhcp_enabled=False, dhcp_start_address=None, dhcp_end_address=None)

Bases: object

Class to store subnet parameters used for preload.

cidr_mask: str = '24'
dhcp_enabled: bool = False
dhcp_end_address: Optional[str] = None
dhcp_start_address: Optional[str] = None
gateway_address: str
ip_version: str = '4'
name: str
role: str = None
start_address: str
class onapsdk.so.instantiation.VfModuleInstantiation(name, request_id, instance_id, vf_module)

Bases: onapsdk.so.instantiation.Instantiation

VF module instantiation class.

classmethod instantiate_ala_carte(vf_module, vnf_instance, cloud_region, tenant, vf_module_instance_name=None, vnf_parameters=None, use_preload=True)

Instantiate VF module.

Iterate throught vf modules from service Tosca file and instantiate vf modules.

Parameters
  • vf_module (VfModule) – VfModule to instantiate

  • vnf_instance (VnfInstance) – VnfInstance object

  • cloud_region (CloudRegion, optional) – Cloud region to use in instantiation request. Defaults to None.

  • tenant (Tenant, optional) – Tenant to use in instnatiation request. Defaults to None.

  • vf_module_instance_name_factory (str, optional) – Factory to create VF module names. It’s going to be a prefix of name. Index of vf module in Tosca file will be added to it. If no value is provided it’s going to be “Python_ONAP_SDK_vf_module_service_instance_{str(uuid4())}”. Defaults to None.

  • vnf_parameters (Iterable[InstantiationParameter], optional) – Parameters which are going to be used in preload upload for vf modules or passed in “userParams”. Defaults to None.

  • use_preload (bool, optional) – This flag determines whether instantiation parameters are used as preload or “userParams” content. Defaults to True

Yields

Iterator[VfModuleInstantiation] – VfModuleInstantiation class object.

Return type

VfModuleInstantiation

class onapsdk.so.instantiation.VfmoduleParameters(name, vfmodule_parameters=None)

Bases: object

Class to store vfmodule parameters used for macro instantiation.

Contains value lists: List of vfModule parameters

name: str
vfmodule_parameters: Iterable[onapsdk.so.instantiation.InstantiationParameter] = None
class onapsdk.so.instantiation.VnfInstantiation(name, request_id, instance_id, line_of_business, platform, vnf)

Bases: onapsdk.so.instantiation.NodeTemplateInstantiation

VNF instantiation class.

classmethod create_from_request_response(request_response)

Create VNF instantiation object based on request details.

Raises
Returns

VnfInstantiation object

Return type

VnfInstantiation

classmethod get_by_vnf_instance_name(vnf_instance_name)

Get VNF instantiation request by instance name.

Raises

InvalidResponse – Vnf instance with given name does not contain requestList or the requestList does not contain any details.

Returns

Vnf instantiation request object

Return type

VnfInstantiation

classmethod instantiate_ala_carte(aai_service_instance, vnf_object, line_of_business, platform, cloud_region, tenant, sdc_service, vnf_instance_name=None, vnf_parameters=None)

Instantiate Vnf using a’la carte method.

Parameters
  • vnf_object (Vnf) – Vnf to instantiate

  • line_of_business_object (LineOfBusiness) – LineOfBusiness to use in instantiation request

  • platform_object (Platform) – Platform to use in instantiation request

  • cloud_region (CloudRegion) – Cloud region to use in instantiation request.

  • tenant (Tenant) – Tenant to use in instnatiation request.

  • vnf_instance_name (str, optional) – Vnf instance name. Defaults to None.

  • vnf_parameters (Iterable[InstantiationParameter], optional) – Instantiation parameters that are sent in the request. Defaults to None

Returns

VnfInstantiation object

Return type

VnfInstantiation

classmethod instantiate_macro(aai_service_instance, vnf_object, line_of_business, platform, cloud_region, tenant, sdc_service, vnf_instance_name=None, vnf_parameters=None, so_vnf=None)

Instantiate Vnf using macro method.

Parameters
  • aai_service_instance (ServiceInstance) – Service instance associated with request

  • vnf_object (Vnf) – Vnf to instantiate

  • line_of_business (LineOfBusiness) – LineOfBusiness to use in instantiation request

  • platform (Platform) – Platform to use in instantiation request

  • cloud_region (CloudRegion) – Cloud region to use in instantiation request.

  • tenant (Tenant) – Tenant to use in instantiation request.

  • vnf_instance_name (str, optional) – Vnf instance name. Defaults to None.

  • vnf_parameters (Iterable[InstantiationParameter], optional) – Instantiation parameters that are sent in the request. Defaults to None

  • so_vnf (SoServiceVnf) – object with vnf instance parameters

Returns

VnfInstantiation object

Return type

VnfInstantiation

classmethod so_action(vnf_instance, operation_type, aai_service_instance, line_of_business, platform, sdc_service, so_service=None)

Execute SO action (update or healthcheck) for selected vnf with SO macro request.

Parameters
  • vnf_instance (VnfInstance) – vnf instance object

  • operation_type (VnfOperation) – name of the operation to trigger

  • aai_service_instance (AaiService) – Service Instance object from aai

  • line_of_business (LineOfBusiness) – LineOfBusiness name to use in instantiation request

  • platform (Platform) – Platform name to use in instantiation request

  • sdc_service (SdcService) – Service model information

  • so_service (SoService, optional) – SO values to use in SO request

Raises

StatusError – if the provided operation is not supported

Returns

VnfInstantiation object

Return type

VnfInstantiation

class onapsdk.so.instantiation.VnfOperation(request_method, request_suffix)

Bases: onapsdk.so.instantiation.Operation

Class to store possible operations’ data for vnfs (request method and suffix).

HEALTHCHECK = Operation(request_method='POST', request_suffix='/healthcheck')
UPDATE = Operation(request_method='PUT', request_suffix='')
request_method: str
request_suffix: str
class onapsdk.so.instantiation.VnfParameters(name, vnf_parameters=None, vfmodule_parameters=None)

Bases: object

Class to store vnf parameters used for macro instantiation.

Contains value lists: List vnf Instantiation parameters and list of vfModule parameters

name: str
vfmodule_parameters: Iterable[onapsdk.so.instantiation.VfmoduleParameters] = None
vnf_parameters: Iterable[onapsdk.so.instantiation.InstantiationParameter] = None

onapsdk.so.so_db_adapter module

Database Adapter module.

class onapsdk.so.so_db_adapter.IdentityService(identity_id, url='http://1.2.3.4:5000/v2.0', mso_id='onapsdk_user', mso_pass='mso_pass_onapsdk', project_domain_name='NULL', user_domain_name='NULL', admin_tenant='service', member_role='admin', identity_server_type='KEYSTONE', identity_authentication_type='USERNAME_PASSWORD', server_type_as_string='KEYSTONE', tenant_metadata=True)

Bases: object

Class to store identity service details.

admin_tenant: str = 'service'
hibernate_lazy_initializer = {}
identity_authentication_type: str = 'USERNAME_PASSWORD'
identity_id: str
identity_server_type: str = 'KEYSTONE'
member_role: str = 'admin'
mso_id: str = 'onapsdk_user'
mso_pass: str = 'mso_pass_onapsdk'
project_domain_name: str = 'NULL'
server_type_as_string: str = 'KEYSTONE'
tenant_metadata: bool = True
url: str = 'http://1.2.3.4:5000/v2.0'
user_domain_name: str = 'NULL'
class onapsdk.so.so_db_adapter.SoDbAdapter(name=None, _server='SO', _status=None)

Bases: onapsdk.so.so_element.SoElement, abc.ABC

DB Adapter class.

classmethod add_cloud_site(cloud_region_id, complex_id, identity_service, orchestrator='multicloud')

Add cloud_site data with identity_service to SO db.

Parameters
  • cloud_region_id (str) – The id of cloud region

  • complex_id (str) – The id of complex

  • identity_service (IdentityService) – Identity service related to the cloud region

  • orchestrator (str, optional) – Orchestrator type. Defaults to multicloud.

Important

identity_services data will be overwrite, but in the same time cloud_sites data will not (shouldn’t) be overwrite! SOCatalogDB REST API has some limitations reported: https://jira.onap.org/browse/SO-2727

Returns

response object

classmethod get_service_vnf_info(identifier)

Get Service VNF and VF details.

Return type

Dict[Any, Any]

Returns

The response in a dict format

onapsdk.so.so_element module

SO Element module.

class onapsdk.so.so_element.OrchestrationRequest(request_id)

Bases: onapsdk.so.so_element.SoElement, onapsdk.utils.mixins.WaitForFinishMixin, abc.ABC

Base SO orchestration request class.

class StatusEnum(value)

Bases: enum.Enum

Status enum.

Store possible statuses for instantiation:
  • IN_PROGRESS,

  • FAILED,

  • COMPLETE.

If instantiation has status which is not covered by these values

UNKNOWN value is used.

COMPLETED = 'COMPLETE'
FAILED = 'FAILED'
IN_PROGRESS = 'IN_PROGRESS'
UNKNOWN = 'UNKNOWN'
WAIT_FOR_SLEEP_TIME = 10
property completed

Store an information if instantion is completed or not.

Instantiation is completed if it’s status is COMPLETED.

Returns

True if instantiation is completed, False otherwise.

Return type

bool

property failed

Store an information if instantion is failed or not.

Instantiation is failed if it’s status is FAILED.

Returns

True if instantiation is failed, False otherwise.

Return type

bool

property finished

Store an information if instantion is finished or not.

Instantiation is finished if it’s status is COMPLETED or FAILED.

Returns

True if instantiation is finished, False otherwise.

Return type

bool

property status

Object instantiation status.

It’s populated by call SO orchestation request endpoint.

Returns

Instantiation status.

Return type

StatusEnum

class onapsdk.so.so_element.SoElement(name=None, _server='SO', _status=None)

Bases: onapsdk.onap_service.OnapService

Mother Class of all SO elements.

api_version = 'v7'
base_url = 'http://so.api.simpledemo.onap.org:30277'
classmethod get_guis()

Retrieve the status of the SO GUIs.

Only one GUI is referenced for SO: SO monitor

Return the list of GUIs

Return type

GuiItem

classmethod get_service_model_info(service_name)

Retrieve Service Model info.

classmethod get_subscription_service_type(vf_name)

Retrieve the model info of the VFs.

classmethod get_vf_model_info(vf_model)

Retrieve the VF model info From Tosca?.

Return type

str

classmethod get_vnf_model_info(vf_name)

Retrieve the model info of the VFs.

property headers

Create headers for SO request.

It is used as a property because x-transactionid header should be unique for each request.

name: str = None

Module contents

ONAP SDK SO package.