Commit 0b2b1ee9 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'develop' of https://labs.etsi.org/rep/tfs/controller into fix/pathcomp-backend-logs

parents a74f6100 0e40bd49
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -95,8 +95,8 @@ def create_app(use_config=None, web_app_root=None):
    from webui.service.link.routes import link              # pylint: disable=import-outside-toplevel
    app.register_blueprint(link)

    from webui.service.policy.routes import policy          # pylint: disable=import-outside-toplevel
    app.register_blueprint(policy)
    from webui.service.policy_rule.routes import policy_rule # pylint: disable=import-outside-toplevel
    app.register_blueprint(policy_rule)

    app.jinja_env.globals.update({              # pylint: disable=no-member
        'enumerate'           : enumerate,
+12 −12
Original line number Diff line number Diff line
@@ -18,33 +18,33 @@ from common.proto.context_pb2 import Empty
from common.proto.policy_pb2 import PolicyRuleStateEnum
from context.client.ContextClient import ContextClient

policy = Blueprint('policy', __name__, url_prefix='/policy')
policy_rule = Blueprint('policy_rule', __name__, url_prefix='/policy_rule')

context_client = ContextClient()

@policy.get('/')
@policy_rule.get('/')
def home():
    context_client.connect()
    policy_rules = context_client.ListPolicyRules(Empty())
    policy_rules = policy_rules.policyRules
    context_client.close()
    return render_template('policy/home.html', policy_rules=policy_rules, prse=PolicyRuleStateEnum)
    return render_template('policy_rule/home.html', policy_rules=policy_rules, prse=PolicyRuleStateEnum)

#@policy.get('<path:policy_uuid>/detail')
#def detail(policy_uuid: str):
#@policy_rule.get('<path:policy_rule_uuid>/detail')
#def detail(policy_rule_uuid: str):
#    try:
#        context_client.connect()
#
#        slice_obj = get_slice_by_uuid(context_client, slice_uuid, rw_copy=False)
#        if slice_obj is None:
#            flash('Context({:s})/Slice({:s}) not found'.format(str(context_uuid), str(slice_uuid)), 'danger')
#            slice_obj = Slice()
#        policy_rule_obj = get_policy_rule_by_uuid(context_client, policy_rule_uuid, rw_copy=False)
#        if policy_rule_obj is None:
#            flash('Context({:s})/PolicyRule({:s}) not found'.format(str(context_uuid), str(policy_rule_uuid)), 'danger')
#            policy_rule_obj = PolicyRule()
#
#        context_client.close()
#
#        return render_template(
#            'slice/detail.html', slice=slice_obj, prse=PolicyRuleStateEnum)
#            'policy_rule/detail.html', policy_rule=policy_rule_obj, prse=PolicyRuleStateEnum)
#    except Exception as e:
#        flash('The system encountered an error and cannot show the details of this slice.', 'warning')
#        flash('The system encountered an error and cannot show the details of this policy_rule.', 'warning')
#        current_app.logger.exception(e)
#        return redirect(url_for('slice.home'))
#        return redirect(url_for('policy_rule.home'))
+4 −4
Original line number Diff line number Diff line
@@ -84,10 +84,10 @@
                  {% endif %}
                </li>
                <li class="nav-item">
                  {% if '/policy/' in request.path %}
                  <a class="nav-link active" aria-current="page" href="{{ url_for('policy.home') }}">Policy</a>
                  {% if '/policy_rule/' in request.path %}
                  <a class="nav-link active" aria-current="page" href="{{ url_for('policy_rule.home') }}">Policy Rules</a>
                  {% else %}
                  <a class="nav-link" href="{{ url_for('policy.home') }}">Policy</a>
                  <a class="nav-link" href="{{ url_for('policy_rule.home') }}">Policy Rules</a>
                  {% endif %}
                </li>
                <li class="nav-item">
+84 −0
Original line number Diff line number Diff line
@@ -17,11 +17,11 @@
{% extends 'base.html' %}

{% block content %}
    <h1>Policy</h1>
    <h1>Policy Rules</h1>

    <div class="row">
        <div class="col">
            {{ policies | length }} policies found in context <i>{{ session['context_uuid'] }}</i>
            {{ policy_rules | length }} policy rules found in context <i>{{ session['context_uuid'] }}</i>
        </div>
    </div>

@@ -43,40 +43,40 @@
          </tr>
        </thead>
        <tbody>
            {% if policies %}
                {% for policy in policies %}
                    {% if policy.WhichOneof('policy_rule') == 'device' %}
            {% if policy_rules %}
                {% for policy_rule in policy_rules %}
                    {% if policy_rule.WhichOneof('policy_rule') == 'device' %}
                        <tr>
                            <td>{{ policy.device.policyRuleBasic.policyRuleId.uuid }}</td>
                            <td>{{ policy.WhichOneof('policy_rule') }}</td>
                            <td>{{ policy.device.policyRuleBasic.priority }}</td>
                            <td>{{ policy.device.policyRuleBasic.conditionList }}</td>
                            <td>{{ policy.device.policyRuleBasic.booleanOperator }}</td>
                            <td>{{ policy.device.policyRuleBasic.actionList }}</td>
                            <td>{{ policy_rule.device.policyRuleBasic.policyRuleId.uuid }}</td>
                            <td>{{ policy_rule.WhichOneof('policy_rule') }}</td>
                            <td>{{ policy_rule.device.policyRuleBasic.priority }}</td>
                            <td>{{ policy_rule.device.policyRuleBasic.conditionList }}</td>
                            <td>{{ policy_rule.device.policyRuleBasic.booleanOperator }}</td>
                            <td>{{ policy_rule.device.policyRuleBasic.actionList }}</td>
                            <td>-</td>
                            <td>{{ policy.device.deviceList }}</td>
                            <td>{{ prse.Name(policy.device.policyRuleBasic.policyRuleState.policyRuleState).replace('POLICY_', '') }}</td>
                            <td>{{ policy.device.policyRuleBasic.policyRuleState.policyRuleStateMessage }}</td>
                            <td>{{ policy_rule.device.deviceList }}</td>
                            <td>{{ prse.Name(policy_rule.device.policyRuleBasic.policyRuleState.policyRuleState).replace('POLICY_', '') }}</td>
                            <td>{{ policy_rule.device.policyRuleBasic.policyRuleState.policyRuleStateMessage }}</td>
                        </tr>
                    {% elif policy.WhichOneof('policy_rule') == 'service' %}
                    {% elif policy_rule.WhichOneof('policy_rule') == 'service' %}
                        <tr>
                            <td>{{ policy.service.policyRuleBasic.policyRuleId.uuid }}</td>
                            <td>{{ policy.WhichOneof('policy_rule') }}</td>
                            <td>{{ policy.service.policyRuleBasic.priority }}</td>
                            <td>{{ policy.service.policyRuleBasic.conditionList }}</td>
                            <td>{{ policy.service.policyRuleBasic.booleanOperator }}</td>
                            <td>{{ policy.service.policyRuleBasic.actionList }}</td>
                            <td>{{ policy.service.serviceId }}</td>
                            <td>{{ policy.service.deviceList }}</td>
                            <td>{{ prse.Name(policy.service.policyRuleBasic.policyRuleState.policyRuleState).replace('POLICY_', '') }}</td>
                            <td>{{ policy.service.policyRuleBasic.policyRuleState.policyRuleStateMessage }}</td>
                            <td>{{ policy_rule.service.policyRuleBasic.policyRuleId.uuid }}</td>
                            <td>{{ policy_rule.WhichOneof('policy_rule') }}</td>
                            <td>{{ policy_rule.service.policyRuleBasic.priority }}</td>
                            <td>{{ policy_rule.service.policyRuleBasic.conditionList }}</td>
                            <td>{{ policy_rule.service.policyRuleBasic.booleanOperator }}</td>
                            <td>{{ policy_rule.service.policyRuleBasic.actionList }}</td>
                            <td>{{ policy_rule.service.serviceId }}</td>
                            <td>{{ policy_rule.service.deviceList }}</td>
                            <td>{{ prse.Name(policy_rule.service.policyRuleBasic.policyRuleState.policyRuleState).replace('POLICY_', '') }}</td>
                            <td>{{ policy_rule.service.policyRuleBasic.policyRuleState.policyRuleStateMessage }}</td>
                        </tr>
                    {% else %}
                        <tr><td colspan="11">Unsupported policy type {{ policy.WhichOneof('policy_rule') }}</td></tr>
                        <tr><td colspan="11">Unsupported policy rule type {{ policy_rule.WhichOneof('policy_rule') }}</td></tr>
                    {% endif %}
                {% endfor %}
            {% else %}
                <tr><td colspan="11">No policies found</td></tr>
                <tr><td colspan="11">No policy rule found</td></tr>
            {% endif %}
        </tbody>
    </table>
Loading