diff --git a/src/webui/service/slice/routes.py b/src/webui/service/slice/routes.py index b6818be8af9434296efd80f09d97a4baac14cfb0..c5287501362db88edaf334426ca6e6d0e3331ef2 100644 --- a/src/webui/service/slice/routes.py +++ b/src/webui/service/slice/routes.py @@ -14,7 +14,7 @@ # import grpc from flask import current_app, redirect, render_template, Blueprint, flash, session, url_for -from common.proto.context_pb2 import ContextId, Slice, SliceId, SliceList, Connection +from common.proto.context_pb2 import ContextId, Slice, SliceId, SliceList, Connection, SliceStatusEnum from context.client.ContextClient import ContextClient #from slice.client.SliceClient import SliceClient @@ -48,7 +48,7 @@ def home(): slices = [] context_not_found = True context_client.close() - return render_template('slice/home.html',slices=slices, context_not_found=context_not_found) + return render_template('slice/home.html',slices=slices, context_not_found=context_not_found, sse=SliceStatusEnum) # #@slice.route('add', methods=['GET', 'POST']) @@ -68,16 +68,18 @@ def detail(slice_uuid: str): request: SliceId = SliceId() request.slice_uuid.uuid = slice_uuid request.context_id.context_uuid.uuid = context_uuid + req = ContextId() + req.context_uuid.uuid = context_uuid try: context_client.connect() response: Slice = context_client.GetSlice(request) - #services: Service = context_client.ListServices(request) + services = context_client.ListServices(req) context_client.close() except Exception as e: flash('The system encountered an error and cannot show the details of this slice.', 'warning') current_app.logger.exception(e) return redirect(url_for('slice.home')) - return render_template('slice/detail.html', slice=response) + return render_template('slice/detail.html', slice=response, sse=SliceStatusEnum, services=services) # #@slice.get('<path:slice_uuid>/delete') #def delete(slice_uuid: str): diff --git a/src/webui/service/templates/service/detail.html b/src/webui/service/templates/service/detail.html index 9d2c1e736a1afb40e1cc2433fae2b2db9371a107..3df155853418b98dc6ff313210276f5a68774122 100644 --- a/src/webui/service/templates/service/detail.html +++ b/src/webui/service/templates/service/detail.html @@ -63,9 +63,12 @@ <td> <a href="{{ url_for('device.detail', device_uuid=endpoint.device_id.device_uuid.uuid) }}"> {{ endpoint.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 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> @@ -79,13 +82,18 @@ <table class="table table-striped table-hover"> <thead> <tr> + <th scope="col">Kind</th> <th scope="col">Type</th> <th scope="col">Value</th> </tr> </thead> <tbody> {% for constraint in service.service_constraints %} + {% if constraint.WhichOneof('constraint')=='custom' %} <tr> + <td> + Custom + </td> <td> {{ constraint.custom.constraint_type }} </td> @@ -95,6 +103,55 @@ </ul> </td> </tr> + {% endif %} + {% if constraint.WhichOneof('constraint')=='endpoint_location' %} + <tr> + <td> + Endpoint Location + </td> + <td> + {{ constraint.endpoint_location.endpoint_id.device_id.device_uuid.uuid }} / {{ + constraint.endpoint_location.endpoint_id.endpoint_uuid.uuid }} + </td> + <td> + <ul> + {{ constraint.endpoint_location.location }} + </ul> + </td> + </tr> + {% endif %} + {% if constraint.WhichOneof('constraint')=='endpoint_priority' %} + <tr> + <td> + Endpoint Priority + </td> + <td> + {{ constraint.endpoint_priority.endpoint_id.device_id.device_uuid.uuid }} / {{ + constraint.endpoint_priority.endpoint_id.endpoint_uuid.uuid }} + </td> + <td> + <ul> + {{ constraint.endpoint_priority.priority }} + </ul> + </td> + </tr> + {% endif %} + {% if constraint.WhichOneof('constraint')=='sla_availability' %} + <tr> + <td> + SLA Availability + </td> + <td> + / + </td> + <td> + <ul> + <li> num_disjoint_paths: {{ constraint.sla_availability.num_disjoint_paths }} </li> + <li> all_active: {{ constraint.sla_availability.all_active }} </li> + </ul> + </td> + </tr> + {% endif %} {% endfor %} </tbody> </table> diff --git a/src/webui/service/templates/slice/detail.html b/src/webui/service/templates/slice/detail.html index 6d8595c881664a50c98d413ee79f35062eff84db..dd59f33523966d5714e7c85876f94e532290d405 100644 --- a/src/webui/service/templates/slice/detail.html +++ b/src/webui/service/templates/slice/detail.html @@ -17,12 +17,20 @@ {% extends 'base.html' %} {% block content %} -<h1>Slice {{ slice.slice_id.slice_uuid.uuid }}</h1> +<h1>Slice {{ slice.slice_id.slice_uuid.uuid }} </h1> +<div class="row mb-3"> + <div class="col-sm-3"> + <button type="button" class="btn btn-success" onclick="window.location.href='{{ url_for('slice.home') }}'"> + <i class="bi bi-box-arrow-in-left"></i> + Back to slice list + </button> + </div> +</div> <div class="row mb-3"> <div class="col-sm-4"> <b>UUID: </b> {{ slice.slice_id.slice_uuid.uuid }}<br><br> - <b>Status: </b> {{ slice.slice_status.slice_status }}<br><br> + <b>Status: </b> {{ sse.Name(slice.slice_status.slice_status).replace('SLICESTATUS_', '') }}<br><br> </div> <div class="col-sm-8"> <table class="table table-striped table-hover"> @@ -56,59 +64,152 @@ </table> </div> </div> - <b>Constraints:</b> +<table class="table table-striped table-hover"> + <thead> + <tr> + <th scope="col">Kind</th> + <th scope="col">Type</th> + <th scope="col">Value</th> + </tr> + </thead> + <tbody> + {% for constraint in slice.slice_constraints %} + {% if constraint.WhichOneof('constraint')=='custom' %} + <tr> + <td> + Custom + </td> + <td> + {{ constraint.custom.constraint_type }} + </td> + <td> + <ul> + {{ constraint.custom.constraint_value }} + </ul> + </td> + </tr> + {% endif %} + {% if constraint.WhichOneof('constraint')=='endpoint_location' %} + <tr> + <td> + Endpoint Location + </td> + <td> + {{ constraint.endpoint_location.endpoint_id.device_id.device_uuid.uuid }} / {{ + constraint.endpoint_location.endpoint_id.endpoint_uuid.uuid }} + </td> + <td> + <ul> + {{ constraint.endpoint_location.location }} + </ul> + </td> + </tr> + {% endif %} + {% if constraint.WhichOneof('constraint')=='endpoint_priority' %} + <tr> + <td> + Endpoint Priority + </td> + <td> + {{ constraint.endpoint_priority.endpoint_id.device_id.device_uuid.uuid }} / {{ + constraint.endpoint_priority.endpoint_id.endpoint_uuid.uuid }} + </td> + <td> + <ul> + {{ constraint.endpoint_priority.priority }} + </ul> + </td> + </tr> + {% endif %} + {% if constraint.WhichOneof('constraint')=='sla_availability' %} + <tr> + <td> + SLA Availability + </td> + <td> + / + </td> + <td> + <ul> + <li> num_disjoint_paths: {{ constraint.sla_availability.num_disjoint_paths }} </li> + <li> all_active: {{ constraint.sla_availability.all_active }} </li> + </ul> + </td> + </tr> + {% endif %} + {% endfor %} + </tbody> +</table> +<b>Configurations:</b> <table class="table table-striped table-hover"> <thead> <tr> - <th scope="col">Type</th> + <th scope="col">Key</th> <th scope="col">Value</th> </tr> </thead> <tbody> - {% for constraint in slice.slice_constraints %} + {% for config in slice.slice_config.config_rules %} + {% if config.WhichOneof('config_rule') == 'custom' %} <tr> <td> - {{ constraint.custom.constraint_type }} + {{ config.custom.resource_key }} </td> <td> <ul> - {{ constraint.custom.constraint_value }} + {% for key, value in (config.custom.resource_value | from_json).items() %} + <li><b>{{ key }}:</b> {{ value }}</li> + {% endfor %} </ul> </td> </tr> + {% endif %} {% endfor %} </tbody> </table> -<!-- -<table class="table table-striped table-hover"> - <thead> - <tr> - <th scope="col">Service Id</th> - <th scope="col">Sub-slice</th> - </tr> - </thead> - <tbody> - {% for connections in connections.connections %} - <tr> - <td> - {{ connections.connection_id.connection_uuid.uuid }} - </td> - <td> - {{ connections.sub_service_ids|map(attribute='service_uuid')|map(attribute='uuid')|join(', ') }} - </td> - - {% for i in range(connections.path_hops_endpoint_ids|length) %} - <td> - {{ connections.path_hops_endpoint_ids[i].device_id.device_uuid.uuid }} / {{ - connections.path_hops_endpoint_ids[i].endpoint_uuid.uuid }} - </td> - {% endfor %} - - - </tr> - {% endfor %} - </tbody> - </table> --> - +<div class="row mb-2"> + <div class="col-sm-6"> + <table class="table table-striped table-hover"> + <thead> + <tr> + <th scope="col">Service Id</th> + </tr> + </thead> + <tbody> + {% for services in services.services %} + <tr> + <td> + <a href="{{ url_for('service.detail', service_uuid=services.service_id.service_uuid.uuid) }}"> + {{ services.service_id.service_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> + {% endfor %} + </tbody> + </table> + </div> + <div class="col-sm-6"> + <table class="table table-striped table-hover"> + <thead> + <tr> + <th scope="col">Sub-slice</th> + </tr> + </thead> + <tbody> + {% for services in services.services %} + <tr> + <td> + {{ services.sub_slice_ids|map(attribute='slice_uuid')|map(attribute='uuid')|join(', ') }} + </td> + </tr> + {% endfor %} + </tbody> + </table> + </div> +</div> {% endblock %} \ No newline at end of file diff --git a/src/webui/service/templates/slice/home.html b/src/webui/service/templates/slice/home.html index d43710797b8949e9b8b3dba86a7cb25519b23fd7..7096407b3e79ccd1b4fe4ec3f143cbbe3fba2876 100644 --- a/src/webui/service/templates/slice/home.html +++ b/src/webui/service/templates/slice/home.html @@ -19,6 +19,14 @@ {% block content %} <h1>Slice</h1> + <div class="row"> + + <div class="col"> + {{ slices | length }} slices found in context <i>{{ session['context_uuid'] }}</i> + </div> + + </div> + <table class="table table-striped table-hover"> <thead> @@ -35,15 +43,17 @@ {% for slice in slices %} <tr> <td> - <!-- <a href="{{ url_for('slice.detail', slice_uuid=slice.slice_id.slice_uuid.uuid) }}"> --> - {{ slice.slice_id.slice_uuid.uuid }} - <!-- </a> --> + {{ slice.slice_id.slice_uuid.uuid }} </td> <td> - {{ slice.slice_endpoint_ids }} + {% for i in range(slice.slice_endpoint_ids|length) %} + <ul> + <li> {{ slice.slice_endpoint_ids[i].device_id.device_uuid.uuid }} / {{ slice.slice_endpoint_ids[i].endpoint_uuid.uuid }} </li> + </ul> + {% endfor %} </td> <td> - {{ slice.slice_status }} + {{ sse.Name(slice.slice_status.slice_status).replace('SLICESTATUS_', '') }} </td> <td> <a href="{{ url_for('slice.detail', slice_uuid=slice.slice_id.slice_uuid.uuid) }}">