diff options
Diffstat (limited to 'docs/usage')
-rw-r--r-- | docs/usage/installation.rst | 32 | ||||
-rw-r--r-- | docs/usage/intro.rst | 16 | ||||
-rw-r--r-- | docs/usage/usage.rst | 14 | ||||
-rw-r--r-- | docs/usage/usage/cds.rst | 173 | ||||
-rw-r--r-- | docs/usage/usage/cloud_configuration.rst | 210 | ||||
-rw-r--r-- | docs/usage/usage/cps.rst | 32 | ||||
-rw-r--r-- | docs/usage/usage/deletion.rst | 28 | ||||
-rw-r--r-- | docs/usage/usage/design_time.rst | 351 | ||||
-rw-r--r-- | docs/usage/usage/dmaap.rst | 47 | ||||
-rw-r--r-- | docs/usage/usage/instantiation.rst | 485 | ||||
-rw-r--r-- | docs/usage/usage/ves.rst | 42 |
11 files changed, 1430 insertions, 0 deletions
diff --git a/docs/usage/installation.rst b/docs/usage/installation.rst new file mode 100644 index 0000000..c324c96 --- /dev/null +++ b/docs/usage/installation.rst @@ -0,0 +1,32 @@ +Installation +############ + + + +Installing with pip +-------------------- + +.. code:: shell + + $ pip install onapsdk + + +Customize the configuration +--------------------------- + +You can customize the global settings of onapsdk by creating an environment +variable ONAP_PYTHON_SDK_SETTINGS and a file my_settings.py. + +By default the global settings are retrieved from the file located in +src/onapsdk/configuration/global_settings.py. You can create your own customized +configuration file and reference it through the environement variable. +You can thus copy/paste the existing global_settings.py file, rename it as +my_settings.py, adapt it with your favorite editor and export the environnement +variable accordingly. + +It can be useful to move from a nodeport to an an ingress based configuration +or test different API versions. + + .. code:: shell + + $ export ONAP_PYTHON_SDK_SETTINGS="onapsdk.configuration.my_settings" diff --git a/docs/usage/intro.rst b/docs/usage/intro.rst new file mode 100644 index 0000000..7031c13 --- /dev/null +++ b/docs/usage/intro.rst @@ -0,0 +1,16 @@ +Introduction +############ + +It *should* be simple to use. +Once you have installed the Python module, few lines of code are needed to +onboard a Service: + +.. code:: Python + + from onapsdk.vf import Vf + from onapsdk.service import Service + + # We assume here that the VF has been already onboarded + vf = VF(name="myVF") + service = Service(name="myService", resources=[vf]) + service.onboard() diff --git a/docs/usage/usage.rst b/docs/usage/usage.rst new file mode 100644 index 0000000..4a1dc9d --- /dev/null +++ b/docs/usage/usage.rst @@ -0,0 +1,14 @@ +Usage +##### + +A minimum knowledge of ONAP is needed, especially on the onboarding part. + +.. toctree:: + :maxdepth: 2 + + usage/cloud_configuration + usage/design_time + usage/instantiation + usage/deletion + usage/cds + usage/cps diff --git a/docs/usage/usage/cds.rst b/docs/usage/usage/cds.rst new file mode 100644 index 0000000..b516c73 --- /dev/null +++ b/docs/usage/usage/cds.rst @@ -0,0 +1,173 @@ +CDS +### + +Preparation for CDS tests +------------------------- + +To enable CDS Enrichment in an ONAP Frankfurt environment the NodePort 30449 +for the CDS Blueprint Processor API service needs to be opened + +#. Check existing CDS Services: + + .. code-block:: sh + + ubuntu@control01:~$ kubectl get service -n onap|grep cds-blueprints-processor-http + cds-blueprints-processor-http ClusterIP 10.43.101.198 <none> 8080/TCP + +#. Change NodePort to CDS cds-blueprints-processor-http + + Add the "nodePort" under "ports" section + and change "type" from "ClusterIP" to "NodePort" + + .. code-block:: sh + + ubuntu@control01:~$ kubectl edit service cds-blueprints-processor-http -n onap + + apiVersion: v1 + kind: Service + metadata: + creationTimestamp: "2020-07-23T02:57:36Z" + labels: + app: cds-blueprints-processor + chart: cds-blueprints-processor-6.0.0 + heritage: Tiller + release: onap + name: cds-blueprints-processor-http + namespace: onap + resourceVersion: "10256" + selfLink: /api/v1/namespaces/onap/services/cds-blueprints-processor-http + uid: 6f065c03-4563-4d64-b6f5-a8892226c909 + spec: + clusterIP: 10.43.101.198 + ports: + - name: blueprints-processor-http + nodePort: 30449 -> add line + port: 8080 + protocol: TCP + targetPort: 8080 + selector: + app: cds-blueprints-processor + release: onap + sessionAffinity: None + type: ClusterIP -> change to NodePort + status: + loadBalancer: {} + +#. Verify NodePort to CDS cds-blueprints-processor-http + + .. code-block:: sh + + ubuntu@control01:~$ kubectl get service -n onap|grep cds-blueprints-processor-http + cds-blueprints-processor-http NodePort 10.43.101.198 <none> 8080:30449/TCP + +#. Load ModelType via Bootstrap + + .. code-block:: sh + + curl --location --request POST 'http://<k8s-host>:30449/api/v1/blueprint-model/bootstrap' \ + --header 'Content-Type: application/json' \ + --header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ + --data-raw '{ + "loadModelType" : true, + "loadResourceDictionary" : false, + "loadCBA" : false + }' + + +Load blueprint from file +------------------------ + +.. code:: Python + + from onapsdk.cds import Blueprint + blueprint = Blueprint.load_from_file("<< path to CBA file >>") + +Enrich blueprint and save +------------------------- + +.. code:: Python + + enriched_blueprint = blueprint.enrich() + enriched_blueprint.save("<< path to dest file >>") + +Publish blueprint +----------------- + +.. code:: Python + + enriched_blueprint.publish() + +Generate data dictionary from blueprint +--------------------------------------- + +The method to generate data dictionaries based on the blueprint mappings. As the result it returns a data dictionaries set +with valid structure, but some additional actions may be needed. Data dictionary input has to be filled by the user +if the type is neither "source-input" nor "source-default". Things, which are needed to be filled are marked by `<< FILL >>` mark. +If the blueprint you are using has only "source-input" or "source-default" input types, the generated data dictionary set is +ready to upload to CDS. + +.. code:: Python + + generated_dd: DataDictionarySet = blueprint.get_data_dictionaries() + generated_dd.save_to_file("<< path to dest file >>") + +Load data dictionary set from file +---------------------------------- + +.. code:: Python + + from onapsdk.cds import DataDictionarySet + dd_set = DataDictionarySet.load_from_file("<< path to dd file >>") + +Upload data dictionary set +-------------------------- + +.. code:: Python + + dd_set.upload() + +Retrieve Blueprint Models from CDS +-------------------------- + +#. All + +.. code:: Python + + from onapsdk.cds import BlueprintModel + all_blueprint_models = BlueprintModel.get_all() + +#. Selected by id of Blueprint Model + +.. code:: Python + + blueprint_model = BlueprintModel.get_by_id(blueprint_model_id='11111111-1111-1111-1111-111111111111') + +#. Selected by name and version of Blueprint Model + +.. code:: Python + + blueprint_model = BlueprintModel.get_by_name_and_version(blueprint_name='test_name', blueprint_version='1.0.0') + +Delete Blueprint Model +-------------------------- + +.. code:: Python + + blueprint_model.delete() + +Download Blueprint Model +-------------------------- + +.. code:: Python + + blueprint_model.save(dst_file_path='/tmp/blueprint.zip') + + +Get Blueprint object for Blueprint Model +-------------------------- + +After that, all operation for blueprint object, like execute blueprint workflow etc. can be executed. + +.. code:: Python + + blueprint = blueprint_model.get_blueprint() diff --git a/docs/usage/usage/cloud_configuration.rst b/docs/usage/usage/cloud_configuration.rst new file mode 100644 index 0000000..b048c0a --- /dev/null +++ b/docs/usage/usage/cloud_configuration.rst @@ -0,0 +1,210 @@ +Cloud configuration +################### + +Create a complex +---------------- + +.. code:: Python + + from onapsdk.aai.cloud_infrastructure import Complex + cmplx = Complex.create( + physical_location_id=COMPLEX_PHYSICAL_LOCATION_ID, + data_center_code=COMPLEX_DATA_CENTER_CODE, + name=COMPLEX_PHYSICAL_LOCATION_ID + ) + +Create cloud region +------------------- + +.. code:: Python + + from onapsdk.aai.cloud_infrastructure import CloudRegion + cloud_region = CloudRegion.create( + cloud_owner=CLOUD_OWNER, + cloud_region_id=CLOUD_REGION, + orchestration_disabled=False, + in_maint=False, + cloud_type=CLOUD_TYPE, + cloud_region_version=CLOUD_REGION_VERSION + ) + +Link cloud region to complex +---------------------------- + +.. code:: Python + + from onapsdk.aai.cloud_infrastructure import CloudRegion, Complex + # We assume that complex has been already created + cmplx = Complex( + physical_location_id=COMPLEX_PHYSICAL_LOCATION_ID, + name=COMPLEX_PHYSICAL_LOCATION_ID + ) + cloud_region = CloudRegion.create( + cloud_owner=CLOUD_OWNER, + cloud_region_id=CLOUD_REGION, + orchestration_disabled=False, + in_maint=False, + cloud_type=CLOUD_TYPE, + cloud_region_version=CLOUD_REGION_VERSION + ) + cloud_region.link_to_complex(cmplx) + +Add ESR Info to cloud region +---------------------------- + +.. code:: Python + + from uuid import uuid4 + from onapsdk.aai.cloud_infrastructure import CloudRegion + # We assume that cloud region has been already created + cloud_region = CloudRegion.get_by_id( + cloud_owner=CLOUD_OWNER, + cloud_region_id=CLOUD_REGION + ) + cloud_region.add_esr_system_info( + esr_system_info_id=str(uuid4()), + user_name=VIM_USERNAME, + password=VIM_PASSWORD, + system_type=CLOUD_TYPE, + service_url=VIM_SERVICE_URL, + cloud_domain=CLOUD_DOMAIN + ) + +Register cloud to MultiCloud +---------------------------- + +.. code:: Python + + from uuid import uuid4 + from onapsdk.aai.cloud_infrastructure import CloudRegion + # We assume that cloud region has been already created + cloud_region = CloudRegion.get_by_id( + cloud_owner=CLOUD_OWNER, + cloud_region_id=CLOUD_REGION + ) + cloud_region.add_esr_system_info( + esr_system_info_id=str(uuid4()), + user_name=VIM_USERNAME, + password=VIM_PASSWORD, + system_type=CLOUD_TYPE, + service_url=VIM_SERVICE_URL, + cloud_domain=CLOUD_DOMAIN + ) + cloud_region.register_to_multicloud() + +Get cloud region tenant +----------------------- + +.. code:: Python + + # We assume that cloud region has been already created + # and connected to multicloud + from onapsdk.aai.cloud_infrastructure import CloudRegion + cloud_region = CloudRegion.get_by_id( + cloud_owner=CLOUD_OWNER, + cloud_region_id=CLOUD_REGION + ) + try: + tenant = next(cloud_region.tenant) + except StopIteration + # No Tenant found in cloud region + +Create customer +--------------- + +.. code:: Python + + from onapsdk.aai.business import Customer + customer = Customer.create(GLOBAL_CUSTOMER_ID, GLOBAL_CUSTOMER_ID, "INFRA") + +Create customer service subscription +------------------------------------ + +.. code:: Python + + # We assume here that the service has been already onboarded + # and customer created + from onapsdk.aai.business import Customer + + customer = Customer.get_by_global_customer_id(GLOBAL_CUSTOMER_ID) + customer.subscribe_service("service_type") + + # Service subscriptions can be also created during Customer + # creation + from onapsdk.aai.business import Customer + + customer = Customer.create(GLOBAL_CUSTOMER_ID, GLOBAL_CUSTOMER_ID, "INFRA", service_subscriptions=["service_type"]) + +Connect service subscription to cloud region and tenant +------------------------------------------------------- + +.. code:: Python + + # We assume here that the service subscription has been already created + # and cloud region has a tenant + from onapsdk.aai.business import Customer + from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant + + customer = Customer.get_by_global_customer_id(GLOBAL_CUSTOMER_ID) + service_subscription = next(customer.service_subscriptions) + cloud_region = CloudRegion.get_by_id( + cloud_owner=CLOUD_OWNER, + cloud_region_id=CLOUD_REGION + ) + tenant = next(cloud_region.tenants) + service_subscription.link_to_cloud_region_and_tenant(cloud_region, tenant) + +Add Cloud SIte entry to SO Catalog DB +------------------------------------------------------- + +.. code:: Python + + from onapsdk.so.so_db_adapter import IdentityService, SoDbAdapter + + identity_service = IdentityService(identity_id="mc_test_identity_1_KEYSTONE", + url="http://test:5000/v3", + mso_id="test_user", + mso_pass="test_password_encrypted", + roject_domain_name="Default", + user_domain_name="Default", + identity_server_type="KEYSTONE_V3") + response = SoDbAdapter.add_cloud_site(cloud_region_id="test_region_1", + complex_id="test_clli_1", + identity_service=identity_service, + orchestrator="NULL") + +Use A&AI bulk API (experimental) +-------------------------------- + +.. code:: Python + + from onapsdk.aai.bulk import AaiBulk, AaiBulkRequest + from onapsdk.aai.cloud_infrastructure.cloud_region import CloudRegion + from onapsdk.utils.jinja import jinja_env + + + for resp in AaiBulk.single_transaction( + [ + AaiBulkRequest( + action="put", + uri=f"/cloud-infrastructure/cloud-regions/cloud-region/aai_bulk_test_cloud_owner_1/aai_bulk_test_cloud_region_id_1", + body=jinja_env().get_template("cloud_region_create.json.j2").render(cloud_region=CloudRegion( + cloud_owner="aai_bulk_test_cloud_owner_1", + cloud_region_id="aai_bulk_test_cloud_region_id_1", + orchestration_disabled=False, + in_maint=False + )) + ), + AaiBulkRequest( + action="put", + uri=f"/cloud-infrastructure/cloud-regions/cloud-region/aai_bulk_test_cloud_owner_2/aai_bulk_test_cloud_region_id_2", + body=jinja_env().get_template("cloud_region_create.json.j2").render(cloud_region=CloudRegion( + cloud_owner="aai_bulk_test_cloud_owner_2", + cloud_region_id="aai_bulk_test_cloud_region_id_2", + orchestration_disabled=False, + in_maint=False + )) + ) + ] + ): + print(resp) diff --git a/docs/usage/usage/cps.rst b/docs/usage/usage/cps.rst new file mode 100644 index 0000000..0a19b29 --- /dev/null +++ b/docs/usage/usage/cps.rst @@ -0,0 +1,32 @@ +CPS +### + +Create dataspace +---------------- + +.. code:: Python + + from onapsdk.cps import Dataspace + dataspace: Dataspace = Dataspace.create(dataspace_name="test_dataspace") + + +Create schema set +---------------- + +.. code:: Python + + from onapsdk.cps import Dataspace, SchemaSet + dataspace: Dataspace = Dataspace(name="test_dataspace") + with Path("schema_set_zip_file.zip").open("rb") as zip_file: + schema_set: SchemaSet = dataspace.create_schema_set("test_schemaset", zip_file) + + +Create anchor +------------- + +.. code:: Python + + from onapsdk.cps import Anchor, Dataspace, SchemaSet + dataspace: Dataspace = Dataspace(name="test_dataspace") + schema_set: SchemaSet = dataspace.get_schema_set("test_schemaset") + anchor: Anchor = dataspace.create_anchor(schema_set, "test_anchor") diff --git a/docs/usage/usage/deletion.rst b/docs/usage/usage/deletion.rst new file mode 100644 index 0000000..c5e5025 --- /dev/null +++ b/docs/usage/usage/deletion.rst @@ -0,0 +1,28 @@ +Instantiated resources deletion +############################### + +Service, vnf and vf module deletion +----------------------------------- + +.. code:: Python + + from onapsdk.aai.business import Customer + + customer = Customer.get_by_global_customer_id(GLOBAL_CUSTOMER_ID) + service_subscription = next(customer.service_subscriptions) + service_instance = service_subscription.get_service_instance_by_name(SERVICE_INSTANCE_NAME) + for vnf_instance in service_instance.vnf_instances: + for vf_module_instance in vnf_instance.vf_modules: + vf_module_deletion_request = vf_module_instance.delete() + while not vf_module_deletion.finished: + time.sleep(10) + + vnf_instance_deletion_request = vnf_instance.delete() + while not vnf_instance_deletion_request.finished: + time.sleep(10) + + service_instance_deletion_request = service_instance.delete() + if service_instance_deletion_request.wait_for_finish(): + print("Service instance deleted") + else: + print("Service deletion failed, check logs" diff --git a/docs/usage/usage/design_time.rst b/docs/usage/usage/design_time.rst new file mode 100644 index 0000000..5990258 --- /dev/null +++ b/docs/usage/usage/design_time.rst @@ -0,0 +1,351 @@ +Design time +########### + +Onboard a Vendor +---------------- + +.. code:: Python + + from onapsdk.vendor import Vendor + vendor = Vendor(name="myVendor") + vendor.onboard() + +Onboard a VSP +------------- + +You will need the package of the VSP to onboard. + +.. code:: Python + + from onapsdk.sdc.vendor import Vendor + from onapsdk.sdc.vsp import Vsp + + # We assume here that the Vendor has been already onboarded + vendor = Vendor(name="myVendor") + vendor.onboard() + vsp = Vsp(name="myVSP", vendor=vendor, package=open(PATH_TO_PACKAGE, 'rb')) + vsp.onboard() + +Create new VSP version +---------------------- + +You will need the package of the VSP to update. + +.. code:: Python + + from onapsdk.sdc.vendor import Vendor + from onapsdk.sdc.vsp import Vsp + + # We assume here that the Vendor has been already onboarded + vsp = Vsp(name="myVSP") + vsp.create_new_version() + vsp.update_package(open(PATH_TO_PACKAGE, 'rb')) + vsp.onboard() + +Onboard a VF +------------ + +.. code:: Python + + from onapsdk.sdc.vsp import Vsp + from onapsdk.sdc.vf import Vf + + # We assume here that the VSP has been already onboarded + vsp = Vsp(name="myVSP") + vf = Vf(name="myVF", vsp=vsp) + vf.onboard() + +Onboard a VF with properties assignement +---------------------------------------- + +.. code:: Python + + from onapsdk.sdc.properties import Property + from onapsdk.sdc.vsp import Vsp + from onapsdk.sdc.vf import Vf + + # We assume here that the VSP has been already onboarded + vsp = Vsp(name="myVSP") + property_1 = Property( + name="prop1", + property_type="string", + value="test" + ) + property_2 = Property( + name="prop2", + property_type="integer" + ) + vf = Vf(name="myVF", + vsp=vsp, + properties=[ + property_1, + property_2 + ], + inputs=[property_1]) + vf.onboard() + +Onboard a VF with Deployment Artifact +------------------------------------- + +.. code:: Python + + from onapsdk.sdc.properties import Property + from onapsdk.sdc.vsp import Vsp + from onapsdk.sdc.vf import Vf + + logger.info("******** Onboard Vendor *******") + vendor = Vendor(name="my_Vendor") + vendor.onboard() + + # We assume here that the VSP has been already onboarded + vsp = Vsp(name="myVSP") + + logger.info("******** Onboard VF *******") + vf = Vf(name="myVF") + vf.vsp = vsp + vf.create() + + logger.info("******** Upload Artifact *******") + vf.add_deployment_artifact(artifact_type="CONTROLLER_BLUEPRINT_ARCHIVE", + artifact_name="CBA.zip", + artifact_label="vfwcds", + artifact="dir/CBA_enriched.zip") + + vf.onboard() + +Onboard a VF with it's component's property input +------------------------------------------------- + +.. code:: Python + + from onapsdk.sdc.properties import ComponentProperty + from onapsdk.sdc.vsp import Vsp + from onapsdk.sdc.vf import Vf + from onapsdk.sdc.vfc import Vfc + + # We assume here that the VSP has been already onboarded + vsp = Vsp(name="myVSP") + + vfc = Vfc(name="AllottedResource") + + logger.info("******** Onboard VF *******") + vf = Vf(name="myVF") + vf.vsp = vsp + vf.create() + vf.add_resource(vfc) + vfc_comp = vf.get_component(vfc) + comp_prop = vfc_comp.get_property("min_instances") + comp_prop.value = 11 + vf.declare_input(comp_prop) + + vf.onboard() + +Onboard a PNF with VSP +---------------------- +.. code:: Python + + from onapsdk.sdc.pnf import Pnf + from onapsdk.sdc.vendor import Vendor + + logger.info("******** Onboard Vendor *******") + vendor = Vendor(name="my_Vendor") + vendor.onboard() + + # We assume here that the VSP has been already onboarded + vsp = Vsp(name="myVSP") + + logger.info("******** Onboard PNF *******") + pnf = PNF(name="myPNF") + pnf.vsp = vsp + pnf.onboard() + +Onboard a PNF with Deployment Artifact (without VSP) +---------------------------------------------------- +.. code:: Python + + from onapsdk.sdc.vendor import Vendor + from onapsdk.sdc.pnf import Pnf + + logger.info("******** Onboard Vendor *******") + vendor = Vendor(name="my_Vendor") + vendor.onboard() + + logger.info("******** Onboard PNF *******") + pnf = Pnf(name=PNF, vendor=vendor) + pnf.create() + + logger.info("******** Upload Artifact *******") + pnf.add_deployment_artifact(artifact_type=ARTIFACT_TYPE, + artifact_name=ARTIFACT_NAME, + artifact_label=ARTIFACT_LABEL, + artifact=ARTIFACT_FILE_PATH) + pnf.onboard() + +Onboard a Service +----------------- + +.. code:: Python + + from onapsdk.sdc.vf import Vf + from onapsdk.sdc.service import Service + + # We assume here that the VF has been already onboarded + vf = Vf(name="myVF") + service = Service(name="myService", resources=[vf]) + service.onboard() + +Onboard a Service with properties assignement +--------------------------------------------- + +.. code:: Python + + from onapsdk.sdc.properties import Property + from onapsdk.sdc.vf import Vf + from onapsdk.sdc.service import Service + + # We assume here that the VF has been already onboarded + vf = Vf(name="myVF") + property_1 = Property( + name="prop1", + property_type="string", + value="test" + ) + property_2 = Property( + name="prop2", + property_type="integer", + declare_input=True + ) + service = Service(name="myService", + resources=[vf], + properties=[ + property_1, + property_2 + ], + inputs=[property_1]) + service.onboard() + +Onboard a Service with Nested inputs +------------------------------------ + +.. code:: Python + + from onapsdk.sdc.properties import NestedInput + from onapsdk.sdc.vf import Vf + from onapsdk.sdc.service import Service + + # We assume here that the VF has been already onboarded + vf = Vf(name="myVF") + inp = vf.get_input("input_name_we_want_to_declare_in_service") + service = Service(name="myService", + resources=[vf], + inputs=[NestedInput(vf, inp)]) + service.onboard() + +Onboard a Service with VL +------------------------- + +.. code:: Python + + from onapsdk.sdc.vl import VL + from onapsdk.sdc.service import Service + + # No VF needed, but you need to be sure that Vl with given + # name exists in SDC + vl = Vl(name="Generic NeutronNet") + service = Service(name="myServiceWithVl", resources=[vl]) + service.onboard() + +Onboard a Service with custom category +-------------------------------------- + +.. code:: Python + + from onapsdk.sdc.category_management import ServiceCategory + from onapsdk.sdc.vf import Vf + from onapsdk.sdc.service import Service + + # Let's create a custom category + CATEGORY_NAME = "Python ONAP SDK category" + ServiceCategory.create(name=CATEGORY_NAME) + + # We assume here that the VF has been already onboarded + # Create a service with category we created few lines above + vf = Vf(name="myVF") + service = Service(name="myService", resources=[vf], category=CATEGORY_NAME) + service.onboard() + +Onboard an Artifact for an embedded VF +-------------------------------------- + +All SDC artifact types are supported + +.. code:: Python + + from onapsdk.service import Service + + # We assume here that the Service has been already onboarded + # with a Vnf + service = Service(name="myService") + # We load artifact data + data = open("{}/myArtifact.yaml".format(os.path.dirname(os.path.abspath(__file__))), 'rb').read() + # We add the artifact to the service Vnf + # + svc.add_artifact_to_vf(vnf_name="myVnf", + artifact_type="DCAE_INVENTORY_BLUEPRINT", + artifact_name="myArtifact.yaml", + artifact=data) + +Onboard a Service with Deployment Artifact +------------------------------------------ + +.. code:: Python + + from onapsdk.sdc.service import Service + + svc = Service(name="myService") + + logger.info("******** Upload Artifact *******") + svc.add_deployment_artifact(artifact_type="OTHER", + artifact_name="eMBB.zip", + artifact_label="embbcn", + artifact="dir/eMBB.zip") + + svc.onboard() + +Onboard a Service with a CBA blueprint for Macro Instantiation +-------------------------------------------------------------- + +.. code:: Python + + from onapsdk.sdc.service import Service, ServiceInstantiationType + + # Set CBA variables and artifact level + # Must match to values in the CBA TOSCA.meta file + SDNC_TEMPLATE_NAME = "vFW-CDS" + SDNC_TEMPLATE_VERSION = "1.0.0" + SDNC_ARTIFACT_NAME = "vnf" + + svc = Service(name="myService", + instantiation_type=ServiceInstantiationType.MACRO) + + svc.create() + + logger.info("*** add a VF, which includes a CBA blueprint ***") + svc.add_resource(vf) + + logger.info("******** Set SDNC properties for VF ********") + component = svc.get_component(vf) + prop = component.get_property("sdnc_model_version") + prop.value = SDNC_TEMPLATE_NAME + prop = component.get_property("sdnc_artifact_name") + prop.value = SDNC_ARTIFACT_NAME + prop = component.get_property("sdnc_model_name") + prop.value = SDNC_TEMPLATE_NAME + prop = component.get_property("controller_actor") + prop.value = "CDS" + prop = component.get_property("skip_post_instantiation_configuration") + prop.value = False + + logger.info("******** Onboard Service *******") + svc.checkin() + svc.onboard() diff --git a/docs/usage/usage/dmaap.rst b/docs/usage/usage/dmaap.rst new file mode 100644 index 0000000..ee62d04 --- /dev/null +++ b/docs/usage/usage/dmaap.rst @@ -0,0 +1,47 @@ +VES +### + +Preparation for DMAAP tests +------------------------- + +#. Check existing DMaap Services: + + .. code-block:: sh + + kubectl get service -n onap| grep mess + message-router NodePort 10.43.30.205 <none> 3905:31163/TCP,3904:32404/TCP + +#. If the port of Ves Service is different than 3904 you can change it corresponding to the installation instruction. + + +Remove all events from DMaap +--------------------------- + +.. code:: Python + + from onapsdk.dmaap.dmaap import Dmaap + response = Dmaap.reset_events() + +Get all events from DMaap +------------------------- + +.. code:: Python + + from onapsdk.dmaap.dmaap import Dmaap + response = Dmaap.get_all_events() + +Get events from specific topic from DMaap +------------------------- + +.. code:: Python + + from onapsdk.dmaap.dmaap import Dmaap + response = Dmaap.get_events_for_topic("fault") + +Get all topics from DMaap +------------------------- + +.. code:: Python + + from onapsdk.dmaap.dmaap import Dmaap + response = Dmaap.get_all_topics()
\ No newline at end of file diff --git a/docs/usage/usage/instantiation.rst b/docs/usage/usage/instantiation.rst new file mode 100644 index 0000000..642439e --- /dev/null +++ b/docs/usage/usage/instantiation.rst @@ -0,0 +1,485 @@ +Instantiation +############# + +Create business objects +----------------------- + +.. code:: Python + + from onapsdk.vid import LineOfBusiness, OwningEntity, Platform, Project + + vid_owning_entity = OwningEntity.create(OWNING_ENTITY) + vid_project = Project.create(PROJECT) + vid_platform = Platform.create(PLATFORM) + vid_line_of_business = LineOfBusiness.create(LINE_OF_BUSINESS) + +Instantiate a service (ALaCarte) +-------------------------------- + +.. code:: Python + + import time + from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant + from onapsdk.aai.business import Customer + from onapsdk.service import Service + from onapsdk.vid import LineOfBusiness, OwningEntity, Platform, Project + from onapsdk.so.instantiation import ServiceInstantiation + + # We assume that: + # - service is onboarded, + # - cloud region, customer, owning_entity and project have been already created, + # - cloud region has at least one tenant + # - customer has service subscription + # - service subscription is connected with cloud region and tenant + SERVICE_INSTANCE_NAME = "vFW-AlaCarte-1" + + service = Service(name="myService") + customer = Customer.get_by_global_customer_id(GLOBAL_CUSTOMER_ID) + cloud_region = CloudRegion.get_by_id( + cloud_owner=CLOUD_OWNER, + cloud_region_id=CLOUD_REGION + ) + tenant = next(cloud_region.tenants) + vid_owning_entity = OwningEntity(OWNING_ENTITY) + owning_entity = AaiOwningEntity.get_by_owning_entity_name(OWNING_ENTITY) + vid_project = Project(PROJECT) + + service_instantiation = ServiceInstantiation.instantiate_so_ala_carte( + service, + cloud_region, + tenant, + customer, + owning_entity, + vid_project, + service_instance_name=SERVICE_INSTANCE_NAME + ) + service_instantiation.wait_for_finish(): + print("Success") + else: + print("Instantiation failed, check logs") + +Instantiate a service (Macro) +----------------------------- + +.. code:: Python + + import time + from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant + from onapsdk.aai.business import Customer + from onapsdk.service import Service + from onapsdk.vid import LineOfBusiness, OwningEntity, Platform, Project + from onapsdk.so.instantiation import ( + ServiceInstantiation, + VnfInstantiation, + InstantiationParameter, + VnfParameters, + VfmoduleParameters + ) + + ... + VSPNAME = "vfwcds_VS" + VFNAME = "vfwcds_VF" + ... + vf = Vf(name=VFNAME) + ... + + # We assume that: + # - service is onboarded, + # - cloud region, customer, owning_entity and project have been already created, + # - cloud region has at least one tenant + # - customer has service subscription + # - service subscription is connected with cloud region and tenant + SERVICE_INSTANCE_NAME = "vFW-Macro-1" + + service = Service(name="myMacroService") + customer = Customer.get_by_global_customer_id(GLOBAL_CUSTOMER_ID) + cloud_region = CloudRegion.get_by_id( + cloud_owner=CLOUD_OWNER, + cloud_region_id=CLOUD_REGION + ) + tenant = next(cloud_region.tenants) + vid_owning_entity = OwningEntity(OWNING_ENTITY) + owning_entity = AaiOwningEntity.get_by_owning_entity_name(OWNING_ENTITY) + vid_project = Project(PROJECT) + + ########################################################################### + ######## VFModule parameters ############################################## + ########################################################################### + vfm_base=[ + InstantiationParameter(name="sec_group", value=TENANT_SEC_GROUP), + InstantiationParameter(name="public_net_id", value=PUBLIC_NET) + ] + + vfm_vsn=[ + InstantiationParameter(name="sec_group", value=TENANT_SEC_GROUP), + InstantiationParameter(name="public_net_id", value=PUBLIC_NET) + ] + + vfm_vfw=[ + InstantiationParameter(name="sec_group", value=TENANT_SEC_GROUP), + InstantiationParameter(name="public_net_id", value=PUBLIC_NET) + ] + + vfm_vpkg=[ + InstantiationParameter(name="sec_group", value=TENANT_SEC_GROUP), + InstantiationParameter(name="public_net_id", value=PUBLIC_NET) + ] + + base_paras=VfmoduleParameters("base_template",vfm_base) + vpkg_paras=VfmoduleParameters("vpkg",vfm_vpkg) + vsn_paras=VfmoduleParameters("vsn",vfm_vsn) + vfw_paras=VfmoduleParameters("vfw",vfm_vfw) + + ########################################################################### + ######## VNF parameters ################################################### + ########################################################################### + + vnf_vfw=[ + InstantiationParameter(name="onap_private_net_id", value=ONAP_PRIVATE_NET), + InstantiationParameter(name="onap_private_subnet_id", value=ONAP_PRIVATE_SUBNET), + InstantiationParameter(name="pub_key", value="ssh-rsa AAAAB3NzaC1yc2EAA\ + AADAQABAAABAQDFBOB1Ea2yej68aqIQw10kEsVf+rNoxT39qrV8JvvTK2yhkniQka1t2oD9h6DlXOL\ + M3HJ6nBegWjOasJmIbminKZ6wvmxZrDVFJXp9Sn1gni0vtEnlDgH14shRUrFDYO0PYjXRHoj7QXZMY\ + xtAdFSbzGuCsaTLcV/xchLBQmqZ4AGhMIiYMfJJF+Ygy0lbgcVmT+8DH7kUUt8SAdh2rRsYFwpKANn\ + QJyPV1dBNuTcD0OW1hEOhXnwqH28tjfb7uHJzTyGZlTmwTs544teTNz5B9L4yT3XiCAlMcaLOBMfBT\ + KRIse+NkiTb+tc60JNnEYR6MqZoqTea/w+YBQaIMcil"), + InstantiationParameter(name="image_name", value=IMAGE_NAME), + InstantiationParameter(name="flavor_name", value=FLAVOR_NAME), + InstantiationParameter(name="sec_group", value=TENANT_SEC_GROUP), + InstantiationParameter(name="install_script_version", value="1.4.0-SNAPSHOT"), + InstantiationParameter(name="demo_artifacts_version", value="1.4.0-SNAPSHOT"), + InstantiationParameter(name="cloud_env", value=CLOUD_TYPE), + InstantiationParameter(name="public_net_id", value=PUBLIC_NET), + InstantiationParameter(name="aic-cloud-region", value=CLOUD_REGION) + ] + + vnf_paras=VnfParameters("vfwcds_VF", vnf_vfw, + [base_paras, vpkg_paras, vsn_paras, vfw_paras]) + + # You must define for each VNF and its vFModule the parameters, + # otherwise they stay empty. + # The matching critera are: + # - VnfParameters.name must match VNF ModelInstanceName + # (see above "vfwcds_VF") + # - VfmoduleParameters.name must match substring in vfModule "instanceName" + # (e.g. "vfwcds_vf0..VfwcdsVf..vsn..module-1") + + service_instantiation = ServiceInstantiation.instantiate_macro( + service, + cloud_region, + tenant, + customer, + owning_entity, + vid_project, + vid_line_of_business, + vid_platform, + service_instance_name=SERVICE_INSTANCE_NAME, + vnf_parameters=[vnf_paras] + ) + + service_instantiation.wait_for_finish(): + print("Success") + else: + print("Instantiation failed, check logs") + +Instantiate a service using SO service template (Macro) +------------------------------------------------------- + +To provide more control on the SO macro instantiation, you can define your service as follows: + +.. code:: Yaml + + myservice: + subscription_service_type: myservice + vnfs: + - model_name: myvfmodel + instance_name: myfirstvnf + parameters: + param1: value1 + processing_priority: 1 + vf_modules: + - instance_name: mysecondvfm + model_name: base + processing_priority: 2 + parameters: + param-vfm1: value-vfm1 + - instance_name: myfirstvfm + model_name: base + processing_priority: 1 + parameters: + param-vfm1: value-vfm1 + - model_name: myvfmodel + instance_name: mysecondvnf + parameters: + param1: value1 + processing_priority: 2 + vf_modules: + - instance_name: myfirstvfm + model_name: base + processing_priority: 1 + parameters: + param-vfm1: value-vfm1 + - instance_name: mysecondvfm + model_name: base + processing_priority: 2 + parameters: + param-vfm1: value-vfm1 + +.. code:: Python + + from onapsdk.aai.business import Customer, OwningEntity, Project, LineOfBusiness, Platform + from onapsdk.aai.cloud_infrastructure import CloudRegion + from onapsdk.sdc.service import Service + from onapsdk.so.instantiation import ServiceInstantiation + from yaml import load + + so_yaml_service = "/path/to/yaml/service" + with open(so_yaml_service, "r") as yaml_template: + so_service_data = load(yaml_template) + + # We assume that: + # - service is onboarded, + # - cloud region, customer, owning_entity and project have been already created, + # - cloud region has at least one tenant + # - customer has service subscription + # - service subscription is connected with cloud region and tenant + + service = Service(next(iter(so_service_data.keys()))) + so_service = SoService.load(so_service_data[service.name]) + SERVICE_INSTANCE_NAME = "my_svc_instance_name" + + customer = Customer.get_by_global_customer_id(GLOBAL_CUSTOMER_ID) + cloud_region = CloudRegion.get_by_id( + cloud_owner=CLOUD_OWNER, + cloud_region_id=CLOUD_REGION + ) + tenant = next(cloud_region.tenants) + owning_entity = OwningEntity(OWNING_ENTITY) + project = Project(PROJECT) + line_of_business = LineOfBusiness(LINE_OF_BUSINESS) + platform = Platform(PLATFORM) + + service_instantiation = ServiceInstantiation.instantiate_macro( + sdc_service=service, + customer=customer, + owning_entity=owning_entity, + project=project, + line_of_business=line_of_business, + platform=platform, + cloud_region=cloud_region, + tenant=tenant, + service_instance_name=SERVICE_INSTANCE_NAME, + so_service=so_service + ) + + +Instantiate VNF (Macro) +--------------- + +Since ONAP Istanbul the creation or deletion of VNFs in macro mode is supported. Examples below: + +.. code:: Python + + import time + from onapsdk.aai.business import Customer + from onapsdk.vid import LineOfBusiness, Platform + + # We assume that + # - service has been already instantiated, + # - line of business and platform are created + + SERVICE_INSTANCE_NAME = "service_instance_demo" + VNF_INSTANCE_NAME = "new_vnf_instance" + + customer = Customer.get_by_global_customer_id(GLOBAL_CUSTOMER_ID) + service_subscription = next(customer.service_subscriptions) + service_instance = service_subscription.get_service_instance_by_name(SERVICE_INSTANCE_NAME) + vnf = service_subscription.sdc_service.vnfs[0] + vid_line_of_business = LineOfBusiness.create(LINE_OF_BUSINESS) + vid_platform = Platform.create(PLATFORM) + + ########################################################################### + ######## VFModule parameters ############################################## + ########################################################################### + + myfirstvfm_params = [ + InstantiationParameter(name="param-vfm1", value="value-vfm1") + ] + + vf1_params = VfmoduleParameters("myfirstvfm", myfirstvfm_params) + + ########################################################################### + ######## VNF parameters ################################################### + ########################################################################### + + vnf_param_list = [ + InstantiationParameter(name="param1", value="value1") + ] + + vnf_paras = VnfParameters("myvfmodel", vnf_param_list, [vf1_params]) + + vnf_instantiation = service_instance.add_vnf( + vnf=vnf, + line_of_business=vid_line_of_business, + platform=vid_platform, + vnf_instance_name=VNF_INSTANCE_NAME, + vnf_parameters=[vnf_paras], + a_la_carte=False + ) + + vnf_instantiation.wait_for_finish(): + print("Success") + else: + print("Instantiation failed, check logs") + + +Instantiate VNF using SO service template (Macro) +--------------- + +To provide more control on the SO macro instantiation for new vnf, you can define your vnf as follows: + +.. code:: Yaml + + model_name: myvfmodel + instance_name: mynewvnf + parameters: + param1: value1 + vf_modules: + - instance_name: mysecondvfm + model_name: base + processing_priority: 2 + parameters: + param-vfm1: value-vfm1 + - instance_name: myfirstvfm + model_name: base + processing_priority: 1 + parameters: + param-vfm1: value-vfm1 + +.. code:: Python + + import time + from onapsdk.aai.business import Customer + from onapsdk.vid import LineOfBusiness, Platform + + SERVICE_INSTANCE_NAME = "service_instance_demo" + VNF_INSTANCE_NAME = "new_vnf_instance" + + # We assume that + # - service has been already instantiated, + # - line of business and platform are created + + customer = Customer.get_by_global_customer_id(GLOBAL_CUSTOMER_ID) + service_subscription = next(customer.service_subscriptions) + service_instance = service_subscription.get_service_instance_by_name(SERVICE_INSTANCE_NAME) + vnf = service_subscription.sdc_service.vnfs[0] + vid_line_of_business = LineOfBusiness.create(LINE_OF_BUSINESS) + vid_platform = Platform.create(PLATFORM) + + so_yaml_vnf = "/path/to/yaml/vnf" + with open(so_yaml_vnf, "r") as yaml_template: + so_vnf_data = load(yaml_template) + + so_vnf = SoServiceVnf.load(so_vnf_data) + + vnf_instantiation = service_instance.add_vnf( + vnf=vnf, + line_of_business=vid_line_of_business, + platform=vid_platform, + vnf_instance_name=VNF_INSTANCE_NAME, + so_vnfs=so_vnfs, + a_la_carte=False + ) + + vnf_instantiation.wait_for_finish(): + print("Success") + else: + print("Instantiation failed, check logs") + + +Instantiate VNF (ALaCarte) +--------------- + +.. code:: Python + + import time + from onapsdk.aai.business import Customer + from onapsdk.vid import LineOfBusiness, Platform + + # We assume that + # - service has been already instantiated, + # - line of business and platform are created + + customer = Customer.get_by_global_customer_id(GLOBAL_CUSTOMER_ID) + service_subscription = next(customer.service_subscriptions) + service_instance = service_subscription.get_service_instance_by_name(SERVICE_INSTANCE_NAME) + vnf = service_subscription.sdc_service.vnfs[0] + vid_line_of_business = LineOfBusiness.create(LINE_OF_BUSINESS) + vid_platform = Platform.create(PLATFORM) + vnf_instantiation = service_instance.add_vnf(vnf, vid_line_of_business, vid_platform) + vnf_instantiation.wait_for_finish(): + print("Success") + else: + print("Instantiation failed, check logs") + +Instantiate Vf module (ALaCarte) +--------------------- + +.. code:: Python + + import time + from onapsdk.aai.business import Customer + + customer = Customer.get_by_global_customer_id(GLOBAL_CUSTOMER_ID) + service_subscription = next(customer.service_subscriptions) + service_instance = service_subscription.get_service_instance_by_name(SERVICE_INSTANCE_NAME) + vnf_instance = next(service_instance.vnf_instances) + vf_module = vnf_instance.vnf.vf_module + vf_module_instantiation = vnf_instance.add_vf_module( + vf_module, + vnf_parameters=[ + VnfParameter(name="parameter1", value="parameter1_value"), + VnfParameter(name="parameter2", value="parameter2_value + ] + ) + vf_module_instantiation.wait_for_finish(): + print("Success") + else: + print("Instantiation failed, check logs") + +Instantiate Vl module (ALaCarte) +--------------------- + +.. code:: Python + + import time + from onapsdk.aai.business import Customer + from onapsdk.vid import LineOfBusiness, Platform + + # We assume that + # - service has been already instantiated, + # - line of business and platform are created + + customer = Customer.get_by_global_customer_id(GLOBAL_CUSTOMER_ID) + service_subscription = next(customer.service_subscriptions) + service_instance = service_subscription.get_service_instance_by_name(SERVICE_INSTANCE_NAME) + + logger.info("******** Get 1st Network in Service Model *******") + network = service_subscription.sdc_service.networks[0] + + logger.info("******** Create Network *******") + sn=Subnet(name="my_subnet", + start_address="10.0.0.1", + cidr_mask="24", + gateway_address="10.0.0.1) + + vid_line_of_business = LineOfBusiness.create(LINE_OF_BUSINESS) + vid_platform = Platform.create(PLATFORM) + + network_instantiation = service_instance.add_network(network, vid_line_of_business, + vid_platform, network_instance_name="my_net", subnets=[sn]) + + if network_instantiation.wait_for_finish(): + print("Success") + else: + print("Instantiation failed, check logs") diff --git a/docs/usage/usage/ves.rst b/docs/usage/usage/ves.rst new file mode 100644 index 0000000..4712d8b --- /dev/null +++ b/docs/usage/usage/ves.rst @@ -0,0 +1,42 @@ +VES +### + +Preparation for VES tests +------------------------- + +To enable CDS Enrichment in an ONAP Frankfurt environment the NodePort 30449 +for the CDS Blueprint Processor API service needs to be opened + +#. Check existing VES Services: + + .. code-block:: sh + + kubectl get service -n onap|grep ves + xdcae-ves-collector NodePort 10.43.48.246 <none> 8443:30417/TCP + +#. If the port of Ves Service is different than 30417 you can change it corresponding to the installation instruction. + + +Send event to Ves Collector +--------------------------- + +.. code:: Python + + from onapsdk.ves.ves import Ves + response = Ves.send_event( + basic_auth={'username': 'sample1', 'password': 'sample1'}, + json_event=event, + version="v7" + ) + +Send event batch to Ves Collector +------------------------- + +.. code:: Python + + from onapsdk.ves.ves import Ves + response = Ves.send_batch_event( + basic_auth={'username': 'sample1', 'password': 'sample1'}, + json_event=event, + version="v7" + ) |