Loading src/context/service/database/ConfigRule.py +1 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ def compose_config_rules_data( configrule_name = '{:s}:{:s}:{:s}:{:s}'.format(parent_kind, kind.value, endpoint_uuid, rule_set_name) elif kind == ConfigRuleKindEnum.PON_ACCESS: _, _, endpoint_uuid = endpoint_get_uuid(config_rule.pon_access.endpoint_id, allow_random=False) rule_set_name = config_rule.pon_access.rule_set.name rule_set_name = "pon_access_service" configrule_name = '{:s}:{:s}:{:s}:{:s}'.format(parent_kind, kind.value, endpoint_uuid, rule_set_name) else: MSG = 'Name for ConfigRule({:s}) cannot be inferred '+\ Loading src/device/service/drivers/pon_driver/PON_Driver.py +14 −7 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ from .Tools import compose_resource_endpoint from .connectionRequest import connectionRequest import requests LOGGER = logging.getLogger(__name__) RE_GET_ENDPOINT_FROM_INTERFACE = re.compile(r'^\/interface\[([^\]]+)\].*') Loading Loading @@ -134,22 +135,28 @@ class PON_Driver(_Driver): resource_path = resource_key.split('/') result = connectionRequest("2", "22", "2","333", "ef", "2500000") result = connectionRequest("2", "22", "2","333", "ef", bw="2500000") results.append(result) except Exception as e: LOGGER.exception(f"Error procesando la configuración {resource}: {str(e)}") results.append(e) try: resource_value = json.loads(resource_value) except: # pylint: disable=bare-except pass set_subnode_value(resolver, self.__running, resource_path, resource_value) #match = RE_GET_ENDPOINT_FROM_INTERFACE.match(resource_key) #if match is not None: # endpoint_uuid = match.group(1) # if '.' in endpoint_uuid: endpoint_uuid = endpoint_uuid.split('.')[0] # self.__synthetic_sampling_parameters.set_endpoint_configured(endpoint_uuid) match = RE_GET_ENDPOINT_FROM_INTERFACE.match(resource_key) if match is not None: endpoint_uuid = match.group(1) if '.' in endpoint_uuid: endpoint_uuid = endpoint_uuid.split('.')[0] self.__synthetic_sampling_parameters.set_endpoint_configured(endpoint_uuid) #results.append(True) results.append(True) return results Loading src/device/service/drivers/pon_driver/connectionRequest.py +46 −44 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ CONTROLLER_IP = "CONTROLLER-IP-ADDRESS" # REPLACE CONTROLLER_PORT = 3333 API_ENDPOINT = f"http://{CONTROLLER_IP}:{CONTROLLER_PORT}/api/service/" def connectionRequest(self, ont_id: str, cvlan: int, ethernet_port: str, svlan: int, profile: str, bw: int) -> bool: def connectionRequest(ont_id: str, cvlan: str, ethernet_port: str, svlan: str, profile: str, bw: str) -> bool: """ Envía una petición POST para establecer la conexión PON. En caso de error, muestra el comando curl equivalente. Loading @@ -29,30 +29,32 @@ def connectionRequest(self, ont_id: str, cvlan: int, ethernet_port: str, svlan: "Content-Type": "application/json" } curl_command = self._generate_curl_command(payload, headers) try: response = requests.post(self.API_ENDPOINT, headers=headers, json=payload) if response.status_code == 200: LOGGER.info(f"PON Connection OK: {payload}") return True LOGGER.error(f"Connection Error. CODE: {response.status_code} - RESPONSE: {response.text}") LOGGER.info(f"CURL COMMAND: \n{curl_command}") curl_command = _generate_curl_command(payload, headers) # --------------------DESCOMENTAR CUANDO FUNCIONE----------------- # try: # response = requests.post(API_ENDPOINT, headers=headers, json=payload) # # if response.status_code == 200: # LOGGER.info(f"PON Connection OK: {payload}") # return True # # LOGGER.error(f"Connection Error. CODE: {response.status_code} - RESPONSE: {response.text}") # LOGGER.info(f"CURL COMMAND: \n{curl_command}") # return False # # except requests.RequestException as e: # LOGGER.error(f"Connection Error: {str(e)}") # LOGGER.info(f"CURL COMMAND: \n{curl_command}") # return False print("CURL COMMAND:") print(curl_command) return False except requests.RequestException as e: LOGGER.error(f"Connection Error: {str(e)}") LOGGER.info(f"CURL COMMAND: \n{curl_command}") return False def _generate_curl_command(self, payload: dict, headers: dict) -> str: def _generate_curl_command(payload: dict, headers: dict) -> str: header_string = " ".join([f"-H '{k}: {v}'" for k, v in headers.items()]) json_data = json.dumps(payload, indent=2).replace("'", "'\\''") return ( f"curl -X POST '{self.API_ENDPOINT}' \\\n" f" {header_string} \\\n" f" -d $'{json_data}'" f"curl -X POST '{API_ENDPOINT}' \\\n {header_string} \\\n -d $'{json_data}'" ) src/webui/service/static/topology_icons/pon-controller.png 0 → 100644 +92.3 KiB Loading image diff... Loading
src/context/service/database/ConfigRule.py +1 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ def compose_config_rules_data( configrule_name = '{:s}:{:s}:{:s}:{:s}'.format(parent_kind, kind.value, endpoint_uuid, rule_set_name) elif kind == ConfigRuleKindEnum.PON_ACCESS: _, _, endpoint_uuid = endpoint_get_uuid(config_rule.pon_access.endpoint_id, allow_random=False) rule_set_name = config_rule.pon_access.rule_set.name rule_set_name = "pon_access_service" configrule_name = '{:s}:{:s}:{:s}:{:s}'.format(parent_kind, kind.value, endpoint_uuid, rule_set_name) else: MSG = 'Name for ConfigRule({:s}) cannot be inferred '+\ Loading
src/device/service/drivers/pon_driver/PON_Driver.py +14 −7 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ from .Tools import compose_resource_endpoint from .connectionRequest import connectionRequest import requests LOGGER = logging.getLogger(__name__) RE_GET_ENDPOINT_FROM_INTERFACE = re.compile(r'^\/interface\[([^\]]+)\].*') Loading Loading @@ -134,22 +135,28 @@ class PON_Driver(_Driver): resource_path = resource_key.split('/') result = connectionRequest("2", "22", "2","333", "ef", "2500000") result = connectionRequest("2", "22", "2","333", "ef", bw="2500000") results.append(result) except Exception as e: LOGGER.exception(f"Error procesando la configuración {resource}: {str(e)}") results.append(e) try: resource_value = json.loads(resource_value) except: # pylint: disable=bare-except pass set_subnode_value(resolver, self.__running, resource_path, resource_value) #match = RE_GET_ENDPOINT_FROM_INTERFACE.match(resource_key) #if match is not None: # endpoint_uuid = match.group(1) # if '.' in endpoint_uuid: endpoint_uuid = endpoint_uuid.split('.')[0] # self.__synthetic_sampling_parameters.set_endpoint_configured(endpoint_uuid) match = RE_GET_ENDPOINT_FROM_INTERFACE.match(resource_key) if match is not None: endpoint_uuid = match.group(1) if '.' in endpoint_uuid: endpoint_uuid = endpoint_uuid.split('.')[0] self.__synthetic_sampling_parameters.set_endpoint_configured(endpoint_uuid) #results.append(True) results.append(True) return results Loading
src/device/service/drivers/pon_driver/connectionRequest.py +46 −44 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ CONTROLLER_IP = "CONTROLLER-IP-ADDRESS" # REPLACE CONTROLLER_PORT = 3333 API_ENDPOINT = f"http://{CONTROLLER_IP}:{CONTROLLER_PORT}/api/service/" def connectionRequest(self, ont_id: str, cvlan: int, ethernet_port: str, svlan: int, profile: str, bw: int) -> bool: def connectionRequest(ont_id: str, cvlan: str, ethernet_port: str, svlan: str, profile: str, bw: str) -> bool: """ Envía una petición POST para establecer la conexión PON. En caso de error, muestra el comando curl equivalente. Loading @@ -29,30 +29,32 @@ def connectionRequest(self, ont_id: str, cvlan: int, ethernet_port: str, svlan: "Content-Type": "application/json" } curl_command = self._generate_curl_command(payload, headers) try: response = requests.post(self.API_ENDPOINT, headers=headers, json=payload) if response.status_code == 200: LOGGER.info(f"PON Connection OK: {payload}") return True LOGGER.error(f"Connection Error. CODE: {response.status_code} - RESPONSE: {response.text}") LOGGER.info(f"CURL COMMAND: \n{curl_command}") curl_command = _generate_curl_command(payload, headers) # --------------------DESCOMENTAR CUANDO FUNCIONE----------------- # try: # response = requests.post(API_ENDPOINT, headers=headers, json=payload) # # if response.status_code == 200: # LOGGER.info(f"PON Connection OK: {payload}") # return True # # LOGGER.error(f"Connection Error. CODE: {response.status_code} - RESPONSE: {response.text}") # LOGGER.info(f"CURL COMMAND: \n{curl_command}") # return False # # except requests.RequestException as e: # LOGGER.error(f"Connection Error: {str(e)}") # LOGGER.info(f"CURL COMMAND: \n{curl_command}") # return False print("CURL COMMAND:") print(curl_command) return False except requests.RequestException as e: LOGGER.error(f"Connection Error: {str(e)}") LOGGER.info(f"CURL COMMAND: \n{curl_command}") return False def _generate_curl_command(self, payload: dict, headers: dict) -> str: def _generate_curl_command(payload: dict, headers: dict) -> str: header_string = " ".join([f"-H '{k}: {v}'" for k, v in headers.items()]) json_data = json.dumps(payload, indent=2).replace("'", "'\\''") return ( f"curl -X POST '{self.API_ENDPOINT}' \\\n" f" {header_string} \\\n" f" -d $'{json_data}'" f"curl -X POST '{API_ENDPOINT}' \\\n {header_string} \\\n -d $'{json_data}'" )
src/webui/service/static/topology_icons/pon-controller.png 0 → 100644 +92.3 KiB Loading image diff...