Commit 09b8ca59 authored by Waleed Akbar's avatar Waleed Akbar
Browse files

Updates in SBI to add support of DSCM pluggables

- Remove unused DeviceDriverEnum entry
- Update test script for integration testing
- added new templates for DSCM configuration
- update jinja main file to prcess DSCM pluggables request
parent 347fc82a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -252,7 +252,6 @@ enum DeviceDriverEnum {
  DEVICEDRIVER_RYU = 18;
  DEVICEDRIVER_GNMI_NOKIA_SRLINUX = 19;
  DEVICEDRIVER_OPENROADM = 20;
  DRVICEDRIVER_NETCONF_DSCM = 21;
}

enum DeviceOperationalStatusEnum {
+5 −2
Original line number Diff line number Diff line
@@ -17,7 +17,10 @@ PROJECTDIR=`pwd`
cd $PROJECTDIR/src
RCFILE=$PROJECTDIR/coverage/.coveragerc

python3 -m pytest --log-level=info --log-cli-level=info --verbose \
    pluggables/tests/test_Pluggables.py
# to run integration test: -m integration
python3 -m pytest --log-level=info --log-cli-level=info --verbose -m "not integration" \
    pluggables/tests/test_pluggables_with_SBI.py
# python3 -m pytest --log-level=info --log-cli-level=info --verbose \
#     pluggables/tests/test_Pluggables.py

echo "Bye!"
+21 −0
Original line number Diff line number Diff line
@@ -136,6 +136,27 @@ def compose_config( # template generation
                templates.append(JINJA_ENV.get_template(enable_ingress_filter_path))
                templates.append(JINJA_ENV.get_template(acl_entry_path))
                templates.append(JINJA_ENV.get_template(acl_ingress_path))
        elif "pluggable" in resource_key:  # MANAGING DSCM (Digital Subcarrier Modules)
            # Resource key format: /pluggable/{template_index}/config/{template_identifier}
            # Example: /pluggable/1/config/hub or /pluggable/1/config/leaf
            # Extract template identifier (hub or leaf) from the resource key
            key_parts = resource_key.strip('/').split('/')
            if len(key_parts) >= 4 and key_parts[-1] in ['hub', 'leaf']:
                template_identifier = key_parts[-1]  # 'hub' or 'leaf'
                template_index = key_parts[1] if len(key_parts) > 1 else '1'
                
                # Build template path: pluggable/{index}/config/edit_config_{hub|leaf}_template.xml
                template_path = f'pluggable/{template_index}/config/edit_config_{template_identifier}_template.xml'
                templates.append(JINJA_ENV.get_template(template_path))
                
                LOGGER.info(f"Loading DSCM template: {template_path}")
            else:
                # Fallback to generic template if format doesn't match expected pattern
                LOGGER.warning(f"Unexpected DSCM resource key format: {resource_key}, using default template")
                template_name = '{:s}/edit_config.xml'.format(RE_REMOVE_FILTERS.sub('', resource_key))
                templates.append(JINJA_ENV.get_template(template_name))
            
            data : Dict[str, Any] = json.loads(resource_value)
        else:
            template_name = '{:s}/edit_config.xml'.format(RE_REMOVE_FILTERS.sub('', resource_key))
            templates.append(JINJA_ENV.get_template(template_name))
+31 −0
Original line number Diff line number Diff line
<components xmlns="http://openconfig.net/yang/platform">
    <component{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}>
        <name>{{name}}</name>
        <optical-channel xmlns="http://openconfig.net/yang/terminal-device-digital-subcarriers">
            {% if operation is defined and operation != 'delete' %}
            <config>
                {% if frequency is defined %}<frequency>{{frequency}}</frequency>{% endif %}
                {% if target_output_power is defined %}<target-output-power>{{target_output_power}}</target-output-power>{% endif %}
                {% if operational_mode is defined %}<operational-mode>{{operational_mode}}</operational-mode>{% endif %}

                {% if digital_sub_carriers_group is defined and digital_sub_carriers_group %}
                    {% for group in digital_sub_carriers_group %}
                    <digital-subcarriers-group>
                        <digital-subcarriers-group-id>{{group.digital_sub_carriers_group_id}}</digital-subcarriers-group-id>

                        {% if group.digital_sub_carrier_id is defined and group.digital_sub_carrier_id %}
                            {% for sub_carrier in group.digital_sub_carrier_id %}
                            <digital-subcarrier-id>
                                <subcarrier-id>{{sub_carrier.sub_carrier_id}}</subcarrier-id>
                                <active>{{sub_carrier.active}}</active>
                            </digital-subcarrier-id>
                            {% endfor %}
                        {% endif %}
                    </digital-subcarriers-group>
                    {% endfor %}
                {% endif %}
            </config>
            {% endif %}
        </optical-channel>
    </component>
</components>
+31 −0
Original line number Diff line number Diff line
<components xmlns="http://openconfig.net/yang/platform">
    <component{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}>
        <name>{{name}}</name>
        <optical-channel xmlns="http://openconfig.net/yang/terminal-device-digital-subcarriers">
            {% if operation is defined and operation != 'delete' %}
            <config>
                {% if frequency is defined %}<frequency>{{frequency}}</frequency>{% endif %}
                {% if target_output_power is defined %}<target-output-power>{{target_output_power}}</target-output-power>{% endif %}
                {% if operational_mode is defined %}<operational-mode>{{operational_mode}}</operational-mode>{% endif %}

                {% if digital_sub_carriers_group is defined and digital_sub_carriers_group %}
                    {% for group in digital_sub_carriers_group %}
                    <digital-subcarriers-group>
                        <digital-subcarriers-group-id>{{group.digital_sub_carriers_group_id}}</digital-subcarriers-group-id>

                        {% if group.digital_sub_carrier_id is defined and group.digital_sub_carrier_id %}
                            {% for sub_carrier in group.digital_sub_carrier_id %}
                            <digital-subcarrier-id>
                                <subcarrier-id>{{sub_carrier.sub_carrier_id}}</subcarrier-id>
                                <active>{{sub_carrier.active}}</active>
                            </digital-subcarrier-id>
                            {% endfor %}
                        {% endif %}
                    </digital-subcarriers-group>
                    {% endfor %}
                {% endif %}
            </config>
            {% endif %}
        </optical-channel>
    </component>
</components>