Commit c83234cb authored by Waleed Akbar's avatar Waleed Akbar
Browse files

feat: Add channel_name field to PluggableConfig and update related translation logic.

parent 80ada479
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ message PluggableConfig {
  double center_frequency_mhz                      = 3;   // center frequency in MHz
  int32  operational_mode                          = 4;   // e.g., 0=off and 1=on 
  int32  line_port                                 = 5;   // line port number
  string channel_name                              = 6;   // channel name
  repeated DigitalSubcarrierGroupConfig dsc_groups = 10;
}

+12 −6
Original line number Diff line number Diff line
@@ -30,13 +30,13 @@ def create_config_rule_from_dict(config_rule_dict: Dict[str, Any]) -> ConfigRule

def translate_pluggable_config_to_netconf(
    pluggable_config: PluggableConfig,  # type: ignore
    component_name: str = "channel-1"           # channel-1 for HUB and channel-1/3/5 for LEAF
    component_name: str = "channel-1"           # Fallback if channel_name not provided (channel-1 for HUB and channel-1/3/5 for LEAF)
) -> Dict[str, Any]:
    """
    Translate PluggableConfig protobuf message to the format expected by NetConfDriver.
    Args:
        pluggable_config: PluggableConfig message containing DSC groups and subcarriers
        component_name: Name of the optical channel component (default: "channel-1")
        component_name: Fallback name if channel_name is not specified in config (default: "channel-1")
    Returns:
        Dictionary in the format expected by NetConfDriver templates:
    """
@@ -44,9 +44,15 @@ def translate_pluggable_config_to_netconf(
    if not pluggable_config or not pluggable_config.dsc_groups:
        LOGGER.warning("Empty pluggable config provided")
        return {
            "name": component_name,
            "name": channel_name,
            "operation": "delete"
        }
    if hasattr(pluggable_config, 'channel_name') and pluggable_config.channel_name:
        channel_name = pluggable_config.channel_name
        LOGGER.debug(f"Using channel_name from PluggableConfig: {channel_name}")
    else:
        channel_name = component_name
        LOGGER.debug(f"Using fallback component_name: {channel_name}")
    
    if not hasattr(pluggable_config, 'center_frequency_mhz') or pluggable_config.center_frequency_mhz <= 0:
        raise ValueError("center_frequency_mhz is required and must be greater than 0 in PluggableConfig")
@@ -88,14 +94,14 @@ def translate_pluggable_config_to_netconf(
    
    # Build the final configuration dictionary
    config = {
        "name": component_name,
        "name": channel_name,
        "frequency": center_frequency_mhz,
        "operational_mode": operational_mode, 
        "target_output_power": target_output_power,
        "digital_sub_carriers_group": digital_sub_carriers_groups
    }
    
    LOGGER.info(f"Translated pluggable config to NETCONF format: component={component_name}, "
    LOGGER.info(f"Translated pluggable config to NETCONF format: component={channel_name}, "
                f"frequency={center_frequency_mhz} MHz, groups={len(digital_sub_carriers_groups)}")
    
    return config
+2 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ def create_pluggable_request(
        _request.initial_config.operational_mode = 1  # Operational mode
        _request.initial_config.target_output_power_dbm = -10.0  # Target output power
        _request.initial_config.line_port = 1  # Line port number
        _request.initial_config.channel_name = "channel-1"  # Channel name for component
        
        # Add sample DSC group configuration
        dsc_group = _request.initial_config.dsc_groups.add()
@@ -202,6 +203,7 @@ def create_configure_pluggable_request(
    _request.config.operational_mode           = 1  # Operational mode
    _request.config.target_output_power_dbm    = -10.0  # Target output power
    _request.config.line_port                  = 1  # Line port number
    _request.config.channel_name               = "channel-1"  # Channel name for component
    
    # Add DSC group configuration
    group_1 = _request.config.dsc_groups.add()