diff options
Diffstat (limited to 'src/onaptests/steps/simulator/pnf_simulator_cnf')
-rw-r--r-- | src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py | 24 |
1 files changed, 14 insertions, 10 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 3a846e3..2a4f47e 100644 --- a/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py +++ b/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py @@ -50,13 +50,13 @@ class PnfSimulatorCnfRegisterStep(BaseStep): config.load_incluster_config() else: config.load_kube_config(config_file=settings.K8S_CONFIG) - k8s_client: "CoreV1API" = client.CoreV1Api() - k8s_watch: "Watch" = watch.Watch() + k8s_client: "client.CoreV1Api" = client.CoreV1Api() + k8s_watch: "watch.Watch" = watch.Watch() status = False try: for event in k8s_watch.stream(k8s_client.list_namespaced_pod, - namespace=settings.K8S_ADDITIONAL_RESOURCES_NAMESPACE, - timeout_seconds=timeout_seconds): + namespace=settings.K8S_ADDITIONAL_RESOURCES_NAMESPACE, + timeout_seconds=timeout_seconds): if event["object"].metadata.name == "pnf-macro-test-simulator": if not event["object"].status.phase in ["Pending", "Running"]: # Invalid pod state @@ -82,9 +82,10 @@ class PnfSimulatorCnfRegisterStep(BaseStep): config.load_incluster_config() else: config.load_kube_config(config_file=settings.K8S_CONFIG) - k8s_client: "CoreV1API" = client.CoreV1Api() + k8s_client: "client.CoreV1Api" = client.CoreV1Api() try: - for service in k8s_client.list_namespaced_service(namespace=settings.K8S_ONAP_NAMESPACE).items: + for service in k8s_client.list_namespaced_service( + namespace=settings.K8S_ONAP_NAMESPACE).items: if service.metadata.name == settings.DCAE_VES_COLLECTOR_POD_NAME: proto = "http" if "443" in str(service.spec.ports[0].port): @@ -102,11 +103,13 @@ class PnfSimulatorCnfRegisterStep(BaseStep): status = self.is_pnf_pod_running() if not status: raise EnvironmentPreparationException("PNF simulator is not running") - time.sleep(settings.PNF_WAIT_TIME) # Let's still wait for PNF simulator to make sure it's initialized + # Let's still wait for PNF simulator to make sure it's initialized + time.sleep(settings.PNF_WAIT_TIME) ves_proto, ves_ip, ves_port = self.get_ves_protocol_ip_and_port() registration_number: int = 0 registered_successfully: bool = False - while registration_number < settings.PNF_REGISTRATION_NUMBER_OF_TRIES and not registered_successfully: + 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", @@ -114,7 +117,7 @@ class PnfSimulatorCnfRegisterStep(BaseStep): "simulatorParams": { "repeatCount": 9999, "repeatInterval": 30, - "vesServerUrl": f"{ves_proto}://sample1:sample1@{ves_ip}:{ves_port}/eventListener/v7" + "vesServerUrl": f"{ves_proto}://sample1:sample1@{ves_ip}:{ves_port}/eventListener/v7" # noqa }, "templateName": "registration.json", "patch": { @@ -132,7 +135,8 @@ class PnfSimulatorCnfRegisterStep(BaseStep): ) response.raise_for_status() registered_successfully = True - self._logger.info(f"PNF registered with {settings.SERVICE_INSTANCE_NAME} source name") + self._logger.info(f"PNF registered with {settings.SERVICE_INSTANCE_NAME} " + "source name") except (requests.ConnectionError, requests.HTTPError) as http_error: self._logger.debug(f"Can't connect with PNF simulator: {str(http_error)}") registration_number = registration_number + 1 |