aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/simulator
diff options
context:
space:
mode:
Diffstat (limited to 'src/onaptests/steps/simulator')
-rw-r--r--src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py86
1 files changed, 30 insertions, 56 deletions
diff --git a/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py b/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py
index a73f668..c1d76b0 100644
--- a/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py
+++ b/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py
@@ -10,7 +10,7 @@ from onapsdk.configuration import settings
from onaptests.steps.base import BaseStep
from onaptests.steps.instantiate.msb_k8s import CreateInstanceStep
-from onaptests.utils.exceptions import EnvironmentPreparationException
+from onaptests.utils.exceptions import EnvironmentPreparationException, OnapTestException
class PnfSimulatorCnfRegisterStep(BaseStep):
@@ -73,7 +73,7 @@ class PnfSimulatorCnfRegisterStep(BaseStep):
config.load_kube_config(settings.K8S_CONFIG)
k8s_client: "CoreV1API" = client.CoreV1Api()
for service in k8s_client.list_namespaced_service(namespace=settings.K8S_NAMESPACE).items:
- if service.metadata.name == "xdcae-ves-collector":
+ if service.metadata.name == settings.DCAE_VES_COLLECTOR_POD_NAME:
return service.spec.cluster_ip, service.spec.ports[0].port
raise EnvironmentPreparationException("Couldn't get VES ip and port")
@@ -83,62 +83,36 @@ class PnfSimulatorCnfRegisterStep(BaseStep):
super().execute()
if not self.is_pnf_pod_running():
EnvironmentPreparationException("PNF simulator is not running")
- time.sleep(30.0) # Let's still wait for PNF simulator to make sure it's initialized
+ time.sleep(settings.PNF_WAIT_TIME) # Let's still wait for PNF simulator to make sure it's initialized
ves_ip, ves_port = self.get_ves_ip_and_port()
- response = requests.post(
- "http://portal.api.simpledemo.onap.org:30999/simulator/event",
- json={
- "vesServerUrl": f"https://{ves_ip}:{ves_port}/eventListener/v7",
- "event": {
- "event": {
- "commonEventHeader": {
- "domain": "pnfRegistration",
- "eventId": "ORAN_SIM_400600927_2020-04-02T17:20:22.2Z",
- "eventName": "pnfRegistration",
- "eventType": "EventType5G",
- "sequence": 0,
- "priority": "Low",
- "reportingEntityId": "",
- "reportingEntityName": "ORAN_SIM_400600927",
- "sourceId": "",
- "sourceName": settings.SERVICE_INSTANCE_NAME,
- "startEpochMicrosec": 94262132085746,
- "lastEpochMicrosec": 94262132085746,
- "nfNamingCode": "sdn controller",
- "nfVendorName": "sdn",
- "timeZoneOffset": "+00:00",
- "version": "4.0.1",
- "vesEventListenerVersion": "7.0.1"
+ registration_number: int = 0
+ registered_successfully: bool = False
+ while registration_number < settings.PNF_REGISTRATION_NUMBER_OF_TRIES and not registered_successfully:
+ try:
+ response = requests.post(
+ "http://portal.api.simpledemo.onap.org:30999/simulator/start",
+ json={
+ "simulatorParams": {
+ "repeatCount": 9999,
+ "repeatInterval": 30,
+ "vesServerUrl": f"https://{ves_ip}:{ves_port}/eventListener/v7"
},
- "pnfRegistrationFields": {
- "pnfRegistrationFieldsVersion": "2.0",
- "lastServiceDate": "2019-08-16",
- "macAddress": "D7:64:C8:CC:E9:32",
- "manufactureDate": "2019-08-16",
- "modelNumber": "Simulated Device",
- "oamV4IpAddress": "172.30.1.6",
- "oamV6IpAddress": "0:0:0:0:0:ffff:a0a:011",
- "serialNumber": "Simulated Device",
- "softwareVersion": "2.3.5",
- "unitFamily": "Simulated Device",
- "unitType": "ntsim_oran",
- "vendorName": "Melacon",
- "additionalFields": {
- "oamPort": "830",
- "protocol": "SSH",
- "username": "netconf",
- "password": "netconf",
- "reconnectOnChangedSchema": "false",
- "sleep-factor": "1.5",
- "tcpOnly": "false",
- "connectionTimeout": "20000",
- "maxConnectionAttempts": "100",
- "betweenAttemptsTimeout": "2000",
- "keepaliveDelay": "120"
+ "templateName": "registration.json",
+ "patch": {
+ "event": {
+ "commonEventHeader": {
+ "sourceName": settings.SERVICE_INSTANCE_NAME
+ }
}
}
}
- }
- }
- )
- response.raise_for_status()
+ )
+ response.raise_for_status()
+ registered_successfully = True
+ self._logger.info(f"PNF registered with {settings.SERVICE_INSTANCE_NAME} source name")
+ except requests.HTTPError as http_error:
+ self._logger.debug(f"Can't connect with PNF simulator: {str(http_error)}")
+ registration_number = registration_number + 1
+ time.sleep(settings.PNF_WAIT_TIME)
+ if not registered_successfully:
+ raise OnapTestException("PNF not registered successfully")