Commit 8f0c7d45 authored by Mohammad Ismaeel's avatar Mohammad Ismaeel
Browse files

Tapi get oc details

parent c0ff3a4b
Loading
Loading
Loading
Loading
+3 −5
Original line number Original line Diff line number Diff line
@@ -116,8 +116,6 @@ spec:
              name: grafana-pv
              name: grafana-pv
    
    


        # Your application-specific environment variables, etc.

        # - name: openvpn-sidecar
        # - name: openvpn-sidecar
        #   image:  kylemanna/openvpn:latest  # Or a custom image with your VPN config
        #   image:  kylemanna/openvpn:latest  # Or a custom image with your VPN config
        #   securityContext:
        #   securityContext:
@@ -183,9 +181,9 @@ spec:
    - name: webui
    - name: webui
      port: 8004
      port: 8004
      targetPort: 8004
      targetPort: 8004
    # - name: grafana
    - name: grafana
    #   port: 3001
      port: 3000
    #   targetPort: 3001
      targetPort: 3000
---
---
apiVersion: autoscaling/v2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
kind: HorizontalPodAutoscaler
+12 −0
Original line number Original line Diff line number Diff line
@@ -67,6 +67,18 @@ def opticalconfig_get_uuid(
        ('name', device_name),
        ('name', device_name),
    ], extra_details=['At least one is required to produce a OpticalConfig UUID'])
    ], extra_details=['At least one is required to produce a OpticalConfig UUID'])


def opticalconfig_uuid_get_duuid(
    device_uuid , allow_random : bool = False
) -> str:
     
    if (len(device_uuid)>0):
        return get_uuid_from_string(f"{device_uuid}_opticalconfig")
    if allow_random: return get_uuid_random()

    raise InvalidArgumentsException([
        ('DeviceId ', device_id),
    ], extra_details=['device_id is required to produce a OpticalConfig UUID'])



def ob_get_uuid(
def ob_get_uuid(
    ob_name:str , allow_random : bool = False
    ob_name:str , allow_random : bool = False
+81 −1
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ from common.proto.context_pb2 import (
)
)


from common.tools.object_factory.OpticalLink import extract_endpoint_names
from common.tools.object_factory.OpticalLink import extract_endpoint_names
from common.tools.context_queries.OpticalConfig import opticalconfig_uuid_get_duuid
from context.client.ContextClient import ContextClient
from context.client.ContextClient import ContextClient
from device.client.DeviceClient import DeviceClient
from device.client.DeviceClient import DeviceClient
from service.client.ServiceClient import ServiceClient
from service.client.ServiceClient import ServiceClient
@@ -158,3 +159,82 @@ def add_service (topo_uuid :str ,context_uuid :str) :
        return render_template('tapi/add_service.html', service_form=service_form)            
        return render_template('tapi/add_service.html', service_form=service_form)            
                    
                    



@tapi.route('<path:device_uuid>/detail',methods=['GET'])    
def show_details(device_uuid):

    config_uuid = opticalconfig_uuid_get_duuid (device_uuid)
    opticalconfigId = OpticalConfigId()
    opticalconfigId.opticalconfig_uuid = config_uuid
    device_details = []
    device_name=''
    try : 
        context_client.connect()
        response = context_client.SelectOpticalConfig(opticalconfigId)
        context_client.close()
        if (response and response.opticalconfig_id.opticalconfig_uuid !=''):
            opticalConfig = OpticalConfig()
            opticalConfig.CopyFrom(response)

            device_name = ""
            config = json.loads(opticalConfig.config)
            logging.info(f"config {config}")
            if "device_name" in config:
                device_name = config["device_name"]

                config_type = config["type"]
                if config_type == DeviceTypeEnum.OPTICAL_TRANSPONDER._value_:
                    LOGGER.info("config details from show detail %s",config)
                    if 'channels' in config:
                        for channel in config['channels'] :
                            new_config={}
                            new_config["name"]=channel['name']
                            new_config['operationalMode']=channel['operational-mode'] if 'operational-mode' in channel else ''
                            new_config['targetOutputPower']=channel['target-output-power'] if 'target-output-power' in channel else ''
                            new_config["frequency"]=channel['frequency'] if 'frequency' in channel else ''
                            new_config['line_port']=channel["line-port"] if 'line-port' in channel else ''
                            new_config["status"] = channel['status'] if 'status' in channel else ""
                            device_details.append(new_config)

                if config_type == DeviceTypeEnum.OPTICAL_ROADM._value_:
                    LOGGER.info("config details from show detail %s",config)
                    if 'channels' in config:
                        for channel in config['channels'] :
                            new_config={}
                            new_config["band_name"]=channel['band_name'] if 'band_name' in channel else None
                            new_config['type']=channel['type'] if 'type' in channel else ''
                            new_config['src_port']=channel['src_port'] if 'src_port' in channel else ''
                            new_config['dest_port']=channel['dest_port'] if 'dest_port' in channel else ''
                            new_config["lower_frequency"]=channel['lower_frequency'] if 'lower_frequency' in channel else ''
                            new_config["upper_frequency"]=channel['upper_frequency'] if 'upper_frequency' in channel else ''
                            new_config["status"] = channel['status'] if 'status' in channel else ""
                            new_config['optical_band_parent']= channel['optical_band_parent'] if 'optical_band_parent' in channel else ''
                            new_config['channel_index']= channel['channel_index'] if 'channel_index' in channel else ''
                            device_details.append(new_config)

                if config_type == DeviceTypeEnum.OPEN_ROADM._value_:
                    if 'interfaces' in config :
                        for interface in config["interfaces"]:
                            if interface["type"] != "Null":
                                new_config={}
                                new_config["name"]=interface["name"] if "name" in interface else '' 
                                new_config["administrative_state"]=interface[ "administrative_state"]
                                new_config["circuit_pack_name"]=interface["circuit_pack_name"]
                                new_config["port"]=interface["port"]
                                new_config["interface_list"]=interface["interface_list"]
                                new_config["frequency"]=interface["frequency"]
                                new_config["width"]=interface[ "width"]
                                new_config["type"]=interface["type"]
                                device_details.append(new_config)

            LOGGER.info("device details  %s",device_details)
       #return render_template( 'tapi/device_details.html', device=device_details,config_id=config_uuid,device_name=device_name,type=config_type)
   
    except Exception as  err : 
                    LOGGER.info(f" error from showing oc details {err}") 
                    flash(f'Error : `{str(err)}`', 'danger')
        
    return render_template(
        'tapi/device_details.html', device=device_details,device_uuid=device_uuid,device_name=device_name
    )
        
 No newline at end of file
+143 −0
Original line number Original line Diff line number Diff line
<!--
 Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

{% extends 'base.html' %}

{% block content %}

<h1>Optical Configurations</h1>

<div class="row">
  {% if device %}
    <div class="col-sm-12">
      <span>Device ID:</span>
      <h5>{{device_uuid}}</h5>
    </div>
    <div class="col-sm-12">
      <div class="col-sm-12">
        <div class="row mb-3 ">
          <div class="col-sm-3">
            <button type="button" class="btn btn-success" onclick="window.location.href='{{ url_for('tapi.home') }}'">
                <i class="bi bi-box-arrow-in-left"></i>
                Back to main
            </button>
          </div>
         
        </div>
      </div>
      <div class="col-sm-12">
        <span>Device Name:</span>
        <span>{{device_name}}</span>
      </div>
    </div>

    {% if type == 'optical-transponder' %}
      <table class="table table-striped table-hover">
        <thead>
          <tr>
            <th scope="col">channel name</th>
            <th scope="col">Frequency</th>
            <th scope="col">Target Output Power</th>
            <th scope="col">Operational Mode</th>
            <th scope="col">Line Port</th>
            <th scope="col">Channel Status</th>
          </tr>
        </thead>
        <tbody>
          {% for channel in device %}
            <tr style="background-color:{%if channel.status == 'DISABLED' %} gray {% endif %};">
              <td>{{channel.name.index}}</td>
              <td>{{channel.frequency}}</td>
              <td>{{channel.targetOutputPower}}</td>
              <td>{{channel.operationalMode}}</td>
              <td>{{channel.line_port}}</td>
              <td>{{channel.status}}</td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    {% elif type == 'openroadm' %}  
      <table class="table table-striped table-hover">
        <thead>
          <tr>
            <th scope="col"> name</th>
            <th scope="col"> type</th>
            <th scope="col">administrative state</th>
            <th scope="col">circuit pack name</th>
            <th scope="col">port</th>
            <th scope="col">interface list</th>
            <th scope="col">frequency</th>
            <th scope="col">width</th>
          </tr>
        </thead>
        <tbody>
            {% for channel in device %}
              <tr style="background-color:{%if channel.status == 'DISABLED' %} gray {% endif %};">
                <td>{{channel.name}}</td>
                <td>{{channel.type}}</td>
                <td>{{channel.administrative_state}}</td>
                <td>{{channel.circuit_pack_name}}</td>
                <td>{{channel.port}}</td>
                <td>{{channel.interface_list}}</td>
                <td>{{channel.frequency}}</td>
                <td>{{channel.width}}</td>
              </tr>
            {% endfor %}
        </tbody>
      </table>
    {% else %}
      <table class="table table-striped table-hover">
        <thead>
          <tr>
            <th scope="col">Channel Index</th>
            <th scope="col">Optical Band Parent</th>
            <th scope="col">Band Name</th>
            <th scope="col">Lower Frequency</th>
            <th scope="col">Upper Frequency</th>
            <th scope="col">type</th>
            <th scope="col">Source Port</th>
            <th scope="col">Destination Port</th>
            <th scope="col">Channel Status </th>
          </tr>
        </thead>
        <tbody>
          {% for channel in device %} 
            <tr>
              <td>{{channel.channel_index}}</td>
              <td>{{channel.optical_band_parent}}</td>
              <td>{{channel.band_name}}</td>
              <td>{{channel.lower_frequency}}</td>
              <td>{{channel.upper_frequency}}</td>
              <td>{{channel.type}}</td>
              <td>{{channel.src_port}}</td>
              <td>{{channel.dest_port}}</td>
              <td>{{channel.status}}</td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    {% endif%}
  </div>

{% else %}
<div class="col">
  <h4 colspan="7">No devices found</h4>
</div>
{% endif %}

</div>

{% endblock %}
+9 −1
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@
            <th scope="col">Name</th>
            <th scope="col">Name</th>
            <th scope="col">Type</th>
            <th scope="col">Type</th>
            <th scope="col">Endpoints (Name / type)</th>
            <th scope="col">Endpoints (Name / type)</th>
            <th scope="col"></th>
    
    
          
          
          </tr>
          </tr>
@@ -60,7 +61,14 @@
                               {% endfor %}
                               {% endfor %}
                           </ul>
                           </ul>
                       </td>
                       </td>
   
                      <td>
                            <a href="{{ url_for('tapi.show_details', device_uuid=device.device.device_id.device_uuid.uuid) }}">
                                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-eye" viewBox="0 0 16 16">
                                    <path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.133 13.133 0 0 1 1.66-2.043C4.12 4.668 5.88 3.5 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.133 13.133 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755C11.879 11.332 10.119 12.5 8 12.5c-2.12 0-3.879-1.168-5.168-2.457A13.134 13.134 0 0 1 1.172 8z"/>
                                    <path d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5zM4.5 8a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0z"/>
                                </svg>
                            </a>
                        </td>
                   
                   
                    
                    
                </tr>
                </tr>