2 Documentation Instantiate VNF
4 Library OperatingSystem
9 Library RequestsLibrary
10 Library ONAPLibrary.PreloadData WITH NAME PreloadData
11 Library ONAPLibrary.Utilities
12 Library ONAPLibrary.JSON
13 Library ONAPLibrary.ServiceMapping WITH NAME ServiceMapping
14 Library ONAPLibrary.Templating WITH NAME Templating
15 Library ONAPLibrary.SO WITH NAME SO
16 Resource ../global_properties.robot
20 ${SO_TEMPLATE_PATH} so
21 ${SO_CATALOGDB_PATH} /ecomp/mso/catalog/v2/serviceVnfs?serviceModelName
22 ${SO_APIHANDLER_PATH} /onap/so/infra/serviceInstantiation/v7/serviceInstances
23 ${CDS_BOOTSTRAP_PATH} /api/v1/blueprint-model/bootstrap
26 Instantiate Service Direct To SO
27 [Documentation] Creates an entire service from a CSAR
28 [Arguments] ${service} ${csar_file} ${vnf_template_file}
29 # Example: ${csar_file}= Set Variable /tmp/csar/service-Vfw20190413133734-csar.csar
30 # Example: ${vnf_template_file}= Set Variable /var/opt/ONAP/testsuite/vcpeutils/preload_templates/template.vfw_vfmodule.json
31 PreloadData.Set Directory preload ./demo/preload_data
32 ${preload_dict}= Get Default Preload Data preload
33 ${template}= Create Dictionary
34 @{keys}= Get Dictionary Keys ${preload_dict}
35 ${parameters}= Get Globally Injected Parameters
36 :FOR ${key} IN @{keys}
37 \ ${value}= Get From Dictionary ${preload_dict} ${key}
38 \ ${tmp_value}= Set Variable If 'GLOBAL_' in $value ${value}
39 \ ${tmp_value}= Run Keyword If 'GLOBAL_' in $value Replace String ${tmp_value} \$ ${EMPTY}
40 \ ${tmp_value}= Run Keyword If 'GLOBAL_' in $value Replace String ${tmp_value} { ${EMPTY}
41 \ ${tmp_value}= Run Keyword If 'GLOBAL_' in $value Replace String ${tmp_value} } ${EMPTY}
42 \ ${value}= Set Variable If 'GLOBAL_' in $value ${parameters["${tmp_value}"]} ${value}
43 \ ${new_key}= Catenate \$ { ${key} }
44 \ ${new_key}= Evaluate '${new_key}'.replace(' ','')
45 \ Set To Dictionary ${template} ${new_key} ${value}
47 ${tmp_key1}= Catenate \$ { ecompnet }
48 ${tmp_key1}= Evaluate '${tmp_key1}'.replace(' ','')
49 ${tmp_key2}= Catenate \$ { GLOBAL_INJECTED_UBUNTU_1404_IMAGE }
50 ${tmp_key2}= Evaluate '${tmp_key2}'.replace(' ','')
51 # ecompnet 13 , 14, 15
52 # use same method as sdnc preload robot script
53 ${ecompnet}= Evaluate str((${GLOBAL_BUILD_NUMBER}%128)+128)
55 Set To Dictionary ${template} ${tmp_key1} ${ecompnet} ${tmp_key2} ${GLOBAL_INJECTED_UBUNTU_1404_IMAGE}
59 ${service_instance_id}= Create Entire Service ${csar_file} ${vnf_template_file} ${template} ${GLOBAL_INJECTED_REGION} ${GLOBAL_INJECTED_OPENSTACK_TENANT_ID} ${GLOBAL_INJECTED_PUBLIC_KEY}
60 Log ServiceInstanceId:${service_instance_id}
61 Should Not Be Equal As Strings ${service_instance_id} None
64 CDS Service Instantiate
65 [Arguments] ${cds_service_model} ${service_uuid} ${service_invariantUUID}
66 ${auth}= Create List ${GLOBAL_SO_CATDB_USERNAME} ${GLOBAL_SO_PASSWORD}
67 ${resp}= SO.Run Get Request ${GLOBAL_SO_CATDB_ENDPOINT} ${SO_CATALOGDB_PATH}=${cds_service_model} auth=${auth}
68 Should Be Equal As Strings ${resp.status_code} 200
69 ${session}= Create Session cds ${GLOBAL_CCSDK_CDS_SERVER_PROTOCOL}://${GLOBAL_INJECTED_CCSDK_CDS_BLUEPRINT_PROCESSOR_IP_ADDR}:${GLOBAL_CCSDK_CDS_HEALTH_SERVER_PORT}
70 ${data}= Create Dictionary loadModelType=true loadResourceDictionary=true loadCBA=true
71 ${headers}= Create Dictionary Content-Type=application/json Authorization=Basic ${GLOBAL_CDS_AUTH}
72 ${resp}= Post Request cds ${CDS_BOOTSTRAP_PATH} data=${data} headers=${headers}
73 ${status_string}= Convert To String ${resp.status_code}
74 Should Match Regexp ${status_string} ^(200|201|202)$
76 @{date_time}= Split String ${time_now}
77 ${time_stamp}= Catenate SEPARATOR=_ @{date_time}[0] @{date_time}[1]
78 ${customized_time_stamp}= Remove String ${time_stamp} :
79 ${cds_instance_name}= Set Variable cds_vlb_svc_${customized_time_stamp}
80 ${global_parameters}= Get Globally Injected Parameters
81 ${owning_entity_id}= Get OwningEntity Id OE-Demonstration
82 ${dict}= Set To Dictionary ${global_parameters} dcae_collector_ip=${GLOBAL_DCAE_COLLECTOR_IP} dcae_collector_port=${GLOBAL_DCAE_COLLECTOR_PORT} vlb_0_int_pktgen_private_port_0_mac=${GLOBAL_VLB_0_INT_PKTGEN_PRIVATE_PORT_0_MAC} vpg_0_int_pktgen_private_port_0_mac=${GLOBAL_VPG_0_INT_PKTGEN_PRIVATE_PORT_0_MAC} service_instance_name=${cds_instance_name} owning_entity=OE-Demonstration homing_solution=none owning_entity_id=${owning_entity_id} subscriber_id=Demonstration cloud_owner=${GLOBAL_AAI_CLOUD_OWNER} subscription_service_type=vLB service_model_name=${cds_service_model} service_model_uuid=${service_uuid} service_model_invariantuuid=${service_invariantUUID} resp=${resp.json()}
83 Templating.Create Environment cds ${GLOBAL_TEMPLATE_FOLDER}
84 ${data}= Templating.Apply Template cds ${SO_TEMPLATE_PATH}/cds_service_template.jinja ${dict}
86 ${auth}= Create List ${GLOBAL_SO_USERNAME} ${GLOBAL_SO_PASSWORD}
87 ${resp}= SO.Run Post Request ${GLOBAL_SO_APIHAND_ENDPOINT} ${SO_APIHANDLER_PATH} ${data} auth=${auth}
88 Should Be Equal As Strings ${resp.status_code} 202
89 [Return] ${resp.json()['requestReferences']['requestId']}